portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r760209 [2/3] - in /portals/jetspeed-2/applications/j2-admin/trunk: ./ src/main/java/org/apache/jetspeed/portlets/ src/main/java/org/apache/jetspeed/portlets/entityeditor/ src/main/java/org/apache/jetspeed/portlets/palm/ src/main/java/org/a...
Date Mon, 30 Mar 2009 22:40:25 GMT
Added: 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=760209&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.java (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.java Mon Mar 30 22:40:23 2009
@@ -0,0 +1,450 @@
+/*
+ * 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.io.NotSerializableException;
+
+import org.apache.jetspeed.audit.AuditActivity;
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.portlets.AdminPortletWebPage;
+import org.apache.jetspeed.portlets.prm.ApplicationDataProvider.AppOrderBy;
+import org.apache.jetspeed.portlets.prm.PortletDataProvider.PortletOrderBy;
+import org.apache.jetspeed.portlets.prm.PortletsListHome.ActionPanel;
+import org.apache.jetspeed.tools.pamanager.PortletApplicationManagement;
+import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager;
+import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManagerResult;
+import org.apache.portals.messaging.PortletMessaging;
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.ResourceReference;
+import org.apache.wicket.extensions.markup.html.repeater.data.sort.OrderByBorder;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Button;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.image.Image;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.markup.repeater.data.DataView;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+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
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public class ApplicationsListHome extends AdminPortletWebPage
+{
+    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";
+    
+    @SuppressWarnings({ "unchecked", "serial"})
+    public ApplicationsListHome()
+    {
+        SearchForm form = new SearchForm("appSearchForm");
+        add(form);
+        
+        // Construct Data View
+        final ApplicationDataProvider dp = new ApplicationDataProvider(this.getServiceLocator());
+        final DataView dataView = new DataView(APP_TABLE, dp)
+        {
+            protected void populateItem(final Item item)
+            {
+                ApplicationBean pa = (ApplicationBean) item.getModelObject();
+                Link nameLink = new Link("nameLink")
+                {
+                    public void onClick()
+                    {
+                        ApplicationsListHome home = (ApplicationsListHome)this.getPage();                        
+                        String appName = this.get("nameLabel").getDefaultModelObjectAsString();                        
+                        System.out.println("clicking on " + appName);
+                        try
+                        {
+                            PortletMessaging.publish(home.getPortletRequest(), 
+                                    ApplicationsListApplication.PRM_TOPIC, ApplicationsListApplication.SELECTED_APP_EVENT, appName);
+                            final PortletDataProvider dp = new PortletDataProvider(appName, getPortletRequest().getLocale(), getServiceLocator());                            
+                            dp.retrievePortlets();
+                            
+                        }
+                        catch (NotSerializableException e)
+                        {
+                            log.error("failed to publish message: " + appName);
+                        }
+                    }
+                };                
+                nameLink.add(new Label("nameLabel", pa.getName()));
+                item.add(nameLink);
+                item.add(new Label("version", pa.getVersion()));
+                item.add(new Label("path", pa.getPath()));
+                item.add(new RunningPanel("running", item.getModel()));
+                item.add(new ActionPanel("actions", item.getModel()));
+//                item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel()
+//                {
+//                    public Object getObject()
+//                    {
+//                        return (item.getIndex() % 2 == 1) ? "portlet-section-alternate" : "class='portlet-section-body'";
+//                    }
+//                }));
+            }
+        };
+        dataView.setItemsPerPage(this.getPreferenceAsInteger("rows"));
+        add(new OrderByBorder("appOrderByName", "name", dp)
+        {
+            protected void onSortChanged()
+            {
+                if (dp.getOrderBy() == AppOrderBy.NAME_ASC)
+                    dp.setOrderBy(AppOrderBy.NAME_DESC);                    
+                else
+                    dp.setOrderBy(AppOrderBy.NAME_ASC);
+                dataView.setCurrentPage(0);
+            }
+        });
+        add(new OrderByBorder("appOrderByVersion", "version", dp)
+        {
+            protected void onSortChanged()
+            {
+                if (dp.getOrderBy() == AppOrderBy.VERSION_ASC)
+                    dp.setOrderBy(AppOrderBy.VERSION_DESC);
+                else
+                    dp.setOrderBy(AppOrderBy.VERSION_ASC);
+                dataView.setCurrentPage(0);
+            }            
+        });
+        add(new OrderByBorder("appOrderByPath", "path", dp)
+        {
+            protected void onSortChanged()
+            {
+                if (dp.getOrderBy() == AppOrderBy.PATH_ASC)
+                    dp.setOrderBy(AppOrderBy.PATH_DESC);
+                else
+                    dp.setOrderBy(AppOrderBy.PATH_ASC);
+                dataView.setCurrentPage(0);
+            }
+        });
+        
+        add(dataView);
+        add(new PagingNavigator("appNavigator", dataView));
+        FeedbackPanel feedback = new FeedbackPanel("feedback");
+        feedback.setEscapeModelStrings(false);       
+        add(feedback);
+        dp.retrieveApplications();
+        retrievePortletList();
+    }
+
+    @SuppressWarnings("serial")
+    class RunningPanel extends Panel
+    {
+        public RunningPanel(String id, final IModel<ApplicationBean> model)
+        {
+            super(id, model);
+            ApplicationBean pa = (ApplicationBean)model.getObject();
+            if (pa.isRunning())
+            {
+                add(new Image("running", new ResourceReference(ApplicationsListHome.class, "running.gif")) {});
+            }
+            else
+            {
+                add(new Image("running", new ResourceReference(ApplicationsListHome.class, "stop.gif")) {});                
+            }
+        }        
+    }
+    
+    @SuppressWarnings("serial")
+    class ActionPanel extends Panel
+    {
+        /**
+         * @param id
+         *            component id
+         * @param model
+         *            model for contact
+         */
+        @SuppressWarnings("unchecked")
+        public ActionPanel(String id, final IModel model)
+        {
+            super(id, model);
+            ApplicationsListHome home = ApplicationsListHome.this;     
+            ApplicationBean pab = (ApplicationBean)model.getObject();
+            PortletApplication pa = home.getServiceLocator().getPortletRegistry().getPortletApplication(pab.getName());
+            ApplicationServerManager asm = home.getServiceLocator().getApplicationServerManager();
+            boolean isLocal = pa.getApplicationType() == PortletApplication.LOCAL;
+            boolean isAdmin = (pa.getContextPath().equals(home.getPortletRequest().getContextPath()));
+            Link start = new Link("start")
+            {
+                public void onClick()
+                {
+                    ApplicationsListHome home = (ApplicationsListHome)this.getPage();     
+                    ApplicationBean pab = (ApplicationBean)model.getObject();
+                    PortletApplication pa = home.getServiceLocator().getPortletRegistry().getPortletApplication(pab.getName());
+                    ApplicationServerManager asm = home.getServiceLocator().getApplicationServerManager();                    
+                    FeedbackPanel feed = (FeedbackPanel)home.get("feedback");
+                    if (isServerReady(asm, feed, "start", pa, pab))
+                    {
+                        try
+                        {
+                            ApplicationServerManagerResult result = asm.start(pa.getContextPath());
+                            if (!result.isOk())
+                            {
+                                throw new Exception(getString("appServerNotConfigured"));
+                            }
+                            else
+                            {
+                                feed.info(messageSubstition("startOK", new String[] {"path"}, new Object[] {pab.getPath()}));
+                                home.getServiceLocator().getAuditActivity().logAdminRegistryActivity(
+                                        getAuthenticatedUsername(), getIPAddress(), AuditActivity.REGISTRY_START, PORTLET_REGISTRY_MANAGER);
+                            }
+                        }
+                        catch (Exception e)
+                        {                            
+                            feed.error(messageSubstition("startFailure", new String[] {"path", "msg"}, new Object[] {pab.getPath(), e.getMessage()}));
+                        }
+                    }                    
+                }
+            };
+            start.setVisible((asm != null && !pab.isRunning()) && !(isLocal || isAdmin));      
+            Link stop = new Link("stop")
+            {
+                public void onClick()
+                {                
+                    ApplicationsListHome home = (ApplicationsListHome)this.getPage();     
+                    ApplicationBean pab = (ApplicationBean)model.getObject();
+                    PortletApplication pa = home.getServiceLocator().getPortletRegistry().getPortletApplication(pab.getName());
+                    ApplicationServerManager asm = home.getServiceLocator().getApplicationServerManager();                    
+                    FeedbackPanel feed = (FeedbackPanel)home.get("feedback");
+                    if (isServerReady(asm, feed, "stop", pa, pab))
+                    {
+                        try
+                        {
+                            ApplicationServerManagerResult result = asm.stop(pa.getContextPath());
+                            if (!result.isOk())
+                            {
+                                throw new Exception(getString("appServerNotConfigured"));
+                            }
+                            else
+                            {
+                                feed.info(messageSubstition("stopOK", new String[] {"path"}, new Object[] {pab.getPath()}));
+                                home.getServiceLocator().getAuditActivity().logAdminRegistryActivity(
+                                        getAuthenticatedUsername(), getIPAddress(), AuditActivity.REGISTRY_STOP, PORTLET_REGISTRY_MANAGER);
+                            }
+                        }
+                        catch (Exception e)
+                        {
+                            feed.error(messageSubstition("stopFailure", new String[] {"path", "msg"}, new Object[] {pab.getPath(), e.getMessage()}));
+                        }
+                    }                    
+                }
+            };
+            stop.setVisible((asm != null && pab.isRunning()) && !(isLocal || isAdmin));  
+            Link undeploy = new Link("undeploy")
+            {
+                public void onClick()
+                {
+                    ApplicationsListHome home = (ApplicationsListHome)this.getPage();     
+                    ApplicationBean pab = (ApplicationBean)model.getObject();
+                    PortletApplication pa = home.getServiceLocator().getPortletRegistry().getPortletApplication(pab.getName());
+                    ApplicationServerManager asm = home.getServiceLocator().getApplicationServerManager();                    
+                    FeedbackPanel feed = (FeedbackPanel)home.get("feedback");
+                    if (isServerReady(asm, feed, "undeploy", pa, pab))
+                    {
+                        try
+                        {
+                            ApplicationServerManagerResult result = asm.undeploy(pa.getContextPath());
+                            if (!result.isOk())
+                            {
+                                throw new Exception(getString("appServerNotConfigured"));
+                            }
+                            else
+                            {
+                                feed.info(messageSubstition("undeployOK", new String[] {"path"}, new Object[] {pab.getPath()}));
+                                home.getServiceLocator().getAuditActivity().logAdminRegistryActivity(
+                                        getAuthenticatedUsername(), getIPAddress(), AuditActivity.REGISTRY_UNDEPLOY, PORTLET_REGISTRY_MANAGER);                                
+                            }
+                        }
+                        catch (Exception e)
+                        {
+                            feed.error(messageSubstition("undeployFailure", new String[] {"path", "msg"}, new Object[] {pab.getPath(), e.getMessage()}));
+                        }
+                    }                                        
+                }
+            };
+            undeploy.setVisible((asm != null && !pab.isRunning()) && !(isLocal || isAdmin));  
+            Link del = new Link("delete")
+            {
+                public void onClick()
+                {      
+                    ApplicationsListHome home = (ApplicationsListHome)this.getPage();     
+                    ApplicationBean pab = (ApplicationBean)model.getObject();
+                    PortletApplication pa = home.getServiceLocator().getPortletRegistry().getPortletApplication(pab.getName());
+                    ApplicationServerManager asm = home.getServiceLocator().getApplicationServerManager();                    
+                    PortletApplicationManagement pam = home.getServiceLocator().getPortletApplicationManager();
+                    FeedbackPanel feed = (FeedbackPanel)home.get("feedback");
+                    if (isServerReady(asm, feed, "remove from registry", pa, pab))
+                    {
+                        try
+                        {
+                            pam.unregisterPortletApplication(pa.getName());
+                            feed.info(messageSubstition("deleteOK", new String[] {"path"}, new Object[] {pab.getPath()}));
+                            home.getServiceLocator().getAuditActivity().logAdminRegistryActivity(
+                                    getAuthenticatedUsername(), getIPAddress(), AuditActivity.REGISTRY_DELETE, PORTLET_REGISTRY_MANAGER);                            
+                        }
+                        catch (Exception e)
+                        {
+                            feed.error(messageSubstition("deleteFailure", new String[] {"path", "msg"}, new Object[] {pab.getPath(), e.getMessage()}));                            
+                        }
+                    }                                        
+                }
+            };
+            del.setVisible(!(isLocal || isAdmin) && !pab.isRunning());
+            add(start);
+            add(stop);
+            add(undeploy);
+            add(del);
+        }
+    }
+    
+    protected boolean isServerReady(ApplicationServerManager asm, FeedbackPanel feedback, String operation, 
+            PortletApplication pa, ApplicationBean pab)
+    {
+        if (pa == null)
+        {
+            feedback.error(messageSubstition("serverReadyFailure", new String[] {"path", "operation"}, new Object[] {pab.getPath(), operation}));                            
+            return false;
+        }
+        else if (asm == null || !asm.isConnected())
+        {
+            feedback.error(messageSubstition("serverNotAvailable", new String[] {"path", "operation"}, new Object[] {pab.getPath(), operation}));                            
+            return false;
+        }
+        return true;
+    }
+        
+    @SuppressWarnings({ "unchecked", "serial"})
+    private class SearchForm extends Form<Void>
+    {
+        private String appSearchField;
+
+        public SearchForm(String name)
+        {
+            super(name);
+            add(new TextField("appSearchField", new PropertyModel(this, "appSearchField")));
+            add(new Button("appSearchButton", new ResourceModel("search"))
+            {
+                @Override
+                public void onSubmit()
+                {
+                    DataView view = (DataView)this.getParent().getParent().get(APP_TABLE);
+                    ApplicationDataProvider dp = (ApplicationDataProvider)view.getDataProvider();
+                    dp.searchApplications(getAppSearchField());
+                }
+            });
+            add(new Link("appDeploy")
+            {
+                @Override
+                public void onClick()
+                {
+                    ApplicationsListHome home = (ApplicationsListHome)this.getPage();                                        
+                    UploadPortletApp upa = new UploadPortletApp(home.getServiceLocator().getDeploymentManager());
+                    this.setResponsePage(upa);
+                }
+            });
+            add(new Link("appHome")
+            {
+                @Override
+                public void onClick()
+                {
+                    DataView view = (DataView)this.getParent().getParent().get(APP_TABLE);
+                    ApplicationDataProvider dp = (ApplicationDataProvider)view.getDataProvider();
+                    dp.setSearchMode(false);
+                    dp.retrieveApplications();
+                }
+            });                    
+        }
+        
+        public String getAppSearchField()
+        {
+            return appSearchField;
+        }
+
+        
+        public void setAppSearchField(String appSearchField)
+        {
+            this.appSearchField = appSearchField;
+        }
+        
+    }
+    
+    @SuppressWarnings({ "unchecked", "serial"})
+    protected void retrievePortletList()
+    {
+        String appName= (String) 
+            PortletMessaging.receive(getPortletRequest(), ApplicationsListApplication.PRM_TOPIC, ApplicationsListApplication.SELECTED_APP_EVENT);        
+        final PortletDataProvider dp = new PortletDataProvider(appName, getPortletRequest().getLocale(), getServiceLocator());
+        final DataView dataView = new DataView(PORTLET_TABLE, dp)
+        {
+            protected void populateItem(final Item item)
+            {
+                PortletDefinitionBean pa = (PortletDefinitionBean) item.getModelObject();
+                item.add(new Label("name", pa.getName()));
+                item.add(new Label("displayName", pa.getDisplayName()));
+//                item.add(new ActionPanel("actions", item.getModel()));
+//                item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel()
+//                {
+//                    public Object getObject()
+//                    {
+//                        return (item.getIndex() % 2 == 1) ? "background-color: #fff;" : "background-color: #ffebcd;";
+//                    }
+//                }));
+            }
+        };
+        dataView.setItemsPerPage(10);
+        add(new OrderByBorder("plOrderByName", "name", dp)
+        {
+            protected void onSortChanged()
+            {
+                if (dp.getOrderBy() == PortletOrderBy.NAME_ASC)
+                    dp.setOrderBy(PortletOrderBy.NAME_DESC);
+                else
+                    dp.setOrderBy(PortletOrderBy.NAME_ASC);                
+                dataView.setCurrentPage(0);
+            }
+        });
+        add(new OrderByBorder("plOrderByDisplayName", "displayName", dp)
+        {
+            protected void onSortChanged()
+            {
+                if (dp.getOrderBy() == PortletOrderBy.DISPLAY_NAME_ASC)
+                    dp.setOrderBy(PortletOrderBy.DISPLAY_NAME_DESC);
+                else
+                    dp.setOrderBy(PortletOrderBy.DISPLAY_NAME_ASC);                
+                dataView.setCurrentPage(0);
+            }
+        });
+        
+        add(dataView);
+        add(new PagingNavigator("plNavigator", dataView));
+        dp.retrievePortlets();
+    }
+}

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

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

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.properties?rev=760209&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.properties (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.properties Mon Mar 30 22:40:23 2009
@@ -0,0 +1,23 @@
+deploy=Deploy...
+refresh=Refresh
+search=Search
+name=Name
+version=Version
+path=Path
+status=Status
+actions=Actions
+start=Start
+stop=Stop
+undeploy=Undeploy
+delete=Delete
+startOK=Started portlet application successful: ${path}
+stopOK=Stopped portlet application successful: ${path}
+startFailure=Failed to start application : ${path} , message: ${msg} 
+stopFailure=Failed to stop application : ${path} , message: ${msg}
+appServerNotConfigured=The App Server does not seem to be configured for remote application lifecycle management
+undeployOK=Undeployed portlet application successful: ${path}
+undeployFailure=Failed to undeploy application : ${path} , message: ${msg}
+deleteFailure=Cannot delete application ${path} from the registry, error: ${msg}
+deleteOK=Portlet application removal from registry was successful: ${path}
+serverReadyFailure=Failed to ${operation} application: ${path}. Portlet Application was not found in registry
+serverNotAvailable=Failed to ${operation} application: ${path}. Connection to Application Server is not available. 

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

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

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletDataProvider.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletDataProvider.java?rev=760209&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletDataProvider.java (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletDataProvider.java Mon Mar 30 22:40:23 2009
@@ -0,0 +1,239 @@
+package org.apache.jetspeed.portlets.prm;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.portlets.JetspeedServiceLocator;
+import org.apache.jetspeed.search.ParsedObject;
+import org.apache.jetspeed.search.SearchResults;
+import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
+import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
+import org.apache.wicket.markup.repeater.data.IDataProvider;
+import org.apache.wicket.model.IModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Provides Data to sortable and detachable list views for Portlet lists
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public class PortletDataProvider extends SortableDataProvider<PortletDefinitionBean> implements IDataProvider<PortletDefinitionBean>
+{
+    public enum PortletOrderBy { NAME_ASC, NAME_DESC, DISPLAY_NAME_ASC, DISPLAY_NAME_DESC }
+    private JetspeedServiceLocator serviceLocator;    
+    private boolean searchMode = false;
+    private String appName;
+    private List<PortletDefinitionBean> portlets = null;
+    private List<PortletDefinitionBean> searchResults = null;
+    private Locale locale;
+    private static final long serialVersionUID = 1L;
+    private final static Logger log = LoggerFactory.getLogger(PortletDataProvider.class);
+    private PortletOrderBy orderBy = PortletOrderBy.NAME_ASC;
+    
+    public PortletDataProvider(String appName, Locale locale, JetspeedServiceLocator locator)
+    {
+        this.serviceLocator = locator;
+        this.locale = locale;
+        this.appName = appName;
+        setSort("name", true);
+    }
+    
+    public Iterator<PortletDefinitionBean> iterator(int first, int count)
+    {
+        System.out.println("retrieving portlets " + count);
+        retrievePortlets(); 
+        int last = first + count;
+        if (last > portlets.size())
+            last = portlets.size() - 1;
+        if (last < 0)
+            last = 0;
+        return portlets.subList(first, last).iterator();
+    }
+
+    public int size()
+    {
+        if (searchMode)
+        {
+            if (searchResults == null)
+                return 0;
+            return searchResults.size();
+        }
+        else
+        {
+            if (portlets == null)
+                return 0;
+            return portlets.size();
+        }
+    }
+    
+    /**
+     * @see org.apache.wicket.model.IDetachable#detach()
+     */
+    public void detach()
+    {
+        super.detach();        
+    }
+
+    public void retrievePortlets()
+    {
+        if (searchMode)
+        {
+            if (searchResults != null)
+            {
+                portlets = searchResults;
+                return;
+            }
+            searchMode = false;
+        }
+        else
+        {
+            System.out.println("retrieving portlets " + appName);
+            if (appName == null)
+                appName = "j2-admin";
+            portlets = new ArrayList<PortletDefinitionBean>();
+            PortletApplication app = serviceLocator.getPortletRegistry().getPortletApplication(appName);
+            if (app != null)
+            {
+                for (PortletDefinition def : app.getPortlets())
+                {
+                    portlets.add(new PortletDefinitionBean(def, locale));
+                }
+            }
+            sort(portlets, this.orderBy);            
+        }
+    }
+
+    public void setSearchMode(boolean mode)
+    {
+        this.searchMode = mode;
+    }
+    
+    public boolean getSearchMode()
+    {
+        return this.searchMode;
+    }
+    
+    public IModel<PortletDefinitionBean> model(PortletDefinitionBean object)
+    {
+        return new PortletDefinitionModel((PortletDefinitionBean)object);
+    }
+
+    public void sort(List<PortletDefinitionBean> list, PortletOrderBy orderBy)
+    {
+        Collections.sort(list, new PortletComparator(orderBy));
+    }
+    
+    public class PortletComparator implements Comparator<PortletDefinitionBean>
+    {
+        PortletOrderBy orderBy;
+        
+        public PortletComparator(PortletOrderBy order)
+        {
+            this.orderBy = order;
+        }
+        
+        public int compare(PortletDefinitionBean portlet1, PortletDefinitionBean portlet2)
+        {
+            String p1 = "";
+            String p2 = "";
+            if (orderBy == PortletOrderBy.NAME_ASC)
+            {
+                p1 = portlet1.getName();
+                p2 = portlet2.getName();
+            }
+            else if (orderBy == PortletOrderBy.NAME_DESC)
+            {
+                p2 = portlet1.getName();
+                p1 = portlet2.getName();
+            }
+            else if (orderBy == PortletOrderBy.DISPLAY_NAME_ASC)
+            {
+                p1 = portlet1.getDisplayName();
+                p2 = portlet2.getDisplayName();
+            }
+            else if (orderBy == PortletOrderBy.DISPLAY_NAME_DESC)
+            {
+                p2 = portlet1.getDisplayName();
+                p1 = portlet2.getDisplayName();
+            }
+            p1 = (p1 == null) ? "" : p1;
+            p2 = (p2 == null) ? "" : p2;
+            return p1.compareToIgnoreCase(p2);            
+        }
+    }
+    
+    @SuppressWarnings("unchecked")    
+    public void searchPortlets(String search)
+    {
+        try
+        {
+            if (search == null)
+            {
+                searchMode = false;
+                return;
+            }
+            searchResults = new ArrayList<PortletDefinitionBean>();
+            SearchResults results = serviceLocator.getSearchEngine().search(search);
+            if (results.size() > 0)
+            {            
+                String name = "";
+                for (ParsedObject po : results.getResults())
+                {
+                    Map<String, String> fields = po.getFields();
+                    if (fields != null && po.getType().equals(ParsedObject.OBJECT_TYPE_PORTLET))
+                    {
+                        Object id = fields.get(ParsedObject.ID);                
+                        Object pa = fields.get(ParsedObject.OBJECT_TYPE_PORTLET_APPLICATION);
+                        String paName = "";
+                        if(pa != null)
+                        {
+                            if(id instanceof Collection)
+                            {
+                                Collection<String> coll = (Collection<String>) id;
+                                paName = (String) coll.iterator().next();
+                            }
+                            else
+                            {
+                                paName = (String)pa;
+                            }
+                        }
+                        name = paName + "::" + id;
+                        PortletDefinition pd = serviceLocator.getPortletRegistry().getPortletDefinitionByUniqueName(name);
+                        if (pd != null)
+                        {
+                            searchResults.add(new PortletDefinitionBean(pd, locale));
+                        }                        
+                    }
+                }
+                sort(searchResults, this.orderBy);                
+            }
+            searchMode = true;
+            
+        }
+        catch (Exception e)
+        {
+            
+        }
+    }
+
+    public PortletOrderBy getOrderBy()
+    {
+        return orderBy;
+    }
+    
+    public void setOrderBy(PortletOrderBy orderBy)
+    {
+        this.orderBy = orderBy;
+    }    
+    
+}

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

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

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletDefinitionBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletDefinitionBean.java?rev=760209&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletDefinitionBean.java (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletDefinitionBean.java Mon Mar 30 22:40:23 2009
@@ -0,0 +1,58 @@
+/*
+ * 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.Locale;
+
+import org.apache.jetspeed.om.portlet.DisplayName;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.wicket.IClusterable;
+
+public class PortletDefinitionBean implements IClusterable
+{
+    protected String name;
+    protected String uniqueName;
+    protected String displayName;
+    private static final long serialVersionUID = 1L;    
+        
+    public PortletDefinitionBean(PortletDefinition portlet, Locale locale)
+    {
+        this.name = portlet.getPortletName();
+        this.uniqueName = portlet.getUniqueName();
+        DisplayName dn = portlet.getDisplayName(locale);
+        if (dn == null)
+            this.displayName = this.name;
+        else
+            this.displayName = dn.getDisplayName();
+    }
+
+    public String toString()
+    {
+        return getDisplayName();
+    }
+        
+    public String getDisplayName()
+    {
+        return displayName;
+    }
+    
+    public String getName()
+    {
+        return name;
+    }
+    
+}

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

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

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletDefinitionModel.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletDefinitionModel.java?rev=760209&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletDefinitionModel.java (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletDefinitionModel.java Mon Mar 30 22:40:23 2009
@@ -0,0 +1,61 @@
+package org.apache.jetspeed.portlets.prm;
+
+import org.apache.wicket.model.LoadableDetachableModel;
+
+
+public class PortletDefinitionModel extends LoadableDetachableModel<PortletDefinitionBean>
+{
+    private static final long serialVersionUID = 1L;
+    private PortletDefinitionBean pd;
+
+    public PortletDefinitionModel(PortletDefinitionBean pd)
+    {
+        this.pd = pd;
+    }
+
+
+    /**
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        return pd.getName().hashCode();
+    }
+
+    /**
+     * used for dataview with ReuseIfModelsEqualStrategy item reuse strategy
+     * 
+     * @see org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(final Object obj)
+    {
+        if (obj == this)
+        {
+            return true;
+        }
+        else if (obj == null)
+        {
+            return false;
+        }
+        else if (obj instanceof PortletDefinitionModel)
+        {
+            PortletDefinitionModel other = (PortletDefinitionModel)obj;
+            return pd.getName().equals(other.getModelBean().getName());
+        }
+        return false;
+    }
+
+    public PortletDefinitionBean getModelBean()
+    {
+        return this.pd;
+    }
+    
+    @Override
+    protected PortletDefinitionBean load()
+    {
+        // TODO Auto-generated method stub
+        return pd;
+    }
+
+}

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

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

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletsListHome.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletsListHome.html?rev=760209&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletsListHome.html (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletsListHome.html Mon Mar 30 22:40:23 2009
@@ -0,0 +1,51 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
+<html 
+	xmlns="http://www.w3.org/1999/xhtml" 
+	xmlns:wicket="http://wicket.sourceforge.net/" 
+	xml:lang="en" 
+	lang="en">
+<head>
+  <title>Portlet Applications</title>
+    
+<style type="text/css">
+table.padded-table td { padding:8px; border:solid 1px;  }
+.feedbackPanelERROR {font-size: 9px;color: red; }
+.feedbackPanelWARN {font-size: 9px;color: orange; }
+.feedbackPanelINFO {font-size: 9px;color: blue; }
+</style>
+
+</head>
+<body>
+
+<table border='1' height = "100%">
+<tr>
+   <td border='0' width="15px">&nbsp;</td>                
+   <td border='1'>                
+	<table class="padded-table">
+		<tr>
+	    	<td height = "100%" valign = "top" border='1'  colspan='6'>
+			  <form wicket:id="plSearchForm">
+	          <input type='text' wicket:id="plSearchField" size="25" style='font-size: 10px;'></input>
+	          <input type='submit' wicket:id="plSearchButton" value='search'/> |          
+	         </form> 
+			</td>		
+		</tr>
+	    <tr>
+	        <th wicket:id="plOrderByName" style='font-size: 10px;'>Portlet Name</th>
+	        <th wicket:id="plOrderByDisplayName" style='font-size: 10px;'>Display Name</th>
+	        <th >Actions</th>
+	    </tr>
+	    <tr wicket:id="portletTable">
+	        <td><span style='font-size: 10px;' wicket:id="name">[name]</span></td>
+	        <td><span style='font-size: 10px;' wicket:id="displayName">[title]</span></td>
+	        <td><span style='font-size: 10px;' wicket:id="actions">[actions]</span></td>  
+	    </tr>
+	</table>
+	<span wicket:id="plNavigator">[dataview navigator]</span>
+   </td>   
+</tr>
+</table>
+<br/>
+</body>
+</html>
\ No newline at end of file

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

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

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletsListHome.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletsListHome.java?rev=760209&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletsListHome.java (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/PortletsListHome.java Mon Mar 30 22:40:23 2009
@@ -0,0 +1,214 @@
+/*
+ * 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 org.apache.jetspeed.portlets.AdminPortletWebPage;
+import org.apache.jetspeed.portlets.prm.PortletDataProvider.PortletOrderBy;
+import org.apache.portals.messaging.PortletMessaging;
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.extensions.markup.html.repeater.data.sort.OrderByBorder;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Button;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.markup.repeater.data.DataView;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.PropertyModel;
+
+
+public class PortletsListHome extends AdminPortletWebPage
+{
+    private static final String PORTLET_TABLE = "portletTable";
+    private String plSearchField;
+    
+    @SuppressWarnings({ "unchecked", "serial"})    
+    public PortletsListHome()
+    {
+        SearchForm form = new SearchForm("plSearchForm");
+        form.add(new TextField("plSearchField", new PropertyModel(this, "plSearchField")));
+        form.add(new Button("plSearchButton")
+        {
+            @Override
+            public void onSubmit()
+            {
+                try
+                {
+                    DataView view = (DataView)this.getParent().getParent().get(PORTLET_TABLE);
+                    PortletDataProvider dp = (PortletDataProvider)view.getDataProvider();
+                    dp.searchPortlets(getPortletSearchField());
+                }
+                catch (Exception e)
+                {
+                    e.printStackTrace();
+                }                
+            }
+        });
+        add(form);
+        
+        // Construct Data View
+        String appName= (String) 
+            PortletMessaging.receive(getPortletRequest(), ApplicationsListApplication.PRM_TOPIC, ApplicationsListApplication.SELECTED_APP_EVENT);
+        System.out.println("app name = " + appName);
+        final PortletDataProvider dp = new PortletDataProvider(appName, getPortletRequest().getLocale(), getServiceLocator());
+        final DataView dataView = new DataView(PORTLET_TABLE, dp)
+        {
+            protected void populateItem(final Item item)
+            {
+                PortletDefinitionBean pa = (PortletDefinitionBean) item.getModelObject();
+                item.add(new Label("name", pa.getName()));
+                item.add(new Label("displayName", pa.getDisplayName()));
+                item.add(new ActionPanel("actions", item.getModel()));
+                item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel()
+                {
+                    public Object getObject()
+                    {
+                        return (item.getIndex() % 2 == 1) ? "background-color: #fff;" : "background-color: #ffebcd;";
+                    }
+                }));
+            }
+        };
+        dataView.setItemsPerPage(10);
+        add(new OrderByBorder("plOrderByName", "name", dp)
+        {
+            protected void onSortChanged()
+            {
+                if (dp.getOrderBy() == PortletOrderBy.NAME_ASC)
+                    dp.setOrderBy(PortletOrderBy.NAME_DESC);
+                else
+                    dp.setOrderBy(PortletOrderBy.NAME_ASC);                
+                dataView.setCurrentPage(0);
+            }
+        });
+        add(new OrderByBorder("plOrderByDisplayName", "displayName", dp)
+        {
+            protected void onSortChanged()
+            {
+                if (dp.getOrderBy() == PortletOrderBy.DISPLAY_NAME_ASC)
+                    dp.setOrderBy(PortletOrderBy.DISPLAY_NAME_DESC);
+                else
+                    dp.setOrderBy(PortletOrderBy.DISPLAY_NAME_ASC);                
+                dataView.setCurrentPage(0);
+            }
+        });
+        
+        add(dataView);
+        add(new PagingNavigator("plNavigator", dataView));
+        dp.retrievePortlets();
+//        add(new Link("plHome")
+//        {
+//            /*
+//             * (non-Javadoc)
+//             * @see org.apache.wicket.markup.html.link.Link#onClick()
+//             */
+//            @Override
+//            public void onClick()
+//            {
+//                try
+//                {
+//                    DataView view = (DataView)this.getParent().get(PORTLET_TABLE);
+//                    PortletDataProvider dp = (PortletDataProvider)view.getDataProvider();
+//                    dp.setSearchMode(false);
+//                    dp.retrievePortlets();
+//                }
+//                catch (Exception e)
+//                {
+//                    e.printStackTrace();
+//                }                                
+//            }
+//        });
+//        add(new Link("plSearchResults")
+//        {
+//            /*
+//             * (non-Javadoc)
+//             * @see org.apache.wicket.markup.html.link.Link#onClick()
+//             */
+//            @Override
+//            public void onClick()
+//            {
+//                try
+//                {                    
+//                    DataView view = (DataView)this.getParent().get(PORTLET_TABLE);
+//                    PortletDataProvider dp = (PortletDataProvider)view.getDataProvider();
+//                    dp.setSearchMode(true);                    
+//                }
+//                catch (Exception e)
+//                {
+//                    e.printStackTrace();
+//                }                                
+//            }
+//        });
+
+    }
+
+    @SuppressWarnings("serial")
+    private class SearchForm extends Form<Void>
+    {
+        public SearchForm(String name)
+        {
+            super(name);
+            // Add one file input field
+        }
+    }     
+
+    public String getPortletSearchField()
+    {
+        return plSearchField;
+    }
+
+    
+    public void setPortletSearchField(String plSearchField)
+    {
+        this.plSearchField = plSearchField;
+    }
+
+    @SuppressWarnings({ "unchecked", "serial"})    
+    class ActionPanel extends Panel
+    {
+        /**
+         * @param id
+         *            component id
+         * @param model
+         *            model for contact
+         */
+        public ActionPanel(String id, final IModel model)
+        {
+            super(id, model);
+//            Link viewLink = new CollabDocumentLink("view", model, false);
+//            viewLink.setPopupSettings(new PopupSettings(PageMap.forName("document"), PopupSettings.RESIZABLE).setWidth(800).setHeight(600));
+//            add(viewLink);
+//            add(new CollabDocumentLink("download", model, true));
+            add(new Link("disable")
+            {
+                public void onClick()
+                {                
+                }
+            });            
+            add(new Link("enable")
+            {
+                public void onClick()
+                {                
+                }
+            });            
+        }
+    }
+    
+}

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

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

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UploadPortletApp.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UploadPortletApp.html?rev=760209&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UploadPortletApp.html (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UploadPortletApp.html Mon Mar 30 22:40:23 2009
@@ -0,0 +1,29 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
+<html 
+	xmlns="http://www.w3.org/1999/xhtml" 
+	xmlns:wicket="http://wicket.sourceforge.net/" 
+	xml:lang="en" 
+	lang="en">
+<head>
+</head>
+<body>
+<h4><wicket:message key="deployHeader"/></h4>
+
+<form wicket:id="uploadForm">
+<table cellspacing="0" class="dataview">
+    <tr>
+        <td colspan="3"><input type="file" size="50" wicket:id="fileInput"/></td>
+    </tr>
+    <tr>
+        <td><input type="submit"  wicket:id="cancelPage" value="cancel" /></td>
+        <td>&nbsp;</td>
+        <td><input type="submit"  wicket:id="uploadFile" value="uploadFile" /></td>
+    </tr>                
+</table>
+</form>
+ <div id="feedbackPanel">
+        <span wicket:id="feedback"/>
+    </div>
+</body>
+</html>
\ No newline at end of file

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

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

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UploadPortletApp.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UploadPortletApp.java?rev=760209&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UploadPortletApp.java (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UploadPortletApp.java Mon Mar 30 22:40:23 2009
@@ -0,0 +1,187 @@
+/*
+ * 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.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.jetspeed.audit.AuditActivity;
+import org.apache.jetspeed.deployment.DeploymentManager;
+import org.apache.jetspeed.portlets.AdminPortletWebPage;
+import org.apache.wicket.markup.html.form.Button;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.upload.FileUpload;
+import org.apache.wicket.markup.html.form.upload.FileUploadField;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.model.ResourceModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * View Mode, Upload Page for Portlet Application List widget: uploads deploys portlet application
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public class UploadPortletApp extends AdminPortletWebPage
+{
+    private transient DeploymentManager dm;
+    private transient FileUpload fileUpload;
+    private final static Logger log = LoggerFactory.getLogger(UploadPortletApp.class);
+
+    @SuppressWarnings("serial")
+    public UploadPortletApp(DeploymentManager dm)
+    {
+        this.dm = dm;
+        FileUploadForm form = new FileUploadForm("uploadForm");
+        form.add(new Button("uploadFile", new ResourceModel("uploadFile"))
+        {
+            /*
+             * (non-Javadoc)
+             * @see org.apache.wicket.markup.html.form.Button#onSubmit()
+             */
+            @Override
+            public void onSubmit()
+            {
+                FeedbackPanel feedback = (FeedbackPanel) UploadPortletApp.this.get("feedback");
+                final FileUpload upload = fileUpload;
+                if (upload != null)
+                {
+                    InputStream warStream = null;
+                    File tempFile = null;
+                    try
+                    {
+                        warStream = upload.getInputStream();            
+                        tempFile = File.createTempFile(upload.getClientFileName(), "");                        
+                        String tmpDir = System.getProperty("java.io.tmpdir");
+                        tempFile = new File(tmpDir, upload.getClientFileName());
+                        if (tempFile.exists())
+                            tempFile.delete();
+                        FileOutputStream fos = new FileOutputStream(tempFile);
+                        drain(warStream, fos);
+                        fos.close();
+                        
+                        UploadPortletApp.this.dm.deploy(tempFile);
+                        feedback.info("Deployed 1 portlet application to server: " + upload.getClientFileName());
+                        UploadPortletApp page = (UploadPortletApp)getPage();
+                        page.getServiceLocator().getAuditActivity().logAdminRegistryActivity(
+                                getAuthenticatedUsername(), getIPAddress(), AuditActivity.REGISTRY_DEPLOY, ApplicationsListHome.PORTLET_REGISTRY_MANAGER);                                                    
+                    }
+                    catch (Exception e)
+                    {
+                        String msg = "Failed to upload document: " + upload.getClientFileName();
+                        log.error(msg, e);
+                        feedback.error(msg);
+                    }
+                    finally
+                    {
+                        if (tempFile != null)
+                        {
+                            tempFile.delete();
+                        }
+                        if (warStream != null)
+                        {
+                            try
+                            {
+                                warStream.close();
+                            }
+                            catch (IOException e)
+                            {
+                            }
+                        }
+                    }
+                }
+            }
+        });
+        form.add(new Button("cancelPage", new ResourceModel("cancel"))
+        {
+            /*
+             * (non-Javadoc)
+             * @see org.apache.wicket.markup.html.form.Button#onSubmit()
+             */
+            @Override
+            public void onSubmit()
+            {
+                setResponsePage(ApplicationsListHome.class);
+            }
+        });
+        add(form);        
+        final FeedbackPanel feedback = new FeedbackPanel("feedback");
+        add(feedback);
+    }
+
+    /**
+     * @return the fileUploadField
+     */
+    public FileUpload getFileUploadField()
+    {
+        return fileUpload;
+    }
+
+    /**
+     * @param fileUploadField
+     *            the fileUploadField to set
+     */
+    public void setFileUploadField(FileUpload fileUploadField)
+    {
+        this.fileUpload = fileUploadField;
+    }
+
+    private class FileUploadForm extends Form<Void>
+    {
+        private static final long serialVersionUID = 1L;
+
+        public FileUploadForm(String name)
+        {
+            super(name);
+            // set this form to multipart mode (allways needed for uploads!)
+            setMultiPart(true);
+            // Add one file input field
+            add(new FileUploadField("fileInput", new PropertyModel(UploadPortletApp.this, "fileUploadField")));
+        }
+    }
+
+    static final int BLOCK_SIZE=4096;
+    
+    protected void drain(InputStream r, OutputStream w) throws IOException
+    {
+        byte[] bytes = new byte[BLOCK_SIZE];
+        try
+        {
+            int length = r.read(bytes);
+            while (length != -1)
+            {
+                if (length != 0)
+                {
+                    w.write(bytes, 0, length);
+                }
+                length = r.read(bytes);
+            }
+        }
+        finally
+        {
+            bytes = null;
+        }
+
+    }
+    
+  
+}

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

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

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UploadPortletApp.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UploadPortletApp.properties?rev=760209&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UploadPortletApp.properties (added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/UploadPortletApp.properties Mon Mar 30 22:40:23 2009
@@ -0,0 +1,3 @@
+deployHeader=Deploy Portlet Application
+cancel=Cancel
+uploadFile=Upload File

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

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

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/running.gif
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/running.gif?rev=760209&view=auto
==============================================================================
Binary file - no diff available.

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/running.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/stop.gif
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/stop.gif?rev=760209&view=auto
==============================================================================
Binary file - no diff available.

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/stop.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java?rev=760209&r1=760208&r2=760209&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java Mon Mar 30 22:40:23 2009
@@ -128,7 +128,7 @@
         {
         	principalParam = getInitParam(principalParamName);	
         }        
-        principalType = getJetspeedPrincipalManagerProvider().getPrincipalType(principalParam);
+        principalType = getServiceLocator().getJetspeedPrincipalManagerProvider().getPrincipalType(principalParam);
         ITab tab = null;
         tabs = new ArrayList();
         final CheckGroup group = new CheckGroup("group", new ArrayList());
@@ -285,7 +285,7 @@
                 {
                     try
                     {
-                        Collection rules = getProfiler().getRulesForPrincipal(getPrincipal());
+                        Collection rules = getServiceLocator().getProfiler().getRulesForPrincipal(getPrincipal());
                         for (Iterator it = getUserRules().iterator(); it.hasNext();) 
                         {
                             Map ruleMap = (Map) it.next();
@@ -297,8 +297,8 @@
                                     PrincipalRule rule = (PrincipalRule) ruleIter.next();
                                     if (rule.getLocatorName().equals(locatorName))
                                     {
-                                        getProfiler().deletePrincipalRule(rule);
-                                        getAuditActivity().logAdminAuthorizationActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
+                                        getServiceLocator().getProfiler().deletePrincipalRule(rule);
+                                        getServiceLocator().getAuditActivity().logAdminAuthorizationActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
                                                                                          getSelectedPrincipal(), AuditActivity.USER_DELETE_PROFILE,
                                                                                          rule.getProfilingRule().getId() + "-" + rule.getLocatorName(),
                                                                                          USER_ADMINISTRATION);
@@ -355,8 +355,8 @@
                         try
                         {
                             String ruleName = getRuleName();
-                            getProfiler().setRuleForPrincipal(getPrincipal(), getProfiler().getRule(ruleName), locatorName);
-                            getAuditActivity().logAdminAuthorizationActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
+                            getServiceLocator().getProfiler().setRuleForPrincipal(getPrincipal(), getServiceLocator().getProfiler().getRule(ruleName), locatorName);
+                            getServiceLocator().getAuditActivity().logAdminAuthorizationActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
                                                                              getSelectedPrincipal(), AuditActivity.USER_ADD_PROFILE,
                                                                              ruleName + "-" + locatorName, USER_ADMINISTRATION);
                         }
@@ -381,18 +381,18 @@
             {
                 if (getPrincipal() != null)
                 {
-                    userEnabled = getUserManager().getUser(getSelectedPrincipal()).isEnabled();
+                    userEnabled = getServiceLocator().getUserManager().getUser(getSelectedPrincipal()).isEnabled();
                 }
                 this.fullRules = new ArrayList();
                 this.userRules = new ArrayList();
-                for (Iterator it = getProfiler().getRules().iterator(); it.hasNext();)
+                for (Iterator it = getServiceLocator().getProfiler().getRules().iterator(); it.hasNext();)
                 {
                     ProfilingRule rule = (ProfilingRule) it.next();
                     this.fullRules.add(rule);
                 }
                 if (getPrincipal() != null)
                 {
-                    for (Iterator it = getProfiler().getRulesForPrincipal(getPrincipal()).iterator(); it.hasNext();)
+                    for (Iterator it = getServiceLocator().getProfiler().getRulesForPrincipal(getPrincipal()).iterator(); it.hasNext();)
                     {
                         PrincipalRule rule = (PrincipalRule) it.next();
                         Map ruleMap = new HashMap();
@@ -544,7 +544,8 @@
 						getManager().addPrincipal(principal, null);
 						User user = ((UserManager)getManager()).getUser(getUserName());						
 						if(!StringUtils.isEmpty(getProfilingRule())){
-							getProfiler().setRuleForPrincipal(principal, getProfiler().getRule(getProfilingRule()), "default");
+						    getServiceLocator().getProfiler().setRuleForPrincipal(principal, 
+						            getServiceLocator().getProfiler().getRule(getProfilingRule()), "default");
 						}
 						UserManager userManager = (UserManager)getManager();
 						PasswordCredential credential = userManager.getPasswordCredential(user);
@@ -714,7 +715,7 @@
                         {
                             // getUserManager().setPassword(getUserName(), null, getCredentialValue());
                             credential.setPassword(null, getCredentialValue());
-                            getAuditActivity().logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
+                            getServiceLocator().getAuditActivity().logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
                                                                           getPrincipal().getName(), AuditActivity.PASSWORD_RESET, USER_ADMINISTRATION);
                             passwordSet = true;
                         }
@@ -722,7 +723,7 @@
                         {
                             // getUserManager().setPasswordUpdateRequired(getUserName(), getCredentialUpdateRequired());
                             credential.setUpdateRequired(getCredentialUpdateRequired());
-                            getAuditActivity()
+                            getServiceLocator().getAuditActivity()
                                               .logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
                                                                           getPrincipal().getName(), AuditActivity.PASSWORD_UPDATE_REQUIRED, USER_ADMINISTRATION);
                         }
@@ -731,7 +732,7 @@
                             // getUserManager().setPasswordEnabled(getUserName(), getCredentialEnabled());
                             credential.setEnabled(getCredentialEnabled());
                             String activity = (getCredentialEnabled() ? AuditActivity.PASSWORD_ENABLED : AuditActivity.PASSWORD_DISABLED);
-                            getAuditActivity().logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
+                            getServiceLocator().getAuditActivity().logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
                                                                           getPrincipal().getName(), activity, USER_ADMINISTRATION);
                         }
                         String expiredFlagStr = getUserExpiredFlag();
@@ -742,7 +743,7 @@
                                 java.sql.Date today = new java.sql.Date(new Date().getTime());
                                 // getUserManager().setPasswordExpiration(getUserName(), today);
                                 credential.setExpirationDate(today);
-                                getAuditActivity().logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
+                                getServiceLocator().getAuditActivity().logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
                                                                               getPrincipal().getName(), AuditActivity.PASSWORD_EXPIRE, USER_ADMINISTRATION);
                             }
                             else if (expiredFlagStr.equals("extend"))
