Examples of WebApplicationDefinitionImpl


Examples of org.apache.cocoon.portal.pluto.om.WebApplicationDefinitionImpl

            System.out.println(portletApp);
        }

        // now generate web part

        WebApplicationDefinitionImpl webApp = null;

        if (webXml.exists()) {
            Unmarshaller unmarshallerWeb = new Unmarshaller(mappingWebXml);
      unmarshallerWeb.setIgnoreExtraElements(true);
            webApp =
                (WebApplicationDefinitionImpl) unmarshallerWeb.unmarshal(
                    new FileReader(webXml));
        } else {
            webApp = new WebApplicationDefinitionImpl();
            DisplayNameImpl dispName = new DisplayNameImpl();
            dispName.setDisplayName(webModule);
            dispName.setLocale(Locale.ENGLISH);
            DisplayNameSetImpl dispSet = new DisplayNameSetImpl();
            dispSet.add(dispName);
            webApp.setDisplayNames(dispSet);
            DescriptionImpl desc = new DescriptionImpl();
            desc.setDescription("Automated generated Application Wrapper");
            desc.setLocale(Locale.ENGLISH);
            DescriptionSetImpl descSet = new DescriptionSetImpl();
            descSet.add(desc);
            webApp.setDescriptions(descSet);
        }

        ControllerFactory controllerFactory = new ControllerFactoryImpl();

        ServletDefinitionListCtrl servletDefinitionSetCtrl =
            (ServletDefinitionListCtrl) controllerFactory.get(
                webApp.getServletDefinitionList());
        Collection servletMappings = webApp.getServletMappings();

        Iterator portlets = portletApp.getPortletDefinitionList().iterator();
        while (portlets.hasNext()) {

            PortletDefinition portlet = (PortletDefinition) portlets.next();

            if ( debug ) {
                System.out.println("  Portlet: " + portlet.getId());
            }
            // check if already exists
            ServletDefinition servlet =
                webApp.getServletDefinitionList().get(portlet.getName());
            if (servlet != null) {
                if (!servlet
                    .getServletClass()
                    .equals("org.apache.pluto.core.PortletServlet")) {
                    System.out.println(
                        "Note: Replaced already existing the servlet with the name '"
                            + portlet.getName()
                            + "' with the wrapper servlet.");
                }
                ServletDefinitionCtrl _servletCtrl =
                    (ServletDefinitionCtrl) controllerFactory.get(servlet);
                _servletCtrl.setServletClass(
                    "org.apache.pluto.core.PortletServlet");
            } else {
                servlet =
                    servletDefinitionSetCtrl.add(
                        portlet.getName(),
                        "org.apache.pluto.core.PortletServlet");
            }

            ServletDefinitionCtrl servletCtrl =
                (ServletDefinitionCtrl) controllerFactory.get(servlet);

            DisplayNameImpl dispName = new DisplayNameImpl();
            dispName.setDisplayName(portlet.getName() + " Wrapper");
            dispName.setLocale(Locale.ENGLISH);
            DisplayNameSetImpl dispSet = new DisplayNameSetImpl();
            dispSet.add(dispName);
            servletCtrl.setDisplayNames(dispSet);
            DescriptionImpl desc = new DescriptionImpl();
            desc.setDescription("Automated generated Portlet Wrapper");
            desc.setLocale(Locale.ENGLISH);
            DescriptionSetImpl descSet = new DescriptionSetImpl();
            descSet.add(desc);
            servletCtrl.setDescriptions(descSet);
            ParameterSet parameters = servlet.getInitParameterSet();

            ParameterSetCtrl parameterSetCtrl =
                (ParameterSetCtrl) controllerFactory.get(parameters);

            Parameter parameter1 = parameters.get("portlet-class");
            if (parameter1 == null) {
                parameterSetCtrl.add(
                    "portlet-class",
                    portlet.getClassName());
            } else {
                ParameterCtrl parameterCtrl =
                    (ParameterCtrl) controllerFactory.get(parameter1);
                parameterCtrl.setValue(portlet.getClassName());

            }
            Parameter parameter2 = parameters.get("portlet-guid");
            if (parameter2 == null) {
                parameterSetCtrl.add(
                    "portlet-guid",
                    portlet.getId().toString());
            } else {
                ParameterCtrl parameterCtrl =
                    (ParameterCtrl) controllerFactory.get(parameter2);
                parameterCtrl.setValue(portlet.getId().toString());

            }

            boolean found = false;
            Iterator mappings = servletMappings.iterator();
            while (mappings.hasNext()) {
                ServletMapping servletMapping =
                    (ServletMapping) mappings.next();
                if (servletMapping
                    .getServletName()
                    .equals(portlet.getName())) {
                    found = true;
                    servletMapping.setUrlPattern(
                        "/" + portlet.getName().replace(' ', '_') + "/*");
                }
            }
            if (!found) {
                ServletMapping servletMapping =
                    new ServletMapping();
                servletMapping.setServletName(portlet.getName());
                servletMapping.setUrlPattern(
                    "/" + portlet.getName().replace(' ', '_') + "/*");
                servletMappings.add(servletMapping);
            }

            SecurityRoleRefSet servletSecurityRoleRefs =
                ((ServletDefinitionImpl)servlet).getInitSecurityRoleRefSet();

            SecurityRoleRefSetCtrl servletSecurityRoleRefSetCtrl =
                (SecurityRoleRefSetCtrl) controllerFactory.get(
                    servletSecurityRoleRefs);

            SecurityRoleSet webAppSecurityRoles = webApp.getSecurityRoles();
               
            SecurityRoleRefSet portletSecurityRoleRefs =
                portlet.getInitSecurityRoleRefSet();

            Iterator p = portletSecurityRoleRefs.iterator();

            while (p.hasNext()) {
                SecurityRoleRef portletSecurityRoleRef =
                    (SecurityRoleRef) p.next();
               
                if portletSecurityRoleRef.getRoleLink()== null
                    &&   
                        webAppSecurityRoles.get(portletSecurityRoleRef.getRoleName())==null
                ){
                    System.out.println(
                        "Note: The web application has no security role defined which matches the role name \""
                            + portletSecurityRoleRef.getRoleName()
                            + "\" of the security-role-ref element defined for the wrapper-servlet with the name '"
                            + portlet.getName()
                            + "'.");
                    break;           
                }
                SecurityRoleRef servletSecurityRoleRef =
                    servletSecurityRoleRefs.get(
                        portletSecurityRoleRef.getRoleName());
                if (null != servletSecurityRoleRef) {
                    System.out.println(
                        "Note: Replaced already existing element of type <security-role-ref> with value \""
                            + portletSecurityRoleRef.getRoleName()
                            + "\" for subelement of type <role-name> for the wrapper-servlet with the name '"
                            + portlet.getName()
                            + "'.");
                    servletSecurityRoleRefSetCtrl.remove(
                        servletSecurityRoleRef);
                }
                servletSecurityRoleRefSetCtrl.add(portletSecurityRoleRef);
            }

        }

        TagDefinition portletTagLib = new TagDefinition();
        Collection taglibs = webApp.getCastorTagDefinitions();
        taglibs.add(portletTagLib);
       
        if (debug) {
            System.out.println(webApp);
        }
