portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r708719 - in /portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade: components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/registration/ compo...
Date Tue, 28 Oct 2008 23:15:58 GMT
Author: taylor
Date: Tue Oct 28 16:15:57 2008
New Revision: 708719

URL: http://svn.apache.org/viewvc?rev=708719&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-871
upgrading portlet/web descriptor processing

Removed:
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/registration/RegistrationTool.java
Modified:
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/VersionedPortletApplicationManager.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorServiceImpl.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorService.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/alternate/versioned-deployment/deployment.xml
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/deployment.xml

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java?rev=708719&r1=708718&r2=708719&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
Tue Oct 28 16:15:57 2008
@@ -30,10 +30,13 @@
 import org.apache.jetspeed.components.portletentity.PortletEntityNotDeletedException;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.components.portletregistry.RegistryException;
+import org.apache.jetspeed.container.PortletEntity;
 import org.apache.jetspeed.container.window.PortletWindowAccessor;
+import org.apache.jetspeed.descriptor.ExtendedDescriptorService;
 import org.apache.jetspeed.factory.PortletFactory;
-import org.apache.jetspeed.om.servlet.WebApplicationDefinition;
 import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.om.servlet.WebApplicationDefinition;
 import org.apache.jetspeed.search.SearchEngine;
 import org.apache.jetspeed.security.JetspeedPermission;
 import org.apache.jetspeed.security.PermissionManager;
@@ -44,9 +47,6 @@
 import org.apache.jetspeed.util.FileSystemHelper;
 import org.apache.jetspeed.util.MultiFileChecksumHelper;
 import org.apache.jetspeed.util.descriptor.PortletApplicationWar;
-import org.apache.jetspeed.container.PortletEntity;
-import org.apache.jetspeed.om.portlet.PortletDefinition;
-import org.apache.pluto.spi.optional.PortletAppDescriptorService;
 
 /**
  * PortletApplicationManager
@@ -79,7 +79,7 @@
     protected boolean started;
     protected String appRoot;
     protected NodeManager nodeManager;
-    protected PortletAppDescriptorService descriptorService;
+    protected ExtendedDescriptorService descriptorService;
     
     /**
 	 * Creates a new PortletApplicationManager object.
@@ -88,7 +88,7 @@
 		PortletEntityAccessComponent entityAccess, PortletWindowAccessor windowAccess,
         PermissionManager permissionManager, SearchEngine searchEngine,
         RoleManager roleManager, List<String> permissionRoles, NodeManager nodeManager,
String appRoot,
-        PortletAppDescriptorService descriptorService)
+        ExtendedDescriptorService descriptorService)
 	{
 		this.portletFactory     = portletFactory;
 		this.registry		    = registry;
@@ -300,12 +300,9 @@
 		try
 		{
             // load the web.xml
-            log.info("Loading web.xml...." + paName);
-            WebApplicationDefinition wa = paWar.createWebApp();
-            paWar.validate();
-
-			log.info("Loading portlet.xml...." + paName);
-			pa = paWar.createPortletApp(paClassLoader, wa, paType);
+            log.info("Loading portlet.xml and web.xml...." + paName);
+			pa = paWar.createPortletApp(paClassLoader);
+			WebApplicationDefinition wa = paWar.getWebApp();
 			if (revision > 0)
 			{
 			    pa.setRevision(revision);
@@ -639,20 +636,6 @@
             }
             throw new RegistryException(msg);
         }
-		finally
-		{
-			if (paWar != null)
-			{
-				try
-				{
-					paWar.close();
-				}
-				catch (IOException e)
-				{
-				    log.error("Failed to close PA WAR for " + contextName, e);
-				}
-			}
-		}
 	}
 
 	protected void stopPA(String contextName, int paType)

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/VersionedPortletApplicationManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/VersionedPortletApplicationManager.java?rev=708719&r1=708718&r2=708719&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/VersionedPortletApplicationManager.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/VersionedPortletApplicationManager.java
Tue Oct 28 16:15:57 2008
@@ -27,6 +27,7 @@
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.components.portletregistry.RegistryException;
 import org.apache.jetspeed.container.window.PortletWindowAccessor;
+import org.apache.jetspeed.descriptor.ExtendedDescriptorService;
 import org.apache.jetspeed.factory.PortletFactory;
 import org.apache.jetspeed.om.portlet.LocalizedField;
 import org.apache.jetspeed.om.portlet.PortletApplication;
@@ -62,10 +63,10 @@
     public VersionedPortletApplicationManager(PortletFactory portletFactory, PortletRegistry
registry, 
             PortletEntityAccessComponent entityAccess, PortletWindowAccessor windowAccess,
             PermissionManager permissionManager, SearchEngine searchEngine,  RoleManager
roleManager,
-            List permissionRoles, /* node manager, */ String appRoot)
+            List<String> permissionRoles, /* node manager, */ String appRoot, ExtendedDescriptorService
descriptorService)
     {
         super(portletFactory, registry, entityAccess, windowAccess, permissionManager, 
-                searchEngine, roleManager, permissionRoles, null, appRoot); 
+                searchEngine, roleManager, permissionRoles, null, appRoot, descriptorService);

                
     }
     
