portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vku...@apache.org
Subject svn commit: r711217 - in /portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets: palm/ pam/ selector/
Date Tue, 04 Nov 2008 09:36:44 GMT
Author: vkumar
Date: Tue Nov  4 01:36:43 2008
New Revision: 711217

URL: http://svn.apache.org/viewvc?rev=711217&view=rev
Log:
Fixing base J2-admin components, after pluto 2.0 changes

Removed:
    portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationBean.java
Modified:
    portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/palm/PortletApplicationLifecycleManager.java
    portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/palm/PortletApplicationStatusBean.java
    portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationBrowser.java
    portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java
    portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java

Modified: portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/palm/PortletApplicationLifecycleManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/palm/PortletApplicationLifecycleManager.java?rev=711217&r1=711216&r2=711217&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/palm/PortletApplicationLifecycleManager.java (original)
+++ portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/palm/PortletApplicationLifecycleManager.java Tue Nov  4 01:36:43 2008
@@ -16,31 +16,31 @@
 */
 package org.apache.jetspeed.portlets.palm;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
-import javax.portlet.PortletConfig;
-import javax.portlet.PortletContext;
-import javax.portlet.PortletException;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletRequest;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-
-import org.apache.jetspeed.CommonPortletServices;
-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.portlet.MutablePortletApplication;
-import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager;
-import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManagerResult;
-import org.apache.portals.bridges.common.GenericServletPortlet;
-import org.apache.portals.gems.util.StatusMessage;
-import org.apache.portals.messaging.PortletMessaging;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.jetspeed.CommonPortletServices;
+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.portlet.PortletApplication;
+import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager;
+import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManagerResult;
+import org.apache.portals.bridges.common.GenericServletPortlet;
+import org.apache.portals.gems.util.StatusMessage;
+import org.apache.portals.messaging.PortletMessaging;
 
 /**
  * PALM Portlet
@@ -90,7 +90,7 @@
             Iterator apps = registry.getPortletApplications().iterator();
             while (apps.hasNext())
             {
-                MutablePortletApplication pa = (MutablePortletApplication)apps.next();
+                PortletApplication pa = (PortletApplication)apps.next();
                 PortletApplicationStatusBean bean = new PortletApplicationStatusBean(pa, portletFactory.isPortletApplicationRegistered(pa));
                 list.add(bean);
             }            
@@ -115,12 +115,12 @@
                 
                 if (!action.equals("refresh") && !isEmpty(value))
                 {
-                    MutablePortletApplication pa = registry.getPortletApplication(value);
+                    PortletApplication pa = registry.getPortletApplication(value);
                     if ( pa == null )
                     {
                         publishStatusMessage(request, "PALM", "status", null, "Portlet Application for lookup value "+value+" no longer exists");
                     }
-                    else if ( pa.getApplicationType() == MutablePortletApplication.LOCAL )
+                    else if ( pa.getApplicationType() == PortletApplication.LOCAL )
                     {
                         // TODO
                     }
@@ -171,7 +171,7 @@
         }        
     }
 
-    protected void startPA(ActionRequest request, MutablePortletApplication pa)
+    protected void startPA(ActionRequest request, PortletApplication pa)
     {
         if ( portletFactory.isPortletApplicationRegistered(pa))
         {
@@ -185,7 +185,7 @@
         {
             try
             {
-                ApplicationServerManagerResult result = asm.start(pa.getWebApplicationDefinition().getContextRoot());
+                ApplicationServerManagerResult result = asm.start(pa.getContextRoot());
                 if ( !result.isOk() )
                 {
                     publishStatusMessage(request, "PALM", "status", null, result.getMessage());
@@ -199,7 +199,7 @@
         }
     }
 
-    protected void stopPA(ActionRequest request, MutablePortletApplication pa)
+    protected void stopPA(ActionRequest request, PortletApplication pa)
     {
         if ( !portletFactory.isPortletApplicationRegistered(pa))
         {
@@ -213,7 +213,7 @@
         {
             try
             {
-                ApplicationServerManagerResult result = asm.stop(pa.getWebApplicationDefinition().getContextRoot());
+                ApplicationServerManagerResult result = asm.stop(pa.getContextRoot());
                 if ( !result.isOk() )
                 {
                     publishStatusMessage(request, "PALM", "status", null, result.getMessage());
@@ -227,7 +227,7 @@
         }
     }
 
-    protected void undeployPA(ActionRequest request, MutablePortletApplication pa)
+    protected void undeployPA(ActionRequest request, PortletApplication pa)
     {
         if ( !serverManagerAvailable || !asm.isConnected() )
         {
@@ -237,7 +237,7 @@
         {
             try
             {
-                ApplicationServerManagerResult result = asm.undeploy(pa.getWebApplicationDefinition().getContextRoot());
+                ApplicationServerManagerResult result = asm.undeploy(pa.getContextRoot());
                 if ( !result.isOk() )
                 {
                     publishStatusMessage(request, "PALM", "status", null, result.getMessage());
@@ -251,7 +251,7 @@
         }
     }
 
-    protected void deletePA(ActionRequest request, MutablePortletApplication pa)
+    protected void deletePA(ActionRequest request, PortletApplication pa)
     {
         if ( portletFactory.isPortletApplicationRegistered(pa))
         {

Modified: portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/palm/PortletApplicationStatusBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/palm/PortletApplicationStatusBean.java?rev=711217&r1=711216&r2=711217&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/palm/PortletApplicationStatusBean.java (original)
+++ portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/palm/PortletApplicationStatusBean.java Tue Nov  4 01:36:43 2008
@@ -18,7 +18,7 @@
 
 import java.io.Serializable;
 
-import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.om.portlet.PortletApplication;
 
 /**
  * PortletApplicationStatusBean
@@ -34,18 +34,18 @@
     private boolean local;
     private boolean running;
     
-    public PortletApplicationStatusBean(MutablePortletApplication pa, boolean running)
+    public PortletApplicationStatusBean(PortletApplication pa, boolean running)
     {
         this.name = pa.getName();
         this.version = pa.getVersion();
-        this.local = pa.getApplicationType() == MutablePortletApplication.LOCAL;
+        this.local = pa.getApplicationType() == PortletApplication.LOCAL;
         if (local)
         {
             this.path = "<local>";
         }
         else    
         {
-            this.path = pa.getWebApplicationDefinition().getContextRoot();
+            this.path = pa.getContextRoot();
         }
         this.running = running;
     }

Modified: portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationBrowser.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationBrowser.java?rev=711217&r1=711216&r2=711217&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationBrowser.java (original)
+++ portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationBrowser.java Tue Nov  4 01:36:43 2008
@@ -23,7 +23,6 @@
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
-
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
@@ -33,8 +32,7 @@
 
 import org.apache.jetspeed.CommonPortletServices;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
-import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
-import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
+import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.portlets.tags.TreeControl;
 import org.apache.jetspeed.portlets.tags.TreeControlNode;
 import org.apache.jetspeed.search.SearchEngine;
@@ -125,12 +123,12 @@
 			    TreeControlNode child = control.findNode(selectedNode);
 			    if(child != null)
 			    {
-			        MutablePortletApplication pa = null;
+			        PortletApplication pa = null;
 			        
 				    String domain = child.getDomain();
 				    if(domain.equals("PA_APP_DOMAIN"))
 				    {
-				        pa = registry.getPortletApplicationByIdentifier(selectedNode);
+				        pa = registry.getPortletApplication(selectedNode);
 				        if(pa != null)
 				        {
 				            actionRequest.getPortletSession().removeAttribute(PortletApplicationResources.REQUEST_SELECT_PORTLET, PortletSession.APPLICATION_SCOPE);
@@ -139,15 +137,15 @@
 				    else if(domain.equals("PD_DOMAIN"))
 				    {
 				        TreeControlNode parent = child.getParent();
-			            pa = registry.getPortletApplicationByIdentifier(parent.getName());
+			            pa = registry.getPortletApplication(parent.getName());
 			            
 			            //set selected tab to portlets tab
 			            if(pa != null)
 			            {
 			                //TODO:  do we need to look up the pdef?  Could we just pass the child name into setAttribute?
 			                String pdefName = child.getName().substring(pa.getName().length() + 2); //remove pa prefix
-			                PortletDefinition pdef = pa.getPortletDefinitionByName(pdefName);
-			                actionRequest.getPortletSession().setAttribute(PortletApplicationResources.REQUEST_SELECT_PORTLET, pdef.getName(), PortletSession.APPLICATION_SCOPE);
+			                PortletDefinition pdef = pa.getPortlet(pdefName);
+			                actionRequest.getPortletSession().setAttribute(PortletApplicationResources.REQUEST_SELECT_PORTLET, pdef.getPortletName(), PortletSession.APPLICATION_SCOPE);
 			                actionRequest.getPortletSession().setAttribute(PortletApplicationResources.REQUEST_SELECT_TAB, new TabBean("pa_portlets"), PortletSession.APPLICATION_SCOPE);
 			            }
 				    }
@@ -192,7 +190,7 @@
 		Iterator it = apps.iterator();
         while (it.hasNext())
         {
-            MutablePortletApplication pa = (MutablePortletApplication)it.next();
+            PortletApplication pa = (PortletApplication)it.next();
             TreeControlNode appNode = new TreeControlNode(pa.getName(), 
                                                           null, 
                                                           pa.getName(), 
@@ -202,13 +200,13 @@
                                                           "PA_APP_DOMAIN"  );
             portletApps.addChild(appNode);
             
-            Iterator pdefIter = pa.getPortletDefinitionList().iterator();
+            Iterator pdefIter = pa.getPortlets().iterator();
             while (pdefIter.hasNext())
             {
-                PortletDefinitionComposite portlet = (PortletDefinitionComposite) pdefIter.next();
-                TreeControlNode portletNode = new TreeControlNode(pa.getName() + "::" + portlet.getName(), 
+                PortletDefinition portlet = (PortletDefinition) pdefIter.next();
+                TreeControlNode portletNode = new TreeControlNode(pa.getName() + "::" + portlet.getPortletName(), 
                                                                   null, 
-                                                                  portlet.getDisplayNameText(locale), 
+                                                                  portlet.getDisplayName(locale).getDisplayName(), 
                                                                   PortletApplicationResources.PORTLET_URL, 
                                                                   null, 
                                                                   false, 

Modified: portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java?rev=711217&r1=711216&r2=711217&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java (original)
+++ portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java Tue Nov  4 01:36:43 2008
@@ -38,22 +38,21 @@
 import org.apache.jetspeed.components.portletregistry.FailedToStorePortletDefinitionException;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.components.portletregistry.RegistryException;
-import org.apache.jetspeed.om.common.GenericMetadata;
-import org.apache.jetspeed.om.common.LocalizedField;
-import org.apache.jetspeed.om.common.MutableDescription;
-import org.apache.jetspeed.om.common.MutableDisplayName;
-import org.apache.jetspeed.om.common.MutableLanguage;
-import org.apache.jetspeed.om.common.ParameterComposite;
-import org.apache.jetspeed.om.common.SecurityRoleRefComposite;
-import org.apache.jetspeed.om.common.UserAttribute;
-import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
-import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
-import org.apache.jetspeed.om.common.preference.PreferenceComposite;
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.om.portlet.DisplayName;
+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.Preference;
+import org.apache.jetspeed.om.portlet.SecurityRoleRef;
+import org.apache.jetspeed.om.portlet.Supports;
+import org.apache.jetspeed.om.portlet.UserAttribute;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.portlets.pam.beans.PortletApplicationBean;
 import org.apache.jetspeed.search.SearchEngine;
-import org.apache.pluto.om.common.SecurityRoleRef;
-import org.apache.pluto.om.portlet.ContentType;
 import org.apache.portals.bridges.beans.TabBean;
 import org.apache.portals.bridges.common.GenericServletPortlet;
 
@@ -130,14 +129,14 @@
             request.getPortletSession().getAttribute(PortletApplicationResources.PAM_CURRENT_PA, 
                                              PortletSession.APPLICATION_SCOPE);
         
-        MutablePortletApplication pa = registry.getPortletApplication(paName);
+        PortletApplication pa = registry.getPortletApplication(paName);
         
         if (null != pa)
         {
             request.setAttribute(VIEW_PA, new PortletApplicationBean(pa));
             
             String pdefName = (String) request.getPortletSession().getAttribute(PortletApplicationResources.REQUEST_SELECT_PORTLET, PortletSession.APPLICATION_SCOPE);
-            PortletDefinitionComposite pdef = (PortletDefinitionComposite) pa.getPortletDefinitionByName(pdefName);
+            PortletDefinition pdef = (PortletDefinition) pa.getPortlet(pdefName);
             
             request.setAttribute(VIEW_PD, pdef);
             
@@ -174,7 +173,7 @@
         super.doView(request, response);
     }
 
-    private void setupSecurityContraintContext(RenderRequest request, MutablePortletApplication pa, PortletDefinitionComposite pdef) throws PortletException
+    private void setupSecurityContraintContext(RenderRequest request, PortletApplication pa, PortletDefinition pdef) throws PortletException
     {
         try
         {
@@ -192,7 +191,7 @@
         catch (Exception e)
         {
             throw new PortletException("Failed to retrieve security constraint references from "
-                    + (pdef == null ? "portlet application " + pa.getName() : "portlet definition " + pdef.getName()));
+                    + (pdef == null ? "portlet application " + pa.getName() : "portlet definition " + pdef.getPortletName()));
         }
     }
 
@@ -226,7 +225,7 @@
         String action = actionRequest.getParameter(PORTLET_ACTION);
         if(action != null)
         {
-            MutablePortletApplication pa = registry.getPortletApplication(paName);
+            PortletApplication pa = registry.getPortletApplication(paName);
             if(isAppAction(action))
             {
                 action = getAction(PORTLET_APP_ACTION_PREFIX, action);
@@ -252,7 +251,7 @@
                 
                 try
                 {
-                    PortletDefinitionComposite pdef = (PortletDefinitionComposite) pa.getPortletDefinitionByName(pdefName);
+                    PortletDefinition pdef = (PortletDefinition) pa.getPortlet(pdefName);
                     if(action.endsWith("metadata"))
                     {
                         processMetadataAction(actionRequest, actionResponse, null, pdef, action);
@@ -315,7 +314,7 @@
      * @param pa
      * @param action
      */