View Full Code Here

Examples of org.apache.cocoon.portal.pluto.om.WebApplicationDefinitionImpl

            System.out.println(portletApp);
        }

        // now generate web part

        WebApplicationDefinitionImpl webApp = null;

        if (webXml.exists()) {
            Unmarshaller unmarshallerWeb = new Unmarshaller(mappingWebXml);
      unmarshallerWeb.setIgnoreExtraElements(true);
            webApp =
                (WebApplicationDefinitionImpl) unmarshallerWeb.unmarshal(
                    new FileReader(webXml));
        } else {
            webApp = new WebApplicationDefinitionImpl();
            DisplayNameImpl dispName = new DisplayNameImpl();
            dispName.setDisplayName(webModule);
            dispName.setLocale(Locale.ENGLISH);
            DisplayNameSetImpl dispSet = new DisplayNameSetImpl();
            dispSet.add(dispName);
            webApp.setDisplayNames(dispSet);
            DescriptionImpl desc = new DescriptionImpl();
            desc.setDescription("Automated generated Application Wrapper");
            desc.setLocale(Locale.ENGLISH);
            DescriptionSetImpl descSet = new DescriptionSetImpl();
            descSet.add(desc);
            webApp.setDescriptions(descSet);
        }

        ControllerFactory controllerFactory = new ControllerFactoryImpl();

        ServletDefinitionListCtrl servletDefinitionSetCtrl =
            (ServletDefinitionListCtrl) controllerFactory.get(
                webApp.getServletDefinitionList());
        Collection servletMappings = webApp.getServletMappings();

        Iterator portlets = portletApp.getPortletDefinitionList().iterator();
        while (portlets.hasNext()) {

            PortletDefinition portlet = (PortletDefinition) portlets.next();

            if ( debug ) {
                System.out.println("  Portlet: " + portlet.getId());
            }
            // check if already exists
            ServletDefinition servlet =
                webApp.getServletDefinitionList().get(portlet.getName());
            if (servlet != null) {
                if (!servlet
                    .getServletClass()
                    .equals("org.apache.pluto.core.PortletServlet")) {
                    System.out.println(
                        "Note: Replaced already existing the servlet with the name '"
                            + portlet.getName()
                            + "' with the wrapper servlet.");
                }
                ServletDefinitionCtrl _servletCtrl =
                    (ServletDefinitionCtrl) controllerFactory.get(servlet);
                _servletCtrl.setServletClass(
                    "org.apache.pluto.core.PortletServlet");
            } else {
                servlet =
                    servletDefinitionSetCtrl.add(
                        portlet.getName(),
                        "org.apache.pluto.core.PortletServlet");
            }

            ServletDefinitionCtrl servletCtrl =
                (ServletDefinitionCtrl) controllerFactory.get(servlet);

            DisplayNameImpl dispName = new DisplayNameImpl();
            dispName.setDisplayName(portlet.getName() + " Wrapper");
            dispName.setLocale(Locale.ENGLISH);
            DisplayNameSetImpl dispSet = new DisplayNameSetImpl();
            dispSet.add(dispName);
            servletCtrl.setDisplayNames(dispSet);
            DescriptionImpl desc = new DescriptionImpl();
            desc.setDescription("Automated generated Portlet Wrapper");
            desc.setLocale(Locale.ENGLISH);
            DescriptionSetImpl descSet = new DescriptionSetImpl();
            descSet.add(desc);
            servletCtrl.setDescriptions(descSet);
            ParameterSet parameters = servlet.getInitParameterSet();

            ParameterSetCtrl parameterSetCtrl =
                (ParameterSetCtrl) controllerFactory.get(parameters);

            Parameter parameter1 = parameters.get("portlet-class");
            if (parameter1 == null) {
                parameterSetCtrl.add(
                    "portlet-class",
                    portlet.getClassName());
            } else {
                ParameterCtrl parameterCtrl =
                    (ParameterCtrl) controllerFactory.get(parameter1);
                parameterCtrl.setValue(portlet.getClassName());

            }
            Parameter parameter2 = parameters.get("portlet-guid");
            if (parameter2 == null) {
                parameterSetCtrl.add(
                    "portlet-guid",
                    portlet.getId().toString());
            } else {
                ParameterCtrl parameterCtrl =
                    (ParameterCtrl) controllerFactory.get(parameter2);
                parameterCtrl.setValue(portlet.getId().toString());

            }

            boolean found = false;
            Iterator mappings = servletMappings.iterator();
            while (mappings.hasNext()) {
                ServletMapping servletMapping =
                    (ServletMapping) mappings.next();
                if (servletMapping
                    .getServletName()
                    .equals(portlet.getName())) {
                    found = true;
                    servletMapping.setUrlPattern(
                        "/" + portlet.getName().replace(' ', '_') + "/*");
                }
            }
            if (!found) {
                ServletMapping servletMapping =
                    new ServletMapping();
                servletMapping.setServletName(portlet.getName());
                servletMapping.setUrlPattern(
                    "/" + portlet.getName().replace(' ', '_') + "/*");
                servletMappings.add(servletMapping);
            }

            SecurityRoleRefSet servletSecurityRoleRefs =
                ((ServletDefinitionImpl)servlet).getInitSecurityRoleRefSet();

            SecurityRoleRefSetCtrl servletSecurityRoleRefSetCtrl =
                (SecurityRoleRefSetCtrl) controllerFactory.get(
                    servletSecurityRoleRefs);

            SecurityRoleSet webAppSecurityRoles = webApp.getSecurityRoles();
               
            SecurityRoleRefSet portletSecurityRoleRefs =
                portlet.getInitSecurityRoleRefSet();

            Iterator p = portletSecurityRoleRefs.iterator();

            while (p.hasNext()) {
                SecurityRoleRef portletSecurityRoleRef =
                    (SecurityRoleRef) p.next();
               
                if portletSecurityRoleRef.getRoleLink()== null
                    &&   
                        webAppSecurityRoles.get(portletSecurityRoleRef.getRoleName())==null
                ){
                    System.out.println(
                        "Note: The web application has no security role defined which matches the role name \""
                            + portletSecurityRoleRef.getRoleName()
                            + "\" of the security-role-ref element defined for the wrapper-servlet with the name '"
                            + portlet.getName()
                            + "'.");
                    break;           
                }
                SecurityRoleRef servletSecurityRoleRef =
                    servletSecurityRoleRefs.get(
                        portletSecurityRoleRef.getRoleName());
                if (null != servletSecurityRoleRef) {
                    System.out.println(
                        "Note: Replaced already existing element of type <security-role-ref> with value \""
                            + portletSecurityRoleRef.getRoleName()
                            + "\" for subelement of type <role-name> for the wrapper-servlet with the name '"
                            + portlet.getName()
                            + "'.");
                    servletSecurityRoleRefSetCtrl.remove(
                        servletSecurityRoleRef);
                }
                servletSecurityRoleRefSetCtrl.add(portletSecurityRoleRef);
            }

        }

        TagDefinition portletTagLib = new TagDefinition();
        Collection taglibs = webApp.getCastorTagDefinitions();
        taglibs.add(portletTagLib);
       
        if (debug) {
            System.out.println(webApp);
        }
