You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2004/07/06 18:11:25 UTC

cvs commit: jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/pam PortletApplicationResources.java PortletApplicationBean.java PortletApplicationBrowser.java PortletApplicationDetail.java

taylor      2004/07/06 09:11:25

  Modified:    applications/pam/src/java/org/apache/jetspeed/portlets/pam
                        PortletApplicationBrowser.java
                        PortletApplicationDetail.java
  Added:       applications/pam/src/java/org/apache/jetspeed/portlets/pam
                        PortletApplicationResources.java
                        PortletApplicationBean.java
  Log:
  Start of inter-portlet communication between PAM Browser and Details. Needs some more prototyping and abstraction.
  
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.5       +29 -24    jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationBrowser.java
  
  Index: PortletApplicationBrowser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationBrowser.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PortletApplicationBrowser.java	2 Jul 2004 03:58:48 -0000	1.4
  +++ PortletApplicationBrowser.java	6 Jul 2004 16:11:25 -0000	1.5
  @@ -26,6 +26,7 @@
   import javax.portlet.PortletConfig;
   import javax.portlet.PortletContext;
   import javax.portlet.PortletException;
  +import javax.portlet.PortletSession;
   import javax.portlet.PortletURL;
   import javax.portlet.RenderRequest;
   import javax.portlet.RenderResponse;
  @@ -41,41 +42,43 @@
   /**
    * This portlet is a browser over all the portlet applications in the system.
    *
  + * @author <a href="mailto:jford@apache.com">Jeremy Ford</a>
    * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  - * @author <a href="mailto:ccardona@gluecode.com">Chris Cardona</a>
  - * 
    * @version $Id$
    */
   public class PortletApplicationBrowser extends ServletPortlet
   {
       private String template;
  +    private PortletContext context;
  +    private PortletRegistryComponent registry;
       
       public void init(PortletConfig config)
       throws PortletException 
       {
           super.init(config);
  +        context = getPortletContext();                
  +        registry = (PortletRegistryComponent)context.getAttribute(PortletApplicationResources.CPS_REGISTRY_COMPONENT);
  +        if (null == registry)
  +        {
  +            throw new PortletException("Failed to find the Portlet Registry on portlet initialization");
  +        }
       }
       
       public void doView(RenderRequest request, RenderResponse response)
       throws PortletException, IOException
       {
  -        PortletContext context = getPortletContext();
           response.setContentType("text/html");
           
  -        PortletRegistryComponent registry = (PortletRegistryComponent)
  -                context.getAttribute("cps:PortletRegistryComponent");
  -        if (registry != null)
  +        List apps = registry.getPortletApplications();
  +        TreeControl control = (TreeControl) request.getPortletSession().getAttribute("j2_tree");
  +        if(control == null)
           {
  -            List apps = registry.getPortletApplications();
  -            TreeControl control = (TreeControl) request.getPortletSession().getAttribute("j2_tree");
  -            if(control == null)
  -            {
  -                PortletURL actionURL = response.createActionURL();
  -            	control = buildTree(apps, actionURL);
  -            	request.getPortletSession().setAttribute("j2_tree", control);
  -            }
  -            request.setAttribute("j2_tree", control);
  -        }        
  +            PortletURL actionURL = response.createActionURL();
  +        	control = buildTree(apps, actionURL);
  +        	request.getPortletSession().setAttribute("j2_tree", control);
  +        }
  +        request.setAttribute("j2_tree", control);
  +        
           super.doView(request, response);
           
       }
  @@ -98,20 +101,22 @@
   		    }
   		}
   		
  -		String selectedNode = actionRequest.getParameter("select_node");
  +		String selectedNode = actionRequest.getParameter(PortletApplicationResources.REQUEST_SELECT_NODE);
   		if(selectedNode != null)
   		{
   		    control.selectNode(selectedNode);
  -		    //TODO:  signal details portlet that node was selected
  -		    
  -		    System.out.println("Node Selected: " + selectedNode);
  +            MutablePortletApplication pa = registry.getPortletApplicationByIdentifier(selectedNode);
  +            if (null != pa)
  +            {
  +                actionRequest.getPortletSession().setAttribute(PortletApplicationResources.PAM_CURRENT_PA, pa, PortletSession.APPLICATION_SCOPE);
  +            }
   		}	
   	}
   	
   	private TreeControl buildTree(List apps, PortletURL actionURL) {
   	    
   	    
  -	    actionURL.setParameter("select_node", "ROOT-NODE");
  +	    actionURL.setParameter(PortletApplicationResources.REQUEST_SELECT_NODE, "ROOT-NODE");
   		TreeControlNode root =
               new TreeControlNode("ROOT-NODE",
                                   null, "J2_ROOT",
  @@ -121,7 +126,7 @@
   		TreeControl control = new TreeControl(root);
   		
   		
  -		actionURL.setParameter("select_node", "APP_ROOT");
  +		actionURL.setParameter(PortletApplicationResources.REQUEST_SELECT_NODE, "APP_ROOT");
   		TreeControlNode portletApps = 
   			new TreeControlNode("APP-NODE", null, "APP_ROOT", actionURL.toString(), null, false, "J2_DOMAIN");
   		root.addChild(portletApps);
  @@ -130,7 +135,7 @@
           while (it.hasNext())
           {
               MutablePortletApplication pa = (MutablePortletApplication)it.next();
  -            actionURL.setParameter("select_node", pa.getName());
  +            actionURL.setParameter(PortletApplicationResources.REQUEST_SELECT_NODE, pa.getName());
               TreeControlNode appNode = new TreeControlNode(pa.getName(), null, pa.getName(), actionURL.toString(), null, false, "PA_APP_DOMAIN"  );
               portletApps.addChild(appNode);
           }
  
  
  
  1.2       +3 -12     jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java
  
  Index: PortletApplicationDetail.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PortletApplicationDetail.java	6 Jun 2004 01:44:54 -0000	1.1
  +++ PortletApplicationDetail.java	6 Jul 2004 16:11:25 -0000	1.2
  @@ -1,18 +1,9 @@
   /*
 * Copyright 2000-2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jetspeed.portlets.pam;
   
  -import java.io.IOException;
//import java.io.InputStream;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletContext;
import javax.portlet.PortletException;
import javax.portlet.PortletMode;
import javax.portlet.PortletURL;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.WindowState;
  -import org.apache.jetspeed.portlet.ServletPortlet;

  -/**
 * This portlet is a browser over all the portlet applications in the system.
 *
 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 * @author <a href="mailto:ccardona@gluecode.com">Chris Cardona</a>
 * @version $Id$
 */
public class PortletApplicationDetail extends ServletPortlet
{
    public void doView(RenderRequest request, RenderResponse response)
  +import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
import javax.portlet.PortletException;
import javax.portlet.PortletSession;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.apache.jetspeed.portlet.ServletPortlet;
import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;

  +/**
 * This portlet is a browser over all the portlet applications in the system.
 *
 * @author <a href="mailto:jford@apache.com">Jeremy Ford</a>
 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 * @version $Id$
 */
public class PortletApplicationDetail extends ServletPortlet
{
    private final String VIEW_PA = "portletApplication"; 

    private PortletContext context;
    private PortletRegistryComponent registry;
    
    public void init(PortletConfig config)
    throws PortletException 
    {
        super.init(config);
        context = getPortletContext();
        registry = (PortletRegistryComponent)context.getAttribute(PortletApplicationResources.CPS_REGISTRY_COMPONENT);
        if (null == registry)
        {
            throw new PortletException("Failed to find the Portlet Registry on portlet initialization");
        }        
    }
    
    public void doView(RenderRequest request, RenderResponse response)
       throws PortletException, IOException
  -    {
  -        PortletContext context = getPortletContext();
  -        response.setContentType("text/html");        
  -        PortletURL url = response.createRenderURL();
  -        PortletURL actionUrl = response.createActionURL();
  -        url.setWindowState(WindowState.MAXIMIZED);
  -        actionUrl.setPortletMode(PortletMode.EDIT);
  -        // url.addParameter("test", "value");
  -        response.getWriter().println("<br/><b>Init Param 'Template' = " + this.getInitParameter("template") +  "</b>");
        response.getWriter().println("<br/><b>Render URL = <a href='" + url +  "'>" + url + "</a></b>");
        response.getWriter().println("<br/><b>Action URL = <a href='" + actionUrl +  "'>" + actionUrl + "</a></b>");
        response.getWriter().println("<br/><b>Request dispatching now</b>");        
  +    {
        response.setContentType("text/html");
        
        MutablePortletApplication pa = (MutablePortletApplication)
                request.getPortletSession().getAttribute(PortletApplicationResources.PAM_CURRENT_PA, 
                                                         PortletSession.APPLICATION_SCOPE);
        
        if (null != pa)
        {
            request.setAttribute(VIEW_PA, new PortletApplicationBean(pa));
        }
           super.doView(request, response);
        }
   	public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException
	{
		System.out.println("PorletApplicationDetail: processAction()");
	}
  
  
  
  1.1                  jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationResources.java
  
  Index: PortletApplicationResources.java
  ===================================================================
  /*
   * Copyright 2000-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.jetspeed.portlets.pam;
  
  /**
   * Common resources used by Portlet Application Manager
   *
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: PortletApplicationResources.java,v 1.1 2004/07/06 16:11:25 taylor Exp $
   */
  public final class PortletApplicationResources
  {
      final static String REQUEST_SELECT_NODE = "select_node";
      final static String PAM_CURRENT_PA = "org.apache.jetspeed.pam.pa";
      final static String CPS_REGISTRY_COMPONENT = "cps:PortletRegistryComponent";
  }
  
  
  
  1.1                  jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationBean.java
  
  Index: PortletApplicationBean.java
  ===================================================================
  /*
   * Copyright 2000-2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.jetspeed.portlets.pam;
  
  import java.util.Collection;
  
  import org.apache.jetspeed.om.common.GenericMetadata;
  import org.apache.jetspeed.om.common.portlet.PortletApplication;
  import org.apache.pluto.om.common.ObjectID;
  import org.apache.pluto.om.portlet.PortletDefinition;
  import org.apache.pluto.om.portlet.PortletDefinitionList;
  import org.apache.pluto.om.servlet.WebApplicationDefinition;
  
  /**
   * This portlet is a browser over all the portlet applications in the system.
   *
   * @author <a href="mailto:jford@apache.com">Jeremy Ford</a>
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: PortletApplicationBean.java,v 1.1 2004/07/06 16:11:25 taylor Exp $
   */
  public class PortletApplicationBean implements PortletApplication
  {
      PortletApplication pa;
      
      
      public PortletApplicationBean(PortletApplication pa)
      {
          this.pa = pa;
      }
      
      /* (non-Javadoc)
       * @see org.apache.jetspeed.om.common.portlet.PortletApplication#getMetadata()
       */
      public GenericMetadata getMetadata()
      {
          return pa.getMetadata();
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.om.common.portlet.PortletApplication#getName()
       */
      public String getName()
      {
          return pa.getName();
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.om.common.portlet.PortletApplication#getPortletDefinitions()
       */
      public Collection getPortletDefinitions()
      {
          return pa.getPortletDefinitions();
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.om.common.portlet.PortletApplication#getPortletDefinitionByName(java.lang.String)
       */
      public PortletDefinition getPortletDefinitionByName(String name)
      {
          return pa.getPortletDefinitionByName(name);
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.om.common.portlet.PortletApplication#getUserAttributeRefs()
       */
      public Collection getUserAttributeRefs()
      {
          return pa.getUserAttributeRefs();
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.om.common.portlet.PortletApplication#getUserAttributes()
       */
      public Collection getUserAttributes()
      {
          return pa.getUserAttributes();
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.om.common.portlet.PortletApplication#getApplicationIdentifier()
       */
      public String getApplicationIdentifier()
      {
          return pa.getApplicationIdentifier();
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.om.common.portlet.PortletApplication#getDescription()
       */
      public String getDescription()
      {
          return pa.getDescription();
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.om.common.portlet.PortletApplication#getApplicationType()
       */
      public int getApplicationType()
      {
          return pa.getApplicationType();
      }
  
      /* (non-Javadoc)
       * @see org.apache.pluto.om.portlet.PortletApplicationDefinition#getId()
       */
      public ObjectID getId()
      {
          return pa.getId();
      }
  
      /* (non-Javadoc)
       * @see org.apache.pluto.om.portlet.PortletApplicationDefinition#getVersion()
       */
      public String getVersion()
      {
          return pa.getVersion();
      }
  
      /* (non-Javadoc)
       * @see org.apache.pluto.om.portlet.PortletApplicationDefinition#getPortletDefinitionList()
       */
      public PortletDefinitionList getPortletDefinitionList()
      {
          return pa.getPortletDefinitionList();
      }
  
      /* (non-Javadoc)
       * @see org.apache.pluto.om.portlet.PortletApplicationDefinition#getWebApplicationDefinition()
       */
      public WebApplicationDefinition getWebApplicationDefinition()
      {
          return pa.getWebApplicationDefinition();
      }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org