-    private void processUserAttributeAction(ActionRequest actionRequest, ActionResponse actionResponse, MutablePortletApplication mpa, String action) 
+    private void processUserAttributeAction(ActionRequest actionRequest, ActionResponse actionResponse, PortletApplication mpa, String action) 
     throws PortletException, IOException
     {
         boolean modified = false;
@@ -330,11 +329,10 @@
                 
                 userAttrName = userAttr.getName();
                 String description = actionRequest.getParameter(userAttrName + ":description");
-                if(!userAttr.getDescription().equals(description))
-                {
-                    userAttr.setDescription(description);
-                    modified = true;
-                }
+                Description desc =  userAttr.getDescription(actionRequest.getLocale());
+                desc.setDescription(description);
+                userAttr.getDescriptions().add(desc);
+                modified = true;
             }
         }
         else if(action.equals("add_user_attribute"))
@@ -343,7 +341,8 @@
             String userAttrDesc = actionRequest.getParameter("user_attr_desc");
             if (userAttrName != null && userAttrName.trim().length() > 0)                
             {
-                mpa.addUserAttribute(userAttrName.trim(), userAttrDesc);
+                UserAttribute userAttrib = mpa.getUserAttribute(userAttrName);
+                userAttrib.addDescription(userAttrDesc);
                 modified = true;
             }
         }