@@ -750,14 +751,14 @@
                                 // getUserManager().setPasswordExpiration(getUserName(), null);
                                 // TODO confirm with Ate/David
                                 credential.setExpirationDate(MAX_DATE);
-                                getAuditActivity().logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
+                                getServiceLocator().getAuditActivity().logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
                                                                               getPrincipal().getName(), AuditActivity.PASSWORD_EXTEND, USER_ADMINISTRATION);
                             }
                             else if (expiredFlagStr.equals("unlimited"))
                             {
                                 // getUserManager().setPasswordExpiration(getUserName(), User.MAX_DATE);
                                 credential.setExpirationDate(MAX_DATE);
-                                getAuditActivity().logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
+                                getServiceLocator().getAuditActivity().logAdminCredentialActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(),
                                                                               getPrincipal().getName(), AuditActivity.PASSWORD_UNLIMITED, USER_ADMINISTRATION);
                             }
                         }
@@ -968,7 +969,7 @@
                         String userAttrValue = (String) userAttrMap.get("value");
                         String oldUserAttrValue = attribs.get(userAttrName);
                         attribs.put(userAttrName, userAttrValue);
-                        getAuditActivity().logAdminAttributeActivity(getPrincipal().getName(), getIPAddress(), getPrincipal().getName(),
+                        getServiceLocator().getAuditActivity().logAdminAttributeActivity(getPrincipal().getName(), getIPAddress(), getPrincipal().getName(),
                                                                      AuditActivity.USER_UPDATE_ATTRIBUTE, userAttrName, oldUserAttrValue, userAttrValue,
                                                                      USER_ADMINISTRATION);
                     }
