You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by dd...@apache.org on 2005/03/08 17:18:14 UTC

svn commit: r156540 - in portals/pluto/trunk/portal/src/java/org/apache/pluto/driver: ./ deploy/ deploy/CLI.java deploy/Deploy.java deploy/PortalRegistrarService.java deploy/PortletApplicationExploder.java

Author: ddewolf
Date: Tue Mar  8 08:18:12 2005
New Revision: 156540

URL: http://svn.apache.org/viewcvs?view=rev&rev=156540
Log:
Adding New Deploy Tools which prevent element stripping in the web.xml by using the standard bean descriptor classes.  Eventually I'd like to change all components to use these simple bean configurations to 1) prevent duplication 2) provide a clear seperation of concerns.

Added:
    portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/
    portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/
    portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/CLI.java
    portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/Deploy.java
    portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/PortalRegistrarService.java
    portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/PortletApplicationExploder.java

Added: portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/CLI.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/CLI.java?view=auto&rev=156540
==============================================================================
--- portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/CLI.java (added)
+++ portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/CLI.java Tue Mar  8 08:18:12 2005
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2003,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.pluto.driver.deploy;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Enumeration;
+
+import org.apache.pluto.descriptors.services.WebAppDescriptorService;
+import org.apache.pluto.descriptors.services.PortletAppDescriptorService;
+import org.apache.pluto.descriptors.services.impl.FileWebAppDescriptorServiceImpl;
+import org.apache.pluto.descriptors.services.impl.FilePortletAppDescriptorServiceImpl;
+
+public class CLI {
+
+    /**
+     * Private Constructor used to prevent instantiation.
+     */
+    private CLI() {
+
+    }
+
+    /**
+     * Command Line Interface for the Pluto Deploy tool.
+     * <pre>
+  Usage: deploy [options] [<portlet-webapp-dir> | <portlet-war-file>]"
+  Options:
+    -destination, -d       destination to which the app should be deployed
+    -portal, -p            specify the portal location
+    -version,              print versioning information
+    -verbose, -v           be extra verbose
+    -help, -h              print this messagae</pre>
+     * @param args
+     * @throws Exception
+     */
+    public static void main(String args[]) throws Exception {
+        CLIArgs cli = parseArgs(args);
+        Deploy deploy = createDeployer(cli);
+        deploy.deploy(cli.portletApplication);
+    }
+
+    public static Deploy createDeployer(CLIArgs args) {
+        PortletApplicationExploder exploder = null;
+        PortalRegistrarService registrar = null;
+        WebAppDescriptorService webAppDescriptorService = null;
+        PortletAppDescriptorService portletAppDescriptorService = null;
+
+        args.destinationDirectory.mkdirs();
+        if(!args.portletApplication.isDirectory()) {
+            exploder = new PortletApplicationExploder(args.destinationDirectory);
+        }
+
+        if(args.portalApplication!=null) {
+            registrar = new PortalRegistrarService(args.portalApplication);
+        }
+        if(args.debug) {
+            System.out.println("<VERBOSE> Portal WebApp: "+ args.portalApplication.getAbsolutePath());
+        }
+
+
+        int extLocation = args.portletApplication.getName().indexOf(".");
+        if(extLocation > 0) {
+            args.destinationDirectory = new File(args.destinationDirectory, args.portletApplication.getName().substring(0, extLocation));
+        }
+        else {
+            args.destinationDirectory = new File(args.destinationDirectory, args.portletApplication.getName());
+        }
+
+        if(args.debug) {
+            System.out.println("<VERBOSE> Portlet Context: "+ args.destinationDirectory.getAbsolutePath());
+        }
+
+        webAppDescriptorService = new FileWebAppDescriptorServiceImpl(args.destinationDirectory);
+        portletAppDescriptorService = new FilePortletAppDescriptorServiceImpl(args.destinationDirectory);
+
+        Deploy deploy = new Deploy(webAppDescriptorService, portletAppDescriptorService);
+        deploy.setDebug(args.debug);
+        deploy.setExploder(exploder);
+        deploy.setRegistrar(registrar);
+        return deploy;
+    }
+
+    public static CLIArgs parseArgs(String[] args) {
+        CLIArgs result = new CLIArgs();
+
+        for (int i=0;i<args.length;i++) {
+            String arg = args[i];
+
+            if("-help".equals(arg) || "-h".equals(arg)) {
+                printUsage();
+                return null;
+            }
+            else if("-version".equals(arg)) {
+                printVersion();
+                return null;
+            }
+            else if("-verbose".equals(arg) || "-v".equals(arg)) {
+                result.debug = true;
+            }
+            else if("-portal".equals(arg) || "-p".equals(arg)) {
+                try {
+                    result.portalApplication = new File(args[++i]);
+                    if(!result.portalApplication.exists()) {
+                        throw new IllegalArgumentException(
+                            "'"+result.portalApplication.getAbsolutePath()+
+                            "' is not a valid portal path"
+                        );
+                    }
+                }
+                catch(ArrayIndexOutOfBoundsException ai) {
+                    throw new IllegalArgumentException(
+                        "-portal must be followed by the location of the portal"
+                    );
+                }
+            }
+            else if("-destination".equals(arg) || "-d".equals(arg)) {
+                result.destinationDirectory = new File(args[++i]);
+            }
+            else if (arg.startsWith("-")) {
+                throw new IllegalArgumentException("Illegal Option: "+arg);
+            }
+            else {
+                result.portletApplication = new File(args[i]);
+            }
+        }
+
+        if(result.portletApplication == null) {
+            throw new IllegalArgumentException(
+                "Portlet Application must be specified"
+            );
+        }
+
+        if(result.debug) {
+            System.out.println("<VERBOSE> Source WebApp: "+ result.portletApplication.getAbsolutePath());
+        }
+
+        if(result.destinationDirectory == null) {
+            result.destinationDirectory = result.portletApplication.getParentFile();
+        }
+
+        if(result.debug) {
+            System.out.println("<VERBOSE> Destination:   "+ result.destinationDirectory.getAbsolutePath());
+        }
+        return result;
+    }
+
+    private static void printUsage() {
+        String sep = System.getProperty("line.separator");
+        StringBuffer sb = new StringBuffer(sep);
+        sb.append("deploy [options] [<portlet-webapp-dir> | <portlet-war-file>]"+sep);
+        sb.append("Options: "+sep);
+        sb.append("  -destination, -d       destination to which the app should be deployed"+sep);
+        sb.append("  -portal, -p            specify the portal location"+sep);
+        sb.append("  -version,              print versioning information"+sep);
+        sb.append("  -verbose, -v           be extra verbose"+sep);
+        sb.append("  -help, -h              print this messagae"+sep);
+        System.out.println(sb);
+    }
+
+    private static void printVersion() {
+        System.out.println("Apache Pluto Deploy / 1.0");
+    }
+
+    static class CLIArgs {
+
+        private File portletApplication;
+        private File portalApplication;
+        private File destinationDirectory;
+        private boolean debug;
+
+    }
+
+}

