You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by rw...@apache.org on 2009/01/11 22:58:24 UTC

svn commit: r733524 [3/6] - in /portals/jetspeed-2/portal/branches/JPA_BRANCH: components/jetspeed-page-manager/ components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/ components/jetspeed-page-manager/src/main/java/org/apache...

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerContext.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerContext.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerContext.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerContext.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.components.portletregistry.jpa;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+/**
+ * RegistryManagerContext
+ * 
+ * Stateful object uses to hold JPA extended entity manager.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id: $
+ */
+public class RegistryManagerContext
+{
+    private EntityManager extendedEntityManager;
+    private RegistryManager registryManager;
+
+    /**
+     * Set extended conversational entity manager instance for context.
+     * 
+     * @param entityManager injected entity manager.
+     */
+    @PersistenceContext (type=PersistenceContextType.EXTENDED, unitName="jetspeed-registry")
+    public void setExtendedEntityManager(EntityManager entityManager)
+    {
+        extendedEntityManager = entityManager;
+    }
+    
+    /**
+     * Get extended conversational entity manager instance for context.
+     * 
+     * @return entity manager.
+     */
+    public EntityManager getExtendedEntityManager()
+    {
+        return extendedEntityManager;
+    }
+    
+    /**
+     * Set registry manager associated with context.
+     * 
+     * @param registryManager
+     */
+    public void setRegistryManager(RegistryManager registryManager)
+    {
+        this.registryManager = registryManager;
+    }
+    
+    /**
+     * Initialize context by registering with registry manager on creating thread.
+     */
+    public void initialize()
+    {
+        registryManager.registerContext(this);
+    }
+
+    /**
+     * Terminate context by unregistering with registry manager on creating thread.
+     */
+    public void terminate()
+    {
+        registryManager.unregisterContext(this);
+        extendedEntityManager.close();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.components.portletregistry.jpa;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+/**
+ * RegistryManagerImpl
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id: $
+ */
+public class RegistryManagerImpl implements RegistryManager
+{
+    private EntityManager entityManager;
+    private ThreadLocal contexts;
+    
+    // Constructor
+    
+    /**
+     * Default constructor.
+     */
+    public RegistryManagerImpl()
+    {
+        contexts = new ThreadLocal();        
+    }
+
+    // Lifecycle
+    
+    /**
+     * Inject shared entity manager from assembly; this entity
+     * manager is expected to honor existing entity manager
+     * context attached to current thread, (otherwise, a new
+     * temporary entity manager is created).
+     * 
+     * @param entityManager injected shared entity manager
+     */
+    @PersistenceContext (unitName="jetspeed-registry")
+    public void setEntityManager(EntityManager entityManager) 
+    {
+        this.entityManager = entityManager;
+    }
+    
+    // Implementation
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.components.portletregistry.jpa.RegistryManager#registerContext(java.lang.Object)
+     */
+    public void registerContext(Object context)
+    {
+        RegistryManagerContext registeredContext = (RegistryManagerContext)contexts.get();
+        if ((registeredContext == null) && (context instanceof RegistryManagerContext))
+        {
+            contexts.set(context);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.components.portletregistry.jpa.RegistryManager#getContext()
+     */
+    public Object getContext()
+    {
+        return (RegistryManagerContext)contexts.get();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.components.portletregistry.jpa.RegistryManager#unregisterContext(java.lang.Object)
+     */
+    public void unregisterContext(Object context)
+    {
+        RegistryManagerContext registeredContext = (RegistryManagerContext)contexts.get();
+        if (context == registeredContext)
+        {
+            contexts.remove();
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.components.portletregistry.jpa.RegistryManager#getEntityManager()
+     */
+    public EntityManager getEntityManager()
+    {
+        RegistryManagerContext context = (RegistryManagerContext)getContext();
+        return ((context != null) ? context.getExtendedEntityManager() : entityManager);
+    }    
+}

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/JetspeedDescriptorServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/JetspeedDescriptorServiceImpl.java?rev=733524&r1=733523&r2=733524&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/JetspeedDescriptorServiceImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/JetspeedDescriptorServiceImpl.java Sun Jan 11 13:58:21 2009
@@ -36,6 +36,7 @@
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.om.portlet.ContainerRuntimeOption;
 import org.apache.jetspeed.om.portlet.DisplayName;
 import org.apache.jetspeed.om.portlet.EventDefinition;
@@ -131,11 +132,13 @@
     private static final String NAMESPACE_PREFIX = "js";
     
     private PortletAppDescriptorService plutoDescriptorService;
+    private PortletRegistry portletRegistry;
     DocumentBuilderFactory domFactory;
     
-    public JetspeedDescriptorServiceImpl(PortletAppDescriptorService plutoDescriptorService)
+    public JetspeedDescriptorServiceImpl(PortletAppDescriptorService plutoDescriptorService, PortletRegistry portletRegistry)
     {
         this.plutoDescriptorService = plutoDescriptorService;
+        this.portletRegistry = portletRegistry;
     }
     
     public PortletApplication read(InputStream webDescriptor, InputStream portletDescriptor, InputStream jetspeedPortletDescriptor, ClassLoader paClassLoader) throws Exception
@@ -311,7 +314,7 @@
     
     protected PortletApplication upgrade(PortletApplicationDefinition pa)
     {
-        PortletApplication jpa = new PortletApplicationDefinitionImpl();        
+        PortletApplication jpa = portletRegistry.newPortletApplication();        
         jpa.setDefaultNamespace(pa.getDefaultNamespace());
         jpa.setResourceBundle(pa.getResourceBundle());
         jpa.setVersion(pa.getVersion());

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/AbstractPortletApplicationDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/AbstractPortletApplicationDefinitionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/AbstractPortletApplicationDefinitionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/AbstractPortletApplicationDefinitionImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,520 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.om.portlet.impl;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+import javax.xml.namespace.QName;
+
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.om.portlet.ContainerRuntimeOption;
+import org.apache.jetspeed.om.portlet.CustomPortletMode;
+import org.apache.jetspeed.om.portlet.CustomWindowState;
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.om.portlet.DisplayName;
+import org.apache.jetspeed.om.portlet.EventDefinition;
+import org.apache.jetspeed.om.portlet.Filter;
+import org.apache.jetspeed.om.portlet.FilterMapping;
+import org.apache.jetspeed.om.portlet.Listener;
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.om.portlet.PublicRenderParameter;
+import org.apache.jetspeed.om.portlet.SecurityConstraint;
+import org.apache.jetspeed.om.portlet.UserAttribute;
+import org.apache.jetspeed.om.portlet.UserAttributeRef;
+import org.apache.jetspeed.util.JetspeedLocale;
+
+/**
+*
+* @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
+* @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+* @version $Id: AbstractPortletApplicationDefinitionImpl.java 720057 2008-11-23 22:31:00Z ate $
+* @since 1.0
+*/
+public abstract class AbstractPortletApplicationDefinitionImpl implements PortletApplication, Serializable
+{
+    private static final long serialVersionUID = -7882852374619861797L;
+
+    // Members
+    
+    protected String description;
+    protected String resourceBundle;
+    protected String defaultNamespace;
+    protected List<EventDefinition> eventDefinitions;
+    protected List<PublicRenderParameter> publicRenderParameters;
+    protected List<SecurityConstraint> securityConstraints;
+    protected List<Filter> filters;
+    protected List<FilterMapping> filterMappings;
+    protected List<Listener> listeners;
+    protected List<ContainerRuntimeOption> containerRuntimeOptions;
+    
+    protected transient Map<PortletMode,PortletMode> supportedCustomModes;
+    protected transient Map<WindowState,WindowState> supportedCustomStates;
+    protected transient Map<PortletMode,PortletMode> mappedCustomModes;
+    protected transient Map<WindowState,WindowState> mappedCustomStates;    
+    protected transient List<PortletMode> supportedPortletModes;
+    protected transient List<WindowState> supportedWindowStates;
+    
+    // Base PortletApplication Implementation
+    
+    public String getDefaultNamespace()
+    {
+        return defaultNamespace;
+    }
+
+    public void setDefaultNamespace(String defaultNamespace)
+    {
+        this.defaultNamespace = defaultNamespace;
+    }
+
+    public String getResourceBundle()
+    {
+        return resourceBundle;
+    }
+
+    public void setResourceBundle(String resourceBundle)
+    {
+        this.resourceBundle = resourceBundle;
+    }
+    
+    public String getDescription()
+    {
+        return description;
+    }
+
+    public void setDescription(String string)
+    {
+        description = string;
+    }
+
+    public Description getDescription(Locale locale)
+    {
+        return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale);
+    }
+    
+    public DisplayName getDisplayName(Locale locale)
+    {
+        return (DisplayName)JetspeedLocale.getBestLocalizedObject(getDisplayNames(), locale);
+    }
+    
+    public PortletDefinition getPortlet(String portletName)
+    {
+        for (PortletDefinition pd : getPortlets())
+        {
+            if (pd.getPortletName().equals(portletName))
+            {
+                return pd;
+            }
+        }
+        return null;
+    }
+
+    public List<EventDefinition> getEventDefinitions()
+    {
+        if (eventDefinitions == null)
+        {
+            eventDefinitions = new ArrayList<EventDefinition>();
+        }
+        return eventDefinitions;
+    }
+
+    public EventDefinition addEventDefinition(String name)
+    {
+        // TODO: check duplicates (complication: set of qname and name)
+        EventDefinitionImpl ed = new EventDefinitionImpl();
+        ed.setName(name);
+        getEventDefinitions().add(ed);
+        return ed;
+    }
+
+    public EventDefinition addEventDefinition(QName qname)
+    {
+        // TODO: check duplicates (complication: set of qname and name)
+        EventDefinitionImpl ed = new EventDefinitionImpl();
+        ed.setQName(qname);
+        getEventDefinitions().add(ed);
+        return ed;
+    }
+
+    public PublicRenderParameter getPublicRenderParameter(String identifier)
+    {
+        for (PublicRenderParameter p : getPublicRenderParameters())
+        {
+            if (p.getIdentifier().equals(identifier))
+            {
+                return p;
+            }
+        }
+        return null;
+    }
+
+    public List<PublicRenderParameter> getPublicRenderParameters()
+    {
+        if (publicRenderParameters == null)
+        {
+            publicRenderParameters = new ArrayList<PublicRenderParameter>();
+        }
+        return publicRenderParameters;
+    }
+
+    public PublicRenderParameter addPublicRenderParameter(String name, String identifier)
+    {
+        if (getPublicRenderParameter(identifier) != null)
+        {
+            throw new IllegalArgumentException("PublicRenderParameter with identifier: "+identifier+" already defined");
+        }
+        // TODO: check duplicates on name|qname?
+        PublicRenderParameterImpl p = new PublicRenderParameterImpl();
+        p.setName(name);
+        p.setIdentifier(identifier);
+        getPublicRenderParameters().add(p);
+        return p;        
+    }
+
+    public PublicRenderParameter addPublicRenderParameter(QName qname, String identifier)
+    {
+        if (getPublicRenderParameter(identifier) != null)
+        {
+            throw new IllegalArgumentException("PublicRenderParameter with identifier: "+identifier+" already defined");
+        }
+        // TODO: check duplicates on name|qname?
+        PublicRenderParameterImpl p = new PublicRenderParameterImpl();
+        p.setQName(qname);
+        p.setIdentifier(identifier);
+        getPublicRenderParameters().add(p);
+        return p;        
+    }
+
+    public CustomPortletMode getCustomPortletMode(String name)
+    {
+        for (CustomPortletMode cpm : getCustomPortletModes())
+        {
+            if (cpm.getPortletMode().equalsIgnoreCase(name))
+            {
+                return cpm;
+            }
+        }
+        return null;
+    }
+
+    public PortletMode getCustomPortletMode(PortletMode mode)
+    {
+        if (JetspeedActions.getStandardPortletModes().contains(mode))
+        {
+            return mode;
+        }
+        else if (JetspeedActions.getExtendedPortletModes().contains(mode))
+        {
+            // make sure transient cache is setup
+            getSupportedPortletModes();
+            return (PortletMode)supportedCustomModes.get(mode);
+        }
+        return null;            
+    }
+    
+    public CustomWindowState getCustomWindowState(String name)
+    {
+        for (CustomWindowState cws : getCustomWindowStates())
+        {
+            if (cws.getWindowState().equalsIgnoreCase(name))
+            {
+                return cws;
+            }
+        }
+        return null;
+    }
+
+    public WindowState getCustomWindowState(WindowState state)
+    {
+        if (JetspeedActions.getStandardWindowStates().contains(state))
+        {
+            return state;
+        }
+        else if (JetspeedActions.getExtendedWindowStates().contains(state))
+        {
+            // make sure transient cache is setup
+            getSupportedWindowStates();
+            return (WindowState)supportedCustomStates.get(state);
+        }
+        return null;            
+    }
+    
+    public List<PortletMode> getSupportedPortletModes()
+    {
+        if ( supportedPortletModes == null )
+        {
+            ArrayList<PortletMode> list = new ArrayList<PortletMode>(JetspeedActions.getStandardPortletModes());
+            supportedCustomModes = new HashMap<PortletMode,PortletMode>();
+            mappedCustomModes = new HashMap<PortletMode,PortletMode>();
+            
+            for (CustomPortletMode customMode : getCustomPortletModes())
+            {
+                if ( !list.contains(customMode.getCustomMode()) && JetspeedActions.getExtendedPortletModes().contains(customMode.getMappedMode()) )
+                {
+                    list.add(customMode.getCustomMode());
+                    supportedCustomModes.put(customMode.getMappedMode(), customMode.getCustomMode());
+                    mappedCustomModes.put(customMode.getCustomMode(), customMode.getMappedMode());
+                }
+            }
+            supportedPortletModes = Collections.unmodifiableList(list);
+        }
+        return supportedPortletModes;
+    }
+    
+    public List<WindowState> getSupportedWindowStates()
+    {
+        if ( supportedWindowStates == null )
+        {
+            ArrayList<WindowState> list = new ArrayList<WindowState>(JetspeedActions.getStandardWindowStates());
+            supportedCustomStates = new HashMap<WindowState,WindowState>();
+            mappedCustomStates = new HashMap<WindowState,WindowState>();
+            
+            for (CustomWindowState customState : getCustomWindowStates())
+            {
+                if ( !list.contains(customState.getCustomState()) && JetspeedActions.getExtendedWindowStates().contains(customState.getMappedState()) )
+                {
+                    list.add(customState.getCustomState());
+                    supportedCustomStates.put(customState.getMappedState(),customState.getCustomState());
+                    mappedCustomStates.put(customState.getCustomState(),customState.getMappedState());
+                }
+            }
+            supportedWindowStates = Collections.unmodifiableList(list);
+        }
+        return supportedWindowStates;
+    }
+
+    public PortletMode getMappedPortletMode(PortletMode mode)
+    {
+        if ( JetspeedActions.getStandardPortletModes().contains(mode) )
+        {
+            return mode;
+        }
+        else if ( getSupportedPortletModes().contains(mode) )
+        {
+            return (PortletMode)mappedCustomModes.get(mode);
+        }
+        return null;
+    }
+    
+    public WindowState getMappedWindowState(WindowState state)
+    {
+        if (JetspeedActions.getStandardWindowStates().contains(state) )
+        {
+            return state;
+        }
+        else if ( getSupportedWindowStates().contains(state) )
+        {
+            return (WindowState)mappedCustomStates.get(state);
+        }
+        return null;
+    }
+    
+    public UserAttribute getUserAttribute(String name)
+    {
+        for (UserAttribute ua : getUserAttributes())
+        {
+            if (ua.getName().equals(name))
+            {
+                return ua;
+            }
+        }
+        return null;
+    }
+
+    public UserAttributeRef getUserAttributeRef(String name)
+    {
+        for (UserAttributeRef uar : getUserAttributeRefs())
+        {
+            if (uar.getName().equals(name))
+            {
+                return uar;
+            }
+        }
+        return null;
+    }
+
+    public List<SecurityConstraint> getSecurityConstraints()
+    {
+        if (securityConstraints == null)
+        {
+            securityConstraints = new ArrayList<SecurityConstraint>();
+        }
+        return securityConstraints;
+    }
+
+    public SecurityConstraint addSecurityConstraint(String transportGuarantee)
+    {
+        SecurityConstraintImpl sc = new SecurityConstraintImpl();
+        ((UserDataConstraintImpl)sc.getUserDataConstraint()).setTransportGuarantee(transportGuarantee);
+        getSecurityConstraints();
+        getSecurityConstraints().add(sc);
+        return sc;        
+    }
+
+    public Filter getFilter(String filterName)
+    {
+        String name = getName();
+        for (Filter f : getFilters())
+        {
+            if (f.getFilterName().equals(name))
+            {
+                return f;
+            }
+        }
+        return null;
+    }
+
+    public List<Filter> getFilters()
+    {
+        if (filters == null)
+        {
+            filters = new ArrayList<Filter>();
+        }
+        return filters;
+    }
+
+    public Filter addFilter(String filterName)
+    {
+        String name = getName();
+        if (getFilter(name) != null)
+        {
+            throw new IllegalArgumentException("Filter with name: "+name+" already defined");
+        }
+        FilterImpl f = new FilterImpl();
+        f.setFilterName(name);
+        getFilters().add(f);
+        return f;        
+    }
+
+    public FilterMapping getFilterMapping(String filterName)
+    {
+        String name = getName();
+        for (FilterMapping f : getFilterMappings())
+        {
+            if (f.getFilterName().equals(name))
+            {
+                return f;
+            }
+        }
+        return null;
+    }
+
+    public List<FilterMapping> getFilterMappings()
+    {
+        if (filterMappings == null)
+        {
+            filterMappings = new ArrayList<FilterMapping>();
+        }
+        return filterMappings;
+    }
+
+    public FilterMapping addFilterMapping(String filterName)
+    {
+        String name = getName();
+        if (getFilterMapping(name) != null)
+        {
+            throw new IllegalArgumentException("Filtermapping for filter: "+name+" already defined");
+        }
+        FilterMappingImpl fm = new FilterMappingImpl();
+        fm.setFilterName(name);
+        getFilterMappings().add(fm);
+        return fm;        
+    }
+
+    public List<Listener> getListeners()
+    {
+        if (listeners == null)
+        {
+            listeners = new ArrayList<Listener>();
+        }
+        return listeners;
+    }
+
+    public Listener addListener(String listenerClass)
+    {
+        for (Listener l : getListeners())
+        {
+            if (l.getListenerClass().equals(listenerClass))
+            {
+                throw new IllegalArgumentException("Listener of class: "+listenerClass+" already defined");
+            }
+        }
+        ListenerImpl l = new ListenerImpl();
+        l.setListenerClass(listenerClass);
+        getListeners().add(l);
+        return l;        
+    }
+
+    public ContainerRuntimeOption getContainerRuntimeOption(String name)
+    {
+        for (ContainerRuntimeOption cro : getContainerRuntimeOptions())
+        {
+            if (cro.getName().equals(name))
+            {
+                return cro;
+            }
+        }
+        return null;
+    }
+
+    public List<ContainerRuntimeOption> getContainerRuntimeOptions()
+    {
+        if (containerRuntimeOptions == null)
+        {
+            containerRuntimeOptions = new ArrayList<ContainerRuntimeOption>();
+        }
+        return containerRuntimeOptions;
+    }
+
+    public ContainerRuntimeOption addContainerRuntimeOption(String name)
+    {
+        if (getContainerRuntimeOption(name) != null)
+        {
+            throw new IllegalArgumentException("Container runtime option with name: "+name+" already defined");
+        }
+        ContainerRuntimeOptionImpl cro = new ContainerRuntimeOptionImpl();
+        cro.setName(name);
+        getContainerRuntimeOptions().add(cro);
+        return cro;        
+    }
+
+    public boolean isLayoutApplication()
+    {
+        if (getMetadata() != null)
+        {
+            Collection c = getMetadata().getFields("layout-app");
+            if (c != null)
+            {
+                if (!c.isEmpty())
+                {
+                   return true;
+                }
+            }
+        }
+        return false;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/AbstractPortletDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/AbstractPortletDefinitionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/AbstractPortletDefinitionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/AbstractPortletDefinitionImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,465 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.om.portlet.impl;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import javax.xml.namespace.QName;
+
+import org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider;
+import org.apache.jetspeed.factory.PortletFactory;
+import org.apache.jetspeed.om.portlet.ContainerRuntimeOption;
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.om.portlet.DisplayName;
+import org.apache.jetspeed.om.portlet.EventDefinitionReference;
+import org.apache.jetspeed.om.portlet.InitParam;
+import org.apache.jetspeed.om.portlet.Language;
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.om.portlet.PortletInfo;
+import org.apache.jetspeed.om.portlet.Preference;
+import org.apache.jetspeed.om.portlet.Preferences;
+import org.apache.jetspeed.om.portlet.SecurityRoleRef;
+import org.apache.jetspeed.om.portlet.Supports;
+import org.apache.jetspeed.util.JetspeedLocale;
+import org.apache.pluto.internal.InternalPortletPreference;
+
+/**
+*
+* @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
+* @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+* @version $Id: AbstractPortletDefinitionImpl.java 720057 2008-11-23 22:31:00Z ate $
+* @since 1.0
+*/
+public abstract class AbstractPortletDefinitionImpl implements PortletDefinition, Serializable
+{
+    private static final long serialVersionUID = -6417938455272271121L;
+
+    // Class Members
+    
+    protected static PortletFactory  portletFactory;
+    protected static PortletPreferencesProvider portletPreferencesProvider;
+
+    public static void setPortletFactory(PortletFactory portletFactory)
+    {
+        AbstractPortletDefinitionImpl.portletFactory = portletFactory;
+    }
+
+    public static void setPortletPreferencesProvider(PortletPreferencesProvider portletPreferencesProvider)
+    {
+        AbstractPortletDefinitionImpl.portletPreferencesProvider = portletPreferencesProvider;
+    }
+
+    // Members
+    
+    protected String cacheScope;
+    protected List<EventDefinitionReference> supportedProcessingEvents;
+    protected List<EventDefinitionReference> supportedPublishingEvents;
+    protected List<String> supportedLocales;
+    protected List<ContainerRuntimeOption> containerRuntimeOptions;    
+    protected List<String> supportedPublicRenderParameters;
+    protected Preferences descriptorPreferences = new PreferencesImpl();    
+    
+    protected transient Map<Locale,InlinePortletResourceBundle> resourceBundles = new HashMap<Locale, InlinePortletResourceBundle>();
+
+    // Base PortletDefinition Implementation
+    
+    public void setDescriptorPreferences(Preferences descriptorPreferences)
+    {
+        this.descriptorPreferences = descriptorPreferences;
+    }
+    
+    public Preferences getDescriptorPreferences()
+    {
+        return this.descriptorPreferences;
+    }
+
+    public Preferences getPortletPreferences()
+    {
+        if (portletPreferencesProvider == null)
+        {
+            return new PreferencesImpl();            
+        }
+        Map<String, InternalPortletPreference> prefMap = portletPreferencesProvider.getDefaultPreferences(this);        
+        Preferences preferences = new PreferencesImpl();
+        List<Preference> list = preferences.getPortletPreferences();
+        for (InternalPortletPreference pref : prefMap.values())
+        {
+            Preference p = preferences.addPreference(pref.getName());
+            p.setReadOnly(pref.isReadOnly());
+            for (String s : pref.getValues())
+            {
+                p.addValue(s);
+            }
+            list.add(p);
+        }
+        return preferences;
+    }
+
+    public Preference addDescriptorPreference(String name)
+    {
+        return descriptorPreferences.addPreference(name);
+    }       
+    
+    protected ClassLoader getPortletClassLoader()
+    {
+        PortletApplication app = getApplication();
+        return portletFactory.getPortletApplicationClassLoader(app);
+    }
+
+    protected ResourceBundle loadResourceBundle( Locale locale )
+    {
+        ResourceBundle resourceBundle = null;
+        try
+        {
+            if (getResourceBundle() != null)
+            {
+                ClassLoader cl = getPortletClassLoader();
+                if (cl != null)
+                {
+                    resourceBundle = ResourceBundle.getBundle(getResourceBundle(), locale, cl);
+                }
+                else
+                {
+                    resourceBundle = ResourceBundle.getBundle(getResourceBundle(), locale, Thread.currentThread().getContextClassLoader());
+                }
+            }
+        }
+        catch (MissingResourceException x)
+        {
+            return null;
+        }
+        return resourceBundle;
+    }
+    
+    public ResourceBundle getResourceBundle(Locale locale)
+    {
+        InlinePortletResourceBundle bundle = resourceBundles.get(locale);
+        if (bundle == null)
+        {
+            Language l = getLanguage(locale);
+            if (l == null)
+            {
+                // always returns a default language
+                l = getLanguage(JetspeedLocale.getDefaultLocale());
+            }
+            ResourceBundle loadedBundle = null;
+            if (getResourceBundle() != null)
+            {
+                loadedBundle = loadResourceBundle(locale);
+                if (loadedBundle == null && !l.equals(JetspeedLocale.getDefaultLocale()))
+                {
+                    loadedBundle = loadResourceBundle(JetspeedLocale.getDefaultLocale());
+                }
+            }
+            if (loadedBundle != null)
+            {
+                bundle = new InlinePortletResourceBundle(l.getTitle(), l.getShortTitle(), l.getKeywords(), loadedBundle);
+            }
+            else
+            {
+                bundle = new InlinePortletResourceBundle(l.getTitle(), l.getShortTitle(), l.getKeywords());
+            }
+            resourceBundles.put(locale, bundle);
+        }
+        return bundle;
+    }
+
+    public Language getLanguage(Locale locale)
+    {
+        Language lang = null;
+        Language fallback = null;
+        
+        for (Language l : getLanguages())
+        {
+            if (l.getLocale().equals(locale))
+            {
+                lang = l;
+                break;
+            }
+            if (l.getLocale().getLanguage().equals(locale.getLanguage()))
+            {
+                fallback = l;
+            }            
+        }
+        if (lang == null)
+        {
+            if (fallback == null)
+            {
+                if (JetspeedLocale.getDefaultLocale().equals(locale))
+                {
+                    // No default Language set/provided yet, adding it on the fly
+                    lang = addLanguage(JetspeedLocale.getDefaultLocale());
+                }
+                else
+                {
+                    // create a new locale on the fly but don't save it
+                    fallback = getLanguage(JetspeedLocale.getDefaultLocale());
+                }
+            }
+            if (fallback != null)
+            {
+                // create a copy of the fallback for the locale but don't save it
+                LanguageImpl l = new LanguageImpl();
+                l.setLocale(locale);
+                l.setTitle(fallback.getTitle());
+                l.setShortTitle(fallback.getShortTitle());
+                l.setKeywords(fallback.getKeywords());
+                lang = l;
+            }
+        }
+        return lang;
+    }
+    
+    /**
+     * @see org.apache.jetspeed.om.portlet.PortletDefinition#getUniqueName()
+     */
+    public String getUniqueName()
+    {
+        PortletApplication app = getApplication();
+        String portletName = getPortletName();
+        if (app != null && app.getName() != null && portletName != null)
+        {
+            return app.getName() + "::" + portletName;
+        }
+        else
+        {
+            throw new IllegalStateException("Cannot generate a unique portlet name until the application and portlet name have been set");
+        }
+    }
+
+    /**
+     * Returns localized text of this PortletDefinitions description.
+     * 
+     * @param locale
+     *            Locale to get the description for
+     * @return Localized text string of the display name or <code>null</code>
+     *         if no Description exists for this locale
+     */
+    public String getDescriptionText( Locale locale )
+    {
+        Description desc = getDescription(locale);
+        return desc != null ? desc.getDescription() : null;
+    }
+    
+    public String getDisplayNameText(Locale locale)
+    {
+        DisplayName dn = getDisplayName(locale);
+        return dn != null ? dn.getDisplayName() : null;
+    }
+
+    public ContainerRuntimeOption getContainerRuntimeOption(String name)
+    {
+        for (ContainerRuntimeOption cro : getContainerRuntimeOptions())
+        {
+            if (cro.getName().equals(name))
+            {
+                return cro;
+            }
+        }
+        return null;
+    }
+
+    public List<ContainerRuntimeOption> getContainerRuntimeOptions()
+    {
+        if (containerRuntimeOptions == null)
+        {
+            containerRuntimeOptions = new ArrayList<ContainerRuntimeOption>();
+        }
+        return containerRuntimeOptions;
+    }
+
+    public ContainerRuntimeOption addContainerRuntimeOption(String name)
+    {
+        if (getContainerRuntimeOption(name) != null)
+        {
+            throw new IllegalArgumentException("Container runtime option with name: "+name+" already defined");
+        }
+        ContainerRuntimeOptionImpl cro = new ContainerRuntimeOptionImpl();
+        cro.setName(name);
+        containerRuntimeOptions.add(cro);
+        return cro;        
+    }
+
+    public PortletInfo getPortletInfo()
+    {
+        return getLanguage(JetspeedLocale.getDefaultLocale());
+    }
+
+    public SecurityRoleRef getSecurityRoleRef(String roleName)
+    {
+        for (SecurityRoleRef ref : getSecurityRoleRefs())
+        {
+            if (ref.getRoleName().equals(roleName))
+            {
+                return ref;
+            }
+        }
+        return null;
+    }
+
+    public Supports getSupports(String mimeType)
+    {
+        for (Supports s : getSupports())
+        {
+            if (s.getMimeType().equals(mimeType))
+            {
+                return s;
+            }
+        }
+        return null;
+    }
+    
+    public List<String> getSupportedLocales()
+    {
+        if (supportedLocales == null)
+        {
+            supportedLocales = new ArrayList<String>();
+        }
+        return supportedLocales;
+    }
+    
+    public void addSupportedLocale(String lang)
+    {
+        for (String l : getSupportedLocales())
+        {
+            if (l.equals(lang))
+            {
+                throw new IllegalArgumentException("Supported locale: "+lang+" already defined");
+            }
+        }
+        supportedLocales.add(lang);    
+    }
+
+    public List<String> getSupportedPublicRenderParameters()
+    {
+        if (supportedPublicRenderParameters == null)
+        {
+            supportedPublicRenderParameters = new ArrayList<String>();
+        }
+        return supportedPublicRenderParameters;
+    }
+    
+    public void addSupportedPublicRenderParameter(String identifier)
+    {
+        for (String ident : getSupportedPublicRenderParameters())
+        {
+            if (ident.equals(identifier))
+            {
+                throw new IllegalArgumentException("Support for public render parameter with identifier: "+identifier+" already defined");
+            }
+        }
+        supportedPublicRenderParameters.add(identifier);
+    }
+
+    /**
+     * Caching scope, allowed values are "private" indicating that the content should not be shared across users and
+     * "public" indicating that the content may be shared across users. The default value if not present is "private".
+     */
+    public String getCacheScope()
+    {
+        return cacheScope != null ? cacheScope : "private";
+    }
+
+    public void setCacheScope(String cacheScope)
+    {
+        this.cacheScope = cacheScope;
+    }
+
+    public DisplayName getDisplayName(Locale locale)
+    {
+        return (DisplayName)JetspeedLocale.getBestLocalizedObject(getDisplayNames(), locale);
+    }
+
+    public InitParam getInitParam(String name)
+    {
+        for (InitParam param : getInitParams())
+        {
+            if (param.getParamName().equals(name))
+            {
+                return param;
+            }
+        }
+        return null;
+    }
+
+    public List<EventDefinitionReference> getSupportedProcessingEvents()
+    {
+        if (supportedProcessingEvents == null)
+        {
+            supportedProcessingEvents = new ArrayList<EventDefinitionReference>();            
+        }
+        return supportedProcessingEvents;
+    }
+
+    public EventDefinitionReference addSupportedProcessingEvent(QName qname)
+    {
+        // TODO: check duplicates
+        getSupportedProcessingEvents();
+        EventDefinitionReferenceImpl edr = new EventDefinitionReferenceImpl();
+        edr.setQName(qname);
+        supportedProcessingEvents.add(edr);
+        return edr;
+    }
+    
+    public EventDefinitionReference addSupportedProcessingEvent(String name)
+    {
+        // TODO check duplicates
+        getSupportedProcessingEvents();
+        EventDefinitionReferenceImpl edr = new EventDefinitionReferenceImpl();
+        edr.setName(name);
+        supportedProcessingEvents.add(edr);
+        return edr;
+    }
+        
+    public List<EventDefinitionReference> getSupportedPublishingEvents()
+    {
+        if (supportedPublishingEvents == null)
+        {
+            supportedPublishingEvents = new ArrayList<EventDefinitionReference>();            
+        }
+        return supportedPublishingEvents;
+    }
+
+    public EventDefinitionReference addSupportedPublishingEvent(QName qname)
+    {
+        // TODO: check duplicates
+        getSupportedPublishingEvents();
+        EventDefinitionReferenceImpl edr = new EventDefinitionReferenceImpl();
+        edr.setQName(qname);
+        supportedPublishingEvents.add(edr);
+        return edr;
+    }
+    
+    public EventDefinitionReference addSupportedPublishingEvent(String name)
+    {
+        // TODO check duplicates
+        getSupportedPublishingEvents();
+        EventDefinitionReferenceImpl edr = new EventDefinitionReferenceImpl();
+        edr.setName(name);
+        supportedPublishingEvents.add(edr);
+        return edr;
+    }
+}

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InlinePortletResourceBundle.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InlinePortletResourceBundle.java?rev=733524&r1=733523&r2=733524&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InlinePortletResourceBundle.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InlinePortletResourceBundle.java Sun Jan 11 13:58:21 2009
@@ -27,7 +27,7 @@
  * 
  * @version: $Id$
  */
-class InlinePortletResourceBundle extends ListResourceBundle
+public class InlinePortletResourceBundle extends ListResourceBundle
 {
     private Object[][] contents;
 

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java?rev=733524&r1=733523&r2=733524&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java Sun Jan 11 13:58:21 2009
@@ -20,38 +20,21 @@
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Locale;
-import java.util.Map;
 
-import javax.portlet.PortletMode;
-import javax.portlet.WindowState;
-import javax.xml.namespace.QName;
-
-import org.apache.jetspeed.JetspeedActions;
 import org.apache.jetspeed.om.common.Support;
-import org.apache.jetspeed.om.portlet.ContainerRuntimeOption;
 import org.apache.jetspeed.om.portlet.CustomPortletMode;
 import org.apache.jetspeed.om.portlet.CustomWindowState;
 import org.apache.jetspeed.om.portlet.Description;
 import org.apache.jetspeed.om.portlet.DisplayName;
-import org.apache.jetspeed.om.portlet.EventDefinition;
-import org.apache.jetspeed.om.portlet.Filter;
-import org.apache.jetspeed.om.portlet.FilterMapping;
 import org.apache.jetspeed.om.portlet.GenericMetadata;
 import org.apache.jetspeed.om.portlet.JetspeedServiceReference;
-import org.apache.jetspeed.om.portlet.Listener;
 import org.apache.jetspeed.om.portlet.LocalizedField;
 import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
-import org.apache.jetspeed.om.portlet.PublicRenderParameter;
-import org.apache.jetspeed.om.portlet.SecurityConstraint;
 import org.apache.jetspeed.om.portlet.SecurityRole;
 import org.apache.jetspeed.om.portlet.UserAttribute;
 import org.apache.jetspeed.om.portlet.UserAttributeRef;
-import org.apache.jetspeed.util.JetspeedLocale;
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.PersistenceBrokerAware;
 import org.apache.ojb.broker.PersistenceBrokerException;
@@ -63,57 +46,30 @@
  * @version $Id$
  * @since 1.0
  */
-public class PortletApplicationDefinitionImpl implements PortletApplication, Serializable, Support, PersistenceBrokerAware
-{ 
-    private int applicationType = PortletApplication.WEBAPP;
+public class PortletApplicationDefinitionImpl extends AbstractPortletApplicationDefinitionImpl implements PortletApplication, Serializable, Support, PersistenceBrokerAware
+{
+    // Members
     
+    private int applicationType = PortletApplication.WEBAPP;
     private String checksum = "0";
     private long checksumLong = -1;
     private long revision;
-    
-    /** Holds value of property version. */
     private String version;
-
-    /** Holds value of property name. */
     private String name;
-    
     private String contextRoot;
-
-    /** Metadata property */
     private Collection<LocalizedField> metadataFields = null;
-    
-    /** Description */
-    private String description;
-
-    private String resourceBundle;
-    private String defaultNamespace;
-    
     private String jetspeedSecurityConstraint;
-    
     private List<Description> descriptions;
     private List<DisplayName> displayNames;
     private List<SecurityRole> roles;
     private List<PortletDefinition> portlets;
-    private List<EventDefinition> eventDefinitions;
-    private List<PublicRenderParameter> publicRenderParameters;
     private List<CustomPortletMode> customPortletModes;
     private List<CustomWindowState> customWindowStates;
     private List<UserAttribute> userAttributes;
-    private List<SecurityConstraint> securityConstraints;
-    private List<Filter> filters;
-    private List<FilterMapping> filterMappings;
-    private List<Listener> listeners;
-    private List<ContainerRuntimeOption> containerRuntimeOptions;
-
     private List<UserAttributeRef> userAttributeRefs;
     private List<JetspeedServiceReference> services = new ArrayList<JetspeedServiceReference>();
     
-    private transient Map<PortletMode,PortletMode> supportedCustomModes;
-    private transient Map<WindowState,WindowState> supportedCustomStates;
-    private transient Map<PortletMode,PortletMode> mappedCustomModes;
-    private transient Map<WindowState,WindowState> mappedCustomStates;    
-    private transient List<PortletMode> supportedPortletModes;
-    private transient List<WindowState> supportedWindowStates;
+    // PortletApplicationDefinition Implementation
     
     /** Creates a new instance of BaseApplication */
     public PortletApplicationDefinitionImpl()
@@ -203,26 +159,6 @@
         return contextRoot;
     }
     
-    public String getDefaultNamespace()
-    {
-        return defaultNamespace;
-    }
-
-    public void setDefaultNamespace(String defaultNamespace)
-    {
-        this.defaultNamespace = defaultNamespace;
-    }
-
-    public String getResourceBundle()
-    {
-        return resourceBundle;
-    }
-
-    public void setResourceBundle(String resourceBundle)
-    {
-        this.resourceBundle = resourceBundle;
-    }
-    
     public String getJetspeedSecurityConstraint()
     {
         return this.jetspeedSecurityConstraint;
@@ -233,16 +169,6 @@
         this.jetspeedSecurityConstraint = constraint;
     }
     
-    public String getDescription()
-    {
-        return description;
-    }
-
-    public void setDescription(String string)
-    {
-        description = string;
-    }
-
     /**
      * @see org.apache.jetspeed.om.portlet.PortletApplication#getMetadata()
      */
@@ -259,11 +185,6 @@
         return metadata;
     }
     
-    public Description getDescription(Locale locale)
-    {
-        return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale);
-    }
-    
     public List<Description> getDescriptions()
     {
         if (descriptions == null)
@@ -287,11 +208,6 @@
         return d;
     }
 
-    public DisplayName getDisplayName(Locale locale)
-    {
-        return (DisplayName)JetspeedLocale.getBestLocalizedObject(getDisplayNames(), locale);
-    }
-    
     public List<DisplayName> getDisplayNames()
     {
         if (displayNames == null)
@@ -339,18 +255,6 @@
         return role;
     }
     
-    public PortletDefinition getPortlet(String portletName)
-    {
-        for (PortletDefinition pd : getPortlets())
-        {
-            if (pd.getPortletName().equals(portletName))
-            {
-                return pd;
-            }
-        }
-        return null;
-    }
-
     public List<PortletDefinition> getPortlets()
     {
         if (portlets == null)
@@ -373,109 +277,6 @@
         return portlet;
     }
 
-    public List<EventDefinition> getEventDefinitions()
-    {
-        if (eventDefinitions == null)
-        {
-            eventDefinitions = new ArrayList<EventDefinition>();
-        }
-        return eventDefinitions;
-    }
-
-    public EventDefinition addEventDefinition(String name)
-    {
-        // TODO: check duplicates (complication: set of qname and name)
-        EventDefinitionImpl ed = new EventDefinitionImpl();
-        ed.setName(name);
-        getEventDefinitions().add(ed);
-        return ed;
-    }
-
-    public EventDefinition addEventDefinition(QName qname)
-    {
-        // TODO: check duplicates (complication: set of qname and name)
-        EventDefinitionImpl ed = new EventDefinitionImpl();
-        ed.setQName(qname);
-        getEventDefinitions().add(ed);
-        return ed;
-    }
-
-    public PublicRenderParameter getPublicRenderParameter(String identifier)
-    {
-        for (PublicRenderParameter p : getPublicRenderParameters())
-        {
-            if (p.getIdentifier().equals(identifier))
-            {
-                return p;
-            }
-        }
-        return null;
-    }
-
-    public List<PublicRenderParameter> getPublicRenderParameters()
-    {
-        if (publicRenderParameters == null)
-        {
-            publicRenderParameters = new ArrayList<PublicRenderParameter>();
-        }
-        return publicRenderParameters;
-    }
-
-    public PublicRenderParameter addPublicRenderParameter(String name, String identifier)
-    {
-        if (getPublicRenderParameter(identifier) != null)
-        {
-            throw new IllegalArgumentException("PublicRenderParameter with identifier: "+identifier+" already defined");
-        }
-        // TODO: check duplicates on name|qname?
-        PublicRenderParameterImpl p = new PublicRenderParameterImpl();
-        p.setName(name);
-        p.setIdentifier(identifier);
-        getPublicRenderParameters().add(p);
-        return p;        
-    }
-
-    public PublicRenderParameter addPublicRenderParameter(QName qname, String identifier)
-    {
-        if (getPublicRenderParameter(identifier) != null)
-        {
-            throw new IllegalArgumentException("PublicRenderParameter with identifier: "+identifier+" already defined");
-        }
-        // TODO: check duplicates on name|qname?
-        PublicRenderParameterImpl p = new PublicRenderParameterImpl();
-        p.setQName(qname);
-        p.setIdentifier(identifier);
-        getPublicRenderParameters().add(p);
-        return p;        
-    }
-
-    public CustomPortletMode getCustomPortletMode(String name)
-    {
-        for (CustomPortletMode cpm : getCustomPortletModes())
-        {
-            if (cpm.getPortletMode().equalsIgnoreCase(name))
-            {
-                return cpm;
-            }
-        }
-        return null;
-    }
-
-    public PortletMode getCustomPortletMode(PortletMode mode)
-    {
-        if (JetspeedActions.getStandardPortletModes().contains(mode))
-        {
-            return mode;
-        }
-        else if (JetspeedActions.getExtendedPortletModes().contains(mode))
-        {
-            // make sure transient cache is setup
-            getSupportedPortletModes();
-            return (PortletMode)supportedCustomModes.get(mode);
-        }
-        return null;            
-    }
-    
     public List<CustomPortletMode> getCustomPortletModes()
     {
         if (customPortletModes == null)
@@ -503,33 +304,6 @@
         return cpm;        
     }
 
-    public CustomWindowState getCustomWindowState(String name)
-    {
-        for (CustomWindowState cws : getCustomWindowStates())
-        {
-            if (cws.getWindowState().equalsIgnoreCase(name))
-            {
-                return cws;
-            }
-        }
-        return null;
-    }
-
-    public WindowState getCustomWindowState(WindowState state)
-    {
-        if (JetspeedActions.getStandardWindowStates().contains(state))
-        {
-            return state;
-        }
-        else if (JetspeedActions.getExtendedWindowStates().contains(state))
-        {
-            // make sure transient cache is setup
-            getSupportedWindowStates();
-            return (WindowState)supportedCustomStates.get(state);
-        }
-        return null;            
-    }
-    
     public List<CustomWindowState> getCustomWindowStates()
     {
         if (customWindowStates == null)
@@ -557,88 +331,6 @@
         return cws;        
     }
 
-    public List<PortletMode> getSupportedPortletModes()
-    {
-        if ( supportedPortletModes == null )
-        {
-            ArrayList<PortletMode> list = new ArrayList<PortletMode>(JetspeedActions.getStandardPortletModes());
-            supportedCustomModes = new HashMap<PortletMode,PortletMode>();
-            mappedCustomModes = new HashMap<PortletMode,PortletMode>();
-            
-            for (CustomPortletMode customMode : getCustomPortletModes())
-            {
-                if ( !list.contains(customMode.getCustomMode()) && JetspeedActions.getExtendedPortletModes().contains(customMode.getMappedMode()) )
-                {
-                    list.add(customMode.getCustomMode());
-                    supportedCustomModes.put(customMode.getMappedMode(), customMode.getCustomMode());
-                    mappedCustomModes.put(customMode.getCustomMode(), customMode.getMappedMode());
-                }
-            }
-            supportedPortletModes = Collections.unmodifiableList(list);
-        }
-        return supportedPortletModes;
-    }
-    
-    public List<WindowState> getSupportedWindowStates()
-    {
-        if ( supportedWindowStates == null )
-        {
-            ArrayList<WindowState> list = new ArrayList<WindowState>(JetspeedActions.getStandardWindowStates());
-            supportedCustomStates = new HashMap<WindowState,WindowState>();
-            mappedCustomStates = new HashMap<WindowState,WindowState>();
-            
-            for (CustomWindowState customState : getCustomWindowStates())
-            {
-                if ( !list.contains(customState.getCustomState()) && JetspeedActions.getExtendedWindowStates().contains(customState.getMappedState()) )
-                {
-                    list.add(customState.getCustomState());
-                    supportedCustomStates.put(customState.getMappedState(),customState.getCustomState());
-                    mappedCustomStates.put(customState.getCustomState(),customState.getMappedState());
-                }
-            }
-            supportedWindowStates = Collections.unmodifiableList(list);
-        }
-        return supportedWindowStates;
-    }
-
-    public PortletMode getMappedPortletMode(PortletMode mode)
-    {
-        if ( JetspeedActions.getStandardPortletModes().contains(mode) )
-        {
-            return mode;
-        }
-        else if ( getSupportedPortletModes().contains(mode) )
-        {
-            return (PortletMode)mappedCustomModes.get(mode);
-        }
-        return null;
-    }
-    
-    public WindowState getMappedWindowState(WindowState state)
-    {
-        if (JetspeedActions.getStandardWindowStates().contains(state) )
-        {
-            return state;
-        }
-        else if ( getSupportedWindowStates().contains(state) )
-        {
-            return (WindowState)mappedCustomStates.get(state);
-        }
-        return null;
-    }
-    
-    public UserAttribute getUserAttribute(String name)
-    {
-        for (UserAttribute ua : getUserAttributes())
-        {
-            if (ua.getName().equals(name))
-            {
-                return ua;
-            }
-        }
-        return null;
-    }
-
     public List<UserAttribute> getUserAttributes()
     {
         if (userAttributes == null)
@@ -660,18 +352,6 @@
         return ua;        
     }
 
-    public UserAttributeRef getUserAttributeRef(String name)
-    {
-        for (UserAttributeRef uar : getUserAttributeRefs())
-        {
-            if (uar.getName().equals(name))
-            {
-                return uar;
-            }
-        }
-        return null;
-    }
-
     public List<UserAttributeRef> getUserAttributeRefs()
     {
         if (userAttributeRefs == null)
@@ -693,147 +373,6 @@
         return uar;        
     }
 
-    public List<SecurityConstraint> getSecurityConstraints()
-    {
-        if (securityConstraints == null)
-        {
-            securityConstraints = new ArrayList<SecurityConstraint>();
-        }
-        return securityConstraints;
-    }
-
-    public SecurityConstraint addSecurityConstraint(String transportGuarantee)
-    {
-        SecurityConstraintImpl sc = new SecurityConstraintImpl();
-        ((UserDataConstraintImpl)sc.getUserDataConstraint()).setTransportGuarantee(transportGuarantee);
-        getSecurityConstraints();
-        getSecurityConstraints().add(sc);
-        return sc;        
-    }
-
-    public Filter getFilter(String filterName)
-    {
-        for (Filter f : getFilters())
-        {
-            if (f.getFilterName().equals(name))
-            {
-                return f;
-            }
-        }
-        return null;
-    }
-
-    public List<Filter> getFilters()
-    {
-        if (filters == null)
-        {
-            filters = new ArrayList<Filter>();
-        }
-        return filters;
-    }
-
-    public Filter addFilter(String filterName)
-    {
-        if (getFilter(name) != null)
-        {
-            throw new IllegalArgumentException("Filter with name: "+name+" already defined");
-        }
-        FilterImpl f = new FilterImpl();
-        f.setFilterName(name);
-        getFilters().add(f);
-        return f;        
-    }
-
-    public FilterMapping getFilterMapping(String filterName)
-    {
-        for (FilterMapping f : getFilterMappings())
-        {
-            if (f.getFilterName().equals(name))
-            {
-                return f;
-            }
-        }
-        return null;
-    }
-
-    public List<FilterMapping> getFilterMappings()
-    {
-        if (filterMappings == null)
-        {
-            filterMappings = new ArrayList<FilterMapping>();
-        }
-        return filterMappings;
-    }
-
-    public FilterMapping addFilterMapping(String filterName)
-    {
-        if (getFilterMapping(name) != null)
-        {
-            throw new IllegalArgumentException("Filtermapping for filter: "+name+" already defined");
-        }
-        FilterMappingImpl fm = new FilterMappingImpl();
-        fm.setFilterName(name);
-        getFilterMappings().add(fm);
-        return fm;        
-    }
-
-    public List<Listener> getListeners()
-    {
-        if (listeners == null)
-        {
-            listeners = new ArrayList<Listener>();
-        }
-        return listeners;
-    }
-
-    public Listener addListener(String listenerClass)
-    {
-        for (Listener l : getListeners())
-        {
-            if (l.getListenerClass().equals(listenerClass))
-            {
-                throw new IllegalArgumentException("Listener of class: "+listenerClass+" already defined");
-            }
-        }
-        ListenerImpl l = new ListenerImpl();
-        l.setListenerClass(listenerClass);
-        getListeners().add(l);
-        return l;        
-    }
-
-    public ContainerRuntimeOption getContainerRuntimeOption(String name)
-    {
-        for (ContainerRuntimeOption cro : getContainerRuntimeOptions())
-        {
-            if (cro.getName().equals(name))
-            {
-                return cro;
-            }
-        }
-        return null;
-    }
-
-    public List<ContainerRuntimeOption> getContainerRuntimeOptions()
-    {
-        if (containerRuntimeOptions == null)
-        {
-            containerRuntimeOptions = new ArrayList<ContainerRuntimeOption>();
-        }
-        return containerRuntimeOptions;
-    }
-
-    public ContainerRuntimeOption addContainerRuntimeOption(String name)
-    {
-        if (getContainerRuntimeOption(name) != null)
-        {
-            throw new IllegalArgumentException("Container runtime option with name: "+name+" already defined");
-        }
-        ContainerRuntimeOptionImpl cro = new ContainerRuntimeOptionImpl();
-        cro.setName(name);
-        getContainerRuntimeOptions().add(cro);
-        return cro;        
-    }
-
     public List<JetspeedServiceReference> getJetspeedServices()
     {
         if (services == null)
@@ -857,22 +396,6 @@
         getJetspeedServices().add(ref);
     }
 
-    public boolean isLayoutApplication()
-    {
-        if (this.getMetadata() != null)
-        {
-            Collection c = this.getMetadata().getFields("layout-app");
-            if (c != null)
-            {
-                if (!c.isEmpty())
-                {
-                   return true;
-                }
-            }
-        }
-        return false;
-     }
-
     /* (non-Javadoc)
      * @see org.apache.jetspeed.om.common.Support#postLoad(java.lang.Object)
      */

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java?rev=733524&r1=733523&r2=733524&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java Sun Jan 11 13:58:21 2009
@@ -25,29 +25,16 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 
-import javax.xml.namespace.QName;
-
-import org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider;
-import org.apache.jetspeed.components.portletregistry.PortletRegistry;
-import org.apache.jetspeed.components.portletregistry.RegistryException;
-import org.apache.jetspeed.factory.PortletFactory;
 import org.apache.jetspeed.om.common.Support;
-import org.apache.jetspeed.om.portlet.ContainerRuntimeOption;
 import org.apache.jetspeed.om.portlet.Description;
 import org.apache.jetspeed.om.portlet.DisplayName;
-import org.apache.jetspeed.om.portlet.EventDefinitionReference;
 import org.apache.jetspeed.om.portlet.GenericMetadata;
 import org.apache.jetspeed.om.portlet.InitParam;
 import org.apache.jetspeed.om.portlet.Language;
 import org.apache.jetspeed.om.portlet.LocalizedField;
 import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
-import org.apache.jetspeed.om.portlet.PortletInfo;
-import org.apache.jetspeed.om.portlet.Preference;
-import org.apache.jetspeed.om.portlet.Preferences;
 import org.apache.jetspeed.om.portlet.SecurityRoleRef;
 import org.apache.jetspeed.om.portlet.Supports;
 import org.apache.jetspeed.util.HashCodeBuilder;
@@ -55,7 +42,6 @@
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.PersistenceBrokerAware;
 import org.apache.ojb.broker.PersistenceBrokerException;
-import org.apache.pluto.internal.InternalPortletPreference;
 
 /**
  * 
@@ -64,95 +50,39 @@
  * @version $Id$
  *  
  */
-public class PortletDefinitionImpl implements PortletDefinition, Serializable, Support, PersistenceBrokerAware
+public class PortletDefinitionImpl extends AbstractPortletDefinitionImpl implements PortletDefinition, Serializable, Support, PersistenceBrokerAware
 {
-    private static PortletRegistry registry;
-    private static PortletFactory  portletFactory;
-    private static PortletPreferencesProvider portletPreferencesProvider;
+    private static final long serialVersionUID = 4313127094480444419L;
 
-    private PortletApplication app;
+    // Members
     
     private Long id;
-
+    private PortletApplication app;    
     protected String portletName;
     protected String portletClass;
     protected String resourceBundle;
     protected String preferenceValidatorClassname;
     private Integer expirationCache;
-    private String cacheScope;
-
-    /** Metadata property */    
     private Collection<LocalizedField> metadataFields = null;
-
     private String jetspeedSecurityConstraint;
-    
     private List<Description> descriptions;
     private List<DisplayName> displayNames;
     private List<InitParam> initParams;
-    private List<EventDefinitionReference> supportedProcessingEvents;
-    private List<EventDefinitionReference> supportedPublishingEvents;
     private List<SecurityRoleRef> securityRoleRefs;
     private List<Supports> supports;
-    private List<String> supportedLocales;
     private List<Language> languages;
-    private List<ContainerRuntimeOption> containerRuntimeOptions;    
-    private List<String> supportedPublicRenderParameters;
-    private Preferences descriptorPreferences = new PreferencesImpl();    
     
     private transient Map<Locale,InlinePortletResourceBundle> resourceBundles = new HashMap<Locale, InlinePortletResourceBundle>();
     
-    protected List portletEntities;
-
-    public static void setPortletRegistry(PortletRegistry registry)
-    {
-        PortletDefinitionImpl.registry = registry;
-    }
-
-    public static void setPortletFactory(PortletFactory portletFactory)
-    {
-        PortletDefinitionImpl.portletFactory = portletFactory;
-    }
-
-    public static void setPortletPreferencesProvider(PortletPreferencesProvider portletPreferencesProvider)
-    {
-        PortletDefinitionImpl.portletPreferencesProvider = portletPreferencesProvider;
-    }
-
+    // PortletDefinition Implementation
+    
+    /**
+     * Default constructor.
+     */
     public PortletDefinitionImpl()
     {
     }
 
-    protected ClassLoader getPortletClassLoader()
-    {
-        return portletFactory.getPortletApplicationClassLoader(app);
-    }
-
-    protected ResourceBundle loadResourceBundle( Locale locale )
-    {
-        ResourceBundle resourceBundle = null;
-        try
-        {
-            if (getResourceBundle() != null)
-            {
-                ClassLoader cl = getPortletClassLoader();
-                if (cl != null)
-                {
-                    resourceBundle = ResourceBundle.getBundle(getResourceBundle(), locale, cl);
-                }
-                else
-                {
-                    resourceBundle = ResourceBundle.getBundle(getResourceBundle(), locale, Thread.currentThread()
-                            .getContextClassLoader());
-                }
-            }
-        }
-        catch (MissingResourceException x)
-        {
-            return null;
-        }
-        return resourceBundle;
-    }
-    
     public PortletApplication getApplication()
     {
         return app;
@@ -183,124 +113,6 @@
         this.portletClass = portletClass;
     }
 
-    public void setDescriptorPreferences(Preferences descriptorPreferences)
-    {
-        this.descriptorPreferences = descriptorPreferences;
-    }
-    
-    public Preferences getDescriptorPreferences()
-    {
-        return this.descriptorPreferences;
-    }
-
-    public Preferences getPortletPreferences()
-    {
-        //System.out.println(">>> Getting prefs ");
-        if (PortletDefinitionImpl.portletPreferencesProvider == null)
-        {
-            return new PreferencesImpl();            
-        }
-        Map<String, InternalPortletPreference> prefMap = PortletDefinitionImpl.portletPreferencesProvider.getDefaultPreferences(this);        
-        Preferences preferences = new PreferencesImpl();
-        List<Preference> list = preferences.getPortletPreferences();
-        for (InternalPortletPreference pref : prefMap.values())
-        {
-            Preference p = preferences.addPreference(pref.getName());
-            p.setReadOnly(pref.isReadOnly());
-            for (String s : pref.getValues())
-            {
-                p.addValue(s);
-            }
-            list.add(p);
-        }
-        return preferences;
-    }
-
-    public Preference addDescriptorPreference(String name)
-    {
-        return descriptorPreferences.addPreference(name);
-    }       
-    
-    
-    public ResourceBundle getResourceBundle(Locale locale)
-    {
-        InlinePortletResourceBundle bundle = resourceBundles.get(locale);
-        if (bundle == null)
-        {
-            Language l = getLanguage(locale);
-            if (l == null)
-            {
-                // always returns a default language
-                l = getLanguage(JetspeedLocale.getDefaultLocale());
-            }
-            ResourceBundle loadedBundle = null;
-            if (getResourceBundle() != null)
-            {
-                loadedBundle = loadResourceBundle(locale);
-                if (loadedBundle == null && !l.equals(JetspeedLocale.getDefaultLocale()))
-                {
-                    loadedBundle = loadResourceBundle(JetspeedLocale.getDefaultLocale());
-                }
-            }
-            if (loadedBundle != null)
-            {
-                bundle = new InlinePortletResourceBundle(l.getTitle(), l.getShortTitle(), l.getKeywords(), loadedBundle);
-            }
-            else
-            {
-                bundle = new InlinePortletResourceBundle(l.getTitle(), l.getShortTitle(), l.getKeywords());
-            }
-            resourceBundles.put(locale, bundle);
-        }
-        return bundle;
-    }
-
-    public Language getLanguage(Locale locale)
-    {
-        Language lang = null;
-        Language fallback = null;
-        
-        for (Language l : getLanguages())
-        {
-            if (l.getLocale().equals(locale))
-            {
-                lang = l;
-                break;
-            }
-            if (l.getLocale().getLanguage().equals(locale.getLanguage()))
-            {
-                fallback = l;
-            }            
-        }
-        if (lang == null)
-        {
-            if (fallback == null)
-            {
-                if (JetspeedLocale.getDefaultLocale().equals(locale))
-                {
-                    // No default Language set/provided yet, adding it on the fly
-                    lang = addLanguage(JetspeedLocale.getDefaultLocale());
-                }
-                else
-                {
-                    // create a new locale on the fly but don't save it
-                    fallback = getLanguage(JetspeedLocale.getDefaultLocale());
-                }
-            }
-            if (fallback != null)
-            {
-                // create a copy of the fallback for the locale but don't save it
-                LanguageImpl l = new LanguageImpl();
-                l.setLocale(locale);
-                l.setTitle(fallback.getTitle());
-                l.setShortTitle(fallback.getShortTitle());
-                l.setKeywords(fallback.getKeywords());
-                lang = l;
-            }
-        }
-        return lang;
-    }
-    
     public List<Language> getLanguages()
     {
         if ( languages == null )
@@ -335,42 +147,6 @@
         return l;
     }
     
-    /**
-     * @see org.apache.jetspeed.om.portlet.PortletDefinition#getUniqueName()
-     */
-    public String getUniqueName()
-    {
-        if (app != null && app.getName() != null && portletName != null)
-        {
-            return app.getName() + "::" + portletName;
-        }
-        else
-        {
-            throw new IllegalStateException(
-                    "Cannot generate a unique portlet name until the application and portlet name have been set");
-        }
-    }
-
-    /**
-     * Returns localized text of this PortletDefinitions description.
-     * 
-     * @param locale
-     *            Locale to get the description for
-     * @return Localized text string of the display name or <code>null</code>
-     *         if no Description exists for this locale
-     */
-    public String getDescriptionText( Locale locale )
-    {
-        Description desc = getDescription(locale);
-        return desc != null ? desc.getDescription() : null;
-    }
-    
-    public String getDisplayNameText(Locale locale)
-    {
-        DisplayName dn = getDisplayName(locale);
-        return dn != null ? dn.getDisplayName() : null;
-    }
-
     public String getPreferenceValidatorClassname()
     {
         return preferenceValidatorClassname;
@@ -465,37 +241,6 @@
         return hasher.toHashCode();
     }
 
-    /**
-     * <p>
-     * store will attempt to perform an atomic persistence call against this
-     * portletDefinition.
-     * </p>
-     * 
-     * @see org.apache.pluto.om.portlet.PortletDefinition#store()
-     * @throws java.io.IOException
-     */
-    public void store() throws IOException
-    {
-        try
-        {
-            registry.savePortletDefinition(this);
-        }
-        catch (RegistryException e)
-        {
-            IOException ioe = new IOException("Failed to store portlet definition: "+e.getMessage());
-            ioe.initCause(e);
-        }
-    }
-
-    public void storeChildren()
-    {
-// TODO        
-//        if (preferenceSet != null)
-//        {
-//            portletPreferencesProvider.savePreferenceSet(this, preferenceSet);
-//        }
-    }
-
     public void postLoad(Object parameter) throws Exception
     {
     }
@@ -508,7 +253,6 @@
 
     public void afterInsert(PersistenceBroker arg0) throws PersistenceBrokerException
     {
-        storeChildren();
     }
 
     public void afterLookup(PersistenceBroker arg0) throws PersistenceBrokerException
@@ -517,7 +261,6 @@
 
     public void afterUpdate(PersistenceBroker arg0) throws PersistenceBrokerException
     {
-        storeChildren();
     }
 
     public void beforeDelete(PersistenceBroker arg0) throws PersistenceBrokerException
@@ -532,39 +275,6 @@
     {
     }
     
-    public ContainerRuntimeOption getContainerRuntimeOption(String name)
-    {
-        for (ContainerRuntimeOption cro : getContainerRuntimeOptions())
-        {
-            if (cro.getName().equals(name))
-            {
-                return cro;
-            }
-        }
-        return null;
-    }
-
-    public List<ContainerRuntimeOption> getContainerRuntimeOptions()
-    {
-        if (containerRuntimeOptions == null)
-        {
-            containerRuntimeOptions = new ArrayList<ContainerRuntimeOption>();
-        }
-        return containerRuntimeOptions;
-    }
-
-    public ContainerRuntimeOption addContainerRuntimeOption(String name)
-    {
-        if (getContainerRuntimeOption(name) != null)
-        {
-            throw new IllegalArgumentException("Container runtime option with name: "+name+" already defined");
-        }
-        ContainerRuntimeOptionImpl cro = new ContainerRuntimeOptionImpl();
-        cro.setName(name);
-        containerRuntimeOptions.add(cro);
-        return cro;        
-    }
-
     public SecurityRoleRef getSecurityRoleRef(String roleName)
     {
         for (SecurityRoleRef ref : getSecurityRoleRefs())
@@ -598,23 +308,6 @@
         return srr;        
     }
     
-    public PortletInfo getPortletInfo()
-    {
-        return getLanguage(JetspeedLocale.getDefaultLocale());
-    }
-
-    public Supports getSupports(String mimeType)
-    {
-        for (Supports s : getSupports())
-        {
-            if (s.getMimeType().equals(mimeType))
-            {
-                return s;
-            }
-        }
-        return null;
-    }
-    
     public List<Supports> getSupports()
     {
         if (supports == null)
@@ -636,63 +329,6 @@
         return s;        
     }
     
-    public List<String> getSupportedLocales()
-    {
-        if (supportedLocales == null)
-        {
-            supportedLocales = new ArrayList<String>();
-        }
-        return supportedLocales;
-    }
-    
-    public void addSupportedLocale(String lang)
-    {
-        for (String l : getSupportedLocales())
-        {
-            if (l.equals(lang))
-            {
-                throw new IllegalArgumentException("Supported locale: "+lang+" already defined");
-            }
-        }
-        supportedLocales.add(lang);    
-    }
-
-    public List<String> getSupportedPublicRenderParameters()
-    {
-        if (supportedPublicRenderParameters == null)
-        {
-            supportedPublicRenderParameters = new ArrayList<String>();
-        }
-        return supportedPublicRenderParameters;
-    }
-    
-    public void addSupportedPublicRenderParameter(String identifier)
-    {
-        for (String ident : getSupportedPublicRenderParameters())
-        {
-            if (ident.equals(identifier))
-            {
-                throw new IllegalArgumentException("Support for public render parameter with identifier: "+identifier+" already defined");
-            }
-        }
-        supportedPublicRenderParameters.add(identifier);
-    }
-
-
-    /**
-     * Caching scope, allowed values are "private" indicating that the content should not be shared across users and
-     * "public" indicating that the content may be shared across users. The default value if not present is "private".
-     */
-    public String getCacheScope()
-    {
-        return cacheScope != null ? cacheScope : "private";
-    }
-
-    public void setCacheScope(String cacheScope)
-    {
-        this.cacheScope = cacheScope;
-    }
-
     public int getExpirationCache()
     {
         return expirationCache != null ? expirationCache.intValue() : 0;
@@ -732,11 +368,6 @@
         return d;
     }
 
-    public DisplayName getDisplayName(Locale locale)
-    {
-        return (DisplayName)JetspeedLocale.getBestLocalizedObject(getDisplayNames(), locale);
-    }
-    
     public List<DisplayName> getDisplayNames()
     {
         if (displayNames == null)
@@ -760,18 +391,6 @@
         return d;
     }
 
-    public InitParam getInitParam(String name)
-    {
-        for (InitParam param : getInitParams())
-        {
-            if (param.getParamName().equals(name))
-            {
-                return param;
-            }
-        }
-        return null;
-    }
-
     public List<InitParam> getInitParams()
     {
         if (initParams == null)
@@ -792,63 +411,4 @@
         initParams.add(param);
         return param;
     }
-    
-    public List<EventDefinitionReference> getSupportedProcessingEvents()
-    {
-        if (supportedProcessingEvents == null)
-        {
-            supportedProcessingEvents = new ArrayList<EventDefinitionReference>();            
-        }
-        return supportedProcessingEvents;
-    }
-
-    public EventDefinitionReference addSupportedProcessingEvent(QName qname)
-    {
-        // TODO: check duplicates
-        getSupportedProcessingEvents();
-        EventDefinitionReferenceImpl edr = new EventDefinitionReferenceImpl();
-        edr.setQName(qname);
-        supportedProcessingEvents.add(edr);
-        return edr;
-    }
-    
-    public EventDefinitionReference addSupportedProcessingEvent(String name)
-    {
-        // TODO check duplicates
-        getSupportedProcessingEvents();
-        EventDefinitionReferenceImpl edr = new EventDefinitionReferenceImpl();
-        edr.setName(name);
-        supportedProcessingEvents.add(edr);
-        return edr;
-    }
-        
-    public List<EventDefinitionReference> getSupportedPublishingEvents()
-    {
-        if (supportedPublishingEvents == null)
-        {
-            supportedPublishingEvents = new ArrayList<EventDefinitionReference>();            
-        }
-        return supportedPublishingEvents;
-    }
-
-    public EventDefinitionReference addSupportedPublishingEvent(QName qname)
-    {
-        // TODO: check duplicates
-        getSupportedPublishingEvents();
-        EventDefinitionReferenceImpl edr = new EventDefinitionReferenceImpl();
-        edr.setQName(qname);
-        supportedPublishingEvents.add(edr);
-        return edr;
-    }
-    
-    public EventDefinitionReference addSupportedPublishingEvent(String name)
-    {
-        // TODO check duplicates
-        getSupportedPublishingEvents();
-        EventDefinitionReferenceImpl edr = new EventDefinitionReferenceImpl();
-        edr.setName(name);
-        supportedPublishingEvents.add(edr);
-        return edr;
-    }
-
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org