View Full Code Here

Examples of org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl

        PortletApplicationDefinitionImpl app = new PortletApplicationDefinitionImpl();
        app.setName(TEST_APP);
        app.setApplicationIdentifier(TEST_APP);

        WebApplicationDefinitionImpl webApp = new WebApplicationDefinitionImpl();
        webApp.setContextRoot("/app1");
        webApp.addDescription(Locale.FRENCH, "Description: Le fromage est dans mon pantalon!");
        webApp.addDisplayName(Locale.FRENCH, "Display Name: Le fromage est dans mon pantalon!");

        PortletDefinitionComposite portlet = new PortletDefinitionImpl();
        portlet.setClassName("org.apache.Portlet");
        portlet.setName(TEST_PORTLET);
        portlet.addDescription(Locale.getDefault(), "Portlet description.");
View Full Code Here

Examples of org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl

        JetspeedServiceReference service2 = new JetspeedServiceReferenceImpl("PortletRegistryComponent");
        app.addJetspeedService(service2);

        addDublinCore(app.getMetadata());

        WebApplicationDefinitionImpl webApp = new WebApplicationDefinitionImpl();
        webApp.setContextRoot("/app1");
        webApp.addDescription(Locale.FRENCH, "Description: Le fromage est dans mon pantalon!");
        webApp.addDisplayName(Locale.FRENCH, "Display Name: Le fromage est dans mon pantalon!");

        PortletDefinitionComposite portlet = new PortletDefinitionImpl();
        portlet.setClassName("org.apache.Portlet");
        portlet.setName("Portlet 1");
        portlet.addDescription(Locale.getDefault(), "Portlet description.");
