Package org.apache.jetspeed.util.descriptor

Examples of org.apache.jetspeed.util.descriptor.PortletApplicationWar


               
            }
           
        }

        PortletApplicationWar paWar = null;
        try
        {
            paWar = new PortletApplicationWar(fileSystem,
                    portletApplicationName, "/" + portletApplicationName);
        } catch (IOException e)
        {
            throw new RegistryException("Failed to create PA WAR", e);
        }

        MutablePortletApplication app;
       
        String paName = paWar.getPortletApplicationName();

        try
        {
            app = paWar.createPortletApp();           
            if (app == null)
            {
                String msg = "Error loading portlet.xml: ";
                log.error(msg);
                throw new RegistryException(msg);
            }

            app.setApplicationType(MutablePortletApplication.WEBAPP);
            app.setChecksum(checksum);

            // load the web.xml
            log.info("Loading web.xml into memory...."
                            + portletApplicationName);
            MutableWebApplication webapp = paWar.createWebApp();
            paWar.validate();
            app.setWebApplicationDefinition(webapp);

            // save it to the registry
            log.info("Saving the portlet.xml in the registry..."
                    + portletApplicationName);
View Full Code Here


    throws PortletApplicationException, FileNotDeployableException, IOException
    {
        System.out.println("Registering Portlet Application [" + portletApplicationName + "]...")
             
        StandardDeploymentObject deploymentObject = new StandardDeploymentObject(new File(warFile));
        registrator.register(new PortletApplicationWar(deploymentObject.getFileObject(),  portletApplicationName, "/"+portletApplicationName ) );
        System.out.println("...PAM Register done");  
        deploymentObject.close();
    }
View Full Code Here

    throws PortletApplicationException, FileNotDeployableException, IOException       
    {
        System.out.println("Deploying Web Application [" + webAppsDir + "] to Portlet Application [" + portletApplicationName + "]...");
              
        StandardDeploymentObject deploymentObject = new StandardDeploymentObject(new File(warFile));
        deployer.deploy(new PortletApplicationWar(deploymentObject.getFileObject(), portletApplicationName, "/"+portletApplicationName));
        System.out.println("...PAM Deploy done");  
        deploymentObject.close();
    }
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();
        assertNotNull("WebApp is null", webApp);

        app.setWebApplicationDefinition(webApp);

        PortletDefinition portlet = app.getPortletDefinitionByName("TestPortlet");
        assertNotNull("TestPortlet is null", portlet);
        checkWebSecurityRoles(webApp);
        checkPortletSecurityRoleRefs(portlet);
        boolean validateFailed = false;
        try
        {
            paWar.validate();
        }
        catch (PortletApplicationException e)
        {
            validateFailed = true;
        }
        assertTrue("Invalid PortletDescriptor validation result", validateFailed);
        SecurityRoleImpl role = new SecurityRoleImpl();
        role.setRoleName("users.manager");
        webApp.addSecurityRole(role);
        try
        {
            paWar.validate();
            validateFailed = false;
        }
        catch (PortletApplicationException e)
        {
        }
        assertEquals("Invalid PortletDescriptor validation result", false, validateFailed);

        // persist the app
        try
        {
           
            portletRegistry.registerPortletApplication(app);
           
        }
        catch (Exception e)
        {
            String msg = "Unable to register portlet application, " + app.getName()
                    + ", through the portlet registry: " + e.toString();
           
            throw new Exception(msg, e);
        }
        // clear cache
       

        // read back in
        app = portletRegistry.getPortletApplication("unit-test");
        validateFailed = true;
        try
        {
            paWar.validate();
            validateFailed = false;
        }
        catch (PortletApplicationException e)
        {
        }
View Full Code Here

  protected void startPA(String contextName, FileSystemHelper warStruct,
    ClassLoader paClassLoader, boolean local)
    throws RegistryException
  {
    PortletApplicationWar paWar = null;

    try
    {
      try
      {
        paWar = new PortletApplicationWar(warStruct, contextName, "/" + contextName);

        if (paClassLoader == null)
        {
          paClassLoader = paWar.createClassloader(getClass().getClassLoader());
        }
      }
      catch (IOException e)
      {
        String msg = "Failed to create PA WAR for " + contextName;
        log.error(msg, e);
        throw new RegistryException(msg, e);
      }

      MutablePortletApplication pa = (MutablePortletApplication) registry
        .getPortletApplication(contextName);

      if ((pa != null) && (paWar.getPortletApplicationChecksum() == pa.getChecksum()))
      {
                portletFactory.unregisterPortletApplication(pa);
      }
      else
      {
        pa = registerPortletApplication(paWar, pa, local, paClassLoader);
      }
            portletFactory.registerPortletApplication(pa, paClassLoader);
    }
    finally
    {
      if (paWar != null)
      {
        try
        {
          paWar.close();
        }
        catch (IOException e)
        {
          log.error("Failed to close PA WAR for " + contextName, e);
        }
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();
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();
        assertNotNull("WebApp is null", webApp);

        app.setWebApplicationDefinition(webApp);

        PortletDefinition portlet = app.getPortletDefinitionByName("TestPortlet");
        assertNotNull("TestPortlet is null", portlet);
        checkWebSecurityRoles(webApp);
        checkPortletSecurityRoleRefs(portlet);
        boolean validateFailed = false;
        try
        {
            paWar.validate();
        }
        catch (PortletApplicationException e)
        {
            validateFailed = true;
        }
        assertTrue("Invalid PortletDescriptor validation result", validateFailed);
        SecurityRoleImpl role = new SecurityRoleImpl();
        role.setRoleName("users.manager");
        webApp.addSecurityRole(role);
        try
        {
            paWar.validate();
            validateFailed = false;
        }
        catch (PortletApplicationException e)
        {
        }
        assertEquals("Invalid PortletDescriptor validation result", false, validateFailed);

        // persist the app
        try
        {
           
            portletRegistry.registerPortletApplication(app);
           
        }
        catch (Exception e)
        {
            String msg = "Unable to register portlet application, " + app.getName()
                    + ", through the portlet registry: " + e.toString();
           
            throw new Exception(msg, e);
        }
        // clear cache
       

        // read back in
        app = portletRegistry.getPortletApplication("unit-test");
        validateFailed = true;
        try
        {
            paWar.validate();
            validateFailed = false;
        }
        catch (PortletApplicationException e)
        {
        }
View Full Code Here

  protected void startPA(String contextName, FileSystemHelper warStruct,
    ClassLoader paClassLoader, boolean local)
    throws RegistryException
  {
    PortletApplicationWar paWar = null;

    try
    {
      try
      {
        paWar = new PortletApplicationWar(warStruct, contextName, "/" + contextName);

        if (paClassLoader == null)
        {
          paClassLoader = paWar.createClassloader(getClass().getClassLoader());
        }
      }
      catch (IOException e)
      {
        String msg = "Failed to create PA WAR for " + contextName;
        log.error(msg, e);
        throw new RegistryException(msg, e);
      }

      MutablePortletApplication pa = (MutablePortletApplication) registry
        .getPortletApplication(contextName);

      if ((pa != null) && (paWar.getPortletApplicationChecksum() == pa.getChecksum()))
      {
                portletFactory.unregisterPortletApplication(pa);
      }
      else
      {
        pa = registerPortletApplication(paWar, pa, local, paClassLoader);
      }
            portletFactory.registerPortletApplication(pa, paClassLoader);
    }
    finally
    {
      if (paWar != null)
      {
        try
        {
          paWar.close();
        }
        catch (IOException e)
        {
          log.error("Failed to close PA WAR for " + contextName, e);
        }
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();
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.util.descriptor.PortletApplicationWar

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.