portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r770762 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets: prm/ prm/application/ prm/model/ prm/portlet/ wicket/component/editor/
Date Fri, 01 May 2009 17:20:14 GMT
Author: woonsan
Date: Fri May  1 17:20:13 2009
New Revision: 770762

URL: http://svn.apache.org/viewvc?rev=770762&view=rev
Log:
JS2-946: Fixing a problem that user attribute localized descriptions are not added.

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/InitParamBean.java
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UserAttributeBean.java
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/InitParamBeanModel.java
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/UserAttributeBeanModel.java
  (with props)
Removed:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/DescriptionModel.java
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DescriptionBean.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/LocalizedFieldBean.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/application/UserAttributePanel.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/ParameterPanel.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.java

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.java?rev=770762&r1=770761&r2=770762&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.java
Fri May  1 17:20:13 2009
@@ -45,8 +45,6 @@
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.PropertyModel;
 import org.apache.wicket.model.ResourceModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * View Mode for Portlet Application List widget
@@ -58,8 +56,6 @@
 {
     private static final String APP_TABLE = "appTable";
     private static final String PORTLET_TABLE = "portletTable";
-    private final static Logger log = LoggerFactory
-            .getLogger(ApplicationsListHome.class);
 
     public static final String PORTLET_REGISTRY_MANAGER = "Portlet Registry Manager";
 

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DescriptionBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DescriptionBean.java?rev=770762&r1=770761&r2=770762&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DescriptionBean.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/DescriptionBean.java
Fri May  1 17:20:13 2009
@@ -16,12 +16,12 @@
  */
 package org.apache.jetspeed.portlets.prm;
 
-import java.io.Serializable;
 import java.util.Locale;
 
 import org.apache.jetspeed.om.portlet.Description;
+import org.apache.wicket.IClusterable;
 
-public class DescriptionBean implements Serializable
+public class DescriptionBean  implements IClusterable
 {
     private static final long serialVersionUID = 1L;
     

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/InitParamBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/InitParamBean.java?rev=770762&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/InitParamBean.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/InitParamBean.java
Fri May  1 17:20:13 2009
@@ -0,0 +1,67 @@
+/* 
+ * 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.portlets.prm;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.om.portlet.InitParam;
+import org.apache.wicket.IClusterable;
+
+public class InitParamBean implements IClusterable
+{
+    private static final long serialVersionUID = 1L;
+    
+    private transient InitParam initParam;
+    
+    public InitParamBean(InitParam initParam)
+    {
+        this.initParam = initParam;
+    }
+    
+    public String getParamName()
+    {
+        return initParam.getParamName();
+    }
+    
+    public String getParamValue()
+    {
+        return initParam.getParamValue();
+    }
+    
+    public void setParamValue(String paramValue)
+    {
+        initParam.setParamValue(paramValue);
+    }
+    
+    public Description getDescription(Locale locale)
+    {
+        return initParam.getDescription(locale);
+    }
+    
+    public List<Description> getDescriptions()
+    {
+        return initParam.getDescriptions();
+    }
+    
+    public Description addDescription(String lang)
+    {
+        return initParam.addDescription(lang);
+    }
+    
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/InitParamBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/InitParamBean.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/InitParamBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/LocalizedFieldBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/LocalizedFieldBean.java?rev=770762&r1=770761&r2=770762&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/LocalizedFieldBean.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/LocalizedFieldBean.java
Fri May  1 17:20:13 2009
@@ -20,10 +20,13 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.jetspeed.om.portlet.LocalizedField;
+import org.apache.wicket.IClusterable;
 
-public class LocalizedFieldBean
+public class LocalizedFieldBean implements IClusterable
 {
-    private LocalizedField field;
+    private static final long serialVersionUID = 1L;
+    
+    private transient LocalizedField field;
     
     public LocalizedFieldBean(LocalizedField field)
     {

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UserAttributeBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UserAttributeBean.java?rev=770762&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UserAttributeBean.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UserAttributeBean.java
Fri May  1 17:20:13 2009
@@ -0,0 +1,57 @@
+/* 
+ * 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.portlets.prm;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.om.portlet.UserAttribute;
+import org.apache.wicket.IClusterable;
+
+public class UserAttributeBean implements IClusterable
+{
+    private static final long serialVersionUID = 1L;
+    
+    private transient UserAttribute userAttribute;
+    
+    public UserAttributeBean(UserAttribute userAttribute)
+    {
+        this.userAttribute = userAttribute;
+    }
+    
+    public String getName()
+    {
+        return userAttribute.getName();
+    }
+    
+    public Description getDescription(Locale locale)
+    {
+        return userAttribute.getDescription(locale);
+    }
+    
+    public List<Description> getDescriptions()
+    {
+        return userAttribute.getDescriptions();
+    }
+    
+    public Description addDescription(String lang)
+    {
+        return userAttribute.addDescription(lang);
+    }
+    
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UserAttributeBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UserAttributeBean.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UserAttributeBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/application/UserAttributePanel.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/application/UserAttributePanel.java?rev=770762&r1=770761&r2=770762&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/application/UserAttributePanel.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/application/UserAttributePanel.java
Fri May  1 17:20:13 2009
@@ -29,6 +29,8 @@
 import org.apache.jetspeed.portlets.JetspeedServiceLocator;
 import org.apache.jetspeed.portlets.prm.DescriptionBean;
 import org.apache.jetspeed.portlets.prm.PortletApplicationNodeBean;
+import org.apache.jetspeed.portlets.prm.UserAttributeBean;
+import org.apache.jetspeed.portlets.prm.model.UserAttributeBeanModel;
 import org.apache.jetspeed.portlets.wicket.AbstractAdminWebApplication;
 import org.apache.jetspeed.portlets.wicket.component.editor.EditorTemplate;
 import org.apache.jetspeed.portlets.wicket.component.editor.LocalizedDescriptionEditor;
@@ -37,12 +39,10 @@
 import org.apache.wicket.markup.html.panel.Fragment;
 import org.apache.wicket.markup.repeater.data.IDataProvider;
 import org.apache.wicket.markup.repeater.data.ListDataProvider;
-import org.apache.wicket.markup.repeater.util.ModelIteratorAdapter;
 import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
 import org.apache.wicket.model.PropertyModel;
 
-public class UserAttributePanel extends EditorTemplate<UserAttribute>
+public class UserAttributePanel extends EditorTemplate<UserAttributeBean>
 {
     private static final long serialVersionUID = 1L;
     
@@ -70,11 +70,12 @@
     }
 
     @Override
-    public void buildItems(Fragment fragment, final UserAttribute userAttr)
+    public void buildItems(Fragment fragment, final UserAttributeBean userAttr)
     {
         JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
         
-        fragment.add(new TextField<String>("name", new PropertyModel<String>(userAttr,
"name")));
+        fragment.add(new TextField<String>("name", new PropertyModel<String>(new
UserAttributeBeanModel(locator, paNodeBean, userAttr), "name")));
+        
         fragment.add(new LocalizedDescriptionEditor("localizationEditor", locator, paNodeBean,
userAttr.getName())
         {
 
@@ -104,27 +105,39 @@
                     @Override
                     public void onSubmit()
                     {
-                        if (newLocale != null && newDescription != null)
+                        try
                         {
-                            Locale locale = new Locale(newLocale);
-                            Description description = userAttr.getDescription(locale);
+                            PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
+                            PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
                             
-                            if (description == null)
+                            if (newLocale != null && newDescription != null)
                             {
-                                description = userAttr.addDescription(newLocale);
+                                // We need to retrieve user attribute each time because portlet
application can be refreshed any time.
+                                UserAttribute attr = app.getUserAttribute(userAttr.getName());
+                                Locale locale = new Locale(newLocale);
+                                Description targetDescription = null;
+                                
+                                for (Description description : attr.getDescriptions())
+                                {
+                                    if (description.getLocale().equals(locale))
+                                    {
+                                        targetDescription = description;
+                                        break;
+                                    }
+                                }
+
+                                if (targetDescription == null)
+                                {
+                                    targetDescription = attr.addDescription(newLocale);
+                                }
+                                
+                                targetDescription.setDescription(newDescription);
+                                
+                                newLocale = null;
+                                newDescription = null;
                             }
-                            
-                            description.setDescription(newDescription);
-                            
-                            newLocale = null;
-                            newDescription = null;
-                        }
 
-                        try
-                        {
-                            JetspeedServiceLocator locator = ((AbstractAdminWebApplication)
getApplication()).getServiceLocator();
-                            PortletApplication app = locator.getPortletRegistry().getPortletApplication(paNodeBean.getApplicationName());
-                            locator.getPortletRegistry().updatePortletApplication(app);
+                            registry.updatePortletApplication(app);
                         }
                         catch (RegistryException e)
                         {
@@ -174,16 +187,16 @@
     }
 
     @Override
-    public void delete(IModel<UserAttribute>[] fields)
+    public void delete(IModel<UserAttributeBean>[] fields)
     {
-        JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
-        PortletApplication app = locator.getPortletRegistry().getPortletApplication(paNodeBean.getApplicationName());
+        PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
+        PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
 
         for (Iterator<UserAttribute> it = app.getUserAttributes().iterator(); it.hasNext();
)
         {
             String id = it.next().getName();
             
-            for (IModel<UserAttribute> field : fields)
+            for (IModel<UserAttributeBean> field : fields)
             {
                 if (field.getObject().getName().equals(id))
                 {
@@ -195,37 +208,35 @@
 
         try
         {
-            locator.getPortletRegistry().updatePortletApplication(app);
+            registry.updatePortletApplication(app);
         }
         catch (RegistryException e)
         {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
-
     }
 
     @Override
-    public Iterator<IModel<UserAttribute>> getItemModels()
+    public Iterator<IModel<UserAttributeBean>> getItemModels()
     {
         JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
         PortletApplication app = locator.getPortletRegistry().getPortletApplication(paNodeBean.getApplicationName());
+        List<IModel<UserAttributeBean>> userAttributeBeans = new ArrayList<IModel<UserAttributeBean>>();
         
-        return new ModelIteratorAdapter<UserAttribute>(app.getUserAttributes().iterator())
+        for (UserAttribute userAttribute : app.getUserAttributes())
         {
-            @Override
-            protected IModel<UserAttribute> model(UserAttribute object)
-            {
-                return new Model<UserAttribute>(object);
-            }
-
-        };
+            userAttributeBeans.add(new UserAttributeBeanModel(locator, paNodeBean, new UserAttributeBean(userAttribute)));
+        }
+        
+        return userAttributeBeans.iterator();
     }
 
     @Override
-    public IModel<UserAttribute> getNewRowModel(UserAttribute object)
+    public IModel<UserAttributeBean> getNewRowModel(UserAttributeBean userAttribute)
     {
-        return new Model<UserAttribute>(object);
+        JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
+        return new UserAttributeBeanModel(locator, paNodeBean, userAttribute);
     }
 
     @Override

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/InitParamBeanModel.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/InitParamBeanModel.java?rev=770762&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/InitParamBeanModel.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/InitParamBeanModel.java
Fri May  1 17:20:13 2009
@@ -0,0 +1,52 @@
+/*
+ * 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.portlets.prm.model;
+
+import org.apache.jetspeed.om.portlet.InitParam;
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.portlets.JetspeedServiceLocator;
+import org.apache.jetspeed.portlets.prm.InitParamBean;
+import org.apache.jetspeed.portlets.prm.PortletApplicationNodeBean;
+import org.apache.wicket.model.LoadableDetachableModel;
+
+public class InitParamBeanModel extends LoadableDetachableModel<InitParamBean>
+{
+    private static final long serialVersionUID = 1L;
+    
+    private JetspeedServiceLocator locator;
+    private PortletApplicationNodeBean paNodeBean;
+    private String paramName;
+
+    public InitParamBeanModel(JetspeedServiceLocator locator, PortletApplicationNodeBean
paNodeBean, InitParamBean initParamBean)
+    {
+        super(initParamBean);
+        this.locator = locator;
+        this.paNodeBean = paNodeBean;
+        this.paramName = initParamBean.getParamName();
+    }
+    
+    @Override
+    protected InitParamBean load()
+    {
+        PortletApplication app = locator.getPortletRegistry().getPortletApplication(paNodeBean.getApplicationName());
+        PortletDefinition def = app.getPortlet(paNodeBean.getName());
+        InitParam initParam = def.getInitParam(paramName);
+        return new InitParamBean(initParam);
+    }
+    
+}
\ No newline at end of file

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/InitParamBeanModel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/InitParamBeanModel.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/InitParamBeanModel.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/UserAttributeBeanModel.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/UserAttributeBeanModel.java?rev=770762&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/UserAttributeBeanModel.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/UserAttributeBeanModel.java
Fri May  1 17:20:13 2009
@@ -0,0 +1,50 @@
+/*
+ * 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.portlets.prm.model;
+
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.UserAttribute;
+import org.apache.jetspeed.portlets.JetspeedServiceLocator;
+import org.apache.jetspeed.portlets.prm.PortletApplicationNodeBean;
+import org.apache.jetspeed.portlets.prm.UserAttributeBean;
+import org.apache.wicket.model.LoadableDetachableModel;
+
+public class UserAttributeBeanModel extends LoadableDetachableModel<UserAttributeBean>
+{
+    private static final long serialVersionUID = 1L;
+    
+    private JetspeedServiceLocator locator;
+    private PortletApplicationNodeBean paNodeBean;
+    private String name;
+
+    public UserAttributeBeanModel(JetspeedServiceLocator locator, PortletApplicationNodeBean
paNodeBean, UserAttributeBean userAttributeBean)
+    {
+        super(userAttributeBean);
+        this.locator = locator;
+        this.paNodeBean = paNodeBean;
+        this.name = userAttributeBean.getName();
+    }
+    
+    @Override
+    protected UserAttributeBean load()
+    {
+        PortletApplication app = locator.getPortletRegistry().getPortletApplication(paNodeBean.getApplicationName());
+        UserAttribute userAttribute = app.getUserAttribute(name);
+        return new UserAttributeBean(userAttribute);
+    }
+    
+}
\ No newline at end of file

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/UserAttributeBeanModel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/UserAttributeBeanModel.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/model/UserAttributeBeanModel.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/ParameterPanel.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/ParameterPanel.java?rev=770762&r1=770761&r2=770762&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/ParameterPanel.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/portlet/ParameterPanel.java
Fri May  1 17:20:13 2009
@@ -30,7 +30,9 @@
 import org.apache.jetspeed.om.portlet.PortletDefinition;
 import org.apache.jetspeed.portlets.JetspeedServiceLocator;
 import org.apache.jetspeed.portlets.prm.DescriptionBean;
+import org.apache.jetspeed.portlets.prm.InitParamBean;
 import org.apache.jetspeed.portlets.prm.PortletApplicationNodeBean;
+import org.apache.jetspeed.portlets.prm.model.InitParamBeanModel;
 import org.apache.jetspeed.portlets.wicket.AbstractAdminWebApplication;
 import org.apache.jetspeed.portlets.wicket.component.editor.EditorTemplate;
 import org.apache.jetspeed.portlets.wicket.component.editor.LocalizedDescriptionEditor;
@@ -39,12 +41,10 @@
 import org.apache.wicket.markup.html.panel.Fragment;
 import org.apache.wicket.markup.repeater.data.IDataProvider;
 import org.apache.wicket.markup.repeater.data.ListDataProvider;
-import org.apache.wicket.markup.repeater.util.ModelIteratorAdapter;
 import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
 import org.apache.wicket.model.PropertyModel;
 
-public class ParameterPanel extends EditorTemplate<InitParam>
+public class ParameterPanel extends EditorTemplate<InitParamBean>
 {
     private static final long serialVersionUID = 1L;
     
@@ -76,14 +76,14 @@
     }
 
     @Override
-    public void buildItems(Fragment fragment, final InitParam model)
+    public void buildItems(Fragment fragment, final InitParamBean initParam)
     {
-        fragment.add(new TextField<String>("name", new PropertyModel<String>(model,
"name")));
-        fragment.add(new TextField<String>("value", new PropertyModel<String>(model,
"value")));
-
         JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
-        
-        fragment.add(new LocalizedDescriptionEditor("localizationEditor", locator, paNodeBean,
model.getParamName())
+
+        fragment.add(new TextField<String>("name", new PropertyModel<String>(new
InitParamBeanModel(locator, paNodeBean, initParam), "paramName")));
+        fragment.add(new TextField<String>("value", new PropertyModel<String>(new
InitParamBeanModel(locator, paNodeBean, initParam), "paramValue")));
+
+        fragment.add(new LocalizedDescriptionEditor("localizationEditor", locator, paNodeBean,
initParam.getParamName())
         {
 
             @Override
@@ -93,7 +93,7 @@
                 PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
                 PortletDefinition def = app.getPortlet(paNodeBean.getName());
 
-                final InitParam param = def.getInitParam(model.getParamName());
+                final InitParam param = def.getInitParam(initParam.getParamName());
 
                 List<DescriptionBean> list = new ArrayList<DescriptionBean>();
 
@@ -187,7 +187,7 @@
     }
 
     @Override
-    public void delete(IModel<InitParam>[] fields)
+    public void delete(IModel<InitParamBean>[] fields)
     {
         PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
         PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
@@ -197,11 +197,11 @@
         while (it.hasNext())
         {
             InitParam initParam = it.next();
-            String id = initParam.getParamName();
+            String paramName = initParam.getParamName();
             
-            for (IModel<InitParam> field : fields)
+            for (IModel<InitParamBean> field : fields)
             {
-                if (field.getObject().getParamName().equals(id))
+                if (field.getObject().getParamName().equals(paramName))
                 {
                     it.remove();
                     break;
@@ -222,28 +222,28 @@
     }
 
     @Override
-    public Iterator<IModel<InitParam>> getItemModels()
+    public Iterator<IModel<InitParamBean>> getItemModels()
     {
-        PortletRegistry registry = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPortletRegistry();
+        JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
+        PortletRegistry registry = locator.getPortletRegistry();
         PortletApplication app = registry.getPortletApplication(paNodeBean.getApplicationName());
         PortletDefinition def = app.getPortlet(paNodeBean.getName());
         
-        return new ModelIteratorAdapter<InitParam>(def.getInitParams().iterator())
+        List<IModel<InitParamBean>> initParamBeanModels = new ArrayList<IModel<InitParamBean>>();
+        
+        for (InitParam initParam : def.getInitParams())
         {
-
-            @Override
-            protected IModel<InitParam> model(InitParam object)
-            {
-                return new Model<InitParam>(object);
-            }
-
-        };
+            initParamBeanModels.add(new InitParamBeanModel(locator, paNodeBean, new InitParamBean(initParam)));
+        }
+        
+        return initParamBeanModels.iterator();
     }
 
     @Override
-    public IModel<InitParam> getNewRowModel(InitParam object)
+    public IModel<InitParamBean> getNewRowModel(InitParamBean initParamBean)
     {
-        return new Model<InitParam>(object);
+        JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
+        return new InitParamBeanModel(locator, paNodeBean, initParamBean);
     }
 
     @Override

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.java?rev=770762&r1=770761&r2=770762&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/EditorTemplate.java
Fri May  1 17:20:13 2009
@@ -43,6 +43,8 @@
  */
 public abstract class EditorTemplate<T> extends Panel
 {
+    private static final long serialVersionUID = 1L;
+
     private List<SelectableModel<T>> rows;
     
     public static final String ITEMS_FRAGMENT_ID = "itemFragment";
@@ -50,16 +52,14 @@
     
     public EditorTemplate(String id)
     {
-        this(id, null);
-    }
-    
-    public EditorTemplate(String id, IModel<?> model)
-    {
-        super(id, model);
+        super(id);
         
         rows = new ArrayList<SelectableModel<T>>();
         
-        RefreshingView<T> data = new RefreshingView<T>("data") {
+        RefreshingView<T> data = new RefreshingView<T>("data") 
+        {
+            private static final long serialVersionUID = 1L;
+            
             @Override
             protected Iterator<IModel<T>> getItemModels()
             {

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.java?rev=770762&r1=770761&r2=770762&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/component/editor/LocalizedDescriptionEditor.java
Fri May  1 17:20:13 2009
@@ -24,6 +24,7 @@
 import org.apache.jetspeed.portlets.prm.DescriptionBean;
 import org.apache.jetspeed.portlets.prm.PortletApplicationNodeBean;
 import org.apache.jetspeed.portlets.prm.model.DescriptionBeanModel;
+import org.apache.jetspeed.portlets.wicket.AbstractAdminWebApplication;
 import org.apache.wicket.markup.html.form.TextField;
 import org.apache.wicket.markup.html.panel.Fragment;
 import org.apache.wicket.markup.repeater.data.IDataProvider;
@@ -61,8 +62,9 @@
     @Override
     public void buildItems(Fragment fragment, final DescriptionBean descriptionBean)
     {
-        fragment.add(new TextField<String>("locale", new PropertyModel(descriptionBean,
"localeString"))); 
-        fragment.add(new TextField<String>("description", new PropertyModel(descriptionBean,
"description")));
+        JetspeedServiceLocator locator = ((AbstractAdminWebApplication) getApplication()).getServiceLocator();
+        fragment.add(new TextField<String>("locale", new PropertyModel(new DescriptionBeanModel(locator,
paNodeBean, name, descriptionBean), "localeString"))); 
+        fragment.add(new TextField<String>("description", new PropertyModel(new DescriptionBeanModel(locator,
paNodeBean, name, descriptionBean), "description")));
     }
     
     @Override



---------------------------------------------------------------------
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