View Full Code Here

Examples of org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl

        PortletApplicationDefinitionImpl app = new PortletApplicationDefinitionImpl();
        app.setName(TEST_APP);
        app.setApplicationIdentifier(TEST_APP);

        WebApplicationDefinitionImpl webApp = new WebApplicationDefinitionImpl();
        webApp.setContextRoot("/app1");
        webApp.addDescription(Locale.FRENCH, "Description: Le fromage est dans mon pantalon!");
        webApp.addDisplayName(Locale.FRENCH, "Display Name: Le fromage est dans mon pantalon!");

        PortletDefinitionComposite portlet = new PortletDefinitionImpl();
        portlet.setClassName("org.apache.Portlet");
        portlet.setName(TEST_PORTLET);
        portlet.addDescription(Locale.getDefault(), "Portlet description.");
View Full Code Here

Examples of org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl

        JetspeedServiceReference service1 = new JetspeedServiceReferenceImpl("PortletEntityAccessComponent");
        app.addJetspeedService(service1);
        JetspeedServiceReference service2 = new JetspeedServiceReferenceImpl("PortletRegistryComponent");
        app.addJetspeedService(service2);

        WebApplicationDefinitionImpl webApp = new WebApplicationDefinitionImpl();
        webApp.setContextRoot("/pa-001");
        webApp.addDescription(Locale.FRENCH, "Description: Le fromage est dans mon pantalon!");
        webApp.addDisplayName(Locale.FRENCH, "Display Name: Le fromage est dans mon pantalon!");

        PortletDefinitionComposite portlet = new PortletDefinitionImpl();
        portlet.setClassName("org.apache.Portlet");
        portlet.setName("Portlet-1");
        portlet.addDescription(Locale.getDefault(), "POrtlet description.");
