Package org.apache.jetspeed.util

Examples of org.apache.jetspeed.util.DirectoryHelper


                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)
View Full Code Here


                }
               
                // redeploy/deploy decorator w/o META_INF jar metadata
                log.info("Deploying decorator " + id + " to " + deployPath);
                deployPathFile.mkdirs();
                deployObject = new DirectoryHelper(deployPathFile);
                sourceObject = event.getDeploymentObject().getFileObject();
                deployObject.copyFrom(sourceObject.getRootDirectory());
                File metaInf = new File(deployPathFile, "META-INF");
                if (metaInf.exists())
                {
                    DirectoryHelper cleanup = new DirectoryHelper(metaInf);
                    cleanup.remove();
                    cleanup.close();
                }
               
                // detect language/country localized decorator components
                final List localeSpecificDeployPathsList = getLocaleSpecificDeployPaths(deployPathFile);
               
                // deploy individual locale specific decorator components
                Iterator deployPathsIter = localeSpecificDeployPathsList.iterator();
                while (deployPathsIter.hasNext())
                {
                    File localeDeployPathFile = (File) deployPathsIter.next();
                   
                    // deploy to locale specific location
                    File deployToPathFile = new File(baseDeployPath + localeDeployPathFile.getPath().substring(deployPath.length()) + File.separator + id);
                    log.info("Deploying decorator " + id + " to " + deployToPathFile.getPath());
                    deployToPathFile.mkdirs();
                   
                    // deploy decorator components by moving from deployed decorator
                    File [] filesToDeploy = localeDeployPathFile.listFiles(new FileFilter()
                        {
                            public boolean accept(File pathname)
                            {
                                return !localeSpecificDeployPathsList.contains(pathname);
                            }
                        });
                    for (int i = 0; (i < filesToDeploy.length); i++)
                    {
                        filesToDeploy[i].renameTo(new File(deployToPathFile, filesToDeploy[i].getName()));
                    }
                }
               
                // cleanup locale specific deployment directories
                Iterator cleanupDeployPathsIter = localeSpecificDeployPathsList.iterator();
                while (cleanupDeployPathsIter.hasNext())
                {
                    File cleanupLocaleDeployPathFile = (File) cleanupDeployPathsIter.next();
                    if (cleanupLocaleDeployPathFile.exists())
                    {
                        DirectoryHelper cleanup = new DirectoryHelper(cleanupLocaleDeployPathFile);
                        cleanup.remove();
                        cleanup.close();
                    }
                }
               
                // register
                registry.register(entry);
View Full Code Here

                // undeploy decorator
                File deployPathFile = new File(deployPath);
                if (deployPathFile.exists())
                {
                    log.info("Undeploying decorator " + id + " at " + deployPath);
                    DirectoryHelper cleanup = new DirectoryHelper(deployPathFile);
                    cleanup.remove();
                    cleanup.close();
                }
               
                // detect language/country localized decorator components
                final List localeSpecificDeployPathsList = getLocaleSpecificDeployPaths(new File(baseDeployPath));
               
                // undeploy individual locale specific decorator components
                Iterator deployPathsIter = localeSpecificDeployPathsList.iterator();
                while (deployPathsIter.hasNext())
                {
                    File localeDeployPathFile = new File((File) deployPathsIter.next(), id);
                    if (localeDeployPathFile.exists())
                    {
                        log.info("Undeploying decorator " + id + " at " + localeDeployPathFile.getPath());
                        DirectoryHelper cleanup = new DirectoryHelper(localeDeployPathFile);
                        cleanup.remove();
                        cleanup.close();
                        localeDeployPathFile.getParentFile().delete();
                    }
                }
               
                // deregister
View Full Code Here

    }

    public void testInfusingWebXML() throws Exception
    {
        File warFile = new File("./test/testdata/deploy/webapp");
        PortletApplicationWar paWar = new PortletApplicationWar(new DirectoryHelper(warFile), "unit-test", "/" );

        SAXBuilder builder = new SAXBuilder(false);

        // 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(PortletApplicationWar.class.getResourceAsStream("web-app_2_3.dtd"));
                }
                else
                    return null;
            }
        });

        FileReader srcReader = new FileReader("./test/testdata/deploy/webapp/WEB-INF/web.xml");
        FileReader targetReader = null;
        Document  doc = builder.build(srcReader);

        Element root = doc.getRootElement();

        try
        {
            Object jetspeedServlet = XPath.selectSingleNode(root, PortletApplicationWar.JETSPEED_SERVLET_XPATH);
            Object jetspeedServletMapping = XPath.selectSingleNode(root, PortletApplicationWar.JETSPEED_SERVLET_MAPPING_XPATH);

            assertNull(jetspeedServlet);
            assertNull(jetspeedServletMapping);

            PortletApplicationWar targetWar = paWar.copyWar("./target/webapp");
            targetWar.processWebXML();

            targetReader = new FileReader("./target/webapp/WEB-INF/web.xml");

            Document targetDoc = builder.build(targetReader);
            Element targetRoot = targetDoc.getRootElement();

            jetspeedServlet = XPath.selectSingleNode(targetDoc, PortletApplicationWar.JETSPEED_SERVLET_XPATH);
            jetspeedServletMapping = XPath.selectSingleNode(targetDoc, PortletApplicationWar.JETSPEED_SERVLET_MAPPING_XPATH);


            assertNotNull(jetspeedServlet);
            assertNotNull(jetspeedServletMapping);

        }
        finally
        {
            srcReader.close();
            paWar.close();
            targetReader.close();
            File warFile2 = new File("./target/webapp");
            DirectoryHelper dirHelper = new DirectoryHelper(warFile2);
            dirHelper.remove();
            dirHelper.close();
        }

    }