Added: portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/Deploy.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/Deploy.java?view=auto&rev=156540
==============================================================================
--- portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/Deploy.java (added)
+++ portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/Deploy.java Tue Mar  8 08:18:12 2005
@@ -0,0 +1,282 @@
+/*
+ * Copyright 2003,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.pluto.driver.deploy;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Collection;
+
+import org.apache.pluto.descriptors.services.WebAppDescriptorService;
+import org.apache.pluto.descriptors.services.PortletAppDescriptorService;
+import org.apache.pluto.descriptors.servlet.WebAppDD;
+import org.apache.pluto.descriptors.servlet.ServletDD;
+import org.apache.pluto.descriptors.servlet.ServletMappingDD;
+import org.apache.pluto.descriptors.servlet.SecurityRoleDD;
+import org.apache.pluto.descriptors.common.InitParamDD;
+import org.apache.pluto.descriptors.common.SecurityRoleRefDD;
+import org.apache.pluto.descriptors.portlet.PortletAppDD;
+import org.apache.pluto.descriptors.portlet.PortletDD;
+
+public class Deploy {
+
+    private static final String INVOKER_SERVLET =
+        "org.apache.pluto.core.PortletServlet";
+
+    // Services Which Must Be Initiated
+    private WebAppDescriptorService webAppDescriptorService;
+    private PortletAppDescriptorService portletAppDescriptorService;
+
+    // Private Services we use internally but don't
+    // want to expose to the rest of the work - yet.
+    private PortletApplicationExploder exploder;
+    private PortalRegistrarService registrar;
+
+    private boolean debug = false;
+
+    public Deploy(WebAppDescriptorService webAppDescriptorService,
+                  PortletAppDescriptorService portletAppDescriptorService) {
+        this.webAppDescriptorService = webAppDescriptorService;
+        this.portletAppDescriptorService = portletAppDescriptorService;
+    }
+
+    /**
+     * Service Getter.
+     * @return
+     */
+    public WebAppDescriptorService getWebAppDDService() {
+        return webAppDescriptorService;
+    }
+
+    /**
+     * Service Setter.
+     */
+    public void setWebAppDDService(WebAppDescriptorService webAppDescriptorService) {
+        this.webAppDescriptorService = webAppDescriptorService;
+    }
+
+    /**
+     * Service Getter.
+     * @return
+     */
+    public PortletAppDescriptorService getPortletAppDDService() {
+        return portletAppDescriptorService;
+    }
+
+    /**
+     * Service Setter.
+     * @param portletAppDescriptorService
+     */
+    public void setPortletAppDDService(PortletAppDescriptorService portletAppDescriptorService) {
+        this.portletAppDescriptorService = portletAppDescriptorService;
+    }
+
+    PortletApplicationExploder getExploder() {
+        return exploder;
+    }
+
+    void setExploder(PortletApplicationExploder exploder) {
+        this.exploder = exploder;
+    }
+
+    PortalRegistrarService getRegistrar() {
+        return registrar;
+    }
+
+    void setRegistrar(PortalRegistrarService registrar) {
+        this.registrar = registrar;
+    }
+
+    public boolean isDebug() {
+        return debug;
+    }
+
+    public void setDebug(boolean debug) {
+        this.debug = debug;
+    }
+
+    public void updateDescriptors()
+        throws IOException {
+        PortletAppDD portletApp = portletAppDescriptorService.read();
+        WebAppDD webApp = webAppDescriptorService.read();
+
+        Iterator portlets = portletApp.getPortlets().iterator();
+        PortletDD portlet;
+        while (portlets.hasNext()) {
+            portlet = (PortletDD) portlets.next();
+
+            createServlet(webApp, portlet);
+            createServletMapping(webApp, portlet);
+        }
+
+        this.webAppDescriptorService.write(webApp);
+    }
+
+    public static void copy(String from, String to) throws IOException {
+        File f = new File(to);
+        f.getParentFile().mkdirs();
+
+        byte[] buffer = new byte[1024];
+        int length = 0;
+        InputStream fis = new FileInputStream(from);
+        FileOutputStream fos = new FileOutputStream(f);
+
+        while ((length = fis.read(buffer)) >= 0) {
+            fos.write(buffer, 0, length);
+        }
+        fos.close();
+    }
+
+    public void deploy(File warFile) throws IOException {
+        if(exploder != null) {
+            exploder.explode(warFile);
+        }
+        updateDescriptors();
+        File portalWebApp = null;
+        if(portalWebApp != null) {
+            registrar.register(portletAppDescriptorService);
+        }
+    }
+
+
+    private void createServlet(WebAppDD webApp, PortletDD portlet) {
+        if(debug) {
+            System.out.println("<VERBOSE> Creating Servlet Wrapper for Portlet: '"+portlet.getPortletName()+"'");
+        }
+        String pnm = portlet.getPortletName();
+        // check if already exists
+        ServletDD servlet = webApp.getServlet(pnm);
+        if (servlet != null) {
+            String cl = servlet.getServletClass();
+            if (!INVOKER_SERVLET.equals(cl)) {
+                System.out.println(
+                    "Note: Replaced already existing the servlet with the name '"
+                    + pnm
+                    + "' with the wrapper servlet."
+                );
+                servlet.setServletClass(INVOKER_SERVLET);
+            }
+        } else {
+            servlet = new ServletDD();
+            servlet.setServletName(pnm);
+            servlet.setServletClass(INVOKER_SERVLET);
+            webApp.getServlets().add(servlet);
+        }
+
+        servlet.setDisplayName(pnm + "Wrapper (Pluto Invoker)");
+        servlet.setDescription("Auto Generated Portlet Invoker Servlet");
+
+        InitParamDD param = new InitParamDD();
+        param.setParamName("portlet-class");
+        param.setParamValue(portlet.getPortletClass());
+        servlet.getInitParams().add(param);
+
+        param = new InitParamDD();
+        param.setParamName("portlet-guid");
+        param.setParamValue(portletAppDescriptorService.getContextPath()+"."+portlet.getPortletName());
+        servlet.getInitParams().add(param);
+
+        createSecurityRoleRefs(webApp, servlet, portlet);
+    }
+
+    private void createSecurityRoleRefs(WebAppDD webApp,
+                                        ServletDD servlet,
+                                        PortletDD portlet) {
+
+        HashMap sRefs = new HashMap();
+        List sSecRoleRefs = servlet.getSecurityRoleRefs();
+        Iterator i = sSecRoleRefs.iterator();
+        SecurityRoleRefDD srr;
+        while(i.hasNext()) {
+            srr = (SecurityRoleRefDD)i.next();
+            sRefs.put(srr.getRoleName(), srr);
+        }
+
+        HashMap wRoles = new HashMap();
+        i = webApp.getSecurityRoles().iterator();
+        SecurityRoleDD sr;
+        while(i.hasNext()) {
+            sr = (SecurityRoleDD)i.next();
+            wRoles.put(sr.getRoleName(), sr);
+        }
+
+        Collection pRoles = portlet.getSecurityRoleRefs();
+        Iterator p = pRoles.iterator();
+        SecurityRoleRefDD pRole;
+        while(p.hasNext()) {
+            pRole = (SecurityRoleRefDD) p.next();
+            if (pRole.getRoleLink()==null
+                && wRoles.get(pRole.getRoleName())==null) {
+                    System.out.println(
+                        "Note: The web application has no security role defined which matches the role name \""
+                        + pRole.getRoleName()
+                        + "\" of the security-role-ref element defined for the wrapper-servlet with the name '"
+                        + portlet.getPortletName()
+                        + "'.");
+                    break;
+            }
+            SecurityRoleRefDD sRR = (SecurityRoleRefDD)
+                sRefs.get(pRole.getRoleName());
+
+            if (null != sRR) {
+                System.out.println("Note: Replaced already existing element of type <security-role-ref> with value \""
+                        + pRole.getRoleName()
+                        + "\" for subelement of type <role-name> for the wrapper-servlet with the name '"
+                        + portlet.getPortletName()
+                        + "'.");
+                    sSecRoleRefs.remove(sRR);
+            }
+            SecurityRoleRefDD dd = new SecurityRoleRefDD();
+            dd.setDescription(pRole.getDescription());
+            dd.setRoleLink(pRole.getRoleLink());
+            dd.setRoleName(pRole.getRoleName());
+            sSecRoleRefs.add(dd);
+        }
+    }
+
+    private void createServletMapping(WebAppDD webApp,
+                                      PortletDD portlet) {
+        if(debug) {
+            System.out.println("<VERBOSE> Creating Servlet Mapping for Portlet: '"+portlet.getPortletName()+"'");
+        }
+        String url= "/"+portlet.getPortletName().replace(' ', '_') + "/*";
+        ServletMappingDD servletMapping = webApp.getServletMapping(url);
+        if (servletMapping != null) {
+            String nm = servletMapping.getServletName();
+            if (!nm.equals(portlet.getPortletName())) {
+                System.out.println(
+                    "Note: Replaced Servlet Mapping with pattern: "+url
+                );
+                servletMapping.setServletName(portlet.getPortletName());
+            }
+        }
+        else  {
+            servletMapping = new ServletMappingDD();
+            servletMapping.setUrlPattern(url);
+            servletMapping.setServletName(portlet.getPortletName());
+            webApp.getServletMappings().add(servletMapping);
+        }
+    }
+
+
+
+}

