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

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


    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;
       
        List<String> portletWarEntries = Arrays.asList( testWarEntryNames );
        List<String> unassembledWarEntries = Arrays.asList( unassembledWarEntryName );
        List<String> testPortlets = Arrays.asList( testPortletNames );
       
        int earEntryCount = 0;
        int totalWarEntryCount = 0;
        int portletWarEntryCount = 0;
       
        JarInputStream earIn = new JarInputStream( new FileInputStream( earFile ) );
       
        JarEntry earEntry;
        JarEntry warEntry;
       
       
        while ( ( earEntry = earIn.getNextJarEntry() ) != null ) {           
            earEntryCount++;
           
            if ( earEntry.getName().endsWith( ".war" ) ) {
                totalWarEntryCount++;
                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 ) ) );
                    }
                }
               
                if ( portletWarEntries.contains( earEntry.getName() ) ) {
                    portletWarEntryCount++;
                    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 );
                   
                    for ( Iterator<? extends PortletDefinition> iter = portletApp.getPortlets().iterator(); iter.hasNext(); ) {
                        PortletDefinition portlet = iter.next();
                        if (! testPortlets.contains( portlet.getPortletName() ) ) {
                            fail( "Unexpected test portlet name encountered: [" + portlet.getPortletName() + "]" );
                        }
                        String servletClassName = webXmlRewriter.getServletClass( portlet.getPortletName() );
View Full Code Here


            {
                throw (IOException) e;
            }
            throw new IOException(e.getMessage());
        }
        PortletApplicationDefinition portletAppDD = new PortletAppDescriptorServiceImpl().read("test", "/test", portletXmlIn);
        portletXmlIn.close();
        for (PortletDefinition portlet : portletAppDD.getPortlets())
        {
            webXmlRewriter.injectPortletServlet(dispatchServletClass, portlet.getPortletName());
        }
        webXmlRewriter.write(assembledWebXmlOut);
    }
