Package org.apache.jetspeed.om.preference.impl

Examples of org.apache.jetspeed.om.preference.impl.PrefsPreferenceSetImpl


    
     */

    public void reset() throws IOException
    {
        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) perPrincipalPrefs.get(getPrincipal());
        try
        {
            if (originalValues != null && preferenceSet != null)
            {
                Iterator prefs = preferenceSet.iterator();

                while (prefs.hasNext())
                {
                    PrefsPreference pref = (PrefsPreference) prefs.next();
                    if (originalValues.containsKey(pref.getName()))
                    {
                        pref.setValues((String[]) originalValues.get(pref.getName()));
                    }
                    else
                    {
                        preferenceSet.remove(pref);
                    }
                    preferenceSet.flush();
                }

                Iterator keys = originalValues.keySet().iterator();
                while (keys.hasNext())
                {
                    String key = (String) keys.next();
                    if (preferenceSet.get(key) == null)
                    {
                        preferenceSet.add(key, Arrays.asList((String[]) originalValues.get(key)));
                    }
                }
            }
            dirty = false;
            backupValues(preferenceSet);
View Full Code Here


    }

    public void removePortletEntity( PortletEntity portletEntity ) throws PortletEntityNotDeletedException
    {
        PrefsPreferenceSetImpl prefsSet  = (PrefsPreferenceSetImpl) portletEntity.getPreferenceSet();
        getPersistenceBrokerTemplate().delete(portletEntity);
        try
        {
            prefsSet.clear();
        }
        catch (BackingStoreException e)
        {
            throw new PortletEntityNotDeletedException("Failed to remove preferences for portlet entity "+portletEntity.getId()+".  "+e.getMessage(), e);
        }
View Full Code Here

     * @param prefSet
     * @throws IOException
     */
    public void storePreferenceSet( PreferenceSet prefSet, PortletEntity entity ) throws IOException
    {
        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) prefSet;
        try
        {           
            getPersistenceBrokerTemplate().store(entity);
            if (preferenceSet != null)
            {
                preferenceSet.flush();
            }           

        }
        catch (Exception e)
        {
View Full Code Here

        return getPreferenceSet(currentUser);
    }

    public PreferenceSet getPreferenceSet(Principal principal)
    {
        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) perPrincipalPrefs.get(principal);
        try
        {
            if (preferenceSet == null || !dirty)
            {
                //TODO: need to be setting this from PortletEntityAccessComponent until then it will always be null.               
                String prefNodePath = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/" + getId() +"/"+ principal.getName() +"/"
                        + PrefsPreference.PORTLET_PREFERENCES_ROOT;
                Preferences prefNode = Preferences.userRoot().node(prefNodePath);
                preferenceSet = new PrefsPreferenceSetImpl(prefNode);
                perPrincipalPrefs.put(principal, preferenceSet);
                backupValues(preferenceSet);
                dirty = true;
            }
        }
View Full Code Here

    
     */

    public void reset() throws IOException
    {
        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) perPrincipalPrefs.get(getPrincipal());
        try
        {
            if (originalValues != null && preferenceSet != null)
            {
                Iterator prefs = preferenceSet.iterator();

                while (prefs.hasNext())
                {
                    PrefsPreference pref = (PrefsPreference) prefs.next();
                    if (originalValues.containsKey(pref.getName()))
                    {
                        pref.setValues((String[]) originalValues.get(pref.getName()));
                    }
                    else
                    {
                        preferenceSet.remove(pref);
                    }
                    preferenceSet.flush();
                }

                Iterator keys = originalValues.keySet().iterator();
                while (keys.hasNext())
                {
                    String key = (String) keys.next();
                    if (preferenceSet.get(key) == null)
                    {
                        preferenceSet.add(key, Arrays.asList((String[]) originalValues.get(key)));
                    }
                }
            }
            dirty = false;
            backupValues(preferenceSet);
View Full Code Here

                {
                    throw new IllegalStateException("Portlet Application must be defined before preferences can be accessed");
                }
               
                Preferences prefNode = PrefsPreference.createPrefenceNode(this);
                preferenceSet = new PrefsPreferenceSetImpl(prefNode);
            }
        }
        catch (BackingStoreException e)
        {
            String msg = "Preference backing store failed: " + e.toString();
View Full Code Here

        return persistenceStore;
    }

    public void storePreferenceSet( PreferenceSet prefSet, PortletEntity entity ) throws IOException
    {
        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) prefSet;
        try
        {
            prepareTransaction(persistenceStore);
            persistenceStore.lockForWrite(entity);
            if (preferenceSet != null)
            {
                preferenceSet.flush();
            }
            persistenceStore.getTransaction().checkpoint();

        }
        catch (Exception e)
View Full Code Here

    }

    public void removePortletEntity( PortletEntity portletEntity ) throws PortletEntityNotDeletedException
    {
        PrefsPreferenceSetImpl prefsSet  = (PrefsPreferenceSetImpl) portletEntity.getPreferenceSet();
        getPersistenceBrokerTemplate().delete(portletEntity);
        try
        {
            prefsSet.clear();
        }
        catch (BackingStoreException e)
        {
            throw new PortletEntityNotDeletedException("Failed to remove preferences for portlet entity "+portletEntity.getId()+".  "+e.getMessage(), e);
        }
View Full Code Here

     * @param prefSet
     * @throws IOException
     */
    public void storePreferenceSet( PreferenceSet prefSet, PortletEntity entity ) throws IOException
    {
        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) prefSet;
        try
        {           
            getPersistenceBrokerTemplate().store(entity);
            if (preferenceSet != null)
            {
                preferenceSet.flush();
            }           

        }
        catch (Exception e)
        {
View Full Code Here

     * @see org.apache.pluto.om.entity.PortletEntity#getPreferenceSet()
     * @return
     */
    public PreferenceSet getPreferenceSet()
    {
        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) preferenceSetRef.get();
        try
        {
            if (preferenceSet == null || !dirty)
            {
                Principal currentUser = getPrincipal();
                //TODO: need to be setting this from PortletEntityAccessComponent until then it will always be null.               
                if (currentUser == null)
                {
                    currentUser = new PortletEntityUserPrincipal(NO_PRINCIPAL);
                }
                String prefNodePath = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/" + getId() +"/"+ currentUser.getName() +"/"
                        + PrefsPreference.PORTLET_PREFERENCES_ROOT;
                Preferences prefNode = Preferences.userRoot().node(prefNodePath);
                preferenceSet = new PrefsPreferenceSetImpl(prefNode);
                preferenceSetRef.set(preferenceSet);
                backupValues(preferenceSet);
                dirty = true;
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.preference.impl.PrefsPreferenceSetImpl

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.