Package org.jasig.portal

Examples of org.jasig.portal.ThemeStylesheetUserPreferences


        throw new PortalException("Unable to generate a new next fragment node id!");
    }

    public ThemeStylesheetUserPreferences getThemeStylesheetUserPreferences (IPerson person, int profileId, int stylesheetId) throws Exception {
    int userId = person.getID();
    ThemeStylesheetUserPreferences tsup;
    Connection con = RDBMServices.getConnection();
    try {
      Statement stmt = con.createStatement();
      try {
        // get stylesheet description
        ThemeStylesheetDescription tsd = getThemeStylesheetDescription(stylesheetId);
       
        int layoutId = this.getLayoutID(userId, profileId);
        ResultSet rs;

        if (layoutId == 0) { // First time, grab the default layout for this user
          String sQuery = "SELECT USER_DFLT_USR_ID FROM UP_USER WHERE USER_ID=" + userId;
          if (log.isDebugEnabled())
              log.debug("RDBMUserLayoutStore::getThemeStylesheetUserPreferences(): " + sQuery);
          rs = stmt.executeQuery(sQuery);
          try {
            rs.next();
            userId = rs.getInt(1);
          } finally {
            rs.close();
          }
        } 

        // get user defined defaults
        String sQuery = "SELECT PARAM_NAME, PARAM_VAL FROM UP_SS_USER_PARM WHERE USER_ID=" + userId + " AND PROFILE_ID="
            + profileId + " AND SS_ID=" + stylesheetId + " AND SS_TYPE=2";
        if (log.isDebugEnabled())
            log.debug("RDBMUserLayoutStore::getThemeStylesheetUserPreferences(): " + sQuery);
        rs = stmt.executeQuery(sQuery);
        try {
          while (rs.next()) {
            // stylesheet param
            tsd.setStylesheetParameterDefaultValue(rs.getString(1), rs.getString(2));
          }
        } finally {
          rs.close();
        }
        tsup = new ThemeStylesheetUserPreferences();
        tsup.setStylesheetId(stylesheetId);
        // fill stylesheet description with defaults
        for (Enumeration e = tsd.getStylesheetParameterNames(); e.hasMoreElements();) {
          String pName = (String)e.nextElement();
          tsup.putParameterValue(pName, tsd.getStylesheetParameterDefaultValue(pName));
        }
        for (Enumeration e = tsd.getChannelAttributeNames(); e.hasMoreElements();) {
          String pName = (String)e.nextElement();
          tsup.addChannelAttribute(pName, tsd.getChannelAttributeDefaultValue(pName));
        }
        // get user preferences
        sQuery = "SELECT PARAM_TYPE, PARAM_NAME, PARAM_VAL, ULS.NODE_ID, CHAN_ID FROM UP_SS_USER_ATTS UUSA, UP_LAYOUT_STRUCT_AGGR ULS WHERE UUSA.USER_ID=" + userId + " AND PROFILE_ID="
            + profileId + " AND SS_ID=" + stylesheetId + " AND SS_TYPE=2 AND UUSA.STRUCT_ID = ULS.NODE_ID AND UUSA.USER_ID = ULS.USER_ID";
        if (log.isDebugEnabled())
            log.debug("RDBMUserLayoutStore::getThemeStylesheetUserPreferences(): " + sQuery);
        rs = stmt.executeQuery(sQuery);
        try {
          while (rs.next()) {
            int param_type = rs.getInt(1);
            if (rs.wasNull()) {
              param_type = 0;
            }
            int structId = rs.getInt(4);
            if (rs.wasNull()) {
              structId = 0;
            }
            int chanId = rs.getInt(5);
            if (rs.wasNull()) {
              chanId = 0;
            }
            if (param_type == 1) {
              // stylesheet param
              log.error( "AggregatedUserLayoutStore::getThemeStylesheetUserPreferences() :  stylesheet global params should be specified in the user defaults table ! UP_SS_USER_ATTS is corrupt. (userId="
                  + Integer.toString(userId) + ", profileId=" + Integer.toString(profileId) + ", stylesheetId=" + Integer.toString(stylesheetId)
                  + ", param_name=\"" + rs.getString(2) + "\", param_type=" + Integer.toString(param_type));
            }
            else if (param_type == 2) {
              // folder attribute
              log.error( "AggregatedUserLayoutStore::getThemeStylesheetUserPreferences() :  folder attribute specified for the theme stylesheet! UP_SS_USER_ATTS corrupt. (userId="
                  + Integer.toString(userId) + ", profileId=" + Integer.toString(profileId) + ", stylesheetId=" + Integer.toString(stylesheetId)
                  + ", param_name=\"" + rs.getString(2) + "\", param_type=" + Integer.toString(param_type));
            }
            else if (param_type == 3) {
              // channel attribute
              tsup.setChannelAttributeValue(getStructId(structId,chanId), rs.getString(2), rs.getString(3));
            }
            else {
              // unknown param type
              log.error( "AggregatedUserLayoutStore::getThemeStylesheetUserPreferences() : unknown param type encountered! DB corrupt. (userId="
                  + Integer.toString(userId) + ", profileId=" + Integer.toString(profileId) + ", stylesheetId=" + Integer.toString(stylesheetId)
View Full Code Here


                    chnl.elements().add(0, sa);
                }
            }
        }
        // The theme transform supports only 'channel' attributes...
        ThemeStylesheetUserPreferences tsup = up.getThemeStylesheetUserPreferences();
        List<String> themeChannelAttrNames = Collections.list(tsup.getChannelAttributeNames());
        for (Iterator<org.dom4j.Element> chnls = (Iterator<org.dom4j.Element>) layoutDoc.selectNodes("//channel").iterator(); chnls.hasNext();) {
            org.dom4j.Element chnl = chnls.next();
            for (String attr : themeChannelAttrNames) {
                String val = tsup.getDefinedChannelAttributeValue(chnl.valueOf("@ID"), attr);
                if (val != null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Adding theme channel attribute:  name=" + attr + ", value=" + val);
                    }
                    org.dom4j.Element ta = fac.createElement("theme-attribute");
View Full Code Here

                sa.getParent().remove(sa);
            }
           
            // Theme Attributes.
            boolean taSet = false;
            ThemeStylesheetUserPreferences tsup = up.getThemeStylesheetUserPreferences();
            // tsup must be manually cleaned out.
            for (Enumeration<String> names = (Enumeration<String>) tsup.getChannelAttributeNames(); names.hasMoreElements();) {
                String n = names.nextElement();
                for (Enumeration<String> chds = (Enumeration<String>) tsup.getChannels(); chds.hasMoreElements();) {
                    String c = chds.nextElement();
                    if (tsup.getDefinedChannelAttributeValue(c, n) != null) {
                        tsup.removeChannel(c);
                    }
                }
            }
            for (Iterator<org.dom4j.Element> it = (Iterator<org.dom4j.Element>) layout.selectNodes("//theme-attribute").iterator(); it.hasNext();) {
                org.dom4j.Element ta = (org.dom4j.Element) it.next();
                String idAttr = ta.getParent().valueOf("@ID");
                // Theme attributes are channels only...
                tsup.setChannelAttributeValue(idAttr, ta.valueOf("name"), ta.valueOf("value"));
                taSet = true;
                // Remove these elements or else DLM will choke...
                ta.getParent().remove(ta);
            }
View Full Code Here

    private ThemeStylesheetUserPreferences _getThemeStylesheetUserPreferences(
            IPerson person, int profileId, int stylesheetId) throws Exception
    {
        int userId = person.getID();
        ThemeStylesheetUserPreferences tsup;
        Connection con = RDBMServices.getConnection();
        try
        {
            // get stylesheet description
            ThemeStylesheetDescription tsd = getThemeStylesheetDescription(stylesheetId);
            // get user defined defaults

            int layoutId = this.getLayoutID(userId, profileId);
           
            // if no layout then get the default user id for this user
            int origId = userId;
            int origProfileId = profileId;
            if (layoutId == 0)
            { // First time, grab the default layout for this user
                String sQuery = "SELECT USER_DFLT_USR_ID FROM UP_USER WHERE USER_ID=?";
                if (log.isDebugEnabled())
                    log.debug(sQuery + " VALUE = " + userId);
                final PreparedStatement pstmt1 = con.prepareStatement(sQuery);
                try {
                    pstmt1.setInt(1,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

            tsup = new ThemeStylesheetUserPreferences();
            tsup.setStylesheetId(stylesheetId);
            // fill stylesheet description with defaults
            for (Enumeration e = tsd.getStylesheetParameterNames(); e
                    .hasMoreElements();)
            {
                String pName = (String) e.nextElement();
                tsup.putParameterValue(pName, tsd
                        .getStylesheetParameterDefaultValue(pName));
            }
            for (Enumeration e = tsd.getChannelAttributeNames(); e
                    .hasMoreElements();)
            {
                String pName = (String) e.nextElement();
                tsup.addChannelAttribute(pName, tsd
                        .getChannelAttributeDefaultValue(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 sQuery2 =
                "SELECT PARAM_NAME, PARAM_VAL " +
                "FROM UP_SS_USER_PARM " +
                "WHERE USER_ID=?" +
                " AND PROFILE_ID=?" +
                " AND SS_ID=?" +
                " AND SS_TYPE=2";

            if (log.isDebugEnabled())
                log.debug(sQuery2 + " VALUES " +  userId + "," + profileId + "," + stylesheetId);
           
            final PreparedStatement pstmt2 = con.prepareStatement(sQuery2);
            try
            {
                pstmt2.setInt(1, userId);
                pstmt2.setInt(2,profileId);
                pstmt2.setInt(3,stylesheetId);
                final ResultSet rs = pstmt2.executeQuery();
                try {
                    while (rs.next())
                    {
                        // stylesheet param
                        String pName = rs.getString(1);
                        if (tsd.containsParameterName(pName))
                          tsup.putParameterValue(pName, rs.getString(2));
                    }
                }
                finally {
                    close(rs);
                }
               
                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 (tsd.containsParameterName(pName))
                              tsup.putParameterValue(pName, rs2.getString(2));
                        }
                    }
                    finally {
                        close(rs2);
                    }
                }
            } finally
            {
                close(pstmt2);
            }
           
            Map<Integer, String> originIds = getOriginIds(con, userId, profileId, 2, stylesheetId);

            // Now load in the channel attributes preferences from the
            // up_ss_user_atts table

            final String sQuery3 = "SELECT PARAM_TYPE, PARAM_NAME, PARAM_VAL, " +
                    "ULS.STRUCT_ID, CHAN_ID " +
                    "FROM UP_SS_USER_ATTS UUSA, UP_LAYOUT_STRUCT ULS " +
                    "WHERE UUSA.USER_ID=?" +
                    " AND PROFILE_ID=?"  +
                    " AND SS_ID=?"  +
                    " AND SS_TYPE=2" +
                    " AND UUSA.STRUCT_ID = ULS.STRUCT_ID" +
                    " AND UUSA.USER_ID = ULS.USER_ID";
            if (log.isDebugEnabled())
                log.debug("SQL to load theme channel attribute prefs: "
                                + sQuery3 + " VALUES " + userId + "," + profileId + "," + stylesheetId);
            final PreparedStatement pstmt3 = con.prepareStatement(sQuery3);
            try {
                pstmt3.setInt(1,userId);
                pstmt3.setInt(2,profileId);
                pstmt3.setInt(3,stylesheetId);
               
                final ResultSet rs = pstmt3.executeQuery();
                try {
                    while (rs.next())
                    {
                        int param_type = rs.getInt(1);
                        if (rs.wasNull())
                        {
                            param_type = 0;
                        }
                        int structId = rs.getInt(4);
                        String originId = null;
                        if (originIds != null)
                                originId = originIds.get(new Integer(structId));
                       
                        if (rs.wasNull())
                        {
                            structId = 0;
                        }
                        int chanId = rs.getInt(5);
                        if (rs.wasNull())
                        {
                            chanId = 0;
                        }
                        // only use channel attributes ignoring any others.
                        // we should never get any others in here unless there
                        // is db corruption and since all are flushed when
                        // writting back to the db it should be self correcting
                        // if it ever does occur somehow.
                        if (param_type == 3)
                        {
                            // channel attribute
                            String channelStructId = null;
                            if ( originId != null )
                                channelStructId = originId;
                            else
                                channelStructId = getStructId(structId,chanId);
                            tsup.setChannelAttributeValue(channelStructId, rs.getString(2), rs.getString(3));
                        }
                    }
                } finally
                {
                    close(rs);
View Full Code Here

        String action = runtimeData.getParameter("action");
        if (action != null) {
            if (runtimeData.getParameter("submitSave")!=null) {
                // save
                String skinName = runtimeData.getParameter("skinName");
                ThemeStylesheetUserPreferences themePrefs = userPrefs.getThemeStylesheetUserPreferences();
                themePrefs.putParameterValue("skin",skinName);
               
                final IPerson person = staticData.getPerson();
                final UserProfile profile = userPrefs.getProfile();
                final int profileId = profile.getProfileId();
                try {
View Full Code Here

    {
        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 {
View Full Code Here

        }
       
        final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
        final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
        final UserPreferences userPreferences = preferencesManager.getUserPreferences();
        final ThemeStylesheetUserPreferences themeStylesheetUserPreferences = userPreferences.getThemeStylesheetUserPreferences();
       
        final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(portletEntityId);
        final String channelSubscribeId = portletEntity.getChannelSubscribeId();
        final String minimized = themeStylesheetUserPreferences.getChannelAttributeValue(channelSubscribeId, "minimized");
       
        if (Boolean.parseBoolean(minimized)) {
            portletWindow.setWindowState(WindowState.MINIMIZED);
        }
    }
View Full Code Here

     * @see org.jasig.portal.layout.dlm.processing.IParameterProcessor#processParameters(org.jasig.portal.UserPreferences, javax.servlet.http.HttpServletRequest)
     */
    public void processParameters(UserPreferences prefs, HttpServletRequest request)
    {
     
        ThemeStylesheetUserPreferences themePrefs = prefs
        .getThemeStylesheetUserPreferences();
    themePrefs.putParameterValue("USE_AJAX", "true");

    }
View Full Code Here

     * @see org.jasig.portal.layout.dlm.processing.IParameterProcessor#processParameters(org.jasig.portal.UserPreferences, javax.servlet.http.HttpServletRequest)
     */
    public void processParameters(UserPreferences prefs, HttpServletRequest request)
    {
     
        ThemeStylesheetUserPreferences themePrefs = prefs
        .getThemeStylesheetUserPreferences();

        // as long as this isn't a guest user, set the "AUTHENTICATED" flag
        if (!person.isGuest()) {
        themePrefs.putParameterValue("AUTHENTICATED", "true");
        }
       
    }
View Full Code Here

  private void chooseSkin(IPerson per, UserPreferencesManager upm,
      IUserLayoutManager ulm, HttpServletRequest request,
      HttpServletResponse response) throws IOException, PortalException {

    String skinName = request.getParameter("skinName");
        ThemeStylesheetUserPreferences themePrefs = upm.getUserPreferences().getThemeStylesheetUserPreferences();
        themePrefs.putParameterValue("skin",skinName);
    try {
      ulStore.setThemeStylesheetUserPreferences(per, upm
          .getUserPreferences().getProfile().getProfileId(), themePrefs);
    } catch (Exception e) {
      log.error("Error storing user skin preferences", e);
View Full Code Here

TOP

Related Classes of org.jasig.portal.ThemeStylesheetUserPreferences

Copyright © 2018 www.massapicom. 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.