portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlest...@apache.org
Subject svn commit: r209328 [9/14] - in /portals/jetspeed-2/trunk/components/portal: src/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/jetspeed/ src/java/org/apache/jetspeed/aggregator/ src/java/org/apache/jetspeed/aggregator/impl/ src/java...
Date Tue, 05 Jul 2005 21:55:50 GMT
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer/TomcatManager.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,328 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.tools.pamanager.servletcontainer;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * <p>
+ * TomcatManager
+ * </p>
+ * 
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ * @version $Id: TomcatManager.java 188436 2005-03-23 22:54:30Z ate $
+ *
+ */
+public class TomcatManager implements ApplicationServerManager
+{
+    private static final String DEFAULT_MANAGER_APP_PATH = "/manager";
+    protected static final Log log = LogFactory.getLog("deployment");
+
+    private String catalinaBase;
+    private String catalinaEngine;
+    private String catalinaContextPath;
+    private String hostUrl;
+    private int hostPort;
+    private String userName;
+    private String password;
+    
+    
+    private String managerAppPath = DEFAULT_MANAGER_APP_PATH;
+    private String stopPath = managerAppPath + "/stop";
+    private String startPath = managerAppPath + "/start";
+    private String deployPath = managerAppPath + "/deploy";
+    private String undeployPath = managerAppPath + "/undeploy";
+    private String reloadPath = managerAppPath + "/reload";
+    private String serverInfoPath = managerAppPath + "/serverinfo";
+
+    private HttpClient client;
+
+    private HttpMethod start;
+
+    private HttpMethod stop;
+
+    private HttpMethod reload;
+
+    private HttpMethod undeploy;
+
+    private PutMethod deploy;
+
+    private HttpMethod install;
+
+    public TomcatManager(String catalinaBase, String catalinaEngine, String hostName, int hostPort, String userName, String password) throws IOException
+    {
+        super();
+        
+        if ( !catalinaBase.endsWith("/") )
+        {
+            this.catalinaBase = catalinaBase + "/";
+        }
+        else
+        {
+            this.catalinaBase = catalinaBase;
+        }    
+        this.catalinaEngine = catalinaEngine;
+        this.hostUrl = hostName;
+        this.hostPort = hostPort;
+        this.userName = userName;
+        this.password = password;        
+        
+        this.catalinaContextPath = this.catalinaBase + "/conf/" + this.catalinaEngine + "/" + this.hostUrl + "/";
+    }
+    
+    private ApplicationServerManagerResult parseResult(String responseBody)
+    {
+        if ( responseBody.startsWith("OK - "))
+        {
+            return new ApplicationServerManagerResult(true, responseBody.substring(5), responseBody);
+        }
+        else if ( responseBody.startsWith("FAIL - "))
+        {
+            return new ApplicationServerManagerResult(false, responseBody.substring(7), responseBody);
+        }
+        else
+        {
+            return new ApplicationServerManagerResult(false, responseBody, responseBody);
+        }
+    }
+
+    public void start() 
+    {     
+        client = new HttpClient();
+
+        HostConfiguration hostConfig = new HostConfiguration();
+        hostConfig.setHost(hostUrl, hostPort, "http");
+
+        client.setHostConfiguration(hostConfig);
+        // Fix for non-buffereing large WAR files during deploy
+        client.getState().setAuthenticationPreemptive(true);
+        client.getState().setCredentials(null, hostUrl, new UsernamePasswordCredentials(userName, password));
+
+        start = new GetMethod(startPath);
+        stop = new GetMethod(stopPath);
+        reload = new GetMethod(reloadPath);
+        undeploy = new GetMethod(undeployPath);
+        deploy = new PutMethod(deployPath);
+    }
+
+    public ApplicationServerManagerResult start(String appPath) throws IOException
+    {
+        try
+        {
+            start.setQueryString(buildPathQueryArgs(appPath));
+            client.executeMethod(start);
+            return parseResult(start.getResponseBodyAsString());
+        }
+        finally
+        {
+            start.recycle();
+            start.setPath(startPath);
+        }
+    }
+
+    public ApplicationServerManagerResult stop(String appPath) throws IOException
+    {
+        try
+        {
+            stop.setQueryString(buildPathQueryArgs(appPath));
+            client.executeMethod(stop);
+            return parseResult(stop.getResponseBodyAsString());
+        }
+        finally
+        {
+            stop.recycle();
+            stop.setPath(stopPath);
+        }
+    }
+
+    public ApplicationServerManagerResult reload(String appPath) throws IOException
+    {
+        try
+        {
+           // reload.setQueryString(buildPathQueryArgs(appPath));
+            // This is the only way to get changes made to web.xml to
+            // be picked up, reload DOES NOT reload the web.xml
+            stop(appPath);
+            Thread.sleep(1500);
+            return start(appPath);
+        }
+        catch (InterruptedException e)
+        {
+            return parseResult("FAIL - "+e.toString());
+        }
+        finally
+        {
+            stop.recycle();
+            stop.setPath(stopPath);
+            start.recycle();
+            start.setPath(startPath);
+        }
+    }
+
+    public ApplicationServerManagerResult undeploy(String appPath) throws IOException
+    {
+        try
+        {
+            undeploy.setQueryString(buildPathQueryArgs(appPath));
+            client.executeMethod(undeploy);
+            return parseResult(undeploy.getResponseBodyAsString());
+        }
+        finally
+        {
+            undeploy.recycle();
+            undeploy.setPath(undeployPath);
+        }
+    }
+
+    public ApplicationServerManagerResult deploy(String appPath, InputStream is, int size) throws IOException
+    {
+        try
+        {
+            deploy.setQueryString(buildPathQueryArgs(appPath));
+
+            //deploy.setRequestContentLength(PutMethod.CONTENT_LENGTH_CHUNKED);
+
+            if (size != -1)
+            {
+                deploy.setRequestContentLength(size);
+            }
+            deploy.setRequestBody(is);
+
+            client.executeMethod(deploy);
+            return parseResult(deploy.getResponseBodyAsString());
+        }
+        finally
+        {
+            deploy.recycle();
+            deploy.setPath(deployPath);
+        }
+    }
+
+    protected NameValuePair[] buildPathQueryArgs(String appPath)
+    {
+        if (!appPath.startsWith("/"))
+        {
+            appPath = "/" + appPath;
+        }
+        return new NameValuePair[] { new NameValuePair("path", appPath)};
+    }
+
+    protected NameValuePair[] buildWarQueryArgs(String warPath, String appPath) throws MalformedURLException
+    {
+        return new NameValuePair[] {
+                new NameValuePair("war", new File(warPath).toURL().toString()),
+                new NameValuePair("path", appPath)};
+    }
+
+    protected NameValuePair[] buildConfigQueryArgs(String configPath, String appPath) throws MalformedURLException
+    {
+        return new NameValuePair[] {
+                new NameValuePair("config", new File(configPath).toURL().toString()),
+                new NameValuePair("path", appPath)};
+    }
+
+    /**
+     * @return
+     */
+    public int getHostPort()
+    {
+        return hostPort;
+    }
+
+    /**
+     * @return
+     */
+    public String getHostUrl()
+    {
+        return hostUrl;
+    }
+
+    /**
+     * <p>
+     * isConnected
+     * </p>
+     *
+     * @see org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager#isConnected()
+     * @return
+     */
+    public boolean isConnected()
+    {
+        Socket checkSocket = null;
+        try
+        {
+            checkSocket = new Socket(hostUrl, hostPort);
+            return true;
+        }
+        catch (UnknownHostException e1)
+        {
+            log.error("Unknown server: " + e1.toString());
+
+            return false;
+        }
+        catch (IOException e1)
+        {
+            log.error("IOException: " + e1.toString());
+
+            return false;
+        }
+        finally
+        {
+            try
+            {
+                // close the server check
+                if (checkSocket != null)
+                {
+                    checkSocket.close();
+                }
+            }
+            catch (IOException e2)
+            {
+                // do nothing
+            }
+        }
+    }
+    /**
+     * <p>
+     * stop
+     * </p>
+     * 
+     * @see org.picocontainer.Startable#stop()
+     *  
+     */
+    public void stop()
+    {
+    }
+    
+    public String getAppServerTarget(String appName)
+    {
+        return appName;
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer/WeblogicManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer/WeblogicManager.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer/WeblogicManager.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/pamanager/servletcontainer/WeblogicManager.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.tools.pamanager.servletcontainer;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Weblogic application server management
+ *
+ * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
+ * @version $Id: WeblogicManager.java 188436 2005-03-23 22:54:30Z ate $
+ */
+public class WeblogicManager implements ApplicationServerManager
+{
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager#start(java.lang.String)
+     */
+    public ApplicationServerManagerResult start(String appPath) throws IOException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager#stop(java.lang.String)
+     */
+    public ApplicationServerManagerResult stop(String appPath) throws IOException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager#reload(java.lang.String)
+     */
+    public ApplicationServerManagerResult reload(String appPath) throws IOException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager#undeploy(java.lang.String)
+     */
+    public ApplicationServerManagerResult undeploy(String appPath) throws IOException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager#deploy(java.lang.String, java.io.InputStream, int)
+     */
+    public ApplicationServerManagerResult deploy(String appPath, InputStream is, int size)
+            throws IOException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager#getHostPort()
+     */
+    public int getHostPort()
+    {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager#getHostUrl()
+     */
+    public String getHostUrl()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager#isConnected()
+     */
+    public boolean isConnected()
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager#getAppServerTarget(java.lang.String)
+     */
+    public String getAppServerTarget(String appName)
+    {
+        return appName;
+    }
+
+    /* (non-Javadoc)
+     * @see org.picocontainer.Startable#start()
+     */
+    public void start()
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.picocontainer.Startable#stop()
+     */
+    public void stop()
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/userinfo/UserInfoManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/userinfo/UserInfoManager.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/userinfo/UserInfoManager.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/userinfo/UserInfoManager.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,60 @@
+/* Copyright 2004 Apache Software Foundation
+ *
+ * Licensed 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.userinfo;
+
+import java.util.Map;
+
+import org.apache.jetspeed.request.RequestContext;
+
+import org.apache.pluto.om.common.ObjectID;
+
+/**
+ * <p>The {@link UserInfoManager} retrieve the Map that will be set as a 
+ * <code>(PortletRequest.USER_INFO</code> request attribute for a specific
+ * portlet application</p>
+ * <p>The portlet specification defines user info as follow (PLT 17):</p>
+ * <p>Portlets can obtain an unmodifiable Map object containing the user attributes,
+ * of user associated with the current request, from the request attributes.
+ * The Map object can be retrieved using the USER_INFO constant defined in the
+ * PortletRequest interface. If the request is done in the context of an
+ * un-authenticated user, calls to the getAttribute method of the request 
+ * using the USER_INFO constant must return null. If the user is
+ * authenticated and there are no user attributes available, the Map must
+ * be an empty Map. The Map object must contain a String name value pair for each available user
+ * attribute. The Map object should only contain user attributes that have been mapped
+ * during deployment.</p>
+ * <p>Portlets can obtain an unmodifiable Map object containing the user attributes, of user
+ * associated with the current request, from the request attributes. The Map object can be
+ * retrieved using the USER_INFO constant defined in the PortletRequest interface. If the
+ * request is done in the context of an un-authenticated user, calls to the getAttribute
+ * method of the request using the USER_INFO constant must return null. If the user is
+ * authenticated and there are no user attributes available, the Map must be an empty Map.
+ * The Map object must contain a String name value pair for each available user attribute.
+ * The Map object should only contain user attributes that have been mapped during
+ * deployment.</p>
+ * 
+ * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
+ */
+public interface UserInfoManager
+{
+    
+    /**
+     * <p>Provide the user info map of user attributes for a given portlet application.</p>
+     * @param oid The portlet application object id.
+     * @param context The request context.
+     * @return The {@link PortletRequest.USER_INFO} map.
+     */
+    Map getUserInfoMap(ObjectID oid, RequestContext context);
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/userinfo/impl/AbstractUserInfoManagerImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/userinfo/impl/AbstractUserInfoManagerImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/userinfo/impl/AbstractUserInfoManagerImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/userinfo/impl/AbstractUserInfoManagerImpl.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,99 @@
+/* Copyright 2004 Apache Software Foundation
+*
+* Licensed 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.userinfo.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.om.common.UserAttribute;
+import org.apache.jetspeed.om.common.UserAttributeRef;
+import org.apache.jetspeed.om.impl.UserAttributeRefImpl;
+
+/**
+ * <p> Common user info management support
+ * </p>
+ * 
+ * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
+ * @version $Id: AbstractUserInfoManagerImpl.java 187254 2004-08-11 23:56:28Z taylor $
+ */
+public abstract class AbstractUserInfoManagerImpl
+{
+    /** Logger */
+    private static final Log log = LogFactory.getLog(UserInfoManagerImpl.class);
+    
+    /**
+     * <p>
+     * Return the linked attributes mapping portlet user attributes to portal
+     * user attributes.
+     * </p>
+     * 
+     * @param userAttributes
+     *            The declarative portlet user attributes.
+     * @param userAttributeRefs
+     *            The declarative jetspeed portlet extension user attributes
+     *            reference.
+     * @return The collection of linked attributes.
+     */
+    protected Collection mapLinkedUserAttributes(Collection userAttributes, Collection userAttributeRefs)
+    {
+        Collection linkedUserAttributes = new ArrayList();
+        if ((null != userAttributeRefs) && (userAttributeRefs.size() > 0))
+        {
+            Iterator attrIter = userAttributes.iterator();
+            while (attrIter.hasNext())
+            {
+                UserAttribute currentAttribute = (UserAttribute) attrIter.next();
+                boolean linkedAttribute = false;
+                if (null != currentAttribute)
+                {
+                    Iterator attrRefsIter = userAttributeRefs.iterator();
+                    while (attrRefsIter.hasNext())
+                    {
+                        UserAttributeRef currentAttributeRef = (UserAttributeRef) attrRefsIter.next();
+                        if (null != currentAttributeRef)
+                        {
+                            if ((currentAttribute.getName()).equals(currentAttributeRef.getNameLink()))
+                            {
+                                if (log.isDebugEnabled())
+                                    log.debug("Linking user attribute ref: [[name, " + currentAttribute.getName()
+                                            + "], [linked name, " + currentAttributeRef.getName() + "]]");
+                                linkedUserAttributes.add(currentAttributeRef);
+                                linkedAttribute = true;
+                            }
+                        }
+                    }
+                }
+                if (!linkedAttribute)
+                {
+                    linkedUserAttributes.add(new UserAttributeRefImpl(currentAttribute));
+                }
+            }
+        }
+        else
+        {
+            Iterator attrIter = userAttributes.iterator();
+            while (attrIter.hasNext())
+            {
+                UserAttribute currentAttribute = (UserAttribute) attrIter.next();
+                linkedUserAttributes.add(new UserAttributeRefImpl(currentAttribute));
+            }
+        }
+        return linkedUserAttributes;
+    }
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/userinfo/impl/UserInfoManagerImpl.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,261 @@
+/* Copyright 2004 Apache Software Foundation
+ *
+ * Licensed 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.userinfo.impl;
+
+import java.security.Principal;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.prefs.Preferences;
+import java.util.prefs.BackingStoreException;
+
+import javax.portlet.PortletRequest;
+import javax.security.auth.Subject;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.om.common.UserAttributeRef;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.User;
+import org.apache.jetspeed.security.UserManager;
+import org.apache.jetspeed.security.UserPrincipal;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.SecurityHelper;
+import org.apache.jetspeed.userinfo.UserInfoManager;
+
+import org.apache.pluto.om.common.ObjectID;
+
+/**
+ * <p>
+ * Implements the {@link org.apache.jetspeed.userinfo.UserInfoManager}
+ * interface.
+ * </p>
+ * 
+ * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
+ * @version $Id: UserInfoManagerImpl.java 187847 2004-10-29 14:29:28Z weaver $
+ */
+public class UserInfoManagerImpl extends AbstractUserInfoManagerImpl implements UserInfoManager
+{
+
+    /** Logger */
+    private static final Log log = LogFactory.getLog(UserInfoManagerImpl.class);
+
+    // TODO Same caching issue as usual. We should look into JCS. That wil do
+    // for now.
+    /** Map used to cache user info maps for each mapped portlet application. */
+    private static Map userInfoMapCache;
+
+    /** The user information property set. */
+    String userInfoPropertySet;
+
+    /** The user manager */
+    UserManager userMgr;
+
+    /** The portlet registry. */
+    PortletRegistry registry;
+
+    /** The object id of the portlet application being processed. */
+    String oid;
+
+    /**
+     * <p>
+     * Constructor providing access to the {@link UserManager}.
+     * </p>
+     * 
+     * @param userMgr The user manager.
+     * @param registry The portlet registry component.
+     */
+    public UserInfoManagerImpl(UserManager userMgr, PortletRegistry registry)
+    {
+        this.userMgr = userMgr;
+        this.registry = registry;
+        this.userInfoPropertySet = User.USER_INFO_PROPERTY_SET;
+        initUserInfoMapCache();
+    }
+
+    /**
+     * <p>
+     * Constructor providing access to the {@link UserManager}and specifying
+     * which property set to use for user information.
+     * </p>
+     * 
+     * @param userMgr The user manager.
+     * @param registry The portlet registry component.
+     * @param userInfoPropertySet The user information property set.
+     *  
+     */
+    public UserInfoManagerImpl(UserManager userMgr, PortletRegistry registry, String userInfoPropertySet)
+    {
+        this.userMgr = userMgr;
+        this.registry = registry;
+        this.userInfoPropertySet = userInfoPropertySet;
+        initUserInfoMapCache();
+    }
+
+    /**
+     * @see org.apache.jetspeed.userinfo.UserInfoManager#setUserInfoMap(org.apache.jetspeed.om.page.Fragment,
+     *      org.apache.jetspeed.request.RequestContext)
+     */
+    public Map getUserInfoMap(ObjectID oid, RequestContext context)
+    {
+        if (log.isDebugEnabled())
+            log.debug("Getting user info for portlet application: " + oid.toString());
+
+        // Check if user info map is in cache.
+        if (userInfoMapCache.containsKey(oid))
+        {
+            return (Map) userInfoMapCache.get(oid);
+        }
+        // Not in cache, map user info.
+        Preferences userPrefs = getUserPreferences(context);
+        if (null == userPrefs)
+        {
+            log.debug(PortletRequest.USER_INFO + " is set to null");
+            return null;
+        }
+
+        MutablePortletApplication pa = registry.getPortletApplication(oid);
+        if (null == pa)
+        {
+            log.debug(PortletRequest.USER_INFO + " is set to null");
+            return null;
+        }
+        Preferences userInfoPrefs = userPrefs.node(userInfoPropertySet);
+        Collection userAttributes = pa.getUserAttributes();
+        Collection userAttributeRefs = pa.getUserAttributeRefs();
+        Map userInfoMap = mapUserInfo(userInfoPrefs, userAttributes, userAttributeRefs);
+
+        return userInfoMap;
+    }
+
+    /**
+     * <p>
+     * Maps the user info properties retrieved from the user preferences to the
+     * user info attribute declared in the portlet.xml descriptor.
+     * </p>
+     * 
+     * @param userInfoPrefs The user info preferences.
+     * @param userAttributes The declarative portlet user attributes.
+     * @param userAttributeRefs The declarative jetspeed portlet extension user
+     *            attributes reference.
+     * @return The user info map.
+     */
+    private Map mapUserInfo(Preferences userInfoPrefs, Collection userAttributes, Collection userAttributeRefs)
+    {
+        if ((null == userAttributes) || (userAttributes.size() == 0))
+        {
+            return null;
+        }
+
+        Map userInfoMap = new HashMap();
+        String[] propertyKeys = null;
+        try
+        {
+            propertyKeys = userInfoPrefs.keys();
+            if ((null != propertyKeys) && log.isDebugEnabled())
+                log.debug("Found " + propertyKeys.length + " children for " + userInfoPrefs.absolutePath());
+        }
+        catch (BackingStoreException bse)
+        {
+            log.error("BackingStoreException: " + bse.toString());
+        }
+        if (null == propertyKeys)
+        {
+            return null;
+        }
+
+        Collection linkedUserAttributes = mapLinkedUserAttributes(userAttributes, userAttributeRefs);
+        Iterator iter = linkedUserAttributes.iterator();
+        while (iter.hasNext())
+        {
+            UserAttributeRef currentAttributeRef = (UserAttributeRef) iter.next();
+            if (null != currentAttributeRef)
+            {
+                for (int i = 0; i < propertyKeys.length; i++)
+                {
+                    if (null != currentAttributeRef.getNameLink())
+                    {
+                        if ((currentAttributeRef.getNameLink()).equals(propertyKeys[i]))
+                        {
+                            userInfoMap.put(currentAttributeRef.getName(), userInfoPrefs.get(propertyKeys[i], null));
+                        }
+                    }
+                    else
+                    {
+                        if ((currentAttributeRef.getName()).equals(propertyKeys[i]))
+                        {
+                            userInfoMap.put(currentAttributeRef.getName(), userInfoPrefs.get(propertyKeys[i], null));
+                        }
+                    }
+                }
+            }
+        }
+
+        userInfoMapCache.put(oid, userInfoMap);
+
+        return userInfoMap;
+    }
+
+    /**
+     * <p>
+     * Gets the user preferences from the user's request.
+     * </p>
+     * <p>
+     * If no user is logged in, return null.
+     * </p>
+     * 
+     * @param context The request context.
+     * @return The user preferences.
+     */
+    private Preferences getUserPreferences(RequestContext context)
+    {
+        Preferences userPrefs = null;
+        Subject subject = context.getSubject();
+        if (null != subject)
+        {
+            Principal userPrincipal = SecurityHelper.getPrincipal(subject, UserPrincipal.class);
+            if (null != userPrincipal)
+            {
+                log.debug("Got user principal: " + userPrincipal.getName());
+                try
+                {
+                    if (userMgr.userExists(userPrincipal.getName()))
+                    {
+                        User user = userMgr.getUser(userPrincipal.getName());
+                        userPrefs = user.getPreferences();
+                    }
+                }
+                catch (SecurityException sex)
+                {
+                    log.warn("Unexpected SecurityException in UserInfoManager", sex);
+                }
+            }
+        }
+        return userPrefs;
+    }
+
+    private void initUserInfoMapCache()
+    {
+        if (null == userInfoMapCache)
+        {
+            userInfoMapCache = new HashMap();
+        }
+    }
+
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/CloneUtil.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/CloneUtil.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/CloneUtil.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/CloneUtil.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * Utility for object cloning
+ * 
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ */
+public class CloneUtil
+{
+    /**
+     * Provides a deep clone serializing/de-serializng <code>objToClone</code>     
+     * 
+     * @param objToClone The object to be cloned
+     * @return The cloned object
+     */
+    public static final Object deepClone(Object objToClone)
+    {
+        try
+        {
+            ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(100);
+            ObjectOutputStream objectoutputstream = new ObjectOutputStream(bytearrayoutputstream);
+            objectoutputstream.writeObject(objToClone);
+            byte abyte0[] = bytearrayoutputstream.toByteArray();
+            objectoutputstream.close();
+            ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(abyte0);
+            ObjectInputStream objectinputstream = new ObjectInputStream(bytearrayinputstream);
+            Object clone = objectinputstream.readObject();
+            objectinputstream.close();
+            return clone;
+        }
+        catch (Exception exception)
+        {
+            // nothing
+        }
+        return null;
+    }
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/DirectoryUtils.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/DirectoryUtils.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/DirectoryUtils.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/DirectoryUtils.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.util;
+
+import java.io.File;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/*
+ * File System Directory Utilities. Some utilities that java.io doesn't give us.
+ *
+ *    rmdir() - removes a directory and all subdirectories and files underneath.
+ *
+ * @author David S. Taylor <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: DirectoryUtils.java 185962 2004-03-08 01:03:33Z jford $
+ *
+ */
+public class DirectoryUtils
+{
+    private final static Log log = LogFactory.getLog(DirectoryUtils.class);
+            
+    public static void main(String[] args)
+    {
+        DirectoryUtils.rmdir(new File(args[0]));
+    }
+
+    /**
+     *  Removes a directory and all subdirectories and files beneath it.
+     *
+     * @param directory The name of the root directory to be deleted.
+     * @return boolean If all went successful, returns true, otherwise false.
+     * 
+     */
+    public static final boolean rmdir(File dir)
+    {    
+		if (dir.isDirectory())
+		{
+			String[] children = dir.list();
+			for (int i = 0; i < children.length; i++)
+			{
+				boolean success = rmdir(new File(dir, children[i]));
+				if (!success)
+				{
+					return false;
+				}
+			}
+		}
+
+		// The directory is now empty so delete it OR it is a plain file
+		return dir.delete();
+    }
+
+    /**
+     *  Recursive deletion engine, traverses through all subdirectories, 
+     *  attempting to delete every file and directory it comes across.
+     *  NOTE: this version doesn't do any security checks, nor does it 
+     *  check for file modes and attempt to change them.
+     *
+     * @param path The directory path to be traversed.
+     * 
+     */            
+//    private static void deleteTraversal(String path)
+//    {
+//        File file = new File(path);
+//        if (file.isFile()) 
+//        {
+//            try 
+//            {
+//                file.delete();
+//            }
+//            catch (Exception e)
+//            {
+//                log.error("Failed to Delete file: " + path + " : " , e);
+//                file.deleteOnExit(); // try to get it later...
+//            }
+//        } 
+//        else if (file.isDirectory()) 
+//        {
+//            if (!path.endsWith(File.separator))
+//                path += File.separator;
+//
+//            String list[] = file.list();
+//
+//            // Process all files recursivly
+//            for(int ix = 0; list != null && ix < list.length; ix++)
+//                deleteTraversal(path + list[ix]);
+//
+//            // now try to delete the directory
+//            try 
+//            {
+//                file.delete();
+//            }
+//            catch (Exception e)
+//            {
+//                log.error("Failed to Delete directory: " + path + " : " , e);
+//                file.deleteOnExit(); // try to get it later...
+//            }
+//            
+//        }
+//    }            
+}
+
+

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/IsolatedLog4JLogger.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/IsolatedLog4JLogger.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/IsolatedLog4JLogger.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/IsolatedLog4JLogger.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.util;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.impl.Log4JLogger;
+import org.apache.log4j.Hierarchy;
+
+/**
+ * IsolatedLog4JLogger routes all commons-logging logging using Log4J to an ContextClassLoader
+ * specific Hierarchy.
+ * </p>
+ * <p>
+ * For web or application servers providing (and enforcing) commons-logging and
+ * Log4J from a shared context (like JBoss), configuring Log4J loggers and appenders
+ * from within a (web) application overrides and resets the global 
+ * Log4J LoggerRepository.
+ * </p>
+ * <p>
+ * Capturing root logging for logging events from within the web application
+ * for example isn't possible using a Log4J propery or xml configuration without
+ * routing <em>ALL</em> root logging through the new (web application specific)
+ * configuration.
+ * </p>
+ * <p>
+ * <em>It is possible using the Log4J API directly instead of configuration files, 
+ * but that requires hardcoded knowledge about how the logging is to be done.</em>
+ * </p>
+ * <p>
+ * Furthermore, if another application later on reconfigures the root logging again, the
+ * current root logging configuration is closed, detached and rerouted to the new configuration.
+ * </p>
+ * <p>
+ * The same applies of course to common named loggers like capturing springframework logging. 
+ * </p>
+ * <p>
+ * The only way to prevent this <em>stealing</em> of logging configuration is allowing only
+ * one log4J configuration for the whole web or application server.<br/>
+ * As this has to be done in a web or application server specific manner, setting up Jetspeed
+ * for different servers will become rather complex and difficult to automate.
+ * </p>
+ * <p>
+ * The IsolatedLog4JLogger solves these problems by routing all logging through a statically
+ * configured ContextClassLoader isolated LoggerRepository.
+ * </p>
+ * Using this class requires a commons-logging.properties file in the WEB-INF/classes
+ * folder containing:
+ * <pre>
+ *   org.apache.commons.logging.Log=org.apache.jetspeed.util.IsolatedLog4JLogger
+ * </pre>
+ * </p>
+ * <p>
+ * During web application initialization, preferably from a ServletContextListener or
+ * a Servlet init method loaded with a load-on-startup value of 0 (zero), a new 
+ * ContextClassLoader (e.g. web application) specific LoggerRepository as well as 
+ * the initialization of Log4J should be configured as follows:
+ * <pre>
+ *   Properties p = new Properties();
+ *   p.load(new FileInputStream(log4jFile));
+ *   // Create a new LoggerRepository
+ *   Hierarchy h = new Hierarchy(new RootCategory(Level.INFO));
+ *   // Configure the LoggerRepository with our own Log4J configuration
+ *   new PropertyConfigurator().doConfigure(p,h);
+ *   // set the LoggerRepository to be used for the current ContextClassLoader
+ *   IsolatedLog4JLogger.setHierarchy(h);
+ * </pre>
+ * Instead of using a PropertyConfigurator a DomConfigurator could be used likewise. 
+ * </p>
+ * <p>
+ * TODO: It might be useful to have this utility class available for usage by Portlet
+ * Applications too. Because this class <em>must</em> be included within a web application
+ * classpath, a separate jetspeed-tools or jetspeed-utils library will have to be created
+ * for it (and possibly other utility classes as well) which then can be put in the web
+ * application lib folder. 
+ * </p>
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: IsolatedLog4JLogger.java 188433 2005-03-23 22:50:44Z ate $
+ */
+public class IsolatedLog4JLogger implements Log
+{
+    private static Hierarchy hierarchy;
+    private static HashMap notIsolatedLoggers = new HashMap();
+
+    private Log4JLogger logger; // the wrapped Log4JLogger 
+    
+    public static void setHierarchy(Hierarchy hierarchy)
+    {
+        synchronized (IsolatedLog4JLogger.class)
+        {
+            if ( IsolatedLog4JLogger.hierarchy == null )
+            {
+                IsolatedLog4JLogger.hierarchy = hierarchy;
+                if ( notIsolatedLoggers.size() > 0 )
+                {
+                    // Reroute existing IsolatedLog4JLogger instances
+                    // which were created before the new LoggerRepository.
+                    // Note: This situation should be prevented as much as
+                    //       possible by calling setHierarchy from
+                    //       a ServletContextListener or a Servlet its init method
+                    //       which has a load-on-startup value of 0 (zero).
+                    Iterator iter = notIsolatedLoggers.entrySet().iterator();
+                    while (iter.hasNext())
+                    {
+                        Map.Entry entry = (Map.Entry)iter.next();
+                        IsolatedLog4JLogger logger = (IsolatedLog4JLogger)entry.getKey();
+                        logger.setLogger(new Log4JLogger(hierarchy.getLogger((String)entry.getValue())));
+                    }
+                }
+                notIsolatedLoggers = null;
+            }
+        }
+    }
+    
+    public IsolatedLog4JLogger(String name)
+    {
+        synchronized (IsolatedLog4JLogger.class)
+        {
+            if ( hierarchy == null )
+            {
+                // A LogFactory.getLog(name) is called before
+                // our ContextClassLoader Hierarchy could be set.
+                // Temporarily save this instance so it can be
+                // rerouted one the Hierarchy is set.
+                logger = new Log4JLogger(name);
+                notIsolatedLoggers.put(this,name);
+            }
+            else
+            {
+                logger = new Log4JLogger(hierarchy.getLogger(name));               
+            }
+        }
+    }
+    
+    private void setLogger(Log4JLogger logger)
+    {
+        this.logger = logger;
+    }
+
+    private Log4JLogger getLogger()
+    {
+        synchronized (IsolatedLog4JLogger.class)
+        {
+            return logger;
+        }
+    }
+
+    public void debug(Object arg0)
+    {
+        getLogger().debug(arg0);
+    }
+    public void debug(Object arg0, Throwable arg1)
+    {
+        getLogger().debug(arg0, arg1);
+    }
+    public boolean equals(Object obj)
+    {
+        return getLogger().equals(obj);
+    }
+    public void error(Object arg0)
+    {
+        getLogger().error(arg0);
+    }
+    public void error(Object arg0, Throwable arg1)
+    {
+        getLogger().error(arg0, arg1);
+    }
+    public void fatal(Object arg0)
+    {
+        getLogger().fatal(arg0);
+    }
+    public void fatal(Object arg0, Throwable arg1)
+    {
+        getLogger().fatal(arg0, arg1);
+    }
+    public void info(Object arg0)
+    {
+        getLogger().info(arg0);
+    }
+    public void info(Object arg0, Throwable arg1)
+    {
+        getLogger().info(arg0, arg1);
+    }
+    public boolean isDebugEnabled()
+    {
+        return getLogger().isDebugEnabled();
+    }
+    public boolean isErrorEnabled()
+    {
+        return getLogger().isErrorEnabled();
+    }
+    public boolean isFatalEnabled()
+    {
+        return getLogger().isFatalEnabled();
+    }
+    public boolean isInfoEnabled()
+    {
+        return getLogger().isInfoEnabled();
+    }
+    public boolean isTraceEnabled()
+    {
+        return getLogger().isTraceEnabled();
+    }
+    public boolean isWarnEnabled()
+    {
+        return getLogger().isWarnEnabled();
+    }
+    public String toString()
+    {
+        return getLogger().toString();
+    }
+    public void trace(Object arg0)
+    {
+        getLogger().trace(arg0);
+    }
+    public void trace(Object arg0, Throwable arg1)
+    {
+        getLogger().trace(arg0, arg1);
+    }
+    public void warn(Object arg0)
+    {
+        getLogger().warn(arg0);
+    }
+    public void warn(Object arg0, Throwable arg1)
+    {
+        getLogger().warn(arg0, arg1);
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/MimeType.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/MimeType.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/MimeType.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/MimeType.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.util;
+
+
+/**
+ *
+ * <p>Utility class for declaring MIME types to use for various requests and provide
+ * utility manipulation methods.</p>
+ * <p>Added Content-Encoding capability, with defaults
+ *
+ * @author <a href="mailto:raphael@apache.org">Rapha\u00ebl Luta</a>
+ * @author <a href="mailto:sgala@apache.org">Santiago Gala</a>
+ * @version $Id: MimeType.java 188405 2005-03-19 12:47:14Z sgala $
+ */
+public class MimeType
+{
+    
+    public static final MimeType HTML  = new MimeType("text/html", "UTF-8"); //FIXME: test
+    public static final MimeType XHTML = new MimeType("text/xhtml");
+    public static final MimeType WML   = new MimeType("text/vnd.wap.wml");
+    public static final MimeType XML   = new MimeType("text/xml");
+    public static final MimeType VXML  = new MimeType("text/vxml");
+    
+    /**
+     * Standard ContentType String, with no encoding appended.
+     */
+    private String mimeType = "";
+    /**
+     * null value means default encoding.
+     * Otherwise, charset to be used.
+     */
+    private String charSet = null;
+    
+    public MimeType(String mimeType)
+    {
+        if (mimeType == null)
+        {
+            throw new NullPointerException();
+        }
+        this.mimeType = mimeType;
+    }
+    
+    /**
+     *
+     */
+    public MimeType(String mimeType, String charSet)
+    {
+        if (mimeType == null)
+        {
+            throw new NullPointerException();
+        }
+        this.mimeType = mimeType;
+        this.charSet = charSet;
+    }
+    
+    /** Extracts from this MimeType a user-friendly identifying code
+     * ie "html" for "text/html" or "wml" for "text/vnd.wap.wml"
+     *
+     * @return the simplified type
+     */
+    public String getCode()
+    {
+        String type = this.mimeType;
+        // get everything after "/"
+        type = type.substring(type.indexOf("/") + 1);
+        // remove any dot in the name
+        int idx = type.lastIndexOf(".");
+        if (idx >= 0)
+        {
+            type = type.substring(idx + 1);
+        }
+        //remove anything before a "-"
+        idx = type.lastIndexOf("-");
+        if (idx >= 0)
+        {
+            type = type.substring(idx + 1);
+        }
+        
+        return type.toLowerCase();
+    }
+    
+    /**
+     * Return the media type associated
+     */
+    public String getContentType()
+    {
+        return this.mimeType;
+    }
+    
+    /**
+     * Return the character encoding associated, if any
+     */
+    public String getCharSet()
+    {
+        return this.charSet;
+    }
+    
+    /**
+     * Convert this MimeType to its external String representation
+     */
+    public String toString()
+    {
+        if (null == this.charSet)
+        {
+            return this.mimeType;
+        }
+        return this.mimeType + "; charset=" + this.charSet;
+    }
+    
+    /**
+     * Compare one MimeType to another
+     */
+    public boolean equals(Object obj)
+    {
+        if (this == obj)
+        {
+            return true;
+        }
+        
+        if (obj instanceof MimeType)
+        {
+            MimeType comp = (MimeType) obj;
+            return this.toString().equals(comp.toString());
+        }
+        else
+        {
+            return false;
+        }
+    }
+    
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/ExtendedPortletMetadata.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/ExtendedPortletMetadata.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/ExtendedPortletMetadata.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/ExtendedPortletMetadata.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.util.descriptor;
+
+import java.io.Reader;
+
+import org.apache.commons.digester.Digester;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+
+import org.apache.jetspeed.tools.pamanager.rules.JetspeedServicesRuleSet;
+import org.apache.jetspeed.tools.pamanager.rules.MetadataRuleSet;
+import org.apache.jetspeed.tools.pamanager.rules.PortletRule;
+import org.apache.jetspeed.tools.pamanager.rules.UserAttributeRefRuleSet;
+
+/**
+ * This class is used to load extended MetaData, like that of the Dublin Core, 
+ * into an exsting PortletApplicationDefinition's object graph.
+ * 
+ * @author <a href="mailto:jford@apache.org">Jeremy Ford </a>
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ * @version $Id: JetspeedDescriptorUtilities.java,v 1.10 2004/06/08 01:35:01
+ *                dlestrat Exp $
+ */
+public class ExtendedPortletMetadata
+{
+    protected final static Log log = LogFactory.getLog(ExtendedPortletMetadata.class);
+
+    protected Reader extendedMetaData;
+    protected MutablePortletApplication portletApp;
+    
+    /**
+     * 
+     * @param extendedMetaData Reader that contains the extended metadata, usually jetspeed-portlet.xml
+     * @param portletApp the MutablePortletApplication we are adding the extended metadata to.
+     */
+    public ExtendedPortletMetadata( Reader extendedMetaData, MutablePortletApplication portletApp )
+    {
+        this.extendedMetaData = extendedMetaData;
+        this.portletApp = portletApp;
+    }
+
+    /**
+     * Performs the actual loading and mapping of the metadata into the PortletApplicationDefinition.
+     * 
+     */
+    public void load() throws MetaDataException
+    {
+        boolean result = false;
+        try
+        {
+            Digester digester = new Digester();
+            digester.setClassLoader(this.getClass().getClassLoader());
+            digester.setValidating(false);
+            digester.setNamespaceAware(true);
+            digester.push(portletApp);
+
+            digester.addRuleSet(new MetadataRuleSet("portlet-app/"));
+            digester.addRuleSet(new JetspeedServicesRuleSet(portletApp));
+            
+            digester.addRule("portlet-app/portlet/portlet-name", new PortletRule(portletApp));
+            digester.addRuleSet(new MetadataRuleSet("portlet-app/portlet/"));
+
+            digester.addRuleSet(new UserAttributeRefRuleSet(portletApp));
+            
+            digester.parse(extendedMetaData);
+
+            result = true;
+        }
+        catch (Throwable t)
+        {
+            throw new MetaDataException("Unable to marshall extended metadata.  " + t.toString(), t);
+        }
+    }
+}
+

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/MetaDataException.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/MetaDataException.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/MetaDataException.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/MetaDataException.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.util.descriptor;
+
+import org.apache.jetspeed.exception.JetspeedException;
+
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+public class MetaDataException extends JetspeedException
+{
+
+    /**
+     * 
+     */
+    public MetaDataException()
+    {
+        super();
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param message
+     */
+    public MetaDataException( String message )
+    {
+        super(message);
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param nested
+     */
+    public MetaDataException( Throwable nested )
+    {
+        super(nested);
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param msg
+     * @param nested
+     */
+    public MetaDataException( String msg, Throwable nested )
+    {
+        super(msg, nested);
+        // TODO Auto-generated constructor stub
+    }
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationDescriptor.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationDescriptor.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationDescriptor.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationDescriptor.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,239 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.util.descriptor;
+
+import java.io.Reader;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.commons.digester.Digester;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.om.common.Support;
+import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
+import org.apache.jetspeed.om.impl.LanguageImpl;
+import org.apache.jetspeed.om.impl.ParameterDescriptionImpl;
+import org.apache.jetspeed.om.impl.PortletDescriptionImpl;
+import org.apache.jetspeed.om.impl.PortletDisplayNameImpl;
+import org.apache.jetspeed.om.impl.PortletInitParameterImpl;
+import org.apache.jetspeed.om.impl.SecurityRoleRefDescriptionImpl;
+import org.apache.jetspeed.om.impl.SecurityRoleRefImpl;
+import org.apache.jetspeed.om.impl.UserAttributeImpl;
+import org.apache.jetspeed.om.portlet.impl.ContentTypeImpl;
+import org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.apache.jetspeed.tools.pamanager.PortletApplicationException;
+import org.apache.pluto.om.common.SecurityRoleRef;
+import org.apache.pluto.om.common.SecurityRoleRefSet;
+import org.apache.pluto.om.common.SecurityRoleSet;
+import org.apache.pluto.om.portlet.PortletDefinition;
+
+/**
+ * 
+ * Object used to perform operation upon a portlet application descriptor,
+ * usually, portlet.xml.
+ *
+ * @author <a href="mailto:roger.ruttimann@earthlink.net">Roger Ruttimann</a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a> 
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ *  
+ * @version $Id: PortletApplicationDescriptor.java 193059 2005-06-23 03:04:20Z taylor $
+ */
+public class PortletApplicationDescriptor
+{
+    protected final static Log log = LogFactory.getLog(PortletApplicationDescriptor.class);
+    protected Reader portletXmlReader;
+    private String appName;
+
+   
+    public PortletApplicationDescriptor(Reader portletXmlReader, String appName)
+    {
+        this.portletXmlReader = portletXmlReader;
+        this.appName = appName;
+    }
+
+    public MutablePortletApplication createPortletApplication()
+    throws PortletApplicationException
+    {
+        return createPortletApplication(this.getClass().getClassLoader());
+    }
+    
+    /**
+     * Maps the content of the portlet application descriptor into
+     * a new <code>MutablePortletApplication object</code>
+     * 
+     * @return MutablePortletApplication newly created MutablePortletApplication with
+     * all values of the portlet application descriptor mapped into it.
+     */
+    public MutablePortletApplication createPortletApplication(ClassLoader classLoader)
+        throws PortletApplicationException
+    {
+        try
+        {
+            // TODO move config to digester-rules.xml. Example: http://www.onjava.com/pub/a/onjava/2002/10/23/digester.html?page=3
+            Digester digester = new Digester();
+            digester.setValidating(false);
+            digester.setClassLoader(this.getClass().getClassLoader());
+                       
+            // digester.addRuleSet(new PortletApplicationRuleSet(appName));
+            
+            digester.addRule("portlet-app", new PortletApplicationRule(appName));
+            digester.addSetProperties("portlet-app", "id", "applicationIdentifier");
+
+
+            digester.addRule("portlet-app/portlet", new PortletRule());
+            
+            digester.addSetProperties("portlet-app/portlet", "id", "portletIdentifier");
+            digester.addBeanPropertySetter("portlet-app/portlet/portlet-name", "name");
+            digester.addBeanPropertySetter("portlet-app/portlet/portlet-class", "className");
+            digester.addBeanPropertySetter("portlet-app/portlet/expiration-cache", "expirationCache");
+            digester.addBeanPropertySetter("portlet-app/portlet/resource-bundle", "resourceBundle");
+            digester.addCallMethod("portlet-app/portlet/supported-locale", "addSupportedLocale", 0);
+            
+            digester.addObjectCreate("portlet-app/portlet/display-name", PortletDisplayNameImpl.class);
+            digester.addSetProperties("portlet-app/portlet/display-name", "xml:lang", "language");
+            digester.addBeanPropertySetter("portlet-app/portlet/display-name", "displayName");
+            digester.addSetNext("portlet-app/portlet/display-name", "addDisplayName");
+
+            digester.addObjectCreate("portlet-app/portlet/description", PortletDescriptionImpl.class);
+            digester.addSetProperties("portlet-app/portlet/description", "xml:lang", "language");
+            digester.addBeanPropertySetter("portlet-app/portlet/description", "description");
+            digester.addSetNext("portlet-app/portlet/description", "addDescription");
+
+            digester.addObjectCreate("portlet-app/portlet/init-param", PortletInitParameterImpl.class);
+            digester.addBeanPropertySetter("portlet-app/portlet/init-param/name", "name");
+            digester.addBeanPropertySetter("portlet-app/portlet/init-param/value", "value");
+            digester.addSetNext("portlet-app/portlet/init-param", "addInitParameter");
+
+            digester.addObjectCreate("portlet-app/portlet/init-param/description", ParameterDescriptionImpl.class);
+            digester.addSetProperties("portlet-app/portlet/init-param/description", "xml:lang", "language");
+            digester.addBeanPropertySetter("portlet-app/portlet/init-param/description", "description");
+            digester.addSetNext("portlet-app/portlet/init-param/description", "addDescription");
+
+            digester.addObjectCreate("portlet-app/portlet/supports", ContentTypeImpl.class);
+            digester.addBeanPropertySetter("portlet-app/portlet/supports/mime-type", "contentType");
+            digester.addCallMethod("portlet-app/portlet/supports/portlet-mode", "addPortletMode", 0);
+            digester.addSetNext("portlet-app/portlet/supports", "addContentType");
+
+            digester.addObjectCreate("portlet-app/portlet/portlet-info", LanguageImpl.class);
+            digester.addBeanPropertySetter("portlet-app/portlet/portlet-info/title", "title");
+            digester.addBeanPropertySetter("portlet-app/portlet/portlet-info/short-title", "shortTitle");
+            digester.addCallMethod("portlet-app/portlet/portlet-info/keywords", "setKeywords", 0, new Class[]{String.class});
+            digester.addSetNext("portlet-app/portlet/portlet-info", "addLanguage");
+            
+            digester.addRuleSet(new PortletPreferenceRuleSet());
+
+            
+            digester.addObjectCreate("portlet-app/user-attribute", UserAttributeImpl.class);
+            digester.addBeanPropertySetter("portlet-app/user-attribute/description", "description");
+            digester.addBeanPropertySetter("portlet-app/user-attribute/name", "name");
+            digester.addSetNext("portlet-app/user-attribute", "addUserAttribute");
+            
+            digester.addObjectCreate("portlet-app/portlet/security-role-ref", SecurityRoleRefImpl.class);
+            digester.addBeanPropertySetter("portlet-app/portlet/security-role-ref/role-name", "roleName");
+            digester.addBeanPropertySetter("portlet-app/portlet/security-role-ref/role-link", "roleLink");
+            digester.addSetNext("portlet-app/portlet/security-role-ref", "addSecurityRoleRef");
+
+            digester.addObjectCreate("portlet-app/portlet/security-role-ref/description", SecurityRoleRefDescriptionImpl.class);
+            digester.addSetProperties("portlet-app/portlet/security-role-ref/description", "xml:lang", "language");
+            digester.addBeanPropertySetter("portlet-app/portlet/security-role-ref/description", "description");
+            digester.addSetNext("portlet-app/portlet/security-role-ref/description", "addDescription");
+            
+            PortletApplicationDefinitionImpl pd = (PortletApplicationDefinitionImpl) digester.parse(portletXmlReader);
+
+           
+            if(pd.getApplicationIdentifier() == null)
+            {
+                pd.setApplicationIdentifier(appName);
+            }
+            
+            Iterator portletDefs = pd.getPortletDefinitions().iterator();
+            while(portletDefs.hasNext())
+            {
+                Object obj = portletDefs.next();
+                PortletDefinitionComposite portletDef = (PortletDefinitionComposite) obj;
+                if(portletDef.getPortletIdentifier() == null)
+                {
+                    portletDef.setPortletIdentifier(portletDef.getName());
+                }
+                
+                ((Support)obj).postLoad(classLoader);
+            }
+            
+            return pd;
+
+        }
+        catch (Throwable t)
+        {
+            t.printStackTrace();
+            String msg = "Could not unmarshal portlet.xml. " + t.toString();
+            log.error(msg, t);
+            throw new PortletApplicationException(msg, t);
+        }
+    }
+    
+
+
+    /**
+     * Validate a PortletApplicationDefinition tree AFTER its
+     * WebApplicationDefinition has been loaded. Currently, only the security
+     * role references of the portlet definitions are validated:
+     * <ul>
+     * <li>A security role reference should reference a security role through a
+     * roleLink. A warning message is logged if a direct reference is used.
+     * <li>For a security role reference a security role must be defined in the
+     * web application. An error message is logged and a
+     * PortletApplicationException is thrown if not.
+     * </ul>
+     * 
+     * @param app
+     *            The PortletApplicationDefinition to validate
+     * @throws PortletApplicationException
+     */
+    public void validate(MutablePortletApplication app)
+            throws PortletApplicationException
+    {
+        SecurityRoleSet roles = app.getWebApplicationDefinition()
+                .getSecurityRoles();
+        Collection portlets = app.getPortletDefinitions();
+        Iterator portletIterator = portlets.iterator();
+        while (portletIterator.hasNext())
+        {
+            PortletDefinition portlet = (PortletDefinition) portletIterator
+                    .next();
+            SecurityRoleRefSet securityRoleRefs = portlet
+                    .getInitSecurityRoleRefSet();
+            Iterator roleRefsIterator = securityRoleRefs.iterator();
+            while (roleRefsIterator.hasNext())
+            {
+                SecurityRoleRef roleRef = (SecurityRoleRef) roleRefsIterator
+                        .next();
+                String roleName = roleRef.getRoleLink();
+                if (roleName == null || roleName.length() == 0)
+                {
+                    roleName = roleRef.getRoleName();
+                }
+                if (roles.get(roleName) == null)
+                {
+                    String errorMsg = "Undefined security role " + roleName
+                            + " referenced from portlet " + portlet.getName();
+                    log.error(errorMsg);
+                    throw new PortletApplicationException(errorMsg);
+                }
+            }
+        }
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationRule.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationRule.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationRule.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationRule.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.util.descriptor;
+
+import org.apache.commons.digester.Rule;
+import org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.xml.sax.Attributes;
+
+/**
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ */
+public class PortletApplicationRule extends Rule
+{
+    protected String appName;
+    
+    public PortletApplicationRule(String appName)
+    {
+        this.appName = appName;
+    }
+
+
+    /**
+     * <p>
+     * begin
+     * </p>
+     *
+     * @see org.apache.commons.digester.Rule#begin(java.lang.String, java.lang.String, org.xml.sax.Attributes)
+     * @param arg0
+     * @param arg1
+     * @param arg2
+     * @throws java.lang.Exception
+     */
+    public void begin( String arg0, String arg1, Attributes arg2 ) throws Exception
+    {
+        PortletApplicationDefinitionImpl app = new PortletApplicationDefinitionImpl();
+        app.setName(appName);
+        digester.push(app);        
+    }
+    
+    
+    /**
+     * <p>
+     * end
+     * </p>
+     *
+     * @see org.apache.commons.digester.Rule#end(java.lang.String, java.lang.String)
+     * @param arg0
+     * @param arg1
+     * @throws java.lang.Exception
+     */
+    public void end( String arg0, String arg1 ) throws Exception
+    {
+       // digester.pop();
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationRuleSet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationRuleSet.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationRuleSet.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationRuleSet.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.util.descriptor;
+
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.RuleSetBase;
+
+/**
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ */
+public class PortletApplicationRuleSet extends RuleSetBase
+{
+    protected String appName;
+    
+    public PortletApplicationRuleSet(String appName)
+    {
+        this.appName = appName;
+    }
+
+    /**
+     * <p>
+     * addRuleInstances
+     * </p>
+     *
+     * @see org.apache.commons.digester.RuleSet#addRuleInstances(org.apache.commons.digester.Digester)
+     * @param arg0
+     */
+    public void addRuleInstances( Digester digester )
+    {
+        digester.addRule("portlet-app", new PortletApplicationRule(appName));
+        digester.addSetProperties("portlet-app", "id", "applicationIdentifier");
+    }
+
+}



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