View Full Code Here

Examples of org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl

        JetspeedServiceReference service2 = new JetspeedServiceReferenceImpl("PortletRegistryComponent");
        app.addJetspeedService(service2);

        addDublinCore(app.getMetadata());

        WebApplicationDefinitionImpl webApp = new WebApplicationDefinitionImpl();
        webApp.setContextRoot("/app1");
        webApp.addDescription(Locale.FRENCH, "Description: Le fromage est dans mon pantalon!");
        webApp.addDisplayName(Locale.FRENCH, "Display Name: Le fromage est dans mon pantalon!");

        PortletDefinitionComposite portlet = new PortletDefinitionImpl();
        portlet.setClassName("org.apache.Portlet");
        portlet.setName("Portlet 1");
        portlet.addDescription(Locale.getDefault(), "Portlet description.");
View Full Code Here

Examples of org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl

        JetspeedServiceReference service2 = new JetspeedServiceReferenceImpl("PortletRegistryComponent");
        app.addJetspeedService(service2);

        addDublinCore(app.getMetadata());

        WebApplicationDefinitionImpl webApp = new WebApplicationDefinitionImpl();
        webApp.setContextRoot("/app1");
        webApp.addDescription(Locale.FRENCH, "Description: Le fromage est dans mon pantalon!");
        webApp.addDisplayName(Locale.FRENCH, "Display Name: Le fromage est dans mon pantalon!");

        PortletDefinitionComposite portlet = new PortletDefinitionImpl();
        portlet.setClassName("org.apache.Portlet");
        portlet.setName("Portlet 1");
        portlet.addDescription(Locale.getDefault(), "POrtlet description.");
View Full Code Here

