Examples of StructureStylesheetUserPreferences


Examples of org.jasig.portal.StructureStylesheetUserPreferences

  {
    // Must get from store because the one in memory is comtaminated with stylesheet params
    // that shouldn't get persisted
    //UserPreferences userPrefsFromStore = context.getUserPreferencesFromStore(context.getCurrentUserPreferences().getProfile());
    //StructureStylesheetUserPreferences ssup = userPrefsFromStore.getStructureStylesheetUserPreferences();
    StructureStylesheetUserPreferences ssup = userPrefs.getStructureStylesheetUserPreferences();

    /*
      userPrefs is loaded directly from the database not copied from the
      UserPreferencesManager's value. As such it does not contain current
      session values like the structure stylesheet parameter userLayoutRoot
      which tells the rendering engine the node id that should be displayed
      in focused mode. While in preferences this node id is the node id of the
      preferences channel. That is a session value and should not be preserved.
      But the UserPreferencesManager's structure stylesheet user preferences
      object is being replaced by the version that we have here so that column
      width changes take immediate affect. Therefore, after persisting them we
      need to push the value of the userLayoutRoot node back into the
      preferences now held by the UserPreferencesManager so that the
      preferences channel remains in focus after changing the column widths.
     */
    String focusedNode = context.getUserPreferencesManager()
        .getUserPreferences().getStructureStylesheetUserPreferences()
        .getParameterValue( "userLayoutRoot" );
    String activeTab = context.getUserPreferencesManager()
        .getUserPreferences().getStructureStylesheetUserPreferences()
        .getParameterValue( "activeTab" );
   
    java.util.Set sColWidths = columnWidths.keySet();
    java.util.Iterator iterator = sColWidths.iterator();
    while(iterator.hasNext())
    {
      String folderId = (String)iterator.next();
      String newWidth = (String)columnWidths.get(folderId);

      // Only accept widths that are either percentages or integers (fixed widths)
      boolean widthIsValid = true;
      try
      {
        Integer.parseInt(newWidth.endsWith("%") ? newWidth.substring(0, newWidth.indexOf("%")) : newWidth);
      }
      catch (java.lang.NumberFormatException nfe)
      {
        widthIsValid = false;
      }

      if (widthIsValid)
      {
        ssup.setFolderAttributeValue(folderId, "width", newWidth);
        Element folder = ulm.getUserLayoutDOM().getElementById( folderId );
        UserPrefsHandler.setUserPreference( folder, "width",
                                            staticData.getPerson() );
      }
      else
        if (log.isDebugEnabled())
            log.debug("User id " + staticData.getPerson().getID() + " entered invalid column width: " + newWidth);
       
    }

    // Persist structure stylesheet user preferences
    saveUserPreferences();
    saveLayout(false);
   
    // now push the focused node value back into new rendering prefs object.
    ssup.putParameterValue( "userLayoutRoot", focusedNode );
   
    if ( activeTab != null )
        ssup.putParameterValue( "activeTab", activeTab );
    }
View Full Code Here

