Package org.apache.jetspeed.om.common.portlet

Examples of org.apache.jetspeed.om.common.portlet.MutablePortletApplication


               
                if (portlet == null)
                    continue;
               
                // Do not display Jetspeed Layout Applications
                MutablePortletApplication pa = (MutablePortletApplication)portlet.getPortletApplicationDefinition();
                if (pa.isLayoutApplication())
                    continue;
                        
                // SECURITY filtering
                String uniqueName = pa.getName() + "::" + portlet.getName();
                if (securityAccessController.checkPortletAccess(portlet, JetspeedActions.MASK_VIEW))
                {
                    String name = portlet.getDisplayNameText(locale);
                    if (name == null)
                    {
View Full Code Here


   
    public void testLoadPortletApplicationTree() throws Exception
    {
        System.out.println("Testing loadPortletApplicationTree");
        PortletApplicationDescriptor pad = new PortletApplicationDescriptor(new FileReader("./test/testdata/deploy/portlet.xml"), "unit-test");
        MutablePortletApplication app = pad.createPortletApplication();           
        assertNotNull("App is null", app);
        assertNotNull("Version is null", app.getVersion());
        assertTrue("Version invalid: " + app.getVersion(), app.getVersion().equals("1.0"));
        assertNotNull("PA Identifier is null", app.getApplicationIdentifier());
        assertTrue(
                "PA Identifier invalid: " + app.getApplicationIdentifier(),
                app.getApplicationIdentifier().equals("TestRegistry"));
      
        ExtendedPortletMetadata md = new ExtendedPortletMetadata(new FileReader("./test/testdata/deploy/jetspeed-portlet.xml"), app);
        md.load();
      
        PortletDefinitionComposite def1 = (PortletDefinitionComposite)app.getPortletDefinitionByName(PORTLET_01);
        PortletDefinitionComposite def2 = (PortletDefinitionComposite)app.getPortletDefinitionByName(PORTLET_02);
        PortletDefinitionComposite def3 = (PortletDefinitionComposite)app.getPortletDefinitionByName(PORTLET_03);
        PortletDefinitionComposite def4 = (PortletDefinitionComposite)app.getPortletDefinitionByName(PORTLET_04);
       
        Collection titles = app.getMetadata().getFields("title");
        Collection def1Titles = def1.getMetadata().getFields("title");
        Collection def2Subjects = def2.getMetadata().getFields("subject");
        Collection def3Creators = def3.getMetadata().getFields("creator");
        Collection def4Field1 = def4.getMetadata().getFields("field1");
        Collection def4Fiels2 = def4.getMetadata().getFields("field2");
       
        String securityRef = app.getJetspeedSecurityConstraint();
        assertEquals(titles.size(), 3);
        assertEquals(def1Titles.size(), 4);
        assertEquals(def2Subjects.size(), 5);
        assertEquals(def3Creators.size(), 4);
        assertEquals(def4Field1.size(), 3);
        assertEquals(def4Fiels2.size(), 2);
       
        // Security Constraints tests
        assertEquals(securityRef, "admin-only");
        assertEquals(def1.getJetspeedSecurityConstraint(), "users-1");
        assertEquals(def2.getJetspeedSecurityConstraint(), "users-2");
        assertEquals(def3.getJetspeedSecurityConstraint(), "users-4");
        assertNull(def4.getJetspeedSecurityConstraint());
       
        Collection servicesCollection = app.getJetspeedServices();
        assertNotNull("Metadata services is null", servicesCollection);
        assertEquals("Expected 2 service definitions", servicesCollection.size(), 2);
        Object[] services = servicesCollection.toArray();
        JetspeedServiceReference service = (JetspeedServiceReference)services[0];
        System.out.println("**** service = " + service.getName());
View Full Code Here

    {
        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)
        {
        }
        assertEquals("Invalid loaded PortletDescriptor validation result", false, validateFailed);

        // remove the app
        try
        {
           
            portletRegistry.removeApplication(app);
           
        }
        catch (Exception e)
        {
            String msg = "Unable to remove portlet application, " + app.getName()
                    + ", through the portlet portletRegistry: " + e.toString();
            throw new Exception(msg, e);
        }

    }
View Full Code Here

       
        String paName = (String)
            request.getPortletSession().getAttribute(PortletApplicationResources.PAM_CURRENT_PA,
                                             PortletSession.APPLICATION_SCOPE);
       
        MutablePortletApplication pa = registry.getPortletApplication(paName);
       
        if (null != pa)
        {
            request.setAttribute(VIEW_PA, new PortletApplicationBean(pa));
           
            String pdefName = (String) request.getPortletSession().getAttribute(PortletApplicationResources.REQUEST_SELECT_PORTLET, PortletSession.APPLICATION_SCOPE);
            PortletDefinitionComposite pdef = (PortletDefinitionComposite) pa.getPortletDefinitionByName(pdefName);
           
            request.setAttribute(VIEW_PD, pdef);
           
            request.setAttribute("tabs", paTabMap.values());
            request.setAttribute("portlet_tabs", pdTabMap.values());
View Full Code Here

        }
       
        String action = actionRequest.getParameter(PORTLET_ACTION);
        if(action != null)
        {
            MutablePortletApplication pa = registry.getPortletApplication(paName);
            if(isAppAction(action))
            {
                action = getAction(PORTLET_APP_ACTION_PREFIX, action);
               
                if(action.endsWith("metadata"))
                {
                    processMetadataAction(actionRequest, actionResponse, pa, null, action);
                }
                else if(action.endsWith("user_attribute"))
                {
                    processUserAttributeAction(actionRequest, actionResponse, pa, action);
                }
                else if(action.endsWith("edit_security_constraint"))
                {
                    processSecurityRef(actionRequest, actionResponse, pa, null, action);
                }
                searchEngine.update(pa);
            }
            else if(isPortletAction(action))
            {
                action = getAction(PORTLET_ACTION_PREFIX, action);
                String pdefName = (String) actionRequest.getPortletSession().getAttribute(PortletApplicationResources.REQUEST_SELECT_PORTLET, PortletSession.APPLICATION_SCOPE);
               
                try
                {
                    PortletDefinitionComposite pdef = (PortletDefinitionComposite) pa.getPortletDefinitionByName(pdefName);
                    if(action.endsWith("metadata"))
                    {
                        processMetadataAction(actionRequest, actionResponse, null, pdef, action);
                    }
                    else if(action.endsWith("portlet"))
View Full Code Here

    }

    // impl not complete
    public void xtestProxy() throws Exception
    {
        MutablePortletApplication app = portletRegistry.getPortletApplication("PA-001");
        MutablePortletApplication cached = MutablePortletApplicationProxy.createProxy(app);
        if (cached instanceof MutablePortletApplication)
            System.out.println("ISA Mutable");
        if (cached instanceof PortletApplicationProxy)
            System.out.println("ISA Mutable Proxy");
        PortletApplicationProxy proxy = (PortletApplicationProxy)cached;
        MutablePortletApplication two = proxy.getRealApplication();
        proxy.setRealApplication(two);
        System.out.println("Two is " + two);
        assertEquals(app, two);
    }
View Full Code Here

    }
   
    public void testCache() throws Exception
    {
        assertNotNull(portletRegistry);
        MutablePortletApplication one = portletRegistry.getPortletApplication("PA-001");
        MutablePortletApplication two = portletRegistry.getPortletApplication("PA-001");
        assertEquals(one, two);
        PortletDefinitionComposite def = portletRegistry.getPortletDefinitionByUniqueName("PA-001::Portlet-1");
        assertNotNull(def);
        assertEquals(def.getPortletApplicationDefinition(), one);
        assertEquals(def, two.getPortletDefinitions().iterator().next());
        MutablePortletApplication o = (MutablePortletApplication)portletRegistry.getPortletApplications().iterator().next();
        assertEquals(one, o);
        assertEquals(portletRegistry.getAllPortletDefinitions().iterator().next(), def);
    }
View Full Code Here

    {
        if (portlet == null)
            return null;
       
        // Do not display Jetspeed Layout Applications
        MutablePortletApplication pa = (MutablePortletApplication)portlet.getPortletApplicationDefinition();
        if (pa.isLayoutApplication())
            return null;
       
        // SECURITY filtering
        String uniqueName = pa.getName() + "::" + portlet.getName();
        if (securityAccessController.checkPortletAccess(portlet, JetspeedActions.MASK_VIEW))
        {
            Parameter param = portlet.getInitParameterSet().get(PORTLET_ICON);
            String image;
            if (param != null)
View Full Code Here

            String addedKeys = request.getParameter("jsAddedKeys");
            String columns = request.getParameter("Columns");
            String rows = request.getParameter("Rows");
            String cats = request.getParameter("jsCats");
            String page = request.getParameter(JSPAGE);
            MutablePortletApplication pa = registry.getPortletApplication("j2-admin");
            String portletName = this.getPortletName();
            PortletDefinitionComposite portlet = (PortletDefinitionComposite) pa.getPortletDefinitionByName(portletName);
            boolean updated = updateNumericPref("Columns", columns, 10, portlet);
            updated = updated | updateNumericPref("Rows", rows, 100, portlet);
                       
            // process removes first
            if (!isEmpty(removes))
View Full Code Here

      {
          control.selectNode(selectedNode);
          TreeControlNode child = control.findNode(selectedNode);
          if(child != null)
          {
              MutablePortletApplication pa = null;
             
            String domain = child.getDomain();
            if(domain.equals("PA_APP_DOMAIN"))
            {
                pa = registry.getPortletApplicationByIdentifier(selectedNode);
                if(pa != null)
                {
                    actionRequest.getPortletSession().removeAttribute(PortletApplicationResources.REQUEST_SELECT_PORTLET, PortletSession.APPLICATION_SCOPE);
                }
            }
            else if(domain.equals("PD_DOMAIN"))
            {
                TreeControlNode parent = child.getParent();
                  pa = registry.getPortletApplicationByIdentifier(parent.getName());
                 
                  //set selected tab to portlets tab
                  if(pa != null)
                  {
                      //TODO:  do we need to look up the pdef?  Could we just pass the child name into setAttribute?
                      String pdefName = child.getName().substring(pa.getName().length() + 2); //remove pa prefix
                      PortletDefinition pdef = pa.getPortletDefinitionByName(pdefName);
                      actionRequest.getPortletSession().setAttribute(PortletApplicationResources.REQUEST_SELECT_PORTLET, pdef.getName(), PortletSession.APPLICATION_SCOPE);
                      actionRequest.getPortletSession().setAttribute(PortletApplicationResources.REQUEST_SELECT_TAB, new TabBean("pa_portlets"), PortletSession.APPLICATION_SCOPE);
                  }
            }
            else
            {
                //warn about not recognized domain
            }
           
            if (pa != null)
                {
                    actionRequest.getPortletSession().setAttribute(PortletApplicationResources.PAM_CURRENT_PA, pa.getName(), PortletSession.APPLICATION_SCOPE);
                }
          }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.common.portlet.MutablePortletApplication

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.