View Full Code Here

        {
            // Remove the webapps directory

            log.info("Rollback: Remove " + portletAppDir + " and all sub-directories.");

            DirectoryHelper dirHelper = new DirectoryHelper(new File(portletAppDir));
            dirHelper.remove();

        }
        catch (Exception e)
        {
            log.error("Error removing file system deployment artifacts: " + e.toString(), e);
View Full Code Here

    {
        try
        {
            doUnregister(paWar.getPortletApplicationName(), false);
            String paName = paWar.getPortletApplicationName();
            DirectoryHelper deployedDir = new DirectoryHelper(new File(webAppsDir + "/" + paName));
            PortletApplicationWar existingWar = new PortletApplicationWar(deployedDir, paName, "/" + paName);

            existingWar.removeWar();
            existingWar.close();
            sysDeploy(paWar, DEPLOY_WAR);
View Full Code Here

        }
        System.out.println("Un-deploying Web Application [" + webApplicationName + "], Portlet Application [" + portletApplicationName + "]...");
       
        String webAppPath = deployer.getDeploymentPath(webApplicationName);
        File warFile = new File(webAppPath);
        deployer.undeploy(new PortletApplicationWar(new DirectoryHelper(warFile), portletApplicationName, "/"+portletApplicationName));
        System.out.println("...PAM Undeploy done");                               
    }
View Full Code Here

   
    public void testSecurityRoles() throws Exception
    {
        System.out.println("Testing securityRoles");
        File warFile = new File("./test/testdata/deploy/webapp");
        PortletApplicationWar paWar = new PortletApplicationWar(new DirectoryHelper(warFile), "unit-test", "/" );

        MutablePortletApplication app = paWar.createPortletApp();
        assertNotNull("App is null", app);

        MutableWebApplication webApp = paWar.createWebApp();
View Full Code Here

            log.info("Deploying decorator " + id + " to " + deployPath);
            JarExpander.expand(event.getDeploymentObject().getFile(), deployPathFile);
            File metaInf = new File(deployPathFile, "META-INF");
            if (metaInf.exists())
            {
                DirectoryHelper cleanup = new DirectoryHelper(metaInf);
                cleanup.remove();
                cleanup.close();
            }

            // detect language/country localized decorator components
            final List localeSpecificDeployPathsList = getLocaleSpecificDeployPaths(deployPathFile);

            // deploy individual locale specific decorator components
            Iterator deployPathsIter = localeSpecificDeployPathsList.iterator();
            while (deployPathsIter.hasNext())
            {
                File localeDeployPathFile = (File) deployPathsIter.next();

                // deploy to locale specific location
                File deployToPathFile = new File(baseDeployPath
                                                 + localeDeployPathFile.getPath().substring(deployPath.length())
                                                 + File.separator + id);
                log.info("Deploying locale specific decorator component to " + deployToPathFile.getPath());
                deployToPathFile.mkdirs();

                // deploy decorator components by moving from deployed decorator
                File[] filesToDeploy = localeDeployPathFile.listFiles(new FileFilter()
                {
                    public boolean accept(File pathname)
                    {
                        return !localeSpecificDeployPathsList.contains(pathname);
                    }
                });
                for (int i = 0; (i < filesToDeploy.length); i++)
                {
                    filesToDeploy[i].renameTo(new File(deployToPathFile, filesToDeploy[i].getName()));
                }
            }

            // cleanup locale specific deployment directories
            Iterator cleanupDeployPathsIter = localeSpecificDeployPathsList.iterator();
            while (cleanupDeployPathsIter.hasNext())
            {
                File cleanupLocaleDeployPathFile = (File) cleanupDeployPathsIter.next();
                if (cleanupLocaleDeployPathFile.exists())
                {
                    DirectoryHelper cleanup = new DirectoryHelper(cleanupLocaleDeployPathFile);
                    cleanup.remove();
                    cleanup.close();
                }
            }

            log.info("Decorator " + id + " deployed successfuly.");
            event.setStatus(DeploymentStatus.STATUS_OKAY);
View Full Code Here

            {
                File localeDeployPathFile = new File((File) localeSpecificDeployPathsList.get(i), id);
                if (localeDeployPathFile.exists())
                {
                    log.info("Undeploying locale specific decorator component at " + localeDeployPathFile.getPath());
                    DirectoryHelper cleanup = new DirectoryHelper(localeDeployPathFile);
                    cleanup.remove();
                    cleanup.close();
                    localeDeployPathFile.getParentFile().delete();
                }
            }

            // now undeploy the decorator root itself
            DirectoryHelper cleanup = new DirectoryHelper(deployPathFile);
            cleanup.remove();
            cleanup.close();

            log.info("Decorator " + id + " undeployed successfuly.");
        }
        catch (Exception e)
        {
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.util.DirectoryHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.