Examples of IUserLayoutManager


Examples of org.jasig.portal.layout.IUserLayoutManager

        final StringBuilder url = this.getUrlBase(request);

        //Add targeted folder id
        final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
        final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
        final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
        final IUserLayout userLayout = userLayoutManager.getUserLayout();
       
        final XPathExpression findChannelTabExpression = this.getFindChannelTabIdExpression(targetFolderId);
        final String tabId = userLayout.findNodeId(findChannelTabExpression);
       
        //Add folder ID of parent tab if it exists
View Full Code Here

Examples of org.jasig.portal.layout.IUserLayoutManager

        final String channelSubscribeId = portletEntity.getChannelSubscribeId();
        // if not a transient node, we need to lookup user layout information
        if (!channelSubscribeId.startsWith(TransientUserLayoutManagerWrapper.SUBSCRIBE_PREFIX)) {
            final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
            final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
            final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
            final IUserLayout userLayout = userLayoutManager.getUserLayout();
           
            final XPathExpression findChannelTabExpression = this.getFindChannelTabIdExpression(channelSubscribeId);
            final String tabId = userLayout.findNodeId(findChannelTabExpression);
           
            //Add folder ID of parent tab if it exists
View Full Code Here

Examples of org.jasig.portal.layout.IUserLayoutManager

            expect(mockUserLayoutNodeDescription.getId()).andReturn(details.getFolderName());
        }
        replay(mockUserLayoutNodeDescription);
        // END only expect IUserLayoutNodeDescription calls if folderName is defined
       
        IUserLayoutManager mockUserLayoutManager = createMock(IUserLayoutManager.class);
        expect(mockUserLayoutManager.getUserLayout()).andReturn(mockUserLayout);
        expect(mockUserLayoutManager.getNode(expressionText)).andReturn(mockUserLayoutNodeDescription);
        replay(mockUserLayoutManager);
        IUserPreferencesManager mockUserPreferencesManager = createMock(IUserPreferencesManager.class);
        expect(mockUserPreferencesManager.getUserLayoutManager()).andReturn(mockUserLayoutManager).times(2);
        replay(mockUserPreferencesManager);
        IUserInstance mockUser = createMock(IUserInstance.class);
View Full Code Here