@@ -994,7 +995,7 @@
                                 try
                                 {
                                     getPrincipal().getSecurityAttributes().removeAttribute(userAttrName);
-                                    getAuditActivity().logAdminAttributeActivity(getPrincipal().getName(), getIPAddress(), getPrincipal().getName(),
+                                    getServiceLocator().getAuditActivity().logAdminAttributeActivity(getPrincipal().getName(), getIPAddress(), getPrincipal().getName(),
                                                                                  AuditActivity.USER_DELETE_ATTRIBUTE, userAttrName, userAttrValue, "",
                                                                                  USER_ADMINISTRATION);
                                     save = true;
@@ -1040,7 +1041,7 @@
                         {
                             getPrincipal().getSecurityAttributes().getAttribute(userAttrName, true).setStringValue(userAttrValue);
                             getManager().updatePrincipal(getPrincipal());
-                            getAuditActivity()
+                            getServiceLocator().getAuditActivity()
                                               .logAdminAttributeActivity(getPrincipal().getName(), getIPAddress(), getPrincipal().getName(),
                                                                          AuditActivity.USER_ADD_ATTRIBUTE, userAttrName, "", userAttrValue, USER_ADMINISTRATION);
                         }
@@ -1266,7 +1267,7 @@
 
         private JetspeedPrincipalManager getBaseManager(JetspeedPrincipalType type)
         {
-            return getJetspeedPrincipalManagerProvider().getManager(type);
+            return getServiceLocator().getJetspeedPrincipalManagerProvider().getManager(type);
         }
 
         private void refreshList()
@@ -1414,7 +1415,7 @@
 
     private JetspeedPrincipalManager getManager()
     {
-        return getJetspeedPrincipalManagerProvider().getManager(principalType);
+        return getServiceLocator().getJetspeedPrincipalManagerProvider().getManager(principalType);
     }
 
     private List getSubsites()
@@ -1422,7 +1423,7 @@
         List nameList = null;
         try
         {
-            nameList = getRoleManager().getRoleNames("");
+            nameList = getServiceLocator().getRoleManager().getRoleNames("");
         }
         catch (SecurityException e)
         {
@@ -1436,7 +1437,7 @@
 
     private List getProfileList()
     {
-        return (List) getProfiler().getRules();
+        return (List) getServiceLocator().getProfiler().getRules();
     }
 
     private List getRoleNames(String filter)
@@ -1444,7 +1445,7 @@
         List nameList = null;
         try
         {
-            nameList = getRoleManager().getRoleNames(filter);
+            nameList = getServiceLocator().getRoleManager().getRoleNames(filter);
         }
         catch (SecurityException e)
         {

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java?rev=760209&r1=760208&r2=760209&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java Mon Mar 30 22:40:23 2009
@@ -45,7 +45,7 @@
 import org.apache.jetspeed.administration.PortalConfigurationConstants;
 import org.apache.jetspeed.audit.AuditActivity;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
-import org.apache.jetspeed.container.InternalPortletContext;
+import org.apache.jetspeed.container.JetspeedPortletContext;
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.folder.FolderNotFoundException;
 import org.apache.jetspeed.om.portlet.UserAttribute;
@@ -188,7 +188,7 @@
 			throw new PortletException("Failed to find the Audit Activity on portlet initialization");
 		}
 
-		paName = ((InternalPortletContext) config.getPortletContext()).getApplicationName();
+		paName = ((JetspeedPortletContext) config.getPortletContext()).getApplicationDefinition().getName();		
 	}
 
 	public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserAdd.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserAdd.java?rev=760209&r1=760208&r2=760209&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserAdd.java (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/users/WicketUserAdd.java Mon Mar 30 22:40:23 2009
@@ -70,15 +70,15 @@
                             throw new SecurityException(SecurityException.PASSWORD_REQUIRED);
                         }
                         
-                        User user = getUserManager().addUser(getUserName());
+                        User user = getServiceLocator().getUserManager().addUser(getUserName());
                         
-                        getAuditActivity().logAdminUserActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(), getUserName(), AuditActivity.USER_CREATE, USER_ADMINISTRATION);            
+                        getServiceLocator().getAuditActivity().logAdminUserActivity(getPortletRequest().getUserPrincipal().getName(), getIPAddress(), getUserName(), AuditActivity.USER_CREATE, USER_ADMINISTRATION);            
                         
                         PortletMessaging.publish(getPortletRequest(), SecurityResources.TOPIC_USERS, SecurityResources.MESSAGE_REFRESH, "true");
                         PortletMessaging.publish(getPortletRequest(), SecurityResources.TOPIC_USERS, SecurityResources.MESSAGE_SELECTED, getUserName());
                                                         
                         //User user = getUserManager().getUser(getUserName());
-                        PasswordCredential credential = getCredential(user);
+                        PasswordCredential credential = getServiceLocator().getCredential(user);
                         credential.setPassword(null,password);
                         
                         
@@ -90,10 +90,10 @@
                             	//getUserManager().setPasswordUpdateRequired(getUserName(), getChangePasswordRequiredOnFirstLogin());
                             }                    
                         }