Examples of org.jasig.portal.StructureStylesheetUserPreferences

        return originIds;
    }

    private StructureStylesheetUserPreferences _getStructureStylesheetUserPreferences (IPerson person, int profileId, int stylesheetId) throws Exception {
        int userId = person.getID();
        StructureStylesheetUserPreferences ssup;
       
        // get stylesheet description
        StructureStylesheetDescription ssd = getStructureStylesheetDescription(stylesheetId);
       
        Connection con = RDBMServices.getConnection();
        try {
            int origId;
            int origProfileId;
            String sQuery = "SELECT USER_DFLT_USR_ID FROM UP_USER WHERE USER_ID = ?";
            final PreparedStatement pstmt1 = con.prepareStatement(sQuery);
            try {
                // now look to see if this user has a layout or not. This is
                // important because preference values are stored by layout
                // element and if the user doesn't have a layout yet then the
                // default user's preferences need to be loaded.
                int layoutId = this.getLayoutID(userId, profileId);

                // if no layout then get the default user id for this user

                origId = userId;
                origProfileId = profileId;
                if (layoutId == 0) {
                   
                    pstmt1.setInt(1,userId);
                    if (LOG.isDebugEnabled())
                        LOG.debug(sQuery + " VALUE " + userId);
                    final ResultSet rs = pstmt1.executeQuery();
                    try {
                        rs.next();
                        userId = rs.getInt(1);
                       
                        // get the profile ID for the default user
                        UserProfile profile = getUserProfileById(person, profileId);
                    IPerson defaultProfilePerson = new PersonImpl();
                    defaultProfilePerson.setID(userId);
                        profileId = getUserProfileByFname(defaultProfilePerson, profile.getProfileFname()).getProfileId();

                    } finally {
                        close(rs);
                    }
                }
            } finally {
                close(pstmt1);
            }

            // create the stylesheet user prefs object then fill
            // it with defaults from the stylesheet definition object

            ssup = new StructureStylesheetUserPreferences();
            ssup.setStylesheetId(stylesheetId);

            // fill stylesheet description with defaults
            for (Enumeration e = ssd.getStylesheetParameterNames(); e.hasMoreElements();) {
                String pName = (String)e.nextElement();
                ssup.putParameterValue(pName, ssd.getStylesheetParameterDefaultValue(pName));
            }
            for (Enumeration e = ssd.getChannelAttributeNames(); e.hasMoreElements();) {
                String pName = (String)e.nextElement();
                ssup.addChannelAttribute(pName, ssd.getChannelAttributeDefaultValue(pName));
            }
            for (Enumeration e = ssd.getFolderAttributeNames(); e.hasMoreElements();) {
                String pName = (String)e.nextElement();
                ssup.addFolderAttribute(pName, ssd.getFolderAttributeDefaultValue(pName));
            }

            // Now load in the stylesheet parameter preferences
            // from the up_ss_user_param but only if they are defined
            // parameters in the stylesheet's .sdf file.
            //
            // First, get the parameters for the effective user ID,
            // then for the original user ID.  These will differ if
            // the user has no layout in the database and is using
            // the default user layout.  The params from the original
            // user ID take precedence.

            String pstmtQuery =
                "SELECT PARAM_NAME, PARAM_VAL " +
                "FROM UP_SS_USER_PARM " +
                "WHERE USER_ID=?" +
                " AND PROFILE_ID=?"+
                " AND SS_ID=?" +
                " AND SS_TYPE=1";

            final PreparedStatement pstmt2 = con.prepareStatement(pstmtQuery);

            try {
                pstmt2.setInt(1, userId);
                pstmt2.setInt(2,profileId);
                pstmt2.setInt(3,stylesheetId);
                final ResultSet rs1 = pstmt2.executeQuery();
                try {
                    while (rs1.next()) {
                        String pName = rs1.getString(1);
                        if (ssd.containsParameterName(pName))
                            ssup.putParameterValue(pName, rs1.getString(2));
                    }
                }
                finally {
                    close(rs1);
                }

                if (userId != origId) {
                    pstmt2.setInt(1, origId);
                    pstmt2.setInt(2,origProfileId);
                    final ResultSet rs2 = pstmt2.executeQuery();
                    try {
                        while (rs2.next()) {
                            String pName = rs2.getString(1);
                            if (ssd.containsParameterName(pName))
                                ssup.putParameterValue(pName, rs2.getString(2));
                        }
                    }
                    finally {
                        close(rs2);
                    }
                }
            }
            finally {
                close(pstmt2);
            }

           
            Map<Integer, String> originIds = getOriginIds(con, userId, profileId, 1, stylesheetId);

            /*
             * now go get the overridden values and compare them against the
             * map for their origin ids.
             */
                    sQuery = "SELECT PARAM_NAME, PARAM_VAL, PARAM_TYPE," +
            " ULS.STRUCT_ID, CHAN_ID " +
                            "FROM UP_LAYOUT_STRUCT ULS, " +
            " UP_SS_USER_ATTS UUSA " +
                            "WHERE UUSA.USER_ID=?"+
                            " AND PROFILE_ID=?" +
                            " AND SS_ID=?" +
                            " AND SS_TYPE=1" +
                            " AND UUSA.STRUCT_ID = ULS.STRUCT_ID" +
                            " AND UUSA.USER_ID = ULS.USER_ID";

            if (LOG.isDebugEnabled())
                LOG.debug(sQuery + "VALUES ");

            final PreparedStatement pstmt4 = con.prepareStatement(sQuery);
            try {
                pstmt4.setInt(1,userId);
                pstmt4.setInt(2,profileId);
                pstmt4.setInt(3,stylesheetId);
                final ResultSet rs = pstmt4.executeQuery();
                try {
                    while (rs.next()) {
                        // get the LONG column first so Oracle doesn't toss a
                        // java.sql.SQLException: Stream has already been closed
                        String param_val = rs.getString(2);
                        int structId = rs.getInt(4);
                        String originId = null;
                        if (originIds != null)
                            originId = originIds.get(new Integer(structId));

                        int param_type = rs.getInt(3);
                        if (rs.wasNull()) {
                            structId = 0;
                        }
                        String pName = rs.getString(1);
                        int chanId = rs.getInt(5);
                        if (rs.wasNull()) {
                            chanId = 0;
                        }
                        /*
                         * ignore unexpected param_types since persisting
                         * removes all entries in table and it will get resolved
                         * without a log entry to point out the error.
                         */
                        if (param_type == 2) {
                            // folder attribute
                            String folderStructId = null;
                            if ( originId != null )
                                folderStructId = originId;
                            else
                                folderStructId = getStructId(structId,chanId);
                            if (ssd.containsFolderAttribute(pName))
                                ssup.setFolderAttributeValue(folderStructId, pName, param_val);
                        }
                        else if (param_type == 3) {
                            // channel attribute
                            String channelStructId = null;
                            if ( originId != null )
                                channelStructId = originId;
                            else
                                channelStructId = getStructId(structId,chanId);
                            if (ssd.containsChannelAttribute(pName))
                                ssup.setChannelAttributeValue(channelStructId, pName, param_val);
                        }
                    }
                } finally {
                    close(rs);
                }
View Full Code Here

Examples of org.jasig.portal.StructureStylesheetUserPreferences

          sstr.setParameter("activeTab", activeTab);
          sstr.setParameter("action", action);
          sstr.setParameter("elementID", elementID != null ? elementID : "none");
          sstr.setParameter("errorMessage", errorMessage);

          StructureStylesheetUserPreferences ssup = userPrefs.getStructureStylesheetUserPreferences();
          StructureAttributesIncorporationFilter saif = new StructureAttributesIncorporationFilter(th, ssup);

          // Put a duplicating filter before th
          StringWriter sw = null;
          OutputFormat outputFormat = null;
View Full Code Here

Examples of org.jasig.portal.StructureStylesheetUserPreferences

          sstr.setParameter("activeTab", activeTab);
          sstr.setParameter("action", action);
          sstr.setParameter("elementID", elementID != null ? elementID : "none");
          sstr.setParameter("errorMessage", errorMessage);

          StructureStylesheetUserPreferences ssup = userPrefs.getStructureStylesheetUserPreferences();
          StructureAttributesIncorporationFilter saif = new StructureAttributesIncorporationFilter(th, ssup);

          // Put a duplicating filter before th
          StringWriter sw = null;
          OutputFormat outputFormat = null;
View Full Code Here

Examples of org.jasig.portal.StructureStylesheetUserPreferences

                //Get the user's profile
                final UserProfile userProfile = uPreferencesManager.getCurrentProfile();
               
                //Find the activeTab index
                final UserPreferences userPreferences = uPreferencesManager.getUserPreferences();
                final StructureStylesheetUserPreferences structureStylesheetUserPreferences = userPreferences.getStructureStylesheetUserPreferences();
                final String activeTab = structureStylesheetUserPreferences.getParameterValue("activeTab");
                final int activeTabIndex = org.apache.commons.lang.math.NumberUtils.toInt(activeTab, 1);
               
                //Get the user's layout and find the targeted folder (tab)
                final IUserLayoutManager userLayoutManager = uPreferencesManager.getUserLayoutManager();
                final IUserLayoutFolderDescription targetedNode = this.getActiveTab(userLayoutManager, activeTabIndex);
View Full Code Here

Examples of org.jasig.portal.StructureStylesheetUserPreferences

        try {
            String newNodeId = null;

             // Sending the theme stylesheets parameters based on the user security context
             ThemeStylesheetUserPreferences themePrefs = userPrefs.getThemeStylesheetUserPreferences();
             StructureStylesheetUserPreferences structPrefs = userPrefs.getStructureStylesheetUserPreferences();

             String authenticated = String.valueOf(person.getSecurityContext().isAuthenticated());
             structPrefs.putParameterValue("authenticated", authenticated);
             String userName = person.getFullName();
             if (userName != null && userName.trim().length() > 0)
                 themePrefs.putParameterValue("userName", userName);

             String[] values;

             if ((values = req.getParameterValues("uP_request_move_targets")) != null) {
                 if ( values[0].trim().length() == 0 ) values[0] = null;
                  this.markMoveTargets(values[0]);
             } else {
                  this.markMoveTargets(null);
               }

             if ((values = req.getParameterValues("uP_request_add_targets")) != null) {
                 String value;
                 int nodeType = values[0].equals("folder")?IUserLayoutNodeDescription.FOLDER:IUserLayoutNodeDescription.CHANNEL;
                 IUserLayoutNodeDescription nodeDesc = this.createNodeDescription(nodeType);
                 nodeDesc.setName("Unnamed");
                 if ( nodeType == IUserLayoutNodeDescription.CHANNEL && (value = req.getParameter("channelPublishID")) != null ) {
                  String contentPublishId = value.trim();
                  if ( contentPublishId.length() > 0 ) {
                   ((IUserLayoutChannelDescription)nodeDesc).setChannelPublishId(contentPublishId);
                   themePrefs.putParameterValue("channelPublishID",contentPublishId);
                  }
                 }
                 newNodeDescription = nodeDesc;
                 this.markAddTargets(newNodeDescription);
             } else {
                 this.markAddTargets(null);
               }

             if ((values = req.getParameterValues("uP_add_target")) != null) {
              String[] values1, values2;
              String value = null;
              values1 =  req.getParameterValues("targetNextID");
              if ( values1 != null && values1.length > 0 )
                 value = values1[0];
              if ( (values2 = req.getParameterValues("targetParentID")) != null ) {
               if newNodeDescription != null ) {
                 if ( CommonUtils.nvl(value).trim().length() == 0 )
                  value = null;

                 // Adding a new node
                 newNodeId = this.addNode(newNodeDescription,values2[0],value).getId();
               }
              }
                 newNodeDescription = null;
             }

             if ((values = req.getParameterValues("uP_move_target")) != null) {
              String[] values1, values2;
              String value = null;
              values1 = req.getParameterValues("targetNextID");
              if ( values1 != null && values1.length > 0 )
                 value = values1[0];
              if ( (values2 = req.getParameterValues("targetParentID")) != null ) {
                 if ( CommonUtils.nvl(value).trim().length() == 0 ) value = null;
                 this.moveNode(values[0],values2[0],value);
              }
             }

             if ((values = req.getParameterValues("uP_rename_target")) != null) {
              String[] values1;
              if ( (values1 = req.getParameterValues("uP_target_name")) != null ) {
                 IUserLayoutNodeDescription nodeDesc = this.getNode(values[0]);
                 if ( nodeDesc != null ) {
                  String oldName = nodeDesc.getName();
                  nodeDesc.setName(values1[0]);
                  if ( !this.updateNode(nodeDesc) )
                   nodeDesc.setName(oldName);
                 }
              }
             }

             if ((values = req.getParameterValues("uP_remove_target")) != null) {
                 for (int i = 0; i < values.length; i++) {
                     this.deleteNode(values[i]);
                 }
             }

             String param = req.getParameter("uP_cancel_targets");
             if ( param != null && param.equals("true") ) {
                this.markAddTargets(null);
                this.markMoveTargets(null);
                newNodeDescription = null;
             }

         param = req.getParameter("uP_reload_layout");
         if ( param != null && param.equals("true") ) {
           this.loadUserLayout();
         }

         // If we have created a new node we need to let the structure XSL know about it
         structPrefs.putParameterValue("newNodeID",CommonUtils.nvl(newNodeId));
           } catch ( Exception e ) {
               throw new PortalException(e);
             }
    }
View Full Code Here

Examples of org.jasig.portal.StructureStylesheetUserPreferences

      }
    }

    int count = 0;
    columns = ulm.getChildIds(tabId);
    StructureStylesheetUserPreferences ssup = upm.getUserPreferences()
    .getStructureStylesheetUserPreferences();
    while (columns.hasMoreElements()) {
      String columnId = (String) columns.nextElement();
      ssup.setFolderAttributeValue(columnId, "width", newcolumns[count] + "%");
      Element folder = ulm.getUserLayoutDOM().getElementById(columnId);
      try {
        // This sets the column attribute in memory but doesn't persist it.  Comment says saves changes "prior to persisting"
        UserPrefsHandler.setUserPreference(folder, "width", per);
            saveSSUPPreservingTab(ulm, upm, per, ssup);
View Full Code Here

Examples of org.jasig.portal.StructureStylesheetUserPreferences

      siblingId = destinationId;

    // move the node as requested and save the layout
    ulm.moveNode(sourceId, ulm.getParentId(destinationId), siblingId);

    StructureStylesheetUserPreferences ssup = upm.getUserPreferences()
        .getStructureStylesheetUserPreferences();

    try {
            String currentTab = ssup.getParameterValue(ACTIVE_TAB_PARAM);
            UserProfile currentProfile = upm.getUserPreferences().getProfile();
            int profileID = currentProfile.getProfileId();
            int structID = currentProfile.getStructureStylesheetId();
            // get the active tab number from the store so that we can preserve it
            String defaultTab = ulStore.getStructureStylesheetUserPreferences(per, profileID, structID).getParameterValue(ACTIVE_TAB_PARAM);
            // set the active tab to previously recorded value
            if (defaultTab.equals(currentTab)) {
                ssup.putParameterValue(ACTIVE_TAB_PARAM, tabPosition);
            }
            else {
                ssup.putParameterValue(ACTIVE_TAB_PARAM, defaultTab);
            }
            // This is a brute force save of the new attributes.  It requires access to the layout store. -SAB
            ulStore.setStructureStylesheetUserPreferences(per, profileID, ssup);
    } catch (Exception e) {
      log.error(e, e);
    }

    ulm.saveUserLayout();

        // reset the active tab for viewing (not default)
    ssup.putParameterValue(ACTIVE_TAB_PARAM, tabPosition);

    printSuccess(response, "Saved new tab position", null);

  }
View Full Code Here

Examples of org.jasig.portal.StructureStylesheetUserPreferences

    // set the new width for each column to be equal
    int width = 100 / count;
    String widthString = width + "%";

    StructureStylesheetUserPreferences ssup = upm.getUserPreferences().getStructureStylesheetUserPreferences();
        UserProfile currentProfile = upm.getUserPreferences().getProfile();
    columns = ulm.getChildIds(tabId);
    String currentTab = ssup.getParameterValue( ACTIVE_TAB_PARAM );
    try {
      while (columns.hasMoreElements()) {
        String columnId = (String) columns.nextElement();
        ssup.setFolderAttributeValue(columnId, "width", widthString);
        Element folder = ulm.getUserLayoutDOM().getElementById(columnId);
        // This sets the column attribute in memory but doesn't persist it.  Comment says saves changes "prior to persisting"
        UserPrefsHandler.setUserPreference(folder, "width", per);
               
        count++;
View Full Code Here

Examples of org.jasig.portal.StructureStylesheetUserPreferences

      HttpServletResponse response) throws IOException, PortalException {

    String[] columnIds = request.getParameterValues("columnIds");
    String[] columnWidths = request.getParameterValues("columnWidths");

    StructureStylesheetUserPreferences ssup = upm.getUserPreferences()
        .getStructureStylesheetUserPreferences();
    String currentTab = ssup.getParameterValue( ACTIVE_TAB_PARAM );

    for (int i = 0; i < columnIds.length; i++) {
      ssup
          .setFolderAttributeValue(columnIds[i], "width",
              columnWidths[i]);
      Element folder = ulm.getUserLayoutDOM()
          .getElementById(columnIds[i]);
      try {
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.