@@ -92,7 +93,7 @@
         PortletApplicationWar paWar = null;
         try
         {
-            paWar = new PortletApplicationWar(warStruct, contextName, contextPath, checksum);
+            paWar = new PortletApplicationWar(warStruct, contextName, contextPath, checksum,
this.descriptorService);
             try
             {
                 if (paClassLoader == null)
@@ -112,7 +113,7 @@
                 //register = false;
             }
             
-            PortletApplication regPA = registry.getPortletApplication(contextName);
+            PortletApplication regPA = registry.getPortletApplication(contextName); 
             PortletApplication newPA = paWar.createPortletApp();
             if (regPA == null)
             {

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java?rev=708719&r1=708718&r2=708719&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-portal/src/main/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java
Tue Oct 28 16:15:57 2008
@@ -16,47 +16,32 @@
  */
 package org.apache.jetspeed.util.descriptor;
 
-import java.io.BufferedInputStream;
 import java.io.File;
-import java.io.FileFilter;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.descriptor.ExtendedDescriptorService;
 import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
 import org.apache.jetspeed.om.servlet.WebApplicationDefinition;
-import org.apache.jetspeed.tools.deploy.JetspeedWebApplicationRewriter;
-import org.apache.jetspeed.tools.deploy.JetspeedWebApplicationRewriterFactory;
 import org.apache.jetspeed.tools.pamanager.PortletApplicationException;
 import org.apache.jetspeed.util.DirectoryHelper;
 import org.apache.jetspeed.util.FileSystemHelper;
 import org.apache.jetspeed.util.MultiFileChecksumHelper;
 import org.apache.pluto.om.portlet.SecurityRoleRef;
-import org.apache.pluto.om.portlet.PortletDefinition;
-import org.apache.pluto.spi.optional.PortletAppDescriptorService;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
 
 /**
  * <p>
@@ -97,10 +82,10 @@
     protected String paName;
     protected String webAppContextRoot;
     protected FileSystemHelper warStruct;
+    
     private WebApplicationDefinition webApp;
     private PortletApplication portletApp;
     private long paChecksum;
-    protected final List openedResources;
     protected ExtendedDescriptorService descriptorService;
 
     protected static final String[] ELEMENTS_BEFORE_SERVLET = new String[]{"icon", "display-name",
"description",
@@ -130,7 +115,6 @@
 
         this.paName = paName;
         this.webAppContextRoot = webAppContextRoot;
-        this.openedResources = new ArrayList();
         this.warStruct = warStruct;
         this.paChecksum = paChecksum;
         this.descriptorService = descriptorService;
@@ -184,21 +168,28 @@
      */
     public WebApplicationDefinition createWebApp() throws PortletApplicationException, IOException
     {
-        Reader webXmlReader = getReader(WEB_XML_PATH);
+        InputStream stream = getInputStream(WEB_XML_PATH);
         try
         {
-            WebApplicationDescriptor webAppDescriptor = new WebApplicationDescriptor(webXmlReader,
webAppContextRoot);
-            webApp = webAppDescriptor.createWebApplication();
-            return webApp;
+//            WebApplicationDescriptor webAppDescriptor = new WebApplica dtionDescriptor(webXmlReader,
webAppContextRoot);
+//            webApp = webAppDescriptor.createWebApplication();
+//            return webApp;
+//            JetspeedWebApplicationRewriterFactory rewriterFactory = new JetspeedWebApplicationRewriterFactory();
+//            JetspeedWebApplicationRewriter rewriter = rewriterFactory.getInstance(doc);
+//            rewriter.getSecurityRoles();
+            return descriptorService.readServletDescriptor(stream);
+        }
+        catch (Exception e)
+        {
+            throw new PortletApplicationException("Failed to read web.xml descriptor: " +
e);
         }
-
         finally
         {
             try
             {
-                if (webXmlReader != null)
+                if (stream != null)
                 {
-                    webXmlReader.close();
+                    stream.close();
                 }
             }
             catch (IOException e1)
@@ -206,6 +197,7 @@
                 e1.printStackTrace();
             }
         }
+        
 
     }
 