Added: portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/PortalRegistrarService.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/PortalRegistrarService.java?view=auto&rev=156540
==============================================================================
--- portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/PortalRegistrarService.java (added)
+++ portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/PortalRegistrarService.java Tue Mar  8 08:18:12 2005
@@ -0,0 +1,77 @@
+/*
+ * 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.pluto.driver.deploy;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.pluto.descriptors.services.PortletAppDescriptorService;
+import org.apache.pluto.descriptors.portlet.PortletAppDD;
+import org.apache.pluto.descriptors.portlet.PortletDD;
+
+/**
+ * Service used by the deployer to register portlet
+ * applications with the Portal.
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Mar 6, 2005
+ */
+class PortalRegistrarService {
+
+    private static final String REGISTRY_FILE = "WEB-INF/data/portletentityregistry.xml";
+
+    private File portalRoot;
+
+    public PortalRegistrarService(File portalRoot) {
+        this.portalRoot = portalRoot;
+    }
+
+    /**
+     * Register the given war.
+     */
+    public void register(PortletAppDescriptorService portletAppDescriptorService)
+    throws IOException {
+        File file = new File(portalRoot, REGISTRY_FILE);
+        RandomAccessFile ras = new RandomAccessFile(file, "rw");
+
+        long length = ras.length();
+        byte[] contentByte = new byte[(int) length];
+        ras.read(contentByte);
+        String contentString = new String(contentByte);
+        long pos = contentString.lastIndexOf("</portlet-entity-registry>");
+        ras.seek(pos);
+        ras.writeBytes("    <application id=\"" + portletAppDescriptorService.getContextPath() + "\">\r\n");
+        ras.writeBytes("        <definition-id>" + portletAppDescriptorService.getContextPath() + "</definition-id>\r\n");
+
+        PortletAppDD app = portletAppDescriptorService.read();
+        PortletDD p;
+        Iterator i = app.getPortlets().iterator();
+        while(i.hasNext()) {
+            p = (PortletDD)i.next();
+            ras.writeBytes("        <portlet id=\"" + p.getPortletName() + "\">\r\n");
+            ras.writeBytes("            <definition-id>" + portletAppDescriptorService.getContextPath()
+                               + "." + p.getPortletName() + "</definition-id>\r\n");
+            ras.writeBytes("        </portlet>\r\n");
+        }
+        ras.writeBytes("    </application>\r\n");
+        ras.writeBytes("</portlet-entity-registry>\r\n");
+        ras.close();
+    }
+}
+