Examples of org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl

    }

    protected void verifyData(boolean afterUpdates) throws Exception
    {
        MutablePortletApplication app;
        WebApplicationDefinitionImpl webApp;
        PortletDefinitionComposite portlet;

        // Now makes sure everthing got persisted

        app = null;

        app = (PortletApplicationDefinitionImpl) portletRegistry.getPortletApplication("App_1");

        assertNotNull(app);

        webApp = (WebApplicationDefinitionImpl) app.getWebApplicationDefinition();
        portlet = (PortletDefinitionImpl) app.getPortletDefinitionByName("Portlet 1");

        assertNotNull("Failed to reteive portlet application", app);

        validateDublinCore(app.getMetadata());

        Collection services = app.getJetspeedServices();
        assertNotNull("jetspeed services is null", services);
        System.out.println("services is " + services);

        assertNotNull("Failed to reteive portlet application via registry", portletRegistry
                .getPortletApplication("App_1"));
        assertNotNull("Web app was not saved along with the portlet app.", webApp);
        assertNotNull("Portlet was not saved along with the portlet app.", app.getPortletDefinitionByName("Portlet 1"));
        if (!afterUpdates)
        {
            assertTrue("\"user.name.family\" user attribute was not found.", app.getUserAttributes().size() == 1);
        }
        else
        {
            assertTrue("\"user.name.family\" and user.pets user attributes were not found.", app.getUserAttributes()
                    .size() == 2);

        }

        portlet = (PortletDefinitionComposite) portletRegistry.getPortletDefinitionByUniqueName("App_1::Portlet 1");

        assertNotNull("Portlet could not be retreived by unique name.", portlet);

        validateDublinCore(portlet.getMetadata());

        assertNotNull("Portlet Application was not set in the portlet defintion.", portlet
                .getPortletApplicationDefinition());
        assertNotNull("French description was not materialized for the web app.", webApp.getDescription(Locale.FRENCH));
        assertNotNull("French display name was not materialized for the web app.", webApp.getDisplayName(Locale.FRENCH));
        assertNotNull("description was not materialized for the portlet.", portlet.getDescription(Locale.getDefault()));
        assertNotNull("display name was not materialized for the portlet.", portlet.getDisplayName(Locale.getDefault()));
        assertNotNull("\"testparam\" portlet parameter was not saved", portlet.getInitParameterSet().get("testparam"));
        assertNotNull("\"preference 1\" was not found.", portlet.getPreferenceSet().get("preference 1"));
        assertNotNull("Language information not found for Portlet 1", portlet.getLanguageSet().get(Locale.getDefault()));
        assertNotNull("Content Type html not found.", portlet.getContentTypeSet().get("html/text"));
        assertNotNull("Content Type wml not found.", portlet.getContentTypeSet().get("wml"));
        Iterator itr = portlet.getPreferenceSet().get("preference 1").getValues();
        int valueCount = 0;

        while (itr.hasNext())
        {
            itr.next();
            valueCount++;
        }
        assertEquals("\"preference 1\" did not have 2 values.", 2, valueCount);

        // Pull out our Web app and add a Description to it
        webApp = null;

        app = portletRegistry.getPortletApplication("App_1");

        webApp = (WebApplicationDefinitionImpl) app.getWebApplicationDefinition();
        assertNotNull("Web app was not located by query.", webApp);
        webApp.addDescription(Locale.getDefault(), "Web app description");

        webApp = null;

        app = portletRegistry.getPortletApplication("App_1");
        webApp = (WebApplicationDefinitionImpl) app.getWebApplicationDefinition();

        assertNotNull("Web app was not located by query.", webApp);
        assertNotNull("Web app did NOT persist its description", webApp.getDescription(Locale.FRENCH));

    }
View Full Code Here

Examples of org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl

        JetspeedServiceReference service2 = new JetspeedServiceReferenceImpl("PortletRegistryComponent");
        app.addJetspeedService(service2);

        addDublinCore(app.getMetadata());

        WebApplicationDefinitionImpl webApp = new WebApplicationDefinitionImpl();
        webApp.setContextRoot("/app1");
        webApp.addDescription(Locale.FRENCH, "Description: Le fromage est dans mon pantalon!");
        webApp.addDisplayName(Locale.FRENCH, "Display Name: Le fromage est dans mon pantalon!");

        PortletDefinitionComposite portlet = new PortletDefinitionImpl();
        portlet.setClassName("org.apache.Portlet");
        portlet.setName("Portlet 1");
        portlet.addDescription(Locale.getDefault(), "Portlet description.");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.