@@ -222,47 +214,27 @@
      * @throws IOException
      * @see org.apache.jetspeed.uitl.descriptor.PortletApplicationDescriptor
      */
-    public PortletApplication createPortletApp(ClassLoader classLoader, WebApplicationDefinition
wa, int paType) throws PortletApplicationException, IOException
+    public PortletApplication createPortletApp(ClassLoader classLoader) throws PortletApplicationException,
IOException
     {
-        InputStream portletXmlStream = getInputStream(PORTLET_XML_PATH);        
+        InputStream portletXmlStream = getInputStream(PORTLET_XML_PATH);
+        InputStream extStream = null;
         try
         {
-            PortletApplication pa = this.descriptorService.read(portletXmlStream);
-//            PortletApplicationDescriptor paDescriptor = new PortletApplicationDescriptor(portletXmlReader,
paName);
-//            portletApp = paDescriptor.createPortletApplication(classLoader);
-            // validate(portletApplication);
-            Reader extMetaDataXml = null;
-            try
-            {
-                extMetaDataXml = getReader(EXTENDED_PORTLET_XML_PATH);
-                if (extMetaDataXml != null)
-                {
-                    ExtendedPortletMetadata extMetaData = new ExtendedPortletMetadata(extMetaDataXml,
portletApp);
-                    extMetaData.load();
-                }
-            }
-            catch (IOException e)
-            {
-                if ( e instanceof FileNotFoundException )
-                {
-                    log.info("No extended metadata found.");
-                }
-                else
-                {
-                    throw new PortletApplicationException("Failed to load existing metadata.",e);
-                }
-            }
-            catch (MetaDataException e)
-            {
-                throw new PortletApplicationException("Failed to load existing metadata.",
e);
-            }
-            finally
+            extStream = getInputStream(EXTENDED_PORTLET_XML_PATH);
+        }
+        catch (FileNotFoundException e)
+        {
+            // no problem, file doesn't exist
+        }
+        try
+        {
+            portletApp = descriptorService.read(portletXmlStream);
+            if (extStream != null)
             {
-                if (null != extMetaDataXml)
-                {
-                    extMetaDataXml.close();
-                }
+                descriptorService.readExtended(extStream, portletApp);
             }
+            webApp = createWebApp();
+            validate();
             portletApp.setChecksum(paChecksum);
             return portletApp;
         }
@@ -272,6 +244,10 @@
             {
                 portletXmlStream.close();
             }
+            if (null != extStream)
+            {
+                extStream.close();
+            }            
         }
     }
 
@@ -281,62 +257,7 @@
         return createPortletApp(this.getClass().getClassLoader());
     }
     
