Package org.jasig.portal.container.om.common

Examples of org.jasig.portal.container.om.common.PreferenceSetImpl


        ChannelParameter[] parameters = channelDef.getParameters();

        if (parameters != null) {
          // Keep track of any portlet preferences
          PreferenceSetImpl preferences = new PreferenceSetImpl();

          for (int i = 0; i < parameters.length; i++) {
            String paramName = parameters[i].getName();
            String paramValue = parameters[i].getValue();
            boolean paramOverride = parameters[i].getOverride();

            if (paramName == null && paramValue == null) {
              throw new RuntimeException("Invalid parameter node");
            }

            if (paramName.startsWith(CPortletAdapter.portletPreferenceNamePrefix)) {
                // We have a portlet preference
                String prefName = paramName.substring(CPortletAdapter.portletPreferenceNamePrefix.length());
                String prefValue = paramValue;
                List prefValues = (List)preferences.get(prefName);
                // Unfortunately, we can only support single-valued preferences
                // at this level unless we change a lot of uPortal code :(
                prefValues = new ArrayList(1);
                prefValues.add(prefValue);
                preferences.add(prefName, prefValues, !paramOverride);
            } else {
                // We have a normal channel parameter
                String insert = "INSERT INTO UP_CHANNEL_PARAM (CHAN_ID, CHAN_PARM_NM, CHAN_PARM_VAL, CHAN_PARM_OVRD) VALUES (" + channelPublishId +
                                ",'" + paramName + "','" + paramValue + "', '" + (paramOverride ? "Y" : "N") + "')";
                if (log.isDebugEnabled())
                    log.debug("RDBMChannelRegistryStore.saveChannelDefinition(): " + insert);
                stmt.executeUpdate(insert);
            }
          }
          if (preferences.size() > 0) {
              PortletPreferencesStoreFactory.getPortletPreferencesStoreImpl().setDefinitionPreferences(channelPublishId, preferences);
          }
        }

        // Commit the transaction
View Full Code Here


        }
        return parameters;
    }
   
    private PreferenceSet getPreferences(Element portletE) {
        PreferenceSetImpl preferences = new PreferenceSetImpl();
        NodeList portletPreferencesNL = portletE.getElementsByTagName("portlet-preferences");
        if (portletPreferencesNL.getLength() > 0) {
            Element portletPreferencesE = (Element)portletPreferencesNL.item(0); // there should only be one
            NodeList preferenceNL = portletPreferencesE.getElementsByTagName("preference");
            for (int i = 0; i < preferenceNL.getLength(); i += 1) {
                Element preferenceE = (Element)preferenceNL.item(i);
                String name = XML.getChildElementText(preferenceE, "name");
                List values = new ArrayList(1); // There is usually just one value
                NodeList valueNL = preferenceE.getElementsByTagName("value");
                for (int j = 0; j < valueNL.getLength(); j += 1) {
                    Element valueE = (Element)valueNL.item(j);
                    values.add(XML.getElementText(valueE));
                }
                boolean readOnly = Boolean.valueOf(XML.getChildElementText(preferenceE, "read-only")).booleanValue();
                preferences.add(name, values, readOnly);
            }
            preferences.setPreferencesValidator(XML.getChildElementText(portletPreferencesE, "preferences-validator"));
        }
        return preferences;
    }
View Full Code Here

    private IUserLayoutChannelDescription channelDescription = null;

    // PortletEntity methods
   
    public PortletEntityImpl() {
        preferences = new PreferenceSetImpl();
        portletWindows = new PortletWindowListImpl();
    }