Examples of org.jasig.portal.layout.IUserLayoutManager

      IUserInstanceManager userInstanceManager = null;
      IUserInstance ui = null;
    IPerson per = null;
    UserPreferencesManager upm = null;
    IUserLayoutManager ulm = null;

    // make sure the user has a current session
    if (request.getSession(false) == null) {
      log.warn("Attempting to use AJAX preferences as GUEST user");
      printError(response, "Your session has timed out.  Please log in again to make changes to your layout.");
      return;
    }

    try {
            final WebApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
            userInstanceManager = (IUserInstanceManager) applicationContext.getBean("userInstanceManager", IUserInstanceManager.class);

           
      // Retrieve the user's UserInstance object
      ui = userInstanceManager.getUserInstance(request);

      // Retrieve the user's IPerson object
      per = ui.getPerson();

      // ensure that the user is currently logged in
      if (per.isGuest()) {
        log.warn("Attempting to use AJAX preferences as GUEST user");
        printError(response, "Your session has timed out.  Please log in again to make changes to your layout.");
        return;
      }

      // Retrieve the preferences manager
      upm = (UserPreferencesManager) ui.getPreferencesManager();

      // Retrieve the layout manager
      ulm = upm.getUserLayoutManager();

    } catch (RuntimeException e) {
      log.error(e, e);
      printError(response, "An unknown error occurred.");
      return;
    }

    try {

      // get the requested preferences action
      String action = request.getParameter("action");

      // perform the requested action
      if (action == null) {

        log.warn("preferences servlet called with no action parameter");

      } else if (action.equals("movePortletHere")) {

        moveChannel(per, upm, ulm, request, response);

      } else if (action.equals("changeColumns")) {

        changeColumns(per, upm, ulm, request, response);

      } else if (action.equals("updateColumnWidths")) {

        updateColumnWidths(per, upm, ulm, request, response);

      } else if (action.equals("addChannel")) {

        addChannel(per, upm, ulm, userInstanceManager, request, response);

      } else if (action.equals("renameTab")) {

        renameTab(per, upm, ulm, request, response);

      } else if (action.equals("addTab")) {

        addTab(per, upm, ulm, request, response);

      } else if (action.equals("moveTabHere")) {

        moveTab(per, upm, ulm, request, response);

      } else if (action.equals("chooseSkin")) {
       
        chooseSkin(per, upm, ulm, request, response);
       
      } else if (action.equals("removeElement")) {

        // Delete the requested element node.  This code is the same for
        // all node types, so we can just have a generic action.
        String elementId = request.getParameter("elementID");
        ulm.deleteNode(elementId);
        try {
          saveUserLayoutPreservingTab(ulm, upm, per);
        } catch (Exception e) {
          log.warn("Error saving layout", e);
        }
View Full Code Here

Examples of org.jasig.portal.layout.IUserLayoutManager

        this.parseSingleTargetEvent(request, response, "uP_detach_target", PortalEvent.DETACH_BUTTON, channelManager);


        final IPerson person = userInstance.getPerson();
        final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
        final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
        final UserPreferences userPreferences = preferencesManager.getUserPreferences();

       
        final StructureStylesheetUserPreferences structureStylesheetUserPreferences = userPreferences.getStructureStylesheetUserPreferences();
        final ThemeStylesheetUserPreferences themeStylesheetUserPreferences = userPreferences.getThemeStylesheetUserPreferences();
       
        String root = request.getParameter("uP_root");
        if (root != null) {
            // If a channel specifies "me" as its root, set the root
            // to the channel's subscribe Id
            if (root.equals("me")) {
                // get uPFile spec and search for "channel" clause
                //TODO get UPFileSpec for original request and store it as a request attribute
                final UPFileSpec upfs = new UPFileSpec(request);
                root = upfs.getTargetNodeId();
            }

            if (IUserLayout.ROOT_NODE_NAME.equals(root)) {
                final String oldChannelId = structureStylesheetUserPreferences.getParameterValue("userLayoutRoot");
               
                if (oldChannelId != null && !IUserLayout.ROOT_NODE_NAME.equals(oldChannelId)) {
                    //Tell the previously maximized channel it is going back to normal
                    if (logger.isDebugEnabled()) {
                        logger.debug("Sending window state event '" + PortalEvent.NORMAL + "' to '" + root + "'.");
                    }
                    channelManager.passPortalEvent(request, response, oldChannelId, PortalEvent.NORMAL);
                }
            }
            else {
                //Make sure that the focused channel isn't rendered minimized
                themeStylesheetUserPreferences.setChannelAttributeValue(root, "minimized", "false");
               
                //Tell the channel it is being maximized
                if (logger.isDebugEnabled()) {
                    logger.debug("Sending window state event '" + PortalEvent.MAXIMIZE + "' to '" + root + "'.");
                }
                channelManager.passPortalEvent(request, response, root, PortalEvent.MAXIMIZE);
            }
           
            structureStylesheetUserPreferences.putParameterValue("userLayoutRoot", root);
        }
       
        // fname and root are mutually exclusive and
        // should not be used in the same request,
        // as an fname is treated as the root target.
        final String fname = request.getParameter(Constants.FNAME_PARAM);
        if (fname != null) {
            // get a subscribe id for the fname
            String subId = null;
            try {
                subId = userLayoutManager.getSubscribeId(fname);
            }
            catch (PortalException pe) {
                logger.warn("Unable to get subscribe ID for fname='" + fname + "'", pe);
            }

            if (subId != null) {
                if (userLayoutManager instanceof TransientUserLayoutManagerWrapper) {
                    // get wrapper implementation for focusing
                    final TransientUserLayoutManagerWrapper transientUserLayoutManagerWrapper = (TransientUserLayoutManagerWrapper) userLayoutManager;
                    // .. and now set it as the focused id
                    transientUserLayoutManagerWrapper.setFocusedId(subId);
                }
   
                structureStylesheetUserPreferences.putParameterValue("userLayoutRoot", subId);
                if (logger.isDebugEnabled()) {
                    logger.debug("setting structure preference 'userLayoutRoot'='" + subId + "'");
                }
            }
        }
       
        // other params
        final String[] structParamNames = request.getParameterValues("uP_sparam");
        if (structParamNames != null) {
            for (final String structParamName : structParamNames) {
                final String structParamValue = request.getParameter(structParamName);
               
                structureStylesheetUserPreferences.putParameterValue(structParamName, structParamValue);
                if (logger.isDebugEnabled()) {
                    logger.debug("set structure parameter '" + structParamName + "'='" + structParamValue + "'.");
                }
            }
        }

        final String[] themeParamNames = request.getParameterValues("uP_tparam");
        if (themeParamNames != null) {
            for (final String themeParamName : themeParamNames) {
                final String themeParamValue = request.getParameter(themeParamName);
               
                themeStylesheetUserPreferences.putParameterValue(themeParamName, themeParamValue);
                if (logger.isDebugEnabled()) {
                    logger.debug("set theme parameter '" + themeParamName + "'='" + themeParamValue + "'.");
                }
            }
        }
       
        // attribute processing
        // structure transformation
        final String[] structFolderAttrNames = request.getParameterValues("uP_sfattr");
        if (structFolderAttrNames != null) {
            for (final String structFolderAttrName : structFolderAttrNames) {
                final String[] folderIds = request.getParameterValues(structFolderAttrName + "_folderId");
               
                if (folderIds != null) {
                    for (final String folderId : folderIds) {
                        final String structFolderAttrValue = request.getParameter(structFolderAttrName + "_" + folderId + "_value");
                        structureStylesheetUserPreferences.setFolderAttributeValue(folderId, structFolderAttrName, structFolderAttrValue);
                       
                        if (logger.isDebugEnabled()) {
                            logger.debug("set structure folder attribute '" + structFolderAttrName + "'='" + structFolderAttrValue + "' on folder '" + folderId + "'.");
                        }
                    }
                }
            }
        }
           
        final String[] structChannelAttrNames = request.getParameterValues("uP_scattr");
        if (structChannelAttrNames != null) {
            for (final String structChannelAttrName : structChannelAttrNames) {
                final String[] channelIds = request.getParameterValues(structChannelAttrName + "_channelId");
               
                if (channelIds != null) {
                    for (final String channelId : channelIds) {
                        final String structChannelAttrValue = request.getParameter(structChannelAttrName + "_" + channelId + "_value");
                        structureStylesheetUserPreferences.setChannelAttributeValue(channelId, structChannelAttrName, structChannelAttrValue);
                       
                        if (logger.isDebugEnabled()) {
                            logger.debug("set structure channel attribute '" + structChannelAttrName + "'='" + structChannelAttrValue + "' on folder '" + channelId + "'.");
                        }
                    }
                }
            }
        }
       
        // theme stylesheet attributes
        final String[] themeChannelAttrNames = request.getParameterValues("uP_tcattr");
        if (themeChannelAttrNames != null) {
            for (final String themeChannelAttrName : themeChannelAttrNames) {
                final String[] channelIds = request.getParameterValues(themeChannelAttrName + "_channelId");
               
                if (channelIds != null) {
                    for (final String channelId : channelIds) {
                        final String themeChannelAttrValue = request.getParameter(themeChannelAttrName + "_" + channelId + "_value");
                        themeStylesheetUserPreferences.setChannelAttributeValue(channelId, themeChannelAttrName, themeChannelAttrValue);
                       
                        if (logger.isDebugEnabled()) {
                            logger.debug("set theme channel attribute '" + themeChannelAttrName + "'='" + themeChannelAttrValue + "' on folder '" + channelId + "'.");
                        }
                       
                        if ("minimized".equals(themeChannelAttrName)) {
                            final Element channel = userLayoutManager.getUserLayoutDOM().getElementById(channelId);
                            try {
                                UserPrefsHandler.setUserPreference(channel, themeChannelAttrName, person);
                            }
                            catch (Exception e) {
                                logger.warn("Failed to set 'minimized' attribute on channel '" + channelId + "' with element: " + channel, e);
                            }
                           
                            final PortalEvent event;
                            if ("true".equals(themeChannelAttrValue)) {
                                event = PortalEvent.MINIMIZE;
                            }
                            else {
                                event = PortalEvent.NORMAL;
                            }
       
                            channelManager.passPortalEvent(request, response, channelId, event);
                            if (logger.isDebugEnabled()) {
                                logger.debug("Sent window state event '" + event + "' to '" + channelId + "'.");
                            }
                        }
                    }
                }
            }
        }
       
        //Processing that only applies to authenticated users
        if (!person.isGuest()) {
            // Request to change the locale
            final String localesString = request.getParameter(Constants.LOCALES_PARAM);
            if (localesString != null) {
                final UserProfile profile = userPreferences.getProfile();
                final LocaleManager localeManager = profile.getLocaleManager();

                final Locale[] locales = LocaleManager.parseLocales(localesString);
                localeManager.setSessionLocales(locales);
            }
           
            // save processing handled at end to provide persisting of changes
            // if desired.
            final String saveWhat = request.getParameter("uP_save");
            if (saveWhat != null) {
//TODO Make UserLayoutStoreFactory a shell and spring inject this
                final IUserLayoutStore userLayoutStore = UserLayoutStoreFactory.getUserLayoutStoreImpl();
               
                try {
                    if (saveWhat.equals("preferences")) {
                        userLayoutStore.putUserPreferences(person, userPreferences);
                    }
                    else if (saveWhat.equals("layout")) {
                        userLayoutManager.saveUserLayout();
                    }
                    else if (saveWhat.equals("all")) {
                        userLayoutStore.putUserPreferences(person, userPreferences);
                        userLayoutManager.saveUserLayout();
                    }
                   
                    if (logger.isDebugEnabled()) {
                        logger.debug("persisted " + saveWhat + " changes.");
                    }

                }
                catch (Exception e) {
                    logger.error("unable to persist " + saveWhat + " changes. ", e);
                }
            }
        }
       
        userLayoutManager.processLayoutParameters(person, userPreferences, request);

        return true;
    }
View Full Code Here

Examples of org.jasig.portal.layout.IUserLayoutManager

    protected String getTargetChannelId(IWritableHttpServletRequest request) {
        String targetChannelId = null;
       
        final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
        final IUserPreferencesManager userPreferencesManager = userInstance.getPreferencesManager();
        final IUserLayoutManager userLayoutManger = userPreferencesManager.getUserLayoutManager();

        // see if this is targeted at an fname channel. if so then it takes
        // precedence. This is done so that a baseActionURL can be used for
        // the basis of an fname targeted channel with the fname query parm
        // appended to direct all query parms to the fname channel
        final String fname = request.getParameter(Constants.FNAME_PARAM);
        if (fname != null) {
            // get a subscribe id for the fname
            try {
                targetChannelId = userLayoutManger.getSubscribeId(fname);
            }
            catch (PortalException pe) {
                this.logger.error("Unable to get subscribe ID for fname=" + fname, pe);
            }
        }
View Full Code Here

Examples of org.jasig.portal.layout.IUserLayoutManager

    private void prepareReorder() throws PortalException {
      String folderID = runtimeData.getParameter("elementID");                  // the folder or channel ID
      String direction = runtimeData.getParameter("dir");       // "up" or "down"

      IUserLayoutManager lm=context.getUserLayoutManager();
      if (direction.equals("up")) {
          String prevSiblingId=lm.getPreviousSiblingId(folderID);
          if(prevSiblingId!=null) {
              lm.moveNode(folderID,lm.getParentId(folderID),prevSiblingId);
          }
          //        for (prev = element.getPreviousSibling(); prev != null && prev.getNodeType() != Node.ELEMENT_NODE && (!prev.getNodeName().equals("channel")  || !prev.getNodeName().equals("folder")); prev = prev.getPreviousSibling());
      } else if (direction.equals("down")) {
          String nextSiblingId=lm.getNextSiblingId(folderID);
          if(nextSiblingId!=null) {
              lm.moveNode(folderID,lm.getParentId(folderID),nextSiblingId);
          }
          //        for(next = element.getNextSibling(); next != null && next.getNodeType() != Node.ELEMENT_NODE && (!next.getNodeName().equals("channel") || !next.getNodeName().equals("folder")); next = next.getNextSibling());
      }
      context.setModified(true);
    }
View Full Code Here

Examples of org.jasig.portal.layout.IUserLayoutManager

    private void prepareReorder() throws PortalException {
      String folderID = runtimeData.getParameter("elementID");                  // the folder or channel ID
      String direction = runtimeData.getParameter("dir");       // "up" or "down"

      IUserLayoutManager lm=context.getUserLayoutManager();
      if (direction.equals("up")) {
          String prevSiblingId=lm.getPreviousSiblingId(folderID);
          if(prevSiblingId!=null) {
              lm.moveNode(folderID,lm.getParentId(folderID),prevSiblingId);
      }
          //        for (prev = element.getPreviousSibling(); prev != null && prev.getNodeType() != Node.ELEMENT_NODE && (!prev.getNodeName().equals("channel")  || !prev.getNodeName().equals("folder")); prev = prev.getPreviousSibling());
      } else if (direction.equals("down")) {
          String nextSiblingId=lm.getNextSiblingId(folderID);
          if(nextSiblingId!=null) {
              lm.moveNode(folderID,lm.getParentId(folderID),nextSiblingId);
      }
          //        for(next = element.getNextSibling(); next != null && next.getNodeType() != Node.ELEMENT_NODE && (!next.getNodeName().equals("channel") || !next.getNodeName().equals("folder")); next = next.getNextSibling());
      }
      context.setModified(true);
    }
View Full Code Here

Examples of org.jasig.portal.layout.IUserLayoutManager

       
        final IPortletWindowRegistry portletWindowRegistry = createMock(IPortletWindowRegistry.class);
        final IUserInstanceManager userInstanceManager = createMock(IUserInstanceManager.class);
        final IUserInstance userInstance = createMock(IUserInstance.class);
        final IUserPreferencesManager userPreferencesManager = createMock(IUserPreferencesManager.class);
        final IUserLayoutManager userLayoutManager = createMock(IUserLayoutManager.class);
        final IUserLayoutChannelDescription userLayoutChannelDescription = createMock(IUserLayoutChannelDescription.class);
        final IPortletDefinitionRegistry portletDefinitionRegistry = createMock(IPortletDefinitionRegistry.class);
        final IPortletDefinition portletDefinition = createMock(IPortletDefinition.class);
        final IChannelDefinition channelDefinition = createMock(IChannelDefinition.class);
        final IPerson person = createMock(IPerson.class);
        final IPortletEntityRegistry portletEntityRegistry = createMock(IPortletEntityRegistry.class);
        final IPortletEntity portletEntity = createMock(IPortletEntity.class);
        final IPortletWindow portletWindow = createMock(IPortletWindow.class);
       
        final MockPortletDefinitionId portletDefinitionId = new MockPortletDefinitionId("42");
        final MockPortletEntityId portletEntityId = new MockPortletEntityId("subId1");
        final MockPortletWindowId portletWindowId = new MockPortletWindowId("windowId1");
       
        expect(userInstanceManager.getUserInstance(request)).andReturn(userInstance);
        expect(userInstance.getPreferencesManager()).andReturn(userPreferencesManager);
        expect(userPreferencesManager.getUserLayoutManager()).andReturn(userLayoutManager);
        expect(userLayoutManager.getSubscribeId("my-info-student-center-home")).andReturn("subId1");
        expect(userLayoutManager.getNode("subId1")).andReturn(userLayoutChannelDescription);
        expect(userLayoutChannelDescription.getChannelPublishId()).andReturn("42");
        expect(portletDefinitionRegistry.getPortletDefinition(42)).andReturn(portletDefinition);
        expect(portletDefinition.getChannelDefinition()).andReturn(channelDefinition);
        expect(channelDefinition.isPortlet()).andReturn(true);
        expect(userInstance.getPerson()).andReturn(person);
View Full Code Here

Examples of org.jasig.portal.layout.IUserLayoutManager

        String fname = req.getParameter( Constants.FNAME_PARAM );

        if ( fname != null )
        {
            // need to get to wrapper for obtaining a subscribe id
            IUserLayoutManager ulm = upm.getUserLayoutManager();
            // get a subscribe id for the fname
            try {
                channelTarget = ulm.getSubscribeId(fname);
            } catch ( PortalException pe ) {
               log.error("ChannelManager::processRequestChannelParameters(): Unable to get subscribe ID for fname="+fname, pe);
              }
        }
        if ( channelTarget == null )
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.