-    /**
-     * 
-     * <p>
-     * getReader
-     * </p>
-     * Returns a <code>java.io.Reader</code> to a resource within this WAR's
-     * structure.
-     * 
-     * @param path
-     *            realtive to an object within this WAR's file structure
-     * @return java.io.Reader to the file within the WAR
-     * @throws IOException
-     *             if the path does not exist or there was a problem reading the
-     *             WAR.
-     *  
-     */
-    protected Reader getReader( String path ) throws IOException
-    {
-        BufferedInputStream is = new BufferedInputStream(getInputStream(path));
-
-        String enc = "UTF-8";
-        try
-        {
-            is.mark(MAX_BUFFER_SIZE);
-            byte[] buf = new byte[MAX_BUFFER_SIZE];
-            int size = is.read(buf, 0, MAX_BUFFER_SIZE);
-            if (size > 0)
-            {
-                String key = "encoding=\"";
-                String data = new String(buf, 0, size, "US-ASCII");
-                int lb = data.indexOf("\n");
-                if (lb > 0)
-                {
-                    data = data.substring(0, lb);
-                }
-                int off = data.indexOf(key);
-                if (off > 0)
-                {
-                    enc = data.substring(off + key.length(), data.indexOf('"', off + key.length()));
-                }
-            }
-        }
-        catch (UnsupportedEncodingException e)
-        {
-            log.warn("Unsupported encoding.", e);
-        }
-        catch (IOException e)
-        {
-            log.warn("Unsupported encoding.", e);
-        }
-
-        //Reset the bytes read
-        is.reset();
-        return new InputStreamReader(is, enc);
-    }
-
+   
     /**
      * 
      * <p>
@@ -362,7 +283,6 @@
         }
 
         FileInputStream fileInputStream = new FileInputStream(child);
-        openedResources.add(fileInputStream);
         return fileInputStream;
     }
 
@@ -390,7 +310,6 @@
             throw new FileNotFoundException("Unable to locate file or path " + child);
         }
         FileOutputStream fileOutputStream = new FileOutputStream(child);
-        openedResources.add(fileOutputStream);
         return fileOutputStream;
     }
 
@@ -483,23 +402,18 @@
                     "createWebApp() and createPortletApp() must be called before invoking
validate()");
         }
 
-        SecurityRoleSet roles = webApp.getSecurityRoles();
-        Collection portlets = portletApp.getPortletDefinitions();
-        Iterator portletIterator = portlets.iterator();
-        while (portletIterator.hasNext())
-        {
-            PortletDefinition portlet = (PortletDefinition) portletIterator.next();
-            SecurityRoleRefSet securityRoleRefs = portlet.getInitSecurityRoleRefSet();
-            Iterator roleRefsIterator = securityRoleRefs.iterator();
-            while (roleRefsIterator.hasNext())
+        List<String> roles = webApp.getRoles();
+        List<PortletDefinition> portlets = portletApp.getPortlets();
+        for (PortletDefinition portlet : portlets)
+        {
+            for (SecurityRoleRef roleRef : portlet.getSecurityRoleRefs())
             {
-                SecurityRoleRef roleRef = (SecurityRoleRef) roleRefsIterator.next();
                 String roleName = roleRef.getRoleLink();
                 if (roleName == null || roleName.length() == 0)
                 {
                     roleName = roleRef.getRoleName();
                 }
-                if (roles.get(roleName) == null)
+                if (roles.contains(roleName) == false)
                 {
                     String errorMsg = "Undefined security role " + roleName + " referenced
from portlet "
                             + portlet.getPortletName();
@@ -509,172 +423,6 @@
         }
     }
 
-    /**
-     * 
-     * <p>
-     * processWebXML
-     * </p>
-     * 
-     * Infuses this PortletApplicationWar's web.xml file with
-     * <code>servlet</code> and a <code>servlet-mapping</code> element
for
-     * the JetspeedContainer servlet. This is only done if the descriptor does
-     * not already contain these items.
-     * 
-     * @throws MetaDataException
-     *             if there is a problem infusing
-     */
-    public void processWebXML() throws MetaDataException
-    {
-        SAXBuilder builder = new SAXBuilder();
-        Writer webXmlWriter = null;
-        InputStream webXmlIn = null;
-
-        try
-        {
-            // Use the local dtd instead of remote dtd. This
-            // allows to deploy the application offline
-            builder.setEntityResolver(new EntityResolver()
-            {
-                public InputSource resolveEntity( java.lang.String publicId, java.lang.String
systemId )
-                        throws SAXException, java.io.IOException
-                {
-
-                    if (systemId.equals("http://java.sun.com/dtd/web-app_2_3.dtd"))
-                    {
-                        return new InputSource(getClass().getResourceAsStream("web-app_2_3.dtd"));
-                    }
-                    else return null;
-                }
-            });
-
-            Document doc = null;
-            
-            try
-            {
-                webXmlIn = getInputStream(WEB_XML_PATH);
-                doc = builder.build(webXmlIn);
-            }
-            catch (FileNotFoundException fnfe)
-            {
-                // web.xml does not exist, create it
-                File file = File.createTempFile("j2-temp-", ".xml");
-                FileWriter writer = new FileWriter(file);
-                writer.write(WEB_XML_STRING);
-                writer.close();
-                doc = builder.build(file);
-                file.delete();
-            }
-            
-            
-            if (webXmlIn != null)
-            {
-                webXmlIn.close();
-            }
-
-            JetspeedWebApplicationRewriterFactory rewriterFactory = new JetspeedWebApplicationRewriterFactory();
-            JetspeedWebApplicationRewriter rewriter = rewriterFactory.getInstance(doc);
-            rewriter.processWebXML();
-            
-            if (rewriter.isChanged())
-            {
-                System.out.println("Writing out infused web.xml for " + paName);
-                XMLOutputter output = new XMLOutputter(Format.getPrettyFormat());
-                webXmlWriter = getWriter(WEB_XML_PATH);
-                output.output(doc, webXmlWriter);
-                webXmlWriter.flush();
-
-            }
-            
-            if(rewriter.isPortletTaglibAdded())
-            {
-                //add portlet tag lib to war
-                String path = Jetspeed.getRealPath("WEB-INF/tld");
-                if (path != null)
-                {
-                    File portletTaglibDir = new File(path);
-                    File child = new File(warStruct.getRootDirectory(), "WEB-INF/tld");
-                    DirectoryHelper dh = new DirectoryHelper(child);
-                    dh.copyFrom(portletTaglibDir, new FileFilter(){
-
-                        public boolean accept(File pathname)
-                        {
-                            return pathname.getName().indexOf("portlet.tld") != -1;
-                        }                    
-                    });                
-                    dh.close();
-                }
-            }
-
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-            throw new MetaDataException("Unable to process web.xml for infusion " + e.toString(),
e);
-        }
-        finally
-        {
-            if (webXmlWriter != null)
-            {
-                try
-                {
-                    webXmlWriter.close();
-                }
-                catch (IOException e1)
-                {
-
-                }
-            }
-
-            if (webXmlIn != null)
-            {
-                try
-                {
-                    webXmlIn.close();
-                }
-                catch (IOException e1)
-                {
-
-                }
-            }
-        }
-
-    }
-
-
-    /**
-     * 
-     * <p>
-     * close
-     * </p>
-     * Closes any resource this PortletApplicationWar may have opened.
-     * 
-     * @throws IOException
-     */
-    public void close() throws IOException
-    {
-
-        Iterator resources = openedResources.iterator();
-        while (resources.hasNext())
-        {
-            try
-            {
-                Object res = resources.next();
-                if (res instanceof InputStream)
-                {
-                    ((InputStream) res).close();
-                }
-                else if (res instanceof OutputStream)
-                {
-                    ((OutputStream) res).close();
-                }
-            }
-            catch (Exception e)
-            {
-
-            }
-        }
-
-    }
 
     /**
      * 
@@ -695,7 +443,7 @@
      */
     public ClassLoader createClassloader( ClassLoader parent ) throws IOException
     {
-        ArrayList urls = new ArrayList();
+        ArrayList<URL> urls = new ArrayList<URL>();
         File webInfClasses = null;
 
         webInfClasses = new File(warStruct.getRootDirectory(), ("WEB-INF/classes/"));
@@ -755,4 +503,16 @@
     {
         return warStruct;
     }
+
+    public WebApplicationDefinition getWebApp()
+    {
+        return webApp;
+    }
+
+    
+    public PortletApplication getPortletApp()
+    {
+        return portletApp;
+    }
+
 }

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorServiceImpl.java?rev=708719&r1=708718&r2=708719&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorServiceImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorServiceImpl.java
Tue Oct 28 16:15:57 2008
@@ -20,7 +20,12 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
 import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
 
 import org.apache.jetspeed.om.portlet.ContainerRuntimeOption;
 import org.apache.jetspeed.om.portlet.DisplayName;