-                        getUserManager().storePasswordCredential(credential);
+                        getServiceLocator().getUserManager().storePasswordCredential(credential);
                         if (!SecurityUtil.isEmpty(getRole()) && user != null) 
                         {
-                            getRoleManager().addRoleToUser(getUserName(), getRole());
+                            getServiceLocator().getRoleManager().addRoleToUser(getUserName(), getRole());
                         }
                         
                         String templateFolder = getPortletRequest().getPreferences().getValue("newUserTemplateDirectory", "/_user/template/");
@@ -115,15 +115,15 @@
                         // copy the entire dir tree from the template folder
                         if (!(templateFolder == null || templateFolder.trim().length() == 0))
                         {
-                            Folder source = getPageManager().getFolder(templateFolder);                
-                            getPageManager().deepCopyFolder(source, subsite, getUserName());
+                            Folder source = getServiceLocator().getPageManager().getFolder(templateFolder);                
+                            getServiceLocator().getPageManager().deepCopyFolder(source, subsite, getUserName());
                         }
                         // TODO: send message that site tree portlet invalidated
                         
                         if (!SecurityUtil.isEmpty(getRule()) && user != null) 
                         {
                             //Principal principal = SecurityUtil.getPrincipal(user.getSubject(), UserPrincipal.class);
-                            getProfiler().setRuleForPrincipal(user, getProfiler().getRule(getRule()), "page");
+                            getServiceLocator().getProfiler().setRuleForPrincipal(user, getServiceLocator().getProfiler().getRule(getRule()), "page");
                         }
                         
                         setResponsePage(WicketUserDetails.class);
@@ -153,7 +153,7 @@
         
         try
         {
-        	 roles = getRoleManager().getRoleNames("");
+        	 roles = getServiceLocator().getRoleManager().getRoleNames("");
         }
         catch (SecurityException e)
         {
@@ -166,7 +166,7 @@
         
         List rules = new LinkedList();
         
-        for (Iterator it = getProfiler().getRules().iterator(); it.hasNext(); )
+        for (Iterator it = getServiceLocator().getProfiler().getRules().iterator(); it.hasNext(); )
         {
             ProfilingRule rule = (ProfilingRule) it.next();
             rules.add(rule.getId());
@@ -186,8 +186,8 @@
         {
             try
             {
-                Folder subsiteFolder = getPageManager().getFolder(subsiteRoot);
-                NodeSet set = getPageManager().getFolders(subsiteFolder);
+                Folder subsiteFolder = getServiceLocator().getPageManager().getFolder(subsiteRoot);
+                NodeSet set = getServiceLocator().getPageManager().getFolders(subsiteFolder);
                 
                 if (set != null && !set.isEmpty())
                 {



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