View Full Code Here

            int layoutId = Integer.parseInt(layout.getId());
            String channelDescId = channelDescription.getId();
            portletPrefsStore.setEntityPreferences(userId, layoutId, channelDescId, preferences);
           
            // Save preferences as original preferences     
            originalPreferences = new PreferenceSetImpl();  
            ((PreferenceSetImpl)originalPreferences).addAll(preferences);
           
        } catch (Exception e) {
            log.error("Could not store portlet entity preferences", e);
           
View Full Code Here

            String channelDescId = channelDescription.getId();
           
            preferences = portletPrefsStore.getEntityPreferences(userId, layoutId, channelDescId);
           
            // Save preferences as original preferences     
            originalPreferences = new PreferenceSetImpl();  
            ((PreferenceSetImpl)originalPreferences).addAll(preferences);           
        } catch (Exception e) {
            log.error("Could not load portlet entity preferences.", e);
           
            if (e instanceof IOException)
View Full Code Here

   
    /**
     * @see org.jasig.portal.IPortletPreferencesStore#getDefinitionPreferences(int)
     */
    public PreferenceSet getDefinitionPreferences(final int chanId) throws Exception {
        final PreferenceSetImpl prefs = new PreferenceSetImpl();
        final Connection con = RDBMServices.getConnection();
       
        final String selectPrefs =
            "SELECT UPDP.PORTLET_PREF_NAME, UPDP.PORTLET_PREF_READONLY, UPPV.PORTLET_PREF_VALUE " +
            "FROM UP_PORTLET_DEFINITION_PREFS UPDP, UP_PORTLET_PREF_VALUES UPPV " +
            "WHERE UPDP.PREF_ID=UPPV.PREF_ID AND CHAN_ID=?";
       
        if (log.isDebugEnabled())
            log.debug("RDBMPortletPreferencesStore::getDefinitionPreferences(chanId=" + chanId + ")");
               
        try {
            PreparedStatement selectCurrentPrefsPstmt = null;
           
            try {
                selectCurrentPrefsPstmt = con.prepareStatement(selectPrefs);
               
                if (log.isDebugEnabled())
                    log.debug("RDBMPortletPreferencesStore::getDefinitionPreferences(): " + selectPrefs);
                selectCurrentPrefsPstmt.setInt(1, chanId);
                final ResultSet rs = selectCurrentPrefsPstmt.executeQuery();
               
                final Map prefsBuilder = new HashMap();
                final Map readOnlyMap = new HashMap();
               
                try {
                    while (rs.next()) {
                        final String prefName = rs.getString("PORTLET_PREF_NAME");
                        final String prefReadOnly = rs.getString("PORTLET_PREF_READONLY");
                        String prefValue = rs.getString("PORTLET_PREF_VALUE");
                        if (prefValue != null && prefValue.startsWith(PREFIX))
                            prefValue = prefValue.substring(PREFIX.length());
                       
                        if (!readOnlyMap.containsKey(prefName)) {
                            if (READ_ONLY_TRUE.equals(prefReadOnly)) {
                                readOnlyMap.put(prefName, Boolean.TRUE);
                            }
                            else {
                                readOnlyMap.put(prefName, Boolean.FALSE);
                            }
                        }
                       
                        List prefList = (List)prefsBuilder.get(prefName);
                       
                        if (prefList == null)
                        {
                            prefList = new LinkedList();
                            prefsBuilder.put(prefName, prefList);
                        }
                       
                        prefList.add(prefValue);
                    }
                }
                finally {
                    try { rs.close(); } catch (Exception e) { }
                }
               
                for (final Iterator prefKeyItr = prefsBuilder.keySet().iterator(); prefKeyItr.hasNext();) {
                    final String prefName = (String)prefKeyItr.next();
                    final List prefValues = (List)prefsBuilder.get(prefName);
                    final boolean readOnly = Boolean.TRUE.equals(readOnlyMap.get(prefName));
                   
                    prefs.add(prefName, prefValues, readOnly);
                }
            }
            finally {
                try { selectCurrentPrefsPstmt.close(); } catch (Exception e) { }
            }
View Full Code Here

    /**
     * @see org.jasig.portal.IPortletPreferencesStore#getEntityPreferences(int, int, java.lang.String)
     */
    public PreferenceSet getEntityPreferences(final int userId, final int layoutId, final String chanDescId) throws Exception {
        final PreferenceSetImpl prefs = new PreferenceSetImpl();
        final Connection con = RDBMServices.getConnection();

        final String selectPrefs =
            "SELECT UPEP.PORTLET_PREF_NAME, UPPV.PORTLET_PREF_VALUE " +
            "FROM UP_PORTLET_ENTITY_PREFS UPEP, UP_PORTLET_PREF_VALUES UPPV " +
            "WHERE UPEP.PREF_ID=UPPV.PREF_ID AND UPEP.USER_ID=? AND UPEP.LAYOUT_ID=? AND UPEP.CHAN_DESC_ID=?";

        if (log.isDebugEnabled())
            log.debug("RDBMPortletPreferencesStore::getEntityPreferences(userId=" + userId + ", layoutId=" + layoutId + ", chanDescId=" + chanDescId + ")");

        try {
            PreparedStatement selectCurrentPrefsPstmt = null;
           
            try {
                selectCurrentPrefsPstmt = con.prepareStatement(selectPrefs);
               
                if (log.isDebugEnabled())
                    log.debug("RDBMPortletPreferencesStore::getEntityPreferences(): " + selectPrefs);
               
                selectCurrentPrefsPstmt.setInt(1, userId);
                selectCurrentPrefsPstmt.setInt(2, layoutId);
                selectCurrentPrefsPstmt.setString(3, chanDescId);
                ResultSet rs = selectCurrentPrefsPstmt.executeQuery();
               
                final Map prefsBuilder = new HashMap();
               
                try {
                    while (rs.next()) {
                        final String prefName = rs.getString("PORTLET_PREF_NAME");
                        String prefValue = rs.getString("PORTLET_PREF_VALUE");
                        if (prefValue != null && prefValue.startsWith(PREFIX))
                            prefValue = prefValue.substring(PREFIX.length());
                                               
                        List prefList = (List)prefsBuilder.get(prefName);
                       
                        if (prefList == null)
                        {
                            prefList = new LinkedList();
                            prefsBuilder.put(prefName, prefList);
                        }
                       
                        prefList.add(prefValue);
                    }
                }
                finally {
                    try { rs.close(); } catch (Exception e) { }
                }
               
                for (final Iterator prefKeyItr = prefsBuilder.keySet().iterator(); prefKeyItr.hasNext();) {
                    final String prefName = (String)prefKeyItr.next();
                    final List prefValues = (List)prefsBuilder.get(prefName);
                   
                    prefs.add(prefName, prefValues);
                }
            }
            finally {
                try { selectCurrentPrefsPstmt.close(); } catch (Exception e) { }
            }
View Full Code Here

TOP

Related Classes of org.jasig.portal.container.om.common.PreferenceSetImpl

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.