@@ -36,12 +41,25 @@
 import org.apache.jetspeed.om.portlet.SecurityRoleRef;
 import org.apache.jetspeed.om.portlet.Supports;
 import org.apache.jetspeed.om.portlet.UserAttribute;
+import org.apache.jetspeed.om.portlet.UserAttributeRef;
 import org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl;
+import org.apache.jetspeed.om.portlet.jetspeed.jaxb.MetadataType;
+import org.apache.jetspeed.om.portlet.jetspeed.jaxb.Portlet;
+import org.apache.jetspeed.om.portlet.jetspeed.jaxb.PortletApp;
+import org.apache.jetspeed.om.portlet.jetspeed.jaxb.Service;
+import org.apache.jetspeed.om.servlet.WebApplicationDefinition;
+import org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl;
+import org.apache.jetspeed.tools.deploy.JetspeedWebApplicationRewriter;
+import org.apache.jetspeed.tools.deploy.JetspeedWebApplicationRewriterFactory;
 import org.apache.pluto.descriptors.services.jaxb.PortletAppDescriptorServiceImpl;
 import org.apache.pluto.om.portlet.CustomPortletMode;
 import org.apache.pluto.om.portlet.CustomWindowState;
 import org.apache.pluto.om.portlet.Description;
 import org.apache.pluto.om.portlet.PortletApplicationDefinition;
