Package org.apache.pluto.container

Examples of org.apache.pluto.container.PortletPreference


    public boolean isReadOnly(String key) {
        if (key == null) {
            throw new IllegalArgumentException(
                EXCEPTIONS.getString("error.null", "Preference key "));
        }
        PortletPreference pref = preferences.get(key);
        return (pref != null && pref.isReadOnly());
    }
View Full Code Here


        if (key == null) {
            throw new IllegalArgumentException(
                EXCEPTIONS.getString("error.null", "Preference key "));
        }
        String[] values = null;
        PortletPreference pref = preferences.get(key);
        if (pref != null) {
            values = pref.getValues();
        }
        if (values == null) {
            values = defaultValues;
        }
        return values;
View Full Code Here

    public void setValue(String key, String value) throws ReadOnlyException {
        if (isReadOnly(key)) {
            throw new ReadOnlyException(EXCEPTIONS.getString(
                "error.preference.readonly", key));
        }
        PortletPreference pref = preferences.get(key);
        String[] values = value == null ? new String[0] : new String[] { value };
        if (pref != null) {
            pref.setValues(values);
        } else {
            pref = new PortletPreferenceImpl(key, values);
            preferences.put(key, pref);
        }
    }
View Full Code Here

                "error.preference.readonly", key));
        }
        if (values == null) {
            values = new String[0];
        }
        PortletPreference pref = preferences.get(key);
        if (pref != null) {
            pref.setValues(values);
        } else {
            pref = new PortletPreferenceImpl(key, values);
            preferences.put(key, pref);
        }
    }
View Full Code Here

        if (isReadOnly(key)) {
            throw new ReadOnlyException(EXCEPTIONS.getString(
                "error.preference.readonly", key));
        }
        // Try to reset preference to the default values.
        PortletPreference p = defaultPreferences.get(key);
        if (p != null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Resetting preference for key: " + key);
            }
            preferences.put(key,p.clone());
        }      
        // Remove preference if default values are not defined (PLT.14.1).
        else {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Resetting preference to null for key: " + key);
View Full Code Here

                    FragmentPreference fragmentPreference = (FragmentPreference)values;
                    preference = new ContentFragmentPreferenceImpl(name, fragmentPreference.isReadOnly(), fragmentPreference.getValueList());
                }
                else if (values instanceof PortletPreference)
                {
                    PortletPreference portletPreference = (PortletPreference)values;
                    preference = new ContentFragmentPreferenceImpl(name, portletPreference.isReadOnly(), Arrays.asList(portletPreference.getValues()));
                }
                else
                {
                    throw new IllegalArgumentException("Unexpected preference value type");
                }
