Examples of ThemeStylesheetDescription


Examples of org.jasig.portal.ThemeStylesheetDescription

     *
     * @param profile profile for which preferences are to be edited
     */
    private void instantiateManagePreferencesState(UserProfile profile) {
        try {
            ThemeStylesheetDescription tsd = ulsdb.getThemeStylesheetDescription(profile.getThemeStylesheetId());
            if(tsd!=null) {
                String cupmClass = tsd.getCustomUserPreferencesManagerClass();
                managePreferences = (IPrivilegedChannel)Class.forName(cupmClass).newInstance();
                ((BaseState)managePreferences).setContext(this);
            } else {
                log.error("CUserPreferences::instantiateManagePreferencesState() : unable to retrieve theme stylesheet description. stylesheetId="+profile.getThemeStylesheetId());
                managePreferences = new GPreferencesState(this);
View Full Code Here

Examples of org.jasig.portal.ThemeStylesheetDescription

            if (channel instanceof ICharacterChannel) {
                ((ICharacterChannel) channel).renderCharacters(printWriter);
            }
            else {
                final IUserPreferencesManager userPreferencesManager = this.portcs.getUserPreferencesManager();
                final ThemeStylesheetDescription tsd = userPreferencesManager.getThemeStylesheetDescription();
                final String serializerName = tsd.getSerializerName();
               
                final BaseMarkupSerializer serOut = MEDIAMANAGER.getSerializerByName(serializerName, printWriter);
                channel.renderXML(serOut);
            }
        }
View Full Code Here

Examples of org.jasig.portal.ThemeStylesheetDescription

        }
        else {
            BaseMarkupSerializer serOut = null;
            try {
                final IUserPreferencesManager userPreferencesManager = this.portcs.getUserPreferencesManager();
                final ThemeStylesheetDescription tsd = userPreferencesManager.getThemeStylesheetDescription();
                serOut = MEDIAMANAGER.getSerializerByName(tsd.getSerializerName(), printWriter);
            }
            catch (Exception e) {
                log.error("unable to obtain proper markup serializer : ", e);
            }
View Full Code Here

Examples of org.jasig.portal.ThemeStylesheetDescription

      // determine id of the parent structure stylesheet
      Integer ssId = getStructureStylesheetId(ssName);
      // stylesheet not found, should thrown an exception here
      if (ssId == null)
        return  null;
      ThemeStylesheetDescription sssd = new ThemeStylesheetDescription();
      sssd.setStructureStylesheetId(ssId.intValue());
      String xmlStylesheetName = this.getName(stylesheetDescriptionXML);
      String xmlStylesheetDescriptionText = this.getDescription(stylesheetDescriptionXML);
      sssd.setStylesheetName(xmlStylesheetName);
      sssd.setStylesheetURI(stylesheetURI);
      sssd.setStylesheetDescriptionURI(stylesheetDescriptionURI);
      sssd.setStylesheetWordDescription(xmlStylesheetDescriptionText);
      sssd.setMimeType(this.getRootElementTextValue(stylesheetDescriptionXML, "mimeType"));
      if (log.isDebugEnabled())
          log.debug("RDBMUserLayoutStore::addThemeStylesheetDescription() : setting mimetype=\""
          + sssd.getMimeType() + "\"");
      sssd.setSerializerName(this.getRootElementTextValue(stylesheetDescriptionXML, "serializer"));
      if (log.isDebugEnabled())
          log.debug("RDBMUserLayoutStore::addThemeStylesheetDescription() : setting serializerName=\""
                  + sssd.getSerializerName() + "\"");
      sssd.setCustomUserPreferencesManagerClass(this.getRootElementTextValue(stylesheetDescriptionXML, "userPreferencesModuleClass"));
      sssd.setSamplePictureURI(this.getRootElementTextValue(stylesheetDescriptionXML, "samplePictureURI"));
      sssd.setSampleIconURI(this.getRootElementTextValue(stylesheetDescriptionXML, "sampleIconURI"));
      sssd.setDeviceType(this.getRootElementTextValue(stylesheetDescriptionXML, "deviceType"));

      // populate parameter and attriute tables
      this.populateParameterTable(stylesheetDescriptionXML, sssd);
      this.populateChannelAttributeTable(stylesheetDescriptionXML, sssd);
View Full Code Here

Examples of org.jasig.portal.ThemeStylesheetDescription

   * Obtain theme stylesheet description object for a given theme stylesheet id.
   * @param stylesheetId the id of the theme stylesheet
   * @return theme stylesheet description
   */
  public ThemeStylesheetDescription getThemeStylesheetDescription (int stylesheetId) throws Exception {
    ThemeStylesheetDescription tsd = null;
    Connection con = null;
    try {
      con = RDBMServices.getConnection();
      Statement stmt = con.createStatement();
      int dbOffset = 0;
      String sQuery = "SELECT SS_NAME,SS_URI,SS_DESCRIPTION_URI,SS_DESCRIPTION_TEXT,STRUCT_SS_ID,SAMPLE_ICON_URI,SAMPLE_URI,MIME_TYPE,DEVICE_TYPE,SERIALIZER_NAME,UP_MODULE_CLASS";
      if (this.databaseMetadata.supportsOuterJoins()) {
        sQuery += ",TYPE,PARAM_NAME,PARAM_DEFAULT_VAL,PARAM_DESCRIPT FROM " + this.databaseMetadata.getJoinQuery().getQuery("ss_theme");
        dbOffset = 11;
      } else {
        sQuery += " FROM UP_SS_THEME UTS WHERE";
      }
      sQuery += " UTS.SS_ID=" + stylesheetId;
      if (log.isDebugEnabled())
          log.debug("RDBMUserLayoutStore::getThemeStylesheetDescription(): " + sQuery);
      ResultSet rs = stmt.executeQuery(sQuery);
      try {
        if (rs.next()) {
          tsd = new ThemeStylesheetDescription();
          tsd.setId(stylesheetId);
          tsd.setStylesheetName(rs.getString(1));
          tsd.setStylesheetURI(rs.getString(2));
          tsd.setStylesheetDescriptionURI(rs.getString(3));
          tsd.setStylesheetWordDescription(rs.getString(4));
          int ssId = rs.getInt(5);
          if (rs.wasNull()) {
            ssId = 0;
          }
          tsd.setStructureStylesheetId(ssId);
          tsd.setSampleIconURI(rs.getString(6));
          tsd.setSamplePictureURI(rs.getString(7));
          tsd.setMimeType(rs.getString(8));
          tsd.setDeviceType(rs.getString(9));
          tsd.setSerializerName(rs.getString(10));
          tsd.setCustomUserPreferencesManagerClass(rs.getString(11));
        }

        if (!this.databaseMetadata.supportsOuterJoins()) {
          rs.close();
          // retrieve stylesheet params and attributes
          sQuery = "SELECT TYPE,PARAM_NAME,PARAM_DEFAULT_VAL,PARAM_DESCRIPT FROM UP_SS_THEME_PARM WHERE SS_ID=" + stylesheetId;
          if (log.isDebugEnabled())
              log.debug("RDBMUserLayoutStore::getThemeStylesheetDescription(): " + sQuery);
          rs = stmt.executeQuery(sQuery);
        }
        while (true) {
          if (!this.databaseMetadata.supportsOuterJoins() && !rs.next()) {
            break;
          }
          int type = rs.getInt(dbOffset + 1);
          if (rs.wasNull()) {
            break;
          }
          if (type == 1) {
            // param
            tsd.addStylesheetParameter(rs.getString(dbOffset + 2), rs.getString(dbOffset + 3), rs.getString(dbOffset + 4));
          }
          else if (type == 3) {
            // channel attribute
            tsd.addChannelAttribute(rs.getString(dbOffset + 2), rs.getString(dbOffset + 3), rs.getString(dbOffset + 4));
          }
          else if (type == 2) {
            // folder attributes are not allowed here
            log.error( "RDBMUserLayoutStore::getThemeStylesheetDescription() : encountered a folder attribute specified for a theme stylesheet ! Corrupted DB entry. (stylesheetId="
                + stylesheetId + " param_name=\"" + rs.getString(dbOffset + 2) + "\" type=" + type + ").");
View Full Code Here

Examples of org.jasig.portal.ThemeStylesheetDescription

        if (log.isDebugEnabled())
            log.debug("RDBMUserLayoutStore::getThemeStylesheetList() : " + sQuery);
        ResultSet rs = stmt.executeQuery(sQuery);
        try {
          while (rs.next()) {
            ThemeStylesheetDescription tsd = getThemeStylesheetDescription(rs.getInt("SS_ID"));
            if (tsd != null)
              list.put(new Integer(tsd.getId()), tsd);
          }
        } finally {
          rs.close();
        }
      } finally {
View Full Code Here

Examples of org.jasig.portal.ThemeStylesheetDescription

        if (log.isDebugEnabled())
            log.debug("RDBMUserLayoutStore::getThemeStylesheetList() : " + sQuery);
        ResultSet rs = stmt.executeQuery(sQuery);
        try {
          while (rs.next()) {
            ThemeStylesheetDescription tsd = getThemeStylesheetDescription(rs.getInt("SS_ID"));
            if (tsd != null)
              list.put(new Integer(tsd.getId()), tsd);
          }
        } finally {
          rs.close();
        }
      } finally {
View Full Code Here

Examples of org.jasig.portal.ThemeStylesheetDescription

     */
    @Override
    public ThemeStylesheetDescription getThemeStylesheetDescription(int stylesheetId)
        throws Exception
    {
        ThemeStylesheetDescription tsd = null;

        // Get it from the cache if it's there
        tsd =
            (ThemeStylesheetDescription) tsdCache.get(
                new Integer(stylesheetId));
View Full Code Here

Examples of org.jasig.portal.ThemeStylesheetDescription

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

Examples of org.jasig.portal.ThemeStylesheetDescription

        Document PLF = (Document) person.getAttribute( Constants.PLF );
        if ( PLF == null )
            throw new Exception( "Unable to obtain user's PLF to translate" +
                                 " incorporated ids to plfIds." );
        int stylesheetId = tsup.getStylesheetId();
        ThemeStylesheetDescription tsDesc =
            getThemeStylesheetDescription(stylesheetId);
        Connection con = RDBMServices.getConnection();
        try {
            // Set autocommit false for the connection
            con.setAutoCommit(false);
            //Statement pstmt = null;
            try {
                // before writing out params clean out old values
                deleteFromUpSsUserParm(con, userId, profileId, stylesheetId,2);

                // write out params only if defined in stylesheet's .sdf file
                // and user's value differs from default
                for (Enumeration e = tsup.getParameterValues().keys(); e.hasMoreElements();) {
                    String pName = (String)e.nextElement();
                    if (tsDesc.containsParameterName(pName) &&
                        ! tsDesc.getStylesheetParameterDefaultValue(pName)
                            .equals(tsup.getParameterValue(pName)))
                    {
                        //String pNameEscaped = RDBMServices.sqlEscape(pName);
                        String sQuery = "INSERT INTO UP_SS_USER_PARM (USER_ID,PROFILE_ID,SS_ID,SS_TYPE,PARAM_NAME,PARAM_VAL) VALUES (?,?,?,2,?,?)";
                        final PreparedStatement pstmt2 = con.prepareStatement(sQuery);
                        try {
                            pstmt2.setInt(1,userId);
                            pstmt2.setInt(2,profileId);
                            pstmt2.setInt(3,stylesheetId);
                            pstmt2.setString(4, pName);
                            pstmt2.setString(5,tsup.getParameterValue(pName));
                            if (LOG.isDebugEnabled())
                                LOG.debug(sQuery + "VALUE " + userId + "," + profileId + "," + stylesheetId + "," + pName + "," + tsup.getParameterValue(pName));
                            pstmt2.executeUpdate();
                        }
                        finally {
                            close(pstmt2);
                        }
                    }
                }
                // now before writing out channel atts clean out old values
                deleteFromUpSsUserAtts(con, userId, profileId, stylesheetId,2);

                // write out channel attributes
                for (Enumeration e = tsup.getChannels(); e.hasMoreElements();) {
                    String channelId = (String)e.nextElement();
                    String plfChannelId = channelId;

                    if ( plfChannelId.startsWith( Constants.FRAGMENT_ID_USER_PREFIX ) ) // icorporated node
                        plfChannelId = getPlfId( PLF, channelId );
                    if ( plfChannelId == null ) //couldn't translate, skip
                        continue;

                    for (Enumeration attre = tsup.getChannelAttributeNames(); attre.hasMoreElements();) {
                        String pName = (String)attre.nextElement();
                        String pValue = tsup.getDefinedChannelAttributeValue(channelId, pName);

                        /*
                         * Persist channel attributes defined in the stylesheet
                         * description only if the user value is non null and
                         * there is no default or the user value
                         * differs from the default.
                         */
                        if (tsDesc.containsChannelAttribute(pName))
                        {
                            String deflt = dtsup
                            .getDefaultChannelAttributeValue(channelId, pName);
                            if(pValue != null && (deflt == null ||
                                    ! pValue.equals(deflt)))
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.