+import org.w3c.dom.Document;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 /**
  * Extends Pluto Descriptor service for loading portlet applications in a Jetspeed format.
@@ -320,5 +338,126 @@
                 jsupports.addWindowState(ws);
             }
         }
-    }    
+    }
+    
+    public void readExtended(InputStream in, PortletApplication app) throws IOException
+    {
+        try
+        {
+            JAXBContext jc = JAXBContext
+                    .newInstance("org.apache.jetspeed.om.portlet.jetspeed.jaxb");
+            Unmarshaller u = jc.createUnmarshaller();
+            PortletApp pa = (PortletApp) u.unmarshal(in);
+            app.setJetspeedSecurityConstraint(pa.getSecurityConstraintRef());
+            for (Service s : pa.getServices())
+            {
+                app.addJetspeedServiceReference(s.getName());
+            }
+            for (MetadataType m : pa.getMetadata())
+            {
+                // TODO: 2.2 metadata
+                // ??? app.getMetadata().addField(locale, name, value);
+                System.out.println("metadata: " + m.getMetadataName());
+                System.out.println("    lang: " + m.getLang());
+                System.out.println("   value: " + m.getContent());
+            }
+            for (Portlet p : pa.getPortlets())
+            {
+                PortletDefinition pd = app.getPortlet(p.getPortletName());
+                if (pd != null)
+                {
+                    pd.setJetspeedSecurityConstraint(p.getSecurityConstraintRef());
+                    for (MetadataType m : p.getMetadata())
+                    {
+                        // TODO: 2.2 metadata 
+                        System.out.println("  metadata: " + m.getMetadataName());
+                        System.out.println("      lang: " + m.getLang());
+                        System.out.println("     value: " + m.getContent());
+                    }
+                }
+            }
+            
+            for (org.apache.jetspeed.om.portlet.jetspeed.jaxb.CustomPortletMode cpm : pa.getCustomPortletModes())
+            {
+                // TODO: 2.2
+//                System.out.println("  cpm name: " + cpm.getName());
+//                System.out.println("    mapped: " + cpm.getMappedName());
+//                System.out.println("      desc: " + cpm.getDescription());
+            }
+            for (org.apache.jetspeed.om.portlet.jetspeed.jaxb.CustomWindowState cws : pa.getCustomWindowStates())
+            {
+                // TODO: 2.2
+//                System.out.println("  cws name: " + cws.getName());
+//                System.out.println("    mapped: " + cws.getMappedName());
+//                System.out.println("      desc: " + cws.getDescription());
+            }
+            for (org.apache.jetspeed.om.portlet.jetspeed.jaxb.UserAttributeRef ref : pa.getUserAttributeRefs())
+            {
+                UserAttributeRef jref = app.addUserAttributeRef(ref.getName());
+                jref.setNameLink(ref.getNameLink());
+                Description desc = jref.addDescription(ref.getDescription());
+                // TODO: 2.2 desscription processing
+            }
+            
+        }
+        catch (JAXBException je)
+        {
+            throw new IOException(je.getMessage());
+        }
+    }
+        
+    public WebApplicationDefinition readServletDescriptor(InputStream is) throws IOException
+    {
+        Document doc = this.parseXml(is);        
+        JetspeedWebApplicationRewriterFactory rewriterFactory = new JetspeedWebApplicationRewriterFactory();
       
+        try
+        {
+            JetspeedWebApplicationRewriter rewriter = rewriterFactory.getInstance(doc);
+            // TODO: 2.2 implement this, get the security roles
+//          digester.addCallMethod("web-app/security-role", "addRole", 0);
+//          digester.addBeanPropertySetter("web-app/security-role/description", "description");
+//          digester.addBeanPropertySetter("web-app/security-role/role-name", "roleName");
+            WebApplicationDefinition webapp = new WebApplicationDefinitionImpl();
+//          webapp.setContextRoot(contextRoot);
+//          webapp.setDescription(contextRoot);            
+            return webapp;
+        }
+        catch (Exception e)
+        {
+            throw new IOException(e.getMessage());
+        }
+    }
+    
+    protected Document parseXml(InputStream source) throws IOException
+    {
+        try
+        {
+            DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
+            domFactory.setNamespaceAware(true); 
+            DocumentBuilder builder = domFactory.newDocumentBuilder();
+            builder.setEntityResolver(new EntityResolver()
+            {
+                public InputSource resolveEntity(java.lang.String publicId, java.lang.String
systemId) throws SAXException,
+                                java.io.IOException
+                {
+                    if (systemId.equals("http://java.sun.com/dtd/web-app_2_3.dtd"))
+                    {
+                        return new InputSource(getClass().getResourceAsStream("web-app_2_3.dtd"));
+                    }
+                    if (systemId.equals("http://java.sun.com/dtd/web-app_2_4.dtd"))
+                    {
+                        return new InputSource(getClass().getResourceAsStream("web-app_2_4.dtd"));
+                    }
+                    return null;
+                }
+            });
+            Document document = builder.parse(source);
+            return document;
+        }
+        catch (Exception e)
+        {
+            throw new IOException(e.toString());
+        }
+    }
+        
 }

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java?rev=708719&r1=708718&r2=708719&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java
Tue Oct 28 16:15:57 2008
@@ -76,7 +76,7 @@
     private transient WebApplicationDefinition webApplication;
     
     /** Metadata property */