@@ -396,8 +395,8 @@
      */
     private void processMetadataAction(ActionRequest actionRequest, 
                                        ActionResponse actionResponse, 
-                                       MutablePortletApplication pa, 
-                                       PortletDefinitionComposite  pd,
+                                       PortletApplication pa, 
+                                       PortletDefinition  pd,
                                        String action)
     throws PortletException, IOException
     {
@@ -424,7 +423,7 @@
             while (fieldsIter.hasNext())
             {
                 LocalizedField field = (LocalizedField) fieldsIter.next();
-                String id = field.getId().toString();
+                String id = field.getName();
                 String value = actionRequest.getParameter(id + ":value");
                 if (value != null)
                 {
@@ -446,7 +445,7 @@
                 while (fieldsIter.hasNext())
                 {
                     LocalizedField field = (LocalizedField) fieldsIter.next();
-                    String id = field.getId().toString();
+                    String id = field.getName();
 
                     for(int i=0; i<ids.length; i++)
                     {
@@ -496,13 +495,13 @@
             catch(RegistryException e)
             {
         	    throw new PortletException("Failed to perform action " + action + " on " 
-        	    		+ (pd == null ? "portlet application " + pa.getName() : "portlet definition " + pd.getName()) );
+        	    		+ (pd == null ? "portlet application " + pa.getName() : "portlet definition " + pd.getPortletName()) );
             }
         }
     }
         
-    private void processPortletAction(ActionRequest actionRequest, ActionResponse actionResponse, MutablePortletApplication pa, 
-    		PortletDefinitionComposite portlet, String action) throws RegistryException
+    private void processPortletAction(ActionRequest actionRequest, ActionResponse actionResponse, PortletApplication pa, 
+    		PortletDefinition portlet, String action) throws RegistryException
     {
         if(action.equals("edit_portlet"))
         {
@@ -510,10 +509,10 @@
             if(displayNameParam == null)
             {            
                 int index = 0;
-                Iterator displayNameIter = portlet.getDisplayNameSet().iterator();
+                Iterator displayNameIter = portlet.getDisplayNames().iterator();
                 while (displayNameIter.hasNext())
                 {
-                    MutableDisplayName displayName = (MutableDisplayName) displayNameIter.next();
+                    DisplayName displayName = (DisplayName) displayNameIter.next();
                     displayNameParam = actionRequest.getParameter("display_name:" + index);
                     
                     //this should never happen
@@ -536,7 +535,7 @@
                     try
                     {
                         Integer.parseInt(expirationCache);
-                        portlet.setExpirationCache(expirationCache);
+                        portlet.setExpirationCache(Integer.parseInt(expirationCache));
                     }
                     catch (NumberFormatException e)
                     {}
@@ -545,7 +544,7 @@
             else
             {
                 String locale = actionRequest.getParameter("locale");
-                portlet.addDisplayName(new Locale(locale), displayNameParam);
+                portlet.addDisplayName(displayNameParam);
             }            
         }
         else if(action.equals("remove_portlet"))
@@ -567,22 +566,16 @@
      * @param action
      * @throws RegistryException
      */
-    private void processPreferenceAction(ActionRequest actionRequest, ActionResponse actionResponse, MutablePortletApplication pa, PortletDefinitionComposite portlet, String action) throws RegistryException
+    private void processPreferenceAction(ActionRequest actionRequest, ActionResponse actionResponse, PortletApplication pa, PortletDefinition portlet, String action) throws RegistryException
     {
         if(action.equals("add_preference"))
         {
             String name = actionRequest.getParameter("name");
             String value = actionRequest.getParameter("value");
             
-            PreferenceComposite pref = (PreferenceComposite) portlet.getPreferenceSet().get(name);
-            if(pref == null)
-            {
-                portlet.addPreference(name, new String[] { value });
-            }
-            else
-            {
-                pref.addValue(value);
-            }
+            Preference pref = portlet.getPortletPreferences().getPortletPreference(name);
+            pref.addValue(value);
+           
         }
         else if(action.equals("edit_preference"))
         {
@@ -590,8 +583,8 @@
             for (int i = 0; i < prefNames.length; i++)
             {
                 String prefName = prefNames[i];
-                PreferenceComposite prefComp = (PreferenceComposite) portlet.getPreferenceSet().get(prefName);
-                List<String> values = prefComp.getValuesList();
+                Preference prefComp = (Preference) portlet.getPortletPreferences().getPortletPreference(prefName);
+                List<String> values = prefComp.getValues();
                 boolean update = false;
                 for (int j = 0; j < values.size(); j++)
                 {
@@ -605,7 +598,7 @@
                 }
                 if (update)
                 {
-                    prefComp.setValues(values);
+                   // prefComp .setValues(values);
                 }
             }
         }
@@ -613,10 +606,10 @@
         {
             String[] prefNames = actionRequest.getParameterValues("pref_remove_id");
             
-            Iterator prefIter = portlet.getPreferenceSet().iterator();
+            Iterator prefIter = portlet.getPortletPreferences().getPortletPreferences().iterator();
             while (prefIter.hasNext())
             {
-                PreferenceComposite pref = (PreferenceComposite) prefIter.next();
+                Preference pref = (Preference) prefIter.next();
                 String name = pref.getName();
                 
                 for(int i=0; i<prefNames.length; i++)
@@ -642,7 +635,7 @@
      * @param action
      * @throws RegistryException
      */
-    private void processLanguage(ActionRequest actionRequest, ActionResponse actionResponse, MutablePortletApplication pa, PortletDefinitionComposite portlet, String action) throws RegistryException
+    private void processLanguage(ActionRequest actionRequest, ActionResponse actionResponse, PortletApplication pa, PortletDefinition portlet, String action) throws RegistryException
     {
          if(action.equals("add_language"))
          {
@@ -650,8 +643,10 @@
              String shortTitle = actionRequest.getParameter("short_title");
              String keywords = actionRequest.getParameter("keyword");
              String locale = actionRequest.getParameter("locale");
-
-             portlet.addLanguage(title, shortTitle, keywords, new Locale(locale));
+             Language lang =  portlet.addLanguage(new Locale(locale));
+             lang.setKeywords(keywords);
+             lang.setShortTitle(shortTitle);
+             lang.setTitle(title);
          }
          else if(action.equals("remove_language"))
          {
@@ -659,7 +654,7 @@
              if(removeIds != null)
              {
                  int id = 0;
-                 Iterator langIter = portlet.getLanguageSet().iterator();
+                 Iterator langIter = portlet.getLanguages().iterator();
                  while (langIter.hasNext())
                  {
                      langIter.next();
@@ -688,7 +683,7 @@
 
                  String id;
                  int index=0;
-                 Iterator langIter = portlet.getLanguageSet().iterator();
+                 Iterator langIter = portlet.getLanguages().iterator();
                  while (langIter.hasNext())
                  {
                      id = editIds[index];
@@ -697,16 +692,15 @@
                      String shortTitle = actionRequest.getParameter("short_title:" + id);
 
                      //must cast to interface to avoid class loader issues
-                     MutableLanguage lang = (MutableLanguage) langIter.next();
+                     Language lang = (Language) langIter.next();
 
                      if(!lang.getTitle().equals(title))
                      {
                          lang.setTitle(title);
                      }
 
-                     Iterator keywordIter = lang.getKeywords();
+                     Iterator keywordIter = lang.getKeywordList().iterator();
                      int keywordIndex = 0;
-                     ArrayList keywordList = new ArrayList();
                      
                      while (keywordIter.hasNext())
                      {
@@ -715,13 +709,12 @@
 
                          if(keywordParam != null && keywordParam.length() > 0)
                          {
-                             keywordList.add(keywordParam);
+                             lang.setKeywords(keywordParam);
                          }
 
                          keywordIndex++;
                      }
 
-                     lang.setKeywords(keywordList);
                      if(lang.getShortTitle() == null || !lang.getShortTitle().equals(shortTitle))
                      {
                          lang.setShortTitle(shortTitle);
@@ -742,7 +735,7 @@
      * @param action
      * @throws FailedToStorePortletDefinitionException
      */
-    private void processParameter(ActionRequest actionRequest, ActionResponse actionResponse, MutablePortletApplication pa, PortletDefinitionComposite portlet, String action) throws FailedToStorePortletDefinitionException
+    private void processParameter(ActionRequest actionRequest, ActionResponse actionResponse, PortletApplication pa, PortletDefinition portlet, String action) throws FailedToStorePortletDefinitionException
     {
         if(action.equals("add_parameter"))
         {
@@ -752,15 +745,17 @@
                 String description = actionRequest.getParameter("description");
                 String locale = actionRequest.getParameter("locale");
                 
-                ParameterComposite parameter = (ParameterComposite)portlet.getInitParameterSet().get(name);
+                InitParam parameter = portlet.getInitParam(name);
                 if(parameter == null)
                 {
                     String value = actionRequest.getParameter("value");
-                    parameter = portlet.addInitParameter(name, value, description, new Locale(locale));
+                    parameter = portlet.addInitParam(name);
+                    parameter.setParamValue(value);
+                    parameter.addDescription(description);
                 }
                 else
                 {
-                    parameter.addDescription(new Locale(locale), description);
+                    parameter.addDescription(description);
                 }
             }
         }
@@ -773,16 +768,16 @@
                 for(int i=0; i<paramIds.length; i++)
                 {
                     String paramId = paramIds[i];
-                    ParameterComposite param = (ParameterComposite) portlet.getInitParameterSet().get(paramId);
+                    InitParam param = portlet.getInitParam(paramId);
                     
                     String value = actionRequest.getParameter(paramId + ":value");
-                    param.setValue(value);
-                    
+                    param.setParamValue(value);
+                                       
                     int index = 0;
-                    Iterator descIter = param.getDescriptionSet().iterator();
+                    Iterator descIter = param.getDescriptions().iterator();
                     while (descIter.hasNext())
                     {
-                        MutableDescription description = (MutableDescription) descIter.next();
+                        Description description = (Description) descIter.next();
                         String descParam = actionRequest.getParameter(paramId + ":description:" + index);
                         //changing locale not allowed.
                         
@@ -808,17 +803,13 @@
             
             if(paramIds != null)
             {
-                Iterator paramIter = portlet.getInitParameterSet().iterator();
-                while (paramIter.hasNext())
+                for(InitParam param : portlet.getInitParams())
                 {
-                    ParameterComposite param = (ParameterComposite) paramIter.next();
-                    
-                    for(int i=0; i<paramIds.length; i++)
-                    {
-                        String paramId = paramIds[i];
-                        if(param.getName().equals(paramId))
-                        {
-                            paramIter.remove();
+                    for(String paramID : paramIds)
+                    {                        
+                        if(paramID.equals(param.getParamName()))
+                        {    
+                           portlet.getInitParams().remove(param);
                             break;
                         }
                     }
@@ -836,7 +827,7 @@
      * @param action
      * @throws FailedToStorePortletDefinitionException
      */
-    private void processSecurity(ActionRequest actionRequest, ActionResponse actionResponse, MutablePortletApplication pa, PortletDefinitionComposite portlet, String action) throws FailedToStorePortletDefinitionException
+    private void processSecurity(ActionRequest actionRequest, ActionResponse actionResponse, PortletApplication pa, PortletDefinition portlet, String action) throws FailedToStorePortletDefinitionException
     {
         if(action.equals("add_security"))
         {
@@ -846,10 +837,12 @@
             {
                 String link = actionRequest.getParameter("link");
                 
-                SecurityRoleRefComposite securityRoleRef = (SecurityRoleRefComposite) portlet.getInitSecurityRoleRefSet().get(name);
+                SecurityRoleRef securityRoleRef = (SecurityRoleRef) portlet.getSecurityRoleRef(name);
                 if(securityRoleRef == null && link != null)
                 {
-                    securityRoleRef = (SecurityRoleRefComposite) portlet.addSecurityRoleRef(name, link);
+                    securityRoleRef = portlet.addSecurityRoleRef(name);
+                    securityRoleRef.setRoleLink(link);
+                    //.addSecurityRoleRef(name, link);
                 }
                 
                 if(securityRoleRef != null)
@@ -862,17 +855,17 @@
                         {
                             locale = "en";
                         }
-                        securityRoleRef.addDescription(new Locale(locale), description);
+                        securityRoleRef.addDescription(description);
                     }
                 }
             }
         }
         else if(action.equals("edit_security"))
         {
-            Iterator securityIter = portlet.getInitSecurityRoleRefSet().iterator();
+            Iterator securityIter = portlet.getSecurityRoleRefs().iterator();
             while (securityIter.hasNext())
             {
-                SecurityRoleRefComposite secRef = (SecurityRoleRefComposite) securityIter.next();
+                SecurityRoleRef secRef = (SecurityRoleRef) securityIter.next();
                 String name = secRef.getRoleName();
                 
                 //TODO:  should this be editable
@@ -885,10 +878,10 @@
                 }
                 
                 int index = 0;
-                Iterator descIter = secRef.getDescriptionSet().iterator();
+                Iterator descIter = secRef.getDescriptions().iterator();
                 while (descIter.hasNext())
                 {
-                    MutableDescription description = (MutableDescription) descIter.next();
+                    Description description = (Description) descIter.next();
                     String descParam = actionRequest.getParameter(name + ":description:" + index);
                     //changing locale not allowed.
                     
@@ -916,8 +909,13 @@
                 for(int i=0; i<securityIds.length; i++)
                 {
                     String id = securityIds[i];
-                    SecurityRoleRef secRef = portlet.getInitSecurityRoleRefSet().get(id);
-                    portlet.getInitSecurityRoleRefSet().remove(secRef);
+                    for(SecurityRoleRef roleRef : portlet.getSecurityRoleRefs()){
+                        if(id.equals(roleRef.getRoleName()))
+                        {
+                            portlet.getSecurityRoleRefs().remove(roleRef);
+                        }
+                                
+                    }
                 }
                 /*
                 Iterator securityIter = portlet.getInitSecurityRoleRefSet()..iterator();
@@ -940,7 +938,7 @@
         registry.savePortletDefinition(portlet);
     }
     
-    private void processSecurityRef(ActionRequest actionRequest, ActionResponse actionResponse, MutablePortletApplication pa, PortletDefinitionComposite pdef, String action) throws PortletException
+    private void processSecurityRef(ActionRequest actionRequest, ActionResponse actionResponse, PortletApplication pa, PortletDefinition pdef, String action) throws PortletException
     {
         String ref = actionRequest.getParameter("security-constraint-ref");
         String currentRef = "";
@@ -976,7 +974,7 @@
             catch(RegistryException e)
             {
                 throw new PortletException("Failed to perform action " + action + " on " 
-                        + (pdef == null ? "portlet application " + pa.getName() : "portlet definition " + pdef.getName()) );
+                        + (pdef == null ? "portlet application " + pa.getName() : "portlet definition " + pdef.getPortletName()) );
             }            
         }
     }
@@ -990,7 +988,7 @@
      * @throws FailedToStorePortletDefinitionException
      */
     private void processContentType(ActionRequest actionRequest, ActionResponse actionResponse, 
-    		MutablePortletApplication pa, PortletDefinitionComposite portlet, String action) throws FailedToStorePortletDefinitionException
+    		PortletApplication pa, PortletDefinition portlet, String action) throws FailedToStorePortletDefinitionException
     {
         if(action.equals("add_content_type"))
         {
@@ -1011,13 +1009,13 @@
 
                 String customModes = actionRequest.getParameter("custom_modes");
                 StringTokenizer tok = new StringTokenizer(customModes, ",");
+                Supports portletSupport =  portlet.addSupports(contentType);
                 while (tok.hasMoreTokens())
                 {
                     //contentTypeImpl.addPortletMode(tok.nextToken());
-                    allModes.add(tok.nextToken());
+                    //allModes.add(tok.nextToken());
+                    portletSupport.addPortletMode(tok.nextToken());
                 }
-                
-                portlet.addContentType(contentType, allModes);
             }
         }
         else if(action.equals("remove_content_type"))
@@ -1025,14 +1023,14 @@
             String[] contentIds = actionRequest.getParameterValues("content_type_remove_id");
             if(contentIds != null)
             {
-                Iterator contentIter = portlet.getContentTypeSet().iterator();
+                Iterator contentIter = portlet.getSupports().iterator();
                 while (contentIter.hasNext())
                 {
-                    ContentType contentType = (ContentType) contentIter.next();
+                    Supports contentType = (Supports) contentIter.next();
                     for(int i=0; i<contentIds.length; i++)
                     {
                         String id = contentIds[i];
-                        if(contentType.getContentType().equals(id))
+                        if(contentType.getMimeType().equals(id))
                         {
                             contentIter.remove();
                             break;
@@ -1062,7 +1060,7 @@
         Iterator portletDefsIter = pa.getPortletDefinitions().iterator();
         while (portletDefsIter.hasNext())
         {
-            PortletDefinitionComposite pDef = (PortletDefinitionComposite) portletDefsIter.next();
+            PortletDefinition pDef = (PortletDefinitionComposite) portletDefsIter.next();
             buffer.append(createPortletDefinitionXml(pDef));
         }
         

Modified: portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java?rev=711217&r1=711216&r2=711217&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java (original)
+++ portals/jetspeed-2/applications/j2-admin/branches/JS2-871-refactoring/src/main/java/org/apache/jetspeed/portlets/selector/CategoryPortletSelector.java Tue Nov  4 01:36:43 2008
@@ -47,12 +47,13 @@
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.headerresource.HeaderResource;
-import org.apache.jetspeed.om.common.LocalizedField;
-import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
-import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
-import org.apache.jetspeed.om.common.preference.PreferenceComposite;
 import org.apache.jetspeed.om.page.Fragment;
 import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.portlet.InitParam;
+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.Preference;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.portlets.CategoryInfo;
 import org.apache.jetspeed.portlets.PortletInfo;
@@ -61,7 +62,6 @@
 import org.apache.jetspeed.search.ParsedObject;
 import org.apache.jetspeed.search.SearchEngine;
 import org.apache.jetspeed.security.SecurityAccessController;
-import org.apache.pluto.om.common.Parameter;
 import org.apache.portals.gems.dojo.AbstractDojoVelocityPortlet;
 import org.apache.velocity.context.Context;
 
@@ -237,7 +237,7 @@
                     Iterator portlets = searchEngine.search(searchString.toString()).getResults().iterator();
                     while (portlets.hasNext())
                     {
-                        PortletDefinitionComposite portlet = 
+                        PortletDefinition portlet = 
                             getPortletFromParsedObject((ParsedObject)portlets.next());
                         PortletInfo portletInfo = filterPortlet(portlet, locale, request);
                         if (portletInfo != null)
@@ -271,9 +271,9 @@
         
         while (portlets.hasNext())
         {
-            PortletDefinitionComposite portlet = null;
+            PortletDefinition portlet = null;
             if (filter == null)
-                portlet = (PortletDefinitionComposite)portlets.next();
+                portlet = (PortletDefinition)portlets.next();
             else
                 portlet = getPortletFromParsedObject((ParsedObject)portlets.next());
             
@@ -319,7 +319,7 @@
 		return list;
 	}
 
-    protected boolean filterByRole(PortletDefinitionComposite portlet, RenderRequest request)
+    protected boolean filterByRole(PortletDefinition portlet, RenderRequest request)
     {
         boolean doFilter = false;
         Collection c = portlet.getMetadata().getFields("selector.conditional.role");
@@ -350,7 +350,7 @@
      * @param portlet
      * @return null if filtered, otherwise PortletInfo to be added to list
      */
-    protected PortletInfo filterPortlet(PortletDefinitionComposite portlet, Locale locale, RenderRequest request)
+    protected PortletInfo filterPortlet(PortletDefinition portlet, Locale locale, RenderRequest request)
     {
         if (portlet == null)
             return null;
@@ -359,22 +359,22 @@
             return null; 
         }        
         // Do not display Jetspeed Layout Applications
-        MutablePortletApplication pa = (MutablePortletApplication)portlet.getPortletApplicationDefinition();
+        PortletApplication pa = (PortletApplication)portlet.getApplication();
         if (pa.isLayoutApplication())
             return null;
         
         // SECURITY filtering
-        String uniqueName = pa.getName() + "::" + portlet.getName();
+        String uniqueName = pa.getName() + "::" + portlet.getPortletName();
         if (securityAccessController.checkPortletAccess(portlet, JetspeedActions.MASK_VIEW))
         {
-            Parameter param = portlet.getInitParameterSet().get(PORTLET_ICON);
+            InitParam param = portlet.getInitParam(PORTLET_ICON);
             String image;
             if (param != null)
             {                
                 //String relativeImagePath = param.getValue();
                 //String context = muta.getWebApplicationDefinition().getContextRoot();
                 // Have to use a supported icon in jetspeed, otherwise image can be out of skew
-                String  imagePath = param.getValue();
+                String  imagePath = param.getParamValue();
                 if (imagePath == null)
                 {
                     image = DEFAULT_IMAGES[rand.nextInt(DEFAULT_IMAGES.length)];
@@ -382,9 +382,9 @@
                 else
                 {
                     if (-1 == imagePath.indexOf("/"))
-                        image = "images/portlets/" + param.getValue();
+                        image = "images/portlets/" + param.getParamValue();
                     else
-                        image = param.getValue();
+                        image = param.getParamValue();
                 }
             }
             else
@@ -403,7 +403,7 @@
         return str.replaceAll("\r|\n|\"|\'", "");
     }
     
-    protected PortletDefinitionComposite getPortletFromParsedObject(ParsedObject po)
+    protected PortletDefinition getPortletFromParsedObject(ParsedObject po)
     {
         boolean found = false;
         String name = "";
@@ -466,9 +466,9 @@
             String rows = request.getParameter("Rows");
             String cats = request.getParameter("jsCats");
             String page = request.getParameter(JSPAGE);
-            MutablePortletApplication pa = registry.getPortletApplication("j2-admin");
+            PortletApplication pa = registry.getPortletApplication("j2-admin");
             String portletName = this.getPortletName();
-            PortletDefinitionComposite portlet = (PortletDefinitionComposite) pa.getPortletDefinitionByName(portletName);
+            PortletDefinition portlet = (PortletDefinition) pa.getPortlet(portletName);
             boolean updated = updateNumericPref("Columns", columns, 10, portlet);
             updated = updated | updateNumericPref("Rows", rows, 100, portlet);
                         
@@ -578,12 +578,14 @@
         }
     }
 
-    private boolean addPref(String prefName, String keywords, PortletDefinitionComposite portlet)
+    private boolean addPref(String prefName, String keywords, PortletDefinition portlet)
     {
-        PreferenceComposite pref = (PreferenceComposite) portlet.getPreferenceSet().get(prefName);        
+        Preference pref = portlet.getPortletPreferences().getPortletPreference(prefName);        
         if (pref == null)
         {
-            portlet.addPreference(prefName, new String[] { keywords });
+            portlet.getPortletPreferences().addPreference(prefName);
+            pref = portlet.getPortletPreferences().getPortletPreference(prefName);
+            pref.addValue(keywords);
         }
         else
         {
@@ -592,36 +594,34 @@
         return true;
     }
     
-    private boolean modifyPref(String prefName, String keywords, PortletDefinitionComposite portlet)
+    private boolean modifyPref(String prefName, String keywords, PortletDefinition portlet)
     {
-        PreferenceComposite prefComp = (PreferenceComposite) portlet.getPreferenceSet().get(prefName);
-        List<String> values = prefComp.getValuesList();
+        Preference prefComp =  portlet.getPortletPreferences().getPortletPreference(prefName);
+        List<String> values = prefComp.getValues();
         if(!values.get(0).equals(keywords))
         {
             values.set(0, keywords);
-            prefComp.setValues(values);
             return true;
         }
         return false;
     }
     
-    private boolean removePref(String prefName, PortletDefinitionComposite portlet)
+    private boolean removePref(String prefName, PortletDefinition portlet)
     {
-        Iterator prefIter = portlet.getPreferenceSet().iterator();
-        while (prefIter.hasNext())
+        List<Preference> preferences = portlet.getPortletPreferences().getPortletPreferences();
+        
+        for(Preference pref : preferences)
         {
-            PreferenceComposite pref = (PreferenceComposite) prefIter.next();
-            String name = pref.getName();
-            if (name.equals(prefName))
+            if(pref.getName().equals(prefName))
             {
-                    prefIter.remove();
-                    return true;
+                preferences.remove(pref);
+                return true;
             }
         }
         return false;
     }
     
-    private boolean updateNumericPref(String prefName, String param, int max, PortletDefinitionComposite portlet)
+    private boolean updateNumericPref(String prefName, String param, int max, PortletDefinition portlet)
     {
         if (!isEmpty(param))
         {
@@ -636,12 +636,11 @@
             }
             if (val > max)
                 return false;
-            PreferenceComposite pref = (PreferenceComposite) portlet.getPreferenceSet().get(prefName);
-            List<String> values = pref.getValuesList();
+            Preference pref = (Preference) portlet.getPortletPreferences().getPortletPreference(prefName);
+            List<String> values = pref.getValues();
             if(!values.get(0).equals(param))
             {
                 values.set(0, param);
-                pref.setValues(values);
                 return true;
             }                           
         }



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


Mime
View raw message