Package org.apache.pluto.container.om.portlet

Examples of org.apache.pluto.container.om.portlet.PortletApplicationDefinition


        }
    }
   
    public PortletApplicationDefinition upgrade()
    {
        PortletApplicationDefinition app = new org.apache.pluto.container.om.portlet.impl.PortletAppType();
        app.setVersion(version);
        if (portlet != null)
        {
            for (PortletType src : portlet)
            {
                PortletDefinition target = app.addPortlet(src.portletName);
                upgradePortlet(src, target);
            }
        }
        if (customPortletMode != null)
        {
            for (CustomPortletModeType src : customPortletMode)
            {
                CustomPortletMode target = app.addCustomPortletMode(src.portletMode);
                if (src.description != null)
                {
                    for (DescriptionType d : src.description)
                    {
                        Description desc = target.addDescription(d.lang);
                        desc.setDescription(d.value);
                    }
                }
            }
        }
        if (customWindowState != null)
        {
            for (CustomWindowStateType src : customWindowState)
            {
                CustomWindowState target = app.addCustomWindowState(src.windowState);
                if (src.description != null)
                {
                    for (DescriptionType d : src.description)
                    {
                        Description desc = target.addDescription(d.lang);
                        desc.setDescription(d.value);
                    }
                }
            }
        }
        if (userAttribute != null)
        {
            for (UserAttributeType src : userAttribute)
            {
                UserAttribute target = app.addUserAttribute(src.name);
                if (src.description != null)
                {
                    for (DescriptionType d : src.description)
                    {
                        Description desc = target.addDescription(d.lang);
                        desc.setDescription(d.value);
                    }
                }
            }
        }
        if (securityConstraint != null)
        {
            for (SecurityConstraintType src : securityConstraint)
            {
                SecurityConstraint target = app.addSecurityConstraint(src.userDataConstraint.transportGuarantee);
                if (src.displayName != null)
                {
                    for (DisplayNameType d : src.displayName)
                    {
                        DisplayName dname = target.addDisplayName(d.lang);
View Full Code Here


            final IOException ioe = new IOException(e.getMessage());
            ioe.initCause(e);
            throw ioe;
        }

        PortletApplicationDefinition pad = null;
        if (app.getValue() instanceof org.apache.pluto.container.om.portlet10.impl.PortletAppType)
        {
             pad = ((org.apache.pluto.container.om.portlet10.impl.PortletAppType)app.getValue()).upgrade();
        }     
        else
        {
            pad = (PortletApplicationDefinition)app.getValue();
        }
       
        pad.setName(name);
        pad.setContextPath(contextPath);
       
        return pad;
    }
View Full Code Here

        }
        filtering = true;
        try
        {
            PortletURLListenerService service = responseContext.getContainer().getContainerServices().getPortletURLListenerService();
            PortletApplicationDefinition portletApp = responseContext.getPortletWindow().getPortletDefinition().getApplication();
            for (PortletURLGenerationListener listener : service.getPortletURLGenerationListeners(portletApp))
            {
                if (PortletURLProvider.TYPE.ACTION == urlProvider.getType())
                {
                    listener.filterActionURL(this);
View Full Code Here

      .append(xmlBegin168).append(portlet168)
      .append(attrs168).append(xmlEnd);
     
          InputStream in = new ByteArrayInputStream(xml286.toString().getBytes());
         
      PortletApplicationDefinition portletApp286 = jaxb.read("test", "/test", in);
     
      in = new ByteArrayInputStream(xml168.toString().getBytes());
      PortletApplicationDefinition portletApp168 = jaxb.read("test", "/test", in);
     
      validatePortletApp168AndPortletApp286(portletApp168, portletApp286);
     
    } catch (IOException e) {
      fail("exception was thrown: " + e);
View Full Code Here

            .append(xmlBegin168NoNamespaceURI).append(portlet168)
            .append(attrs168).append(xmlEnd);
           
            InputStream in = new ByteArrayInputStream(xml286NoNamespaceURI.toString().getBytes());
           
            PortletApplicationDefinition portletApp286NoNamespaceURI = jaxb.read("test", "/test", in);
           
            in = new ByteArrayInputStream(xml168NoNamespaceURI.toString().getBytes());
            PortletApplicationDefinition portletApp168NoNamespaceURI = jaxb.read("test", "/test", in);
           
            validatePortletApp168AndPortletApp286(portletApp168NoNamespaceURI, portletApp286NoNamespaceURI);
           
        } catch (IOException e) {
            fail("exception was thrown: " + e);
View Full Code Here

    }
    }

    public void testParseNoExpirationCache168() throws IOException {
        InputStream inputStream = new ByteArrayInputStream(portlet168NoCache.toString().getBytes());
        PortletApplicationDefinition portletDD = jaxb.read( "test", "/test", inputStream );

        assertEquals( "1.0", portletDD.getVersion() );
        assertEquals( 1, portletDD.getPortlets().size() );

        PortletDefinition pd = (PortletDefinition) portletDD.getPortlets().get( 0 );
        assertEquals( pd.getExpirationCache(), 0 );
    }
View Full Code Here

        assertEquals( pd.getExpirationCache(), 0 );
    }

    public void testParseNoExpirationCache286() throws IOException {
        InputStream inputStream = new ByteArrayInputStream(portlet286NoCache.toString().getBytes());
        PortletApplicationDefinition portletDD = jaxb.read( "test", "/test", inputStream );

        assertEquals( "2.0", portletDD.getVersion() );
        assertEquals( 1, portletDD.getPortlets().size() );

        PortletDefinition pd = (PortletDefinition) portletDD.getPortlets().get( 0 );
        assertEquals( pd.getExpirationCache(), 0 );
    }
View Full Code Here

    }
   
    protected void verifyAssembly( InputStream webXml, InputStream portletXml ) throws Exception {
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        PlutoWebXmlRewriter webXmlRewriter = new PlutoWebXmlRewriter( webXml );
        PortletApplicationDefinition portletApp = portletSvc.read( "test", "/test", portletXml );
       
        assertNotNull( "Web Application Descripter was null.", webXmlRewriter );
        assertNotNull( "Portlet Application Descriptor was null.", portletApp );
        assertTrue( "Portlet Application Descriptor doesn't define any portlets.", portletApp.getPortlets().size() > 0 );
        assertTrue( "Web Application Descriptor doesn't define any servlets.", webXmlRewriter.hasServlets() );
        assertTrue( "Web Application Descriptor doesn't define any servlet mappings.", webXmlRewriter.hasServletMappings() );
       
        PortletDefinition portlet = (PortletDefinition) portletApp.getPortlets().iterator().next();
        assertTrue( "Unable to retrieve test portlet named [" + testPortletName + "]", portlet.getPortletName().equals( testPortletName ) );
       
        String servletClassName = webXmlRewriter.getServletClass( testPortletName );
        assertNotNull( "Unable to retrieve portlet dispatch for portlet named [" + testPortletName + "]", servletClassName );       
        assertEquals( "Dispatcher servlet incorrect for test portlet [" + testPortletName + "]",  Assembler.DISPATCH_SERVLET_CLASS, servletClassName );       
View Full Code Here

        PlutoWebXmlRewriter webXmlRewriter = null;
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        int entryCount = 0;
        ByteArrayOutputStream portletXmlBytes = new ByteArrayOutputStream();
        ByteArrayOutputStream webXmlBytes = new ByteArrayOutputStream();
        PortletApplicationDefinition portletApp = null;       
               
        JarInputStream assembledWarIn = new JarInputStream( new FileInputStream( warFile ) );
        JarEntry tempEntry;
       
        while ( ( tempEntry = assembledWarIn.getNextJarEntry() ) != null  ) {
            entryCount++;
           
            if ( Assembler.PORTLET_XML.equals( tempEntry.getName() ) ) {
                IOUtils.copy( assembledWarIn, portletXmlBytes );
                portletApp = portletSvc.read( "test", "/test", new ByteArrayInputStream( portletXmlBytes.toByteArray() ) );
            }
            if ( Assembler.SERVLET_XML.equals( tempEntry.getName() ) ) {
                IOUtils.copy( assembledWarIn, webXmlBytes );
                webXmlRewriter = new PlutoWebXmlRewriter( new ByteArrayInputStream( webXmlBytes.toByteArray() ) );
            }
        }
       
        assertTrue( "Assembled WAR file was empty.", entryCount > 0 );
        assertNotNull( "Web Application Descripter was null.", webXmlRewriter );
        assertNotNull( "Portlet Application Descriptor was null.", portletApp );
        assertTrue( "Portlet Application Descriptor doesn't define any portlets.", portletApp.getPortlets().size() > 0 );
        assertTrue( "Web Application Descriptor doesn't define any servlets.", webXmlRewriter.hasServlets() );
        assertTrue( "Web Application Descriptor doesn't define any servlet mappings.", webXmlRewriter.hasServletMappings() );

        PortletDefinition portlet = (PortletDefinition) portletApp.getPortlets().iterator().next();
        assertTrue( "Unable to retrieve test portlet named [" + testPortletName + "]", portlet.getPortletName().equals( testPortletName ) );

        String servletClassName = webXmlRewriter.getServletClass( testPortletName );
        assertNotNull( "Unable to retrieve portlet dispatch for portlet named [" + testPortletName + "]", servletClassName );       
        assertEquals( "Dispatcher servlet incorrect for test portlet [" + testPortletName + "]",  Assembler.DISPATCH_SERVLET_CLASS, servletClassName );
View Full Code Here

    protected void validateEarAssembly( File earFile ) throws Exception {
        assertTrue( "EAR archive [" + earFile.getAbsolutePath() + "] cannot be found or cannot be read",
                earFile.exists() && earFile.canRead() );
       
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        PortletApplicationDefinition portletApp = null;

        PlutoWebXmlRewriter webXmlRewriter = null;
       
        int earEntryCount = 0;
        int warEntryCount = 0;
       
        JarInputStream earIn = new JarInputStream( new FileInputStream( earFile ) );
       
        JarEntry earEntry;
        JarEntry warEntry;
       
        while ( ( earEntry = earIn.getNextJarEntry() ) != null ) {
            earEntryCount++;
            if ( earEntry.getName().endsWith( ".war" ) ) {
                warEntryCount++;
                JarInputStream warIn = new JarInputStream( earIn );
                while ( ( warEntry = warIn.getNextJarEntry() ) != null ) {
                    if ( Assembler.PORTLET_XML.equals( warEntry.getName() ) ) {
                      portletApp = portletSvc.read( "test", "/test",
                                new ByteArrayInputStream( IOUtils.toByteArray( warIn ) ) );
                    }
                    if ( Assembler.SERVLET_XML.equals( warEntry.getName() ) ) {
                        webXmlRewriter = new PlutoWebXmlRewriter( new ByteArrayInputStream( IOUtils.toByteArray( warIn ) ) );
                    }
                }               
            }
        }
       
        assertTrue( "EAR archive did not contain any entries", earEntryCount > 0 );
        assertTrue( "WAR archive did not contain any entries", warEntryCount > 0 );
        assertNotNull( "WAR archive did not contain a portlet.xml", portletApp );
        assertNotNull( "WAR archive did not contain a servlet.xml", webXmlRewriter );
        assertTrue( "WAR archive did not contain any servlets", webXmlRewriter.hasServlets() );
        assertTrue( "WAR archive did not contain any servlet mappings", webXmlRewriter.hasServletMappings() );
        assertTrue( "WAR archive did not contain any portlets", portletApp.getPortlets().size() > 0 );
       
        PortletDefinition portlet = (PortletDefinition) portletApp.getPortlets().iterator().next();
        assertEquals( "Unexpected test portlet name.", testPortletName, portlet.getPortletName() );
       
        String servletClassName = webXmlRewriter.getServletClass( portlet.getPortletName() );
        assertNotNull( "web.xml does not contain assembly for test portlet", servletClassName );
        assertEquals( "web.xml does not contain correct dispatch servet", Assembler.DISPATCH_SERVLET_CLASS,
View Full Code Here

TOP

Related Classes of org.apache.pluto.container.om.portlet.PortletApplicationDefinition

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.