-    private Collection metadataFields = null;
+    private Collection<GenericMetadata> metadataFields = null;
     
     /** Description */
     private String description;
@@ -233,7 +233,7 @@
     {
         if(metadataFields == null)
         {
-            metadataFields = new ArrayList();
+            metadataFields = new ArrayList<GenericMetadata>();
         }
         
         GenericMetadata metadata = new PortletApplicationMetadataImpl();
@@ -345,7 +345,7 @@
         PublicRenderParameterImpl p = new PublicRenderParameterImpl();
         p.setName(name);
         p.setIdentifier(identifier);
-        publicRenderParameters.add(p);
+        getPublicRenderParameters().add(p);
         return p;        
     }
 
@@ -359,7 +359,7 @@
         PublicRenderParameterImpl p = new PublicRenderParameterImpl();
         p.setQName(qname);
         p.setIdentifier(identifier);
-        publicRenderParameters.add(p);
+        getPublicRenderParameters().add(p);
         return p;        
     }
 
@@ -413,7 +413,7 @@
         
         CustomPortletModeImpl cpm = new CustomPortletModeImpl();
         cpm.setPortletMode(name);
-        customPortletModes.add(cpm);
+        getCustomPortletModes().add(cpm);
         return cpm;        
     }
 
@@ -467,7 +467,7 @@
         
         CustomWindowStateImpl cws = new CustomWindowStateImpl();
         cws.setWindowState(name);