Added: portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/PortletApplicationExploder.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/PortletApplicationExploder.java?view=auto&rev=156540
==============================================================================
--- portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/PortletApplicationExploder.java (added)
+++ portals/pluto/trunk/portal/src/java/org/apache/pluto/driver/deploy/PortletApplicationExploder.java Tue Mar  8 08:18:12 2005
@@ -0,0 +1,112 @@
+/*
+ * 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.pluto.driver.deploy;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.StreamTokenizer;
+import java.io.FileOutputStream;
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
+import java.util.Enumeration;
+
+/**
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Mar 6, 2005
+ */
+class PortletApplicationExploder {
+
+    private File destination;
+
+    private boolean validateJsp;
+
+    /**
+     *
+     * @param destination
+     */
+    public PortletApplicationExploder(File destination) {
+        this.destination = destination;
+    }
+
+    public PortletApplicationExploder(File destination, boolean validate) {
+        this(destination);
+        this.validateJsp = validate;
+    }
+
+    public void explode(File war) throws IOException {
+        File destination = getDestinationDirectory(war.getName());
+        destination.delete();
+        destination.mkdirs();
+        JarFile jarFile = new JarFile(war);
+
+        Enumeration files = jarFile.entries();
+        while (files.hasMoreElements()) {
+            JarEntry entry = (JarEntry) files.nextElement();
+            String fileName = entry.getName();
+            InputStream is = jarFile.getInputStream(entry);
+            if(validateJsp && !entry.isDirectory() && entry.getName().endsWith(".jsp")) {
+
+                validateJsp(is);
+            }
+
+                File file = new File(destination, fileName);
+                if (entry.isDirectory()) {
+                    file.mkdirs();
+                } else {
+                    file.getParentFile().mkdirs();
+                    byte[] buffer = new byte[1024];
+                    int length = 0;
+                    is = jarFile.getInputStream(entry);
+                    FileOutputStream fos = new FileOutputStream(file);
+                    while ((length = is.read(buffer)) >= 0) {
+                        fos.write(buffer, 0, length);
+                    }
+                    fos.close();
+            }
+        }
+
+    }
+
+    private void validateJsp(InputStream is) throws IOException {
+        Reader r = new BufferedReader(new InputStreamReader(is));
+        StreamTokenizer st = new StreamTokenizer(r);
+        st.quoteChar('\'');
+        st.quoteChar('"');
+        while(st.nextToken()!=StreamTokenizer.TT_EOF) {
+            if(st.ttype=='\'' || st.ttype=='"'){
+                String sval = st.sval;
+                String sqc = Character.toString((char)st.ttype);
+                if(sval.equals("/WEB-INF/tld/portlet.tld")){
+                    System.out.println("Warning: " + sqc+st.sval+sqc + " has been found in file " + ". Use instead " +sqc+"http://java.sun.com/portlet"+sqc+" with your portlet taglib declaration!\n");
+                    break;
+                }
+            }
+        }
+    }
+
+    private File getDestinationDirectory(String warName) {
+        int extLocation = warName.indexOf(".");
+        warName = warName.substring(0, extLocation);
+        return new File(destination, warName);
+    }
+
+}
+