View Full Code Here

            Iterator<String> preferences = userPreferences.keySet().iterator();
            JSNVPElements v = new JSNVPElements("preference");
            while (preferences.hasNext())
            {
                String pKey = preferences.next();
                PortletPreference portletPreference = userPreferences.get(pKey);
                JSNVPElement element = new JSNVPElement();
                element.setKey(pKey);
                element.setValues(portletPreference.getValues());
                element.setReadOnly(portletPreference.isReadOnly());
                v.add(element);
            }
            if (v.size() > 0)
            {
                userPreference.setPreferences(v);
View Full Code Here

            List<PortletPreference> inserts = new LinkedList<PortletPreference>();       
            Iterator<DatabasePreference> preferences = getPersistenceBrokerTemplate().getIteratorByQuery(query);
            while (preferences.hasNext())
            {
                DatabasePreference preference = preferences.next();
                PortletPreference found = map.get(preference.getName());
                if (found == null)
                {
                    deletes.add(preference);
                }
                else
                {
                    if (isModified(preference, found))                   
                        updates.add(preference);
                }
                mergeMap.put(preference.getName(), preference);
               
            }
            for (PortletPreference preference : map.values())
            {
                DatabasePreference dbPref = mergeMap.get(preference.getName());
                if (dbPref == null)
                {
                    inserts.add(preference);
                }               
            }
            // perform database manipulations
            for (DatabasePreference dbPref : deletes)
            {
                getPersistenceBrokerTemplate().delete(dbPref);
            }
            for (PortletPreference preference : inserts)
            {
                DatabasePreference dbPref = new DatabasePreference();
                dbPref.setDtype(DISCRIMINATOR_USER);
                dbPref.setApplicationName(appName);
                dbPref.setPortletName(portletName);
                dbPref.setEntityId(entityId);
                dbPref.setUserName(userName);
                dbPref.setName(preference.getName());
                dbPref.setReadOnly(preference.isReadOnly());
                short index = 0;
                for (String value : preference.getValues())
                {
                    DatabasePreferenceValue dbValue = new DatabasePreferenceValue();
                    dbValue.setIndex(index);
                    dbValue.setValue(value);
                    dbPref.getPreferenceValues().add(dbValue);               
                    index++;
                }
                getPersistenceBrokerTemplate().store(dbPref);
            }
            for (DatabasePreference dbPref : updates)
            {
                dbPref.getPreferenceValues().clear();
                PortletPreference preference = map.get(dbPref.getName());
                short index = 0;
                for (String value : preference.getValues())
                {
                    DatabasePreferenceValue dbValue = new DatabasePreferenceValue();
                    dbValue.setIndex(index);
                    dbValue.setValue(value);
                    index++;
View Full Code Here

        List<PortletPreference> inserts = new LinkedList<PortletPreference>();
        Iterator<DatabasePreference> preferences = getPersistenceBrokerTemplate().getIteratorByQuery(query);
        while (preferences.hasNext())
        {
            DatabasePreference preference = preferences.next();
            PortletPreference found = map.get(preference.getName());
            if (found == null)
            {
                deletes.add(preference);
            }
            else
            {
                if (isModified(preference, found))
                    updates.add(preference);
            }
            mergeMap.put(preference.getName(), preference);
        }
        for (PortletPreference preference : map.values())
        {
            DatabasePreference dbPref = mergeMap.get(preference.getName());
            if (dbPref == null)
            {
                inserts.add(preference);
            }
        }
        // perform database manipulations
        for (DatabasePreference dbPref : deletes)
        {
            getPersistenceBrokerTemplate().delete(dbPref);
        }
        for (PortletPreference preference : inserts)
        {
            DatabasePreference dbPref = new DatabasePreference();
            dbPref.setDtype(DISCRIMINATOR_PORTLET);
            dbPref.setApplicationName(appName);
            dbPref.setPortletName(portletName);
            dbPref.setEntityId(windowId);
            dbPref.setUserName(userName);
            dbPref.setName(preference.getName());
            dbPref.setReadOnly(preference.isReadOnly());
            short index = 0;
            for (String value : preference.getValues())
            {
                DatabasePreferenceValue dbValue = new DatabasePreferenceValue();
                dbValue.setIndex(index);
                dbValue.setValue(value);
                dbPref.getPreferenceValues().add(dbValue);
                index++;
            }
            getPersistenceBrokerTemplate().store(dbPref);
        }
        for (DatabasePreference dbPref : updates)
        {
            dbPref.getPreferenceValues().clear();
            PortletPreference preference = map.get(dbPref.getName());
            short index = 0;
            for (String value : preference.getValues())
            {
                DatabasePreferenceValue dbValue = new DatabasePreferenceValue();
                dbValue.setIndex(index);
                dbValue.setValue(value);
                index++;
View Full Code Here

                        preference.setReadOnly(fragmentPreference.isReadOnly());
                        preference.getValueList().addAll(fragmentPreference.getValueList());
                    }
                    else if (values instanceof PortletPreference)
                    {
                        PortletPreference portletPreference = (PortletPreference)values;
                        preference.setReadOnly(portletPreference.isReadOnly());
                        preference.getValueList().addAll(Arrays.asList(portletPreference.getValues()));
                    }
                    else
                    {
                        throw new IllegalArgumentException("Unexpected preference value type");
                    }
View Full Code Here

TOP

Related Classes of org.apache.pluto.container.PortletPreference

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.