-        customWindowStates.add(cws);
+        getCustomWindowStates().add(cws);
         return cws;        
     }
 
@@ -570,7 +570,7 @@
         }
         UserAttributeImpl ua = new UserAttributeImpl();
         ua.setName(name);
-        userAttributes.add(ua);
+        getUserAttributes().add(ua);
         return ua;        
     }
 
@@ -603,7 +603,7 @@
         }
         UserAttributeRefImpl uar = new UserAttributeRefImpl();
         uar.setName(name);
-        userAttributeRefs.add(uar);
+        getUserAttributeRefs().add(uar);
         return uar;        
     }
 
@@ -621,7 +621,7 @@
         SecurityConstraintImpl sc = new SecurityConstraintImpl();
         ((UserDataConstraintImpl)sc.getUserDataConstraint()).setTransportGuarantee(transportGuarantee);
         getSecurityConstraints();
-        securityConstraints.add(sc);
+        getSecurityConstraints().add(sc);
         return sc;        
     }
 
@@ -654,7 +654,7 @@
         }
         FilterImpl f = new FilterImpl();
         f.setFilterName(name);
-        filters.add(f);
+        getFilters().add(f);
         return f;        
     }
 
@@ -687,7 +687,7 @@
         }
         FilterMappingImpl fm = new FilterMappingImpl();
         fm.setFilterName(name);
-        filterMappings.add(fm);
+        getFilterMappings().add(fm);
         return fm;        
     }
 
@@ -711,7 +711,7 @@
         }
         ListenerImpl l = new ListenerImpl();
         l.setListenerClass(listenerClass);
-        listeners.add(l);
+        getListeners().add(l);
         return l;        
     }
 
@@ -744,7 +744,7 @@
         }
         ContainerRuntimeOptionImpl cro = new ContainerRuntimeOptionImpl();
         cro.setName(name);
-        containerRuntimeOptions.add(cro);
+        getContainerRuntimeOptions().add(cro);
         return cro;        
     }
 
@@ -768,7 +768,7 @@
         }
         JetspeedServiceReferenceImpl ref = new JetspeedServiceReferenceImpl();
         ref.setName(name);
-        services.add(ref);
+        getJetspeedServices().add(ref);
     }
 
     public boolean isLayoutApplication()

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorService.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorService.java?rev=708719&r1=708718&r2=708719&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorService.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorService.java
Tue Oct 28 16:15:57 2008
@@ -21,6 +21,7 @@
 import java.io.OutputStream;
 
 import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.servlet.WebApplicationDefinition;
 import org.apache.pluto.spi.optional.PortletAppDescriptorService;
 
 
@@ -55,4 +56,8 @@
      */
     void write(PortletApplication portletDescriptor, OutputStream out) throws IOException;
 
+    void readExtended(InputStream in, PortletApplication app) throws IOException;
+ 
+    public WebApplicationDefinition readServletDescriptor(InputStream is) throws IOException;
+    
 }

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/alternate/versioned-deployment/deployment.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/alternate/versioned-deployment/deployment.xml?rev=708719&r1=708718&r2=708719&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/alternate/versioned-deployment/deployment.xml
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/alternate/versioned-deployment/deployment.xml
Tue Oct 28 16:15:57 2008
@@ -54,6 +54,7 @@
       <value>${applicationRoot}</value>
     </constructor-arg>
 
+      <constructor-arg><ref bean="org.apache.pluto.services.DescriptorService"/></constructor-arg>
 
     <!-- optional configuration for automatic creation of not yet existing roles as defined
in the deployed web.xml:
       <property name="autoCreateRoles"><value>true</value></property>

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/deployment.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/deployment.xml?rev=708719&r1=708718&r2=708719&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/deployment.xml
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-portal-resources/src/main/resources/assembly/deployment.xml
Tue Oct 28 16:15:57 2008
@@ -84,6 +84,7 @@
       <value>${applicationRoot}</value>
     </constructor-arg>
 
+    <constructor-arg><ref bean="org.apache.pluto.services.DescriptorService"/></constructor-arg>
 
     <!-- optional configuration for automatic creation of not yet existing roles as defined
in the deployed web.xml:
       <property name="autoCreateRoles"><value>true</value></property>



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