Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Error thrown (instead of fault) when user with insufficient permissions tries to subscribe tochatmod

Avatar

Level 2

When a user with insufficient permissions tries to subscribe to chatModel (say with access model 10, user role 8), the application throws following error instead of raising a fault.

Error: MessageManager.createNode : insufficient permissions to create node

at com.adobe.rtc.messaging.manager::MessageManager/http://www.adobe.com/2006/connect/cocomo/messaging/internal::createNode()[C:\work\main\connect\cocomo\src\com\adobe\rtc\messaging\manager\MessageManager.as:247]

at com.adobe.rtc.sharedModel::CollectionNode/publishItem()[C:\work\main\connect\cocomo\src\com\adobe\rtc\sharedModel\CollectionNode.as:615]

at com.adobe.rtc.sharedManagers::UserManager/createUser()[C:\work\main\connect\cocomo\src\com\adobe\rtc\sharedManagers\UserManager.as:692]

at com.adobe.rtc.sharedManagers::UserManager/onSynchronizationChange()[C:\work\main\connect\cocomo\src\com\adobe\rtc\sharedManagers\UserManager.as:813]

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at com.adobe.rtc.sharedModel::CollectionNode/http://www.adobe.com/2006/connect/cocomo/messaging/internal::setIsSynchronized()[C:\work\main\connect\cocomo\src\com\adobe\rtc\sharedModel\CollectionNode.as:665]

at com.adobe.rtc.messaging.manager::MessageManager/receiveAllSynchData()[C:\work\main\connect\cocomo\src\com\adobe\rtc\messaging\manager\MessageManager.as:785]

at com.adobe.rtc.messaging.manager::MessageManager/http://www.adobe.com/2006/connect/cocomo/messaging/internal::receiveItems()[C:\work\main\connect\cocomo\src\com\adobe\rtc\messaging\manager\MessageManager.as:541]

at com.adobe.rtc.session.managers::SessionManagerBase/receiveItems()[C:\work\main\connect\cocomo\src\com\adobe\rtc\session\managers\SessionManagerBase.as:374]

If a fault had been raised, I could gracefully catch it and display a pop-up to the user in my application. Is there some way by which I can prevent this error getting displayed in my application.

8 Replies

Avatar

Former Community Member

Hi

have you try to use "try" and "catch" and parse the error message like following?

               try{
                    // your subscrib to chat
                }catch (error:Error){
                    if(error.message.indexOf("insufficient permissions") {
                        //do proper handling
                    }
                }

Dean

Avatar

Level 2

The point is chatModel.subscribe() is an asynch call. The exception trace I have pasted no where specifies chatModel.subscribe(). So the error is never caught by catch statment. That is sole point I am trying to highlight.

Avatar

Former Community Member

Sorry, missed read your post.  However, it is still catchable.

I created a child class of SimpleChatModel with override method of following:

public class MyChatModel extends SimpleChatModel

{

         override protected function onSynchronizationChange(p_event:CollectionNodeEvent):void
        {
            _myName = (_userManager.getUserDescriptor(_userManager.myUserID) as UserDescriptor).displayName;
            if (_collectionNode.isSynchronized) {


                //if the node doesn't exist and I'm a host, create it empty so that viewers can publish to it
                if (!_collectionNode.isNodeDefined(HISTORY_NODE_EVERYONE) && _collectionNode.canUserConfigure(_userManager.myUserID)) {

                    try{


                    _collectionNode.createNode(HISTORY_NODE_EVERYONE, new NodeConfiguration(UserRoles.VIEWER, UserRoles.VIEWER, true, false, false, _isClearAfterSessionRemoved, NodeConfiguration.STORAGE_SCHEME_QUEUE, true));
                    _collectionNode.createNode(HISTORY_NODE_PARTICIPANTS, new NodeConfiguration(UserRoles.PUBLISHER, UserRoles.VIEWER, true, false, false, _isClearAfterSessionRemoved, NodeConfiguration.STORAGE_SCHEME_QUEUE));
                    _collectionNode.createNode(HISTORY_NODE_HOSTS, new NodeConfiguration(UserRoles.OWNER, UserRoles.VIEWER, true, false, false, _isClearAfterSessionRemoved, NodeConfiguration.STORAGE_SCHEME_QUEUE));
                    _collectionNode.createNode(TYPING_NODE_NAME, new NodeConfiguration(UserRoles.VIEWER, UserRoles.VIEWER, true, false, true, _isClearAfterSessionRemoved, NodeConfiguration.STORAGE_SCHEME_MANUAL));
                    //create by publishing the default
                    _collectionNode.publishItem(new MessageItem(TIMEFORMAT_NODE_NAME, TIMEFORMAT_AM_PM));
                    //create by publishing the default
                    _collectionNode.publishItem(new MessageItem(USE_TIMESTAMPS_NODE_NAME, true));
                    _userManager = _connectSession.userManager;

                   }catch (error:Error) {

                         if(error.message.indexOf("insufficient") ) {

                              do .....

                         }

                    }
                }
            }
           
            dispatchEvent(p_event);
        }

}

Avatar

Level 2

Just to be on the safer side I tried your solution, but it didn't work.

Here is the reason why, if we peruse the error trace, error is isn't thrown from ChatModel.onSynchronizationChange(). Your solution would have worked if error was thrown from this method. Had the error been thrown from this method, we could override it, catch the error and BINGO, world would have been such a happy place.

But error is thrown from MessageManager.createNode() [see the trace]

Avatar

Employee

Hi Amalhotr,

From the error, I am seeing that you are getting MessageManager.createNode : insufficient permissions to create node. If I am not wrong what it basically means is that you are trying to create collectionnodes in the SimpleChatModel even before subsribing to it. You need to login as on owner of the room first, and then setup the room (create collection nodes etc)and keep the room ready for others.

So once all the nodes were created by the owner, then in future any other user can subscribe and view the items in the collectionNode based on the permission level of the node and the user's user priviliges.

So you would avoid the error, Login in as owner of the room the first time you run your app. Let me know if you are still stuck.

Thanks

Arun

Avatar

Level 2

Here is the usecase. The owner is already connected to an instance of SimpleChatModel(access model=20). Now if some other user with role say 10 tries to connect I need to gracefully show the popup in my application, not the error trace that comes. I simply want to catch the error and may be show a alert box. I reiterate owner is already connected to the SimpleChatModel.

Avatar

Former Community Member

Adding to Arun's post, from your trace, it seems like your client is trying to connect un-authorized and since your room is not open to public, it throws error (UserManager - createUser).   can you share your code?

Avatar

Former Community Member

Ditto what Dean's saying - it seems the problem isn't in the

SimpleChatModel at all, but in UserManager - this is very strange, as the

only time you should be hitting this is if you're trying to create a

customUserField (this, in turn, creates a node on UserManager).

We intentionally don't allow you to catch these errors, since you do need

to resolve them before you're done development - they're meant for cases

that your application really shouldn't get into. For example, if your user

doesn't have a role of UserRoles.OWNER, he shouldn't be trying to create

nodes - a simple check of the user's role before attempting to create a node

would be a better way of avoiding the error than eating it in a try..catch

block. Catching errors is more appropriate when an fault is the result of

environmental issues outside of your control. For the case where your user

has role of 8, and your chatModel is 10, again, you can avoid the error by

checking before you subscribe.

hope that helps

nigel