taylor      2004/08/12 21:54:16

  Modified:    fusion/src/java/org/apache/jetspeed/fusion/portal/portlets
                        JetspeedFusionPortlet.java
  Log:
  When checking for mode access to a portlet, Fusion looks at both J1 security checks 
and JSR 168 modes support constraints
  
  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.6       +27 -6     
jakarta-jetspeed/fusion/src/java/org/apache/jetspeed/fusion/portal/portlets/JetspeedFusionPortlet.java
  
  Index: JetspeedFusionPortlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/fusion/src/java/org/apache/jetspeed/fusion/portal/portlets/JetspeedFusionPortlet.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JetspeedFusionPortlet.java        12 Aug 2004 18:41:30 -0000      1.5
  +++ JetspeedFusionPortlet.java        13 Aug 2004 04:54:16 -0000      1.6
  @@ -43,6 +43,7 @@
   import org.apache.jetspeed.services.resources.FusionResources;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
   import org.apache.jetspeed.util.JetspeedClearElement;
  +import org.apache.jetspeed.util.PortletSessionState;
   import org.apache.pluto.om.entity.PortletEntity;
   import org.apache.pluto.om.portlet.PortletDefinition;
   import org.apache.pluto.om.window.PortletWindow;
  @@ -340,22 +341,42 @@
           
           syncNavigationalState(window, jrun, mode, instance);        
       }
  +
  +    private static final String SUPPORTS_EDIT_MODE = 
"org.apache.jetspeed.fusion.edit.mode";
  +    private static final String SUPPORTS_VIEW_MODE = 
"org.apache.jetspeed.fusion.view.mode";
  +     
  +    private boolean supportsMode(PortletMode mode, RunData rundata, String modeType)
  +    {
  +        Boolean supportsMode = 
  +            (Boolean)PortletSessionState.getAttribute(this, rundata, modeType);
  +        if (supportsMode == null)
  +        {
  +            String pa = 
getPortletConfig().getInitParameter(PORTLET_APPLICATION_NAME, null);
  +            String pd = 
getPortletConfig().getInitParameter(PORTLET_DEFINITION_NAME, null);
  +            String registryKey = pa + "::" + pd;
  +            PortletDefinition pdef = 
registryAccess.getPortletDefinitionByUniqueName(registryKey);
  +            boolean supports = pdef.getContentTypeSet().supportsPortletMode(mode);
  +            PortletSessionState.setAttribute(this, rundata, modeType, new 
Boolean(supports));
  +            return supports;
  +        }
  +        else
  +        {
  +            return supportsMode.booleanValue();
  +        }        
  +    }
       
       public boolean getAllowEdit( RunData rundata )
       {
  -        // TODO: look 'allow' up in J2 portlet
  -        return super.getAllowEdit(rundata);
  +        return super.getAllowEdit(rundata) && supportsMode(PortletMode.EDIT, 
rundata, SUPPORTS_EDIT_MODE);
       }
       
       public boolean getAllowView( RunData rundata )
       {
  -        // TODO: look 'allow' up in J2 portlet
  -        return super.getAllowView(rundata);
  +        return super.getAllowView(rundata) && supportsMode(PortletMode.VIEW, 
rundata, SUPPORTS_VIEW_MODE);
       }
       
       public boolean getAllowMaximize( RunData rundata )
       {
  -        // TODO: look 'allow' up in J2 portlet
           return super.getAllowEdit(rundata);
       }
           
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to