View Full Code Here

  public String register(ServletConfig config) throws PortletContainerException {
      ServletContext servletContext = config.getServletContext();
      String contextPath = getContextPath(servletContext);
        if (!portletContexts.containsKey(contextPath)) {

            PortletApplicationDefinition portletApp = portletRegistry.getPortletAppDD(servletContext, contextPath, contextPath);

            DriverPortletContext portletContext = new DriverPortletContextImpl(servletContext, portletApp, rdService);

            portletContexts.put(contextPath, portletContext);

            fireRegistered(portletContext);

            if (LOG.isInfoEnabled()) {
                LOG.info("Registered portlet application for context '" + contextPath + "'");

                LOG.info("Registering "+portletApp.getPortlets().size()+" portlets for context /"+portletContext.getApplicationName());
            }

            classLoaders.put(portletApp.getName(), Thread.currentThread().getContextClassLoader());
            for (PortletDefinition portlet: portletApp.getPortlets()) {
                String appName = portletContext.getApplicationName();
                if (appName == null) {
                    throw new PortletContainerException("Portlet application name should not be null.");
                }
                portletConfigs.put(
View Full Code Here

        // If the supplied window state isn't a JSR 168 window state,
        // we look to see if it is a custom window state.

        String appId = PortletWindowConfig.parseContextPath(portletId);
        String applicationName = appId;
        PortletApplicationDefinition portletAppDD = null;

        if (portletRegistry == null)
        {
            return false;
        }

        try
        {
            portletAppDD = portletRegistry.getPortletApplication(applicationName);
        }
        catch (PortletContainerException e)
        {
            StringBuffer errMsg = new StringBuffer("Cannot determine supported window " +
                    "states for portletId [" + portletId + "] and window state [" + state + "].  ");
            String msg = errMsg.append("Unable to access the Portlet Registry Service.").toString();
            LOG.error(msg, e);
        }

        List customWindowStates = portletAppDD.getCustomWindowStates();
        if (customWindowStates != null)
        {
            for (Iterator i = customWindowStates.iterator(); i.hasNext();)
            {
                CustomWindowState customState = (CustomWindowState) i.next();
View Full Code Here

            if (portletRegistry == null)
            {
                LOG.error("Optional Portlet Registry Service not found.");
                throw new PortletContainerException("Optional Portlet Registry Service not found.");
            }
            PortletApplicationDefinition ctx = portletRegistry.getPortletApplication(applicationName);
            Iterator i = ctx.getPortlets().iterator();
            while (i.hasNext())
            {
                PortletDefinition dd = (PortletDefinition) i.next();
                if (portletName.equals(dd.getPortletName()))
                {
View Full Code Here

//        {
//            applicationName = applicationName.substring(1);
//        }
        try
        {
            PortletApplicationDefinition portletApp = portletRegistry.getPortletApplication(applicationName);
            Iterator customModes = portletApp.getCustomPortletModes().iterator();
            while (customModes.hasNext())
            {
                CustomPortletModeType customMode = (CustomPortletModeType) customModes.next();
                boolean isPortletManagedMode = !customMode.isPortalManaged();
                if (isPortletManagedMode && customMode.getPortletMode().equalsIgnoreCase(mode))
View Full Code Here

        if (portletRegistry == null)
        {
            LOG.error("Optional Portlet Registry Service not found.");
            throw new PortletContainerException("Optional Portlet Registry Service not found.");
        }
        PortletApplicationDefinition portletApp = portletRegistry.getPortletApplication(applicationName);
        Iterator i = portletApp.getPortlets().iterator();
        while (i.hasNext())
        {
            PortletDefinition dd = (PortletDefinition) i.next();
            if (portletName.equals(dd.getPortletName()))
            {
View Full Code Here

  public void addEvent(Event event) {
    this.events.add(event)
  }

  private EventDefinition getEventDefintion(QName name) {
    PortletApplicationDefinition appDD = portletWindow.getPortletDefinition().getApplication();
    for (EventDefinition def : appDD.getEventDefinitions()){
      if (def.getQName() != null){
        if (def.getQName().equals(name))
          return def;
      }
      else{
        QName tmp = new QName(appDD.getDefaultNamespace(),def.getName());
        if (tmp.equals(name))
          return def;
      }
    }
    throw new IllegalStateException();
View Full Code Here

            LOG.warn(e.getMessage(),e);
        }  
    }

    private EventDefinition getEventDefintion(PortletWindow portletWindow, QName name) {
        PortletApplicationDefinition appDD = portletWindow.getPortletDefinition().getApplication();
        for (EventDefinition def : appDD.getEventDefinitions()){
            if (def.getQName() != null){
                if (def.getQName().equals(name))
                    return def;
            }
            else{
                QName tmp = new QName(appDD.getDefaultNamespace(),def.getName());
                if (tmp.equals(name))
                    return def;
            }
        }
        throw new IllegalStateException();
View Full Code Here

    Collection<PortletWindowConfig> portlets = getAllPortlets(driverConfig);

    for (PortletWindowConfig portlet : portlets) {
      String contextPath = portlet.getContextPath();
            String applicationName = contextPath;
      PortletApplicationDefinition portletAppDD = null;
      try {
        portletAppDD = portletRegistry.getPortletApplication(applicationName);
        List<? extends PortletDefinition> portletDDs = portletAppDD.getPortlets();
        List<QName> aliases = getAllAliases(eventName, portletAppDD);
        for (PortletDefinition portletDD : portletDDs) {
          List<? extends EventDefinitionReference> processingEvents = portletDD.getSupportedProcessingEvents();
          if (isEventSupported(processingEvents, eventName, portletAppDD.getDefaultNamespace())) {
                        if (portletDD.getPortletName().equals(portlet.getPortletName())) {
                                                          resultSet.add(portlet.getId());
                        }
          } else {

            if (processingEvents != null) {
              for (EventDefinitionReference ref : processingEvents) {
                  QName name = ref.getQualifiedName(portletAppDD.getDefaultNamespace());
                  if (name == null)
                  {
                      continue;
                  }
                // add also grouped portlets, that ends with "."
                if (name.toString().endsWith(".")
                    && eventName.toString().startsWith(name.toString())
                    && portletDD.getPortletName().equals(portlet.getPortletName())) {
                  resultSet.add(portlet.getId());
                }
                // also look for alias names:
                if (aliases != null) {
                  for (QName alias : aliases) {
                    if (alias.toString().equals(name.toString())
                        && portletDD.getPortletName().equals(portlet.getPortletName())) {
                      resultSet.add(portlet.getId());
                    }
                  }
                }
                // also look for default namespaced events
                if (name.getNamespaceURI() == null || name.getNamespaceURI().equals("")) {
                  String defaultNamespace = portletAppDD.getDefaultNamespace();
                  QName qname = new QName(defaultNamespace, name.getLocalPart());
                  if (eventName.toString().equals(qname.toString())
                      && portletDD.getPortletName().equals(portlet.getPortletName())) {
                    resultSet.add(portlet.getId());
                  }
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.