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 at...@apache.org on 2008/12/12 13:07:04 UTC
svn commit: r725977 [19/48] - in /portals/jetspeed-2/portal/trunk: ./
app-servers/security/jboss/src/java/META-INF/jboss-secsvc/
app-servers/security/jboss/src/java/org/apache/jetspeed/appservers/security/jboss/
applications/jetspeed/src/main/javascrip...
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/GetThemesAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/GetUserInformationAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/GetUserListAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/LayoutValve.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/LayoutValve.java?rev=725977&r1=725976&r2=725977&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/LayoutValve.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/LayoutValve.java Fri Dec 12 04:06:29 2008
@@ -1,58 +1,58 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.layout.impl;
-
-import org.apache.jetspeed.ajax.AjaxRequestService;
-import org.apache.jetspeed.pipeline.PipelineException;
-import org.apache.jetspeed.pipeline.valve.Valve;
-import org.apache.jetspeed.pipeline.valve.ValveContext;
-import org.apache.jetspeed.request.RequestContext;
-
-public class LayoutValve implements Valve
-{
-
- // Ajax service handler
- AjaxRequestService ajaxService = null;
-
- public LayoutValve(AjaxRequestService ajaxService)
- {
- this.ajaxService = ajaxService;
- }
-
- public void initialize() throws PipelineException
- {
- }
-
- public void invoke(RequestContext requestContext,
- ValveContext valveContext) throws PipelineException
- {
- try
- {
- // Delegate the call to the AjaxService
- ajaxService.process(requestContext);
-
- if(valveContext != null)
- {
- valveContext.invokeNext(requestContext);
- }
- }
- catch (Throwable t)
- {
- throw new PipelineException(t);
- }
- }
-}
+ * 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.layout.impl;
+
+import org.apache.jetspeed.ajax.AjaxRequestService;
+import org.apache.jetspeed.pipeline.PipelineException;
+import org.apache.jetspeed.pipeline.valve.Valve;
+import org.apache.jetspeed.pipeline.valve.ValveContext;
+import org.apache.jetspeed.request.RequestContext;
+
+public class LayoutValve implements Valve
+{
+
+ // Ajax service handler
+ AjaxRequestService ajaxService = null;
+
+ public LayoutValve(AjaxRequestService ajaxService)
+ {
+ this.ajaxService = ajaxService;
+ }
+
+ public void initialize() throws PipelineException
+ {
+ }
+
+ public void invoke(RequestContext requestContext,
+ ValveContext valveContext) throws PipelineException
+ {
+ try
+ {
+ // Delegate the call to the AjaxService
+ ajaxService.process(requestContext);
+
+ if(valveContext != null)
+ {
+ valveContext.invokeNext(requestContext);
+ }
+ }
+ catch (Throwable t)
+ {
+ throw new PipelineException(t);
+ }
+ }
+}
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/LayoutValve.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/MovePortletAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/MultipleAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/MultipleAction.java?rev=725977&r1=725976&r2=725977&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/MultipleAction.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/MultipleAction.java Fri Dec 12 04:06:29 2008
@@ -1,326 +1,326 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.layout.impl;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.apache.jetspeed.ajax.AJAXException;
-import org.apache.jetspeed.ajax.AjaxAction;
-import org.apache.jetspeed.ajax.AjaxBuilder;
-import org.apache.jetspeed.ajax.AjaxRequestService;
-import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
-import org.apache.jetspeed.page.PageManager;
-import org.apache.jetspeed.request.JetspeedRequestContext;
-import org.apache.jetspeed.request.RequestContext;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.context.Context;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-
-/**
- *
- * @author David Gurney
- *
- * The purpose of this object is to run several AJAX actions and aggregate the
- * results into a single response. This is useful when the client needs to make
- * more than one call as the result of a single user action.
- *
- * The sample request URL is shown below:
- *
- * http://host:port/ajaxapi?action=multiple&commands=(action;name,value;name,value)(action;name,value)
- *
- * The constructor accepts a map of the actions that are available to be run.
- * The name,value pairs are parameter values needed by the action. The actions
- * are run in the order that they are found on the URL string
- *
- */
-public class MultipleAction extends BasePortletAction implements AjaxAction,
- AjaxBuilder, BeanFactoryAware
-{
-
- protected static final String ALL_RESULTS = "results";
-
- protected static final String BUILD_RESULTS = "buildresults";
-
- protected static final String MULTIPLE_ACTION_PROCESSOR = "Multiple Action Processor";
-
- protected static final String COMMANDS = "commands";
-
- protected static final String COMMAND_TOKEN = ")";
-
- protected static final String PARAM_TOKEN = ";";
-
- protected static final String VALUE_TOKEN = ",";
-
- protected Map actionMap = null;
-
- protected VelocityEngine m_oVelocityEngine = null;
-
- public MultipleAction(AjaxRequestService requestService, String p_sTemplate,
- String p_sErrorTemplate, PageManager p_oPageManager,
- PortletActionSecurityBehavior p_oSecurityBehavior,
- VelocityEngine p_oVelocityEngine)
- {
- super(p_sTemplate, p_sErrorTemplate, p_oPageManager,
- p_oSecurityBehavior);
- actionMap = requestService.getActionMap();
- m_oVelocityEngine = p_oVelocityEngine;
- }
-
- public void setBeanFactory(BeanFactory beanFactory) throws BeansException
- {
- // get the proxied object for this, and put it in the map to avoid circular dep
- Object proxy = beanFactory.getBean("AjaxMultipleAction");
- actionMap.put("multiple", proxy);
- }
-
- public boolean run(RequestContext p_oRequestContext, Map p_oResultMap)
- throws AJAXException
- {
- boolean a_bReturnSuccess = true;
- List a_oResultArray = new ArrayList();
-
- p_oResultMap.put(ACTION, "multiple");
- p_oResultMap.put(STATUS, "success");
-
- // Get the command string
- String a_sCommands = p_oRequestContext.getRequestParameter(COMMANDS);
- if (a_sCommands == null || a_sCommands.length() <= 0)
- {
- buildErrorContext(p_oRequestContext, p_oResultMap);
- p_oResultMap.put(STATUS, "failure");
- p_oResultMap.put(REASON, "command parameters not found");
-
- throw new AJAXException("command parameters not found");
- }
-
- // Tokenize the commands into single commands
- StringTokenizer a_oCommandTok = new StringTokenizer(a_sCommands,
- COMMAND_TOKEN);
-
- // Process each command
- while (a_oCommandTok.hasMoreTokens())
- {
- // Get the token
- String a_sCommand = a_oCommandTok.nextToken();
-
- // Strip off the opening (
- a_sCommand = a_sCommand.substring(1);
-
- // Tokenize the single commands into parameters
- StringTokenizer a_oParamTok = new StringTokenizer(a_sCommand,
- PARAM_TOKEN);
- if (a_oParamTok == null || a_oParamTok.hasMoreTokens() == false)
- {
- buildErrorContext(p_oRequestContext, p_oResultMap);
- p_oResultMap.put(STATUS, "failure");
- p_oResultMap.put(REASON, "incorrect url request");
-
- throw new AJAXException("incorrect url request");
- }
-
- // Get the action - which is the first item in the list
- String a_sAction = a_oParamTok.nextToken();
-
- // Lookup the action from the action map
- Object a_oActionObject = actionMap.get(a_sAction);
- if (a_oActionObject == null
- && !(a_oActionObject instanceof AjaxAction))
- {
- buildErrorContext(p_oRequestContext, p_oResultMap);
- p_oResultMap.put(REASON, "unknown action requested==>"
- + a_sAction);
-
- throw new AJAXException("unknown action requested==>"
- + a_sAction);
- }
-
- AjaxAction a_oAction = (AjaxAction) a_oActionObject;
-
- JetspeedRequestContext a_oJetspeedRequestContext = (JetspeedRequestContext) p_oRequestContext;
-
- // Process each parameter for this action
- while (a_oParamTok.hasMoreTokens())
- {
- String a_sName = a_oParamTok.nextToken(VALUE_TOKEN);
- // Strip of the leading ; if present
- if (a_sName.indexOf(';') >= 0)
- {
- a_sName = a_sName.substring(1);
- }
-
- String a_sValue = a_oParamTok.nextToken();
-
- // Put the parameters on the request context
- a_oJetspeedRequestContext.setAttribute(a_sName, a_sValue);
- }
-
- // Invoke the action
- Map a_oResultMap = new HashMap();
- boolean a_bSuccess;
-
- try
- {
- a_bSuccess = a_oAction.runBatch(a_oJetspeedRequestContext,
- a_oResultMap);
- } catch (Exception e)
- {
- // Move the reason into the return map
- p_oResultMap.put(REASON, a_oResultMap.get(REASON));
-
- throw new AJAXException(e);
- }
-
- // Check for success
- if (a_bSuccess)
- {
- // Invoke the builder for this action if possible
- if (a_oAction instanceof AjaxBuilder)
- {
- processBuilder((AjaxBuilder) a_oAction, a_oResultMap,
- p_oRequestContext, a_bSuccess);
- }
-
- // Get the build results
- String a_sBuildResults = (String) a_oResultMap
- .get(BUILD_RESULTS);
-
- // Look for an xml tag and strip it off
- int a_iStartIndex = a_sBuildResults.indexOf("<?xml");
- if (a_iStartIndex >= 0)
- {
- // Look for the end of the tag
- int a_iEndIndex = a_sBuildResults.indexOf(">",
- a_iStartIndex);
- if (a_iEndIndex >= 0)
- {
- String a_sStart = a_sBuildResults.substring(0,
- a_iStartIndex);
- String a_sEnd = a_sBuildResults.substring(
- a_iEndIndex + 1, a_sBuildResults.length());
- a_sBuildResults = a_sStart + a_sEnd;
- }
- }
-
- if (a_sBuildResults != null)
- {
- // Save the results
- a_oResultArray.add(a_sBuildResults);
- }
- } else
- {
- // Move the reason into the return map
- p_oResultMap.put(REASON, a_oResultMap.get(REASON));
-
- // Exit the loop
- a_bReturnSuccess = false;
- break;
- }
- }
-
- // Save the results for later building into the response
- p_oResultMap.put(ALL_RESULTS, a_oResultArray);
-
- return a_bReturnSuccess;
- }
-
- // Process the builder if provided
- protected void processBuilder(AjaxBuilder p_oBuilder, Map p_oInputMap,
- RequestContext p_oRequestContext, boolean p_oActionSuccessFlag)
- {
- try
- {
- // Ask the builder to construct the context
- // Add the input map to the velocity context
- boolean result = true;
-
- if (p_oActionSuccessFlag == true)
- {
- result = p_oBuilder
- .buildContext(p_oRequestContext, p_oInputMap);
- } else
- {
- result = p_oBuilder.buildErrorContext(p_oRequestContext,
- p_oInputMap);
- }
-
- Context a_oContext = new VelocityContext(p_oInputMap);
-
- // Check to see if we have a valid context
- if (result)
- {
- // Get the name of the template from the builder
- String a_sTemplateName = null;
-
- if (p_oActionSuccessFlag == true)
- {
- a_sTemplateName = p_oBuilder.getTemplate();
- } else
- {
- a_sTemplateName = p_oBuilder.getErrorTemplate();
- }
-
- // Get a reader to the velocity template
- final InputStream a_oTemplateStream = this.getClass()
- .getClassLoader().getResourceAsStream(a_sTemplateName);
-
- Reader a_oTemplate = new InputStreamReader(a_oTemplateStream);
-
- // The results of the velocity template will be stored here
- StringWriter a_oStringWriter = new StringWriter();
-
- // Run the velocity template
- m_oVelocityEngine.evaluate(a_oContext, a_oStringWriter,
- MULTIPLE_ACTION_PROCESSOR, a_oTemplate);
-
- // Get the results from the velocity processing
- String a_sResults = a_oStringWriter.getBuffer().toString();
-
- // Save the results on the input map
- p_oInputMap.put(BUILD_RESULTS, a_sResults);
- } else
- {
- log.error("could not create builder context");
- }
- } catch (Exception e)
- {
- log.error("builder failed", e);
- p_oInputMap.put(Constants.REASON, e.toString());
- }
- }
-
- public boolean buildContext(RequestContext p_oRequestContext,
- Map p_oInputMap)
- {
- boolean a_bResults = true;
-
- a_bResults = super.buildContext(p_oRequestContext, p_oInputMap);
-
- return a_bResults;
- }
-
-}
+ * 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.layout.impl;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.apache.jetspeed.ajax.AJAXException;
+import org.apache.jetspeed.ajax.AjaxAction;
+import org.apache.jetspeed.ajax.AjaxBuilder;
+import org.apache.jetspeed.ajax.AjaxRequestService;
+import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.request.JetspeedRequestContext;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.context.Context;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+
+/**
+ *
+ * @author David Gurney
+ *
+ * The purpose of this object is to run several AJAX actions and aggregate the
+ * results into a single response. This is useful when the client needs to make
+ * more than one call as the result of a single user action.
+ *
+ * The sample request URL is shown below:
+ *
+ * http://host:port/ajaxapi?action=multiple&commands=(action;name,value;name,value)(action;name,value)
+ *
+ * The constructor accepts a map of the actions that are available to be run.
+ * The name,value pairs are parameter values needed by the action. The actions
+ * are run in the order that they are found on the URL string
+ *
+ */
+public class MultipleAction extends BasePortletAction implements AjaxAction,
+ AjaxBuilder, BeanFactoryAware
+{
+
+ protected static final String ALL_RESULTS = "results";
+
+ protected static final String BUILD_RESULTS = "buildresults";
+
+ protected static final String MULTIPLE_ACTION_PROCESSOR = "Multiple Action Processor";
+
+ protected static final String COMMANDS = "commands";
+
+ protected static final String COMMAND_TOKEN = ")";
+
+ protected static final String PARAM_TOKEN = ";";
+
+ protected static final String VALUE_TOKEN = ",";
+
+ protected Map actionMap = null;
+
+ protected VelocityEngine m_oVelocityEngine = null;
+
+ public MultipleAction(AjaxRequestService requestService, String p_sTemplate,
+ String p_sErrorTemplate, PageManager p_oPageManager,
+ PortletActionSecurityBehavior p_oSecurityBehavior,
+ VelocityEngine p_oVelocityEngine)
+ {
+ super(p_sTemplate, p_sErrorTemplate, p_oPageManager,
+ p_oSecurityBehavior);
+ actionMap = requestService.getActionMap();
+ m_oVelocityEngine = p_oVelocityEngine;
+ }
+
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException
+ {
+ // get the proxied object for this, and put it in the map to avoid circular dep
+ Object proxy = beanFactory.getBean("AjaxMultipleAction");
+ actionMap.put("multiple", proxy);
+ }
+
+ public boolean run(RequestContext p_oRequestContext, Map p_oResultMap)
+ throws AJAXException
+ {
+ boolean a_bReturnSuccess = true;
+ List a_oResultArray = new ArrayList();
+
+ p_oResultMap.put(ACTION, "multiple");
+ p_oResultMap.put(STATUS, "success");
+
+ // Get the command string
+ String a_sCommands = p_oRequestContext.getRequestParameter(COMMANDS);
+ if (a_sCommands == null || a_sCommands.length() <= 0)
+ {
+ buildErrorContext(p_oRequestContext, p_oResultMap);
+ p_oResultMap.put(STATUS, "failure");
+ p_oResultMap.put(REASON, "command parameters not found");
+
+ throw new AJAXException("command parameters not found");
+ }
+
+ // Tokenize the commands into single commands
+ StringTokenizer a_oCommandTok = new StringTokenizer(a_sCommands,
+ COMMAND_TOKEN);
+
+ // Process each command
+ while (a_oCommandTok.hasMoreTokens())
+ {
+ // Get the token
+ String a_sCommand = a_oCommandTok.nextToken();
+
+ // Strip off the opening (
+ a_sCommand = a_sCommand.substring(1);
+
+ // Tokenize the single commands into parameters
+ StringTokenizer a_oParamTok = new StringTokenizer(a_sCommand,
+ PARAM_TOKEN);
+ if (a_oParamTok == null || a_oParamTok.hasMoreTokens() == false)
+ {
+ buildErrorContext(p_oRequestContext, p_oResultMap);
+ p_oResultMap.put(STATUS, "failure");
+ p_oResultMap.put(REASON, "incorrect url request");
+
+ throw new AJAXException("incorrect url request");
+ }
+
+ // Get the action - which is the first item in the list
+ String a_sAction = a_oParamTok.nextToken();
+
+ // Lookup the action from the action map
+ Object a_oActionObject = actionMap.get(a_sAction);
+ if (a_oActionObject == null
+ && !(a_oActionObject instanceof AjaxAction))
+ {
+ buildErrorContext(p_oRequestContext, p_oResultMap);
+ p_oResultMap.put(REASON, "unknown action requested==>"
+ + a_sAction);
+
+ throw new AJAXException("unknown action requested==>"
+ + a_sAction);
+ }
+
+ AjaxAction a_oAction = (AjaxAction) a_oActionObject;
+
+ JetspeedRequestContext a_oJetspeedRequestContext = (JetspeedRequestContext) p_oRequestContext;
+
+ // Process each parameter for this action
+ while (a_oParamTok.hasMoreTokens())
+ {
+ String a_sName = a_oParamTok.nextToken(VALUE_TOKEN);
+ // Strip of the leading ; if present
+ if (a_sName.indexOf(';') >= 0)
+ {
+ a_sName = a_sName.substring(1);
+ }
+
+ String a_sValue = a_oParamTok.nextToken();
+
+ // Put the parameters on the request context
+ a_oJetspeedRequestContext.setAttribute(a_sName, a_sValue);
+ }
+
+ // Invoke the action
+ Map a_oResultMap = new HashMap();
+ boolean a_bSuccess;
+
+ try
+ {
+ a_bSuccess = a_oAction.runBatch(a_oJetspeedRequestContext,
+ a_oResultMap);
+ } catch (Exception e)
+ {
+ // Move the reason into the return map
+ p_oResultMap.put(REASON, a_oResultMap.get(REASON));
+
+ throw new AJAXException(e);
+ }
+
+ // Check for success
+ if (a_bSuccess)
+ {
+ // Invoke the builder for this action if possible
+ if (a_oAction instanceof AjaxBuilder)
+ {
+ processBuilder((AjaxBuilder) a_oAction, a_oResultMap,
+ p_oRequestContext, a_bSuccess);
+ }
+
+ // Get the build results
+ String a_sBuildResults = (String) a_oResultMap
+ .get(BUILD_RESULTS);
+
+ // Look for an xml tag and strip it off
+ int a_iStartIndex = a_sBuildResults.indexOf("<?xml");
+ if (a_iStartIndex >= 0)
+ {
+ // Look for the end of the tag
+ int a_iEndIndex = a_sBuildResults.indexOf(">",
+ a_iStartIndex);
+ if (a_iEndIndex >= 0)
+ {
+ String a_sStart = a_sBuildResults.substring(0,
+ a_iStartIndex);
+ String a_sEnd = a_sBuildResults.substring(
+ a_iEndIndex + 1, a_sBuildResults.length());
+ a_sBuildResults = a_sStart + a_sEnd;
+ }
+ }
+
+ if (a_sBuildResults != null)
+ {
+ // Save the results
+ a_oResultArray.add(a_sBuildResults);
+ }
+ } else
+ {
+ // Move the reason into the return map
+ p_oResultMap.put(REASON, a_oResultMap.get(REASON));
+
+ // Exit the loop
+ a_bReturnSuccess = false;
+ break;
+ }
+ }
+
+ // Save the results for later building into the response
+ p_oResultMap.put(ALL_RESULTS, a_oResultArray);
+
+ return a_bReturnSuccess;
+ }
+
+ // Process the builder if provided
+ protected void processBuilder(AjaxBuilder p_oBuilder, Map p_oInputMap,
+ RequestContext p_oRequestContext, boolean p_oActionSuccessFlag)
+ {
+ try
+ {
+ // Ask the builder to construct the context
+ // Add the input map to the velocity context
+ boolean result = true;
+
+ if (p_oActionSuccessFlag == true)
+ {
+ result = p_oBuilder
+ .buildContext(p_oRequestContext, p_oInputMap);
+ } else
+ {
+ result = p_oBuilder.buildErrorContext(p_oRequestContext,
+ p_oInputMap);
+ }
+
+ Context a_oContext = new VelocityContext(p_oInputMap);
+
+ // Check to see if we have a valid context
+ if (result)
+ {
+ // Get the name of the template from the builder
+ String a_sTemplateName = null;
+
+ if (p_oActionSuccessFlag == true)
+ {
+ a_sTemplateName = p_oBuilder.getTemplate();
+ } else
+ {
+ a_sTemplateName = p_oBuilder.getErrorTemplate();
+ }
+
+ // Get a reader to the velocity template
+ final InputStream a_oTemplateStream = this.getClass()
+ .getClassLoader().getResourceAsStream(a_sTemplateName);
+
+ Reader a_oTemplate = new InputStreamReader(a_oTemplateStream);
+
+ // The results of the velocity template will be stored here
+ StringWriter a_oStringWriter = new StringWriter();
+
+ // Run the velocity template
+ m_oVelocityEngine.evaluate(a_oContext, a_oStringWriter,
+ MULTIPLE_ACTION_PROCESSOR, a_oTemplate);
+
+ // Get the results from the velocity processing
+ String a_sResults = a_oStringWriter.getBuffer().toString();
+
+ // Save the results on the input map
+ p_oInputMap.put(BUILD_RESULTS, a_sResults);
+ } else
+ {
+ log.error("could not create builder context");
+ }
+ } catch (Exception e)
+ {
+ log.error("builder failed", e);
+ p_oInputMap.put(Constants.REASON, e.toString());
+ }
+ }
+
+ public boolean buildContext(RequestContext p_oRequestContext,
+ Map p_oInputMap)
+ {
+ boolean a_bResults = true;
+
+ a_bResults = super.buildContext(p_oRequestContext, p_oInputMap);
+
+ return a_bResults;
+ }
+
+}
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/MultipleAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/NestedFragmentContext.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/NestedFragmentContext.java?rev=725977&r1=725976&r2=725977&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/NestedFragmentContext.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/NestedFragmentContext.java Fri Dec 12 04:06:29 2008
@@ -1,226 +1,226 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.layout.impl;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.components.portletregistry.PortletRegistry;
-import org.apache.jetspeed.layout.PortletPlacementException;
-import org.apache.jetspeed.om.page.Fragment;
-import org.apache.jetspeed.om.page.Page;
-/**
- * NestedFragmentContext
- *
- * This object captures the nested position of a fragment
- * within a page. Given a target fragment and a page,
- * the target fragment col/row within its parent is
- * recorded, followed by the target fragment's parent
- * col/row within its parent, etc.
- *
- * The purpose of this object is to support the
- * create-new-page-on-edit feature. For example, when
- * a fragment is moved, causing the creation of a new
- * page, the information captured by this object
- * allows the copy of the fragment in the new page to
- * be located.
- *
- * @author <a>Steve Milek</a>
- * @author <a href="mailto:smilek@apache.org">Steve Milek</a>
- * @version $Id: $
- */
-public class NestedFragmentContext
-{
- protected static final Log log = LogFactory.getLog( NestedFragmentContext.class );
- protected static final String eol = System.getProperty( "line.separator" );
-
- private Fragment targetFragment;
- private Fragment rootFragment;
- private Page page;
- private List fragmentLevels;
-
- public NestedFragmentContext( Fragment targetFragment, Page page, PortletRegistry registry )
- throws PortletPlacementException
- {
- this.targetFragment = targetFragment;
- this.page = page;
- this.rootFragment = page.getRootFragment();
- init( registry );
- }
-
- protected void init( PortletRegistry registry )
- throws PortletPlacementException
- {
- List nestedFragmentLevels = new ArrayList();
- Fragment nextTarget = targetFragment;
- Fragment nextParent = null;
- do
- {
- nextParent = NestedFragmentContext.getParentFragmentById( nextTarget.getId(), rootFragment );
- if ( nextParent != null )
- {
- NestedFragmentLevel level = new NestedFragmentLevel( nextTarget, nextParent, registry );
- nestedFragmentLevels.add( level );
-
- nextTarget = nextParent;
- }
- else
- {
- if ( ! nextTarget.getId().equals( rootFragment.getId() ) )
- {
- throw new PortletPlacementException( "Cannot determine complete nested structure for fragment " + targetFragment.getId() );
- }
- nextTarget = null;
- }
- }
- while ( nextTarget != null );
- this.fragmentLevels = nestedFragmentLevels;
- }
-
- public Fragment getFragmentOnNewPage( Page newPage, PortletRegistry registry )
- throws PortletPlacementException
- {
- Fragment newPageRootFragment = newPage.getRootFragment();
-
- int depth = fragmentLevels.size();
-
- Fragment nextFragment = newPageRootFragment;
- for ( int i = depth -1; i >= 0 ; i-- )
- {
- NestedFragmentLevel level = (NestedFragmentLevel)fragmentLevels.get(i);
- PortletPlacementContextImpl placement = new PortletPlacementContextImpl( newPage, registry, nextFragment );
- try
- {
- nextFragment = placement.getFragmentAtOldCoordinate( new CoordinateImpl( level.getChildCol(), level.getChildRow() ) );
-
- }
- catch ( PortletPlacementException ppex )
- {
- log.error( "getFragmentOnNewPage failure to locate fragment on new page (index=" + i + ") :" + eol + this.toString() + ( placement != null ? ( eol + placement.dumpFragments(null) ) : "" ) + eol, ppex );
- throw ppex;
- }
- catch ( RuntimeException ex )
- {
- log.error( "getFragmentOnNewPage failure to locate fragment on new page (index=" + i + ") :" + eol + this.toString() + ( placement != null ? ( eol + placement.dumpFragments(null) ) : "" ) + eol, ex );
- throw ex;
- }
- if ( nextFragment == null )
- {
- throw new PortletPlacementException( "Cannot locate copy of fragment " + targetFragment.getId() + " in the new page structure :" + eol + this.toString() + ( placement != null ? ( eol + placement.dumpFragments(null) ) : "" ));
- }
- }
- return nextFragment;
- }
-
- public String toString()
- {
- StringBuffer out = new StringBuffer();
- int depth = fragmentLevels.size();
- int ldepth = 0;
- for ( int i = depth -1; i >= 0 ; i-- )
- {
- NestedFragmentLevel level = (NestedFragmentLevel)fragmentLevels.get(i);
- if ( ldepth > 0 )
- {
- out.append( eol );
- for ( int j = 0 ; j < ldepth ; j++ )
- out.append( " " );
- }
- ldepth++;
- out.append( level.toString() );
- }
- return out.toString();
- }
-
- class NestedFragmentLevel
- {
- private int childRow;
- private int childCol;
- private Fragment child;
- private Fragment parent;
-
- NestedFragmentLevel( Fragment child, Fragment parent, PortletRegistry registry )
- throws PortletPlacementException
- {
- this.child = child;
- this.parent = parent;
- PortletPlacementContextImpl placement = new PortletPlacementContextImpl( page, registry, parent );
- this.childRow = placement.getFragmentRow( child );
- this.childCol = placement.getFragmentCol( child );
- }
-
- protected int getChildRow()
- {
- return this.childRow;
- }
- protected int getChildCol()
- {
- return this.childCol;
- }
- protected Fragment getChild()
- {
- return this.child;
- }
- protected Fragment getParent()
- {
- return this.parent;
- }
- public String toString()
- {
- return child.getType() + " col=" + childCol + " row=" + childRow + " id=" + child.getId() + " parent-id=" + parent.getId() ;
- }
- }
-
- public static Fragment getParentFragmentById( String id, Fragment parent )
- {
- // find fragment by id, tracking fragment parent
- if ( id == null )
- {
- return null;
- }
-
- Fragment matchedParent = null;
- if( parent != null )
- {
- // process the children
- List children = parent.getFragments();
- for( int i = 0, cSize = children.size() ; i < cSize ; i++)
- {
- Fragment childFrag = (Fragment)children.get( i );
- if ( childFrag != null )
- {
- if ( id.equals( childFrag.getId() ) )
- {
- matchedParent = parent;
- break;
- }
- else
- {
- matchedParent = NestedFragmentContext.getParentFragmentById( id, childFrag );
- if ( matchedParent != null )
- {
- break;
- }
- }
- }
- }
- }
- return matchedParent;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.layout.impl;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.layout.PortletPlacementException;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.Page;
+/**
+ * NestedFragmentContext
+ *
+ * This object captures the nested position of a fragment
+ * within a page. Given a target fragment and a page,
+ * the target fragment col/row within its parent is
+ * recorded, followed by the target fragment's parent
+ * col/row within its parent, etc.
+ *
+ * The purpose of this object is to support the
+ * create-new-page-on-edit feature. For example, when
+ * a fragment is moved, causing the creation of a new
+ * page, the information captured by this object
+ * allows the copy of the fragment in the new page to
+ * be located.
+ *
+ * @author <a>Steve Milek</a>
+ * @author <a href="mailto:smilek@apache.org">Steve Milek</a>
+ * @version $Id: $
+ */
+public class NestedFragmentContext
+{
+ protected static final Log log = LogFactory.getLog( NestedFragmentContext.class );
+ protected static final String eol = System.getProperty( "line.separator" );
+
+ private Fragment targetFragment;
+ private Fragment rootFragment;
+ private Page page;
+ private List fragmentLevels;
+
+ public NestedFragmentContext( Fragment targetFragment, Page page, PortletRegistry registry )
+ throws PortletPlacementException
+ {
+ this.targetFragment = targetFragment;
+ this.page = page;
+ this.rootFragment = page.getRootFragment();
+ init( registry );
+ }
+
+ protected void init( PortletRegistry registry )
+ throws PortletPlacementException
+ {
+ List nestedFragmentLevels = new ArrayList();
+ Fragment nextTarget = targetFragment;
+ Fragment nextParent = null;
+ do
+ {
+ nextParent = NestedFragmentContext.getParentFragmentById( nextTarget.getId(), rootFragment );
+ if ( nextParent != null )
+ {
+ NestedFragmentLevel level = new NestedFragmentLevel( nextTarget, nextParent, registry );
+ nestedFragmentLevels.add( level );
+
+ nextTarget = nextParent;
+ }
+ else
+ {
+ if ( ! nextTarget.getId().equals( rootFragment.getId() ) )
+ {
+ throw new PortletPlacementException( "Cannot determine complete nested structure for fragment " + targetFragment.getId() );
+ }
+ nextTarget = null;
+ }
+ }
+ while ( nextTarget != null );
+ this.fragmentLevels = nestedFragmentLevels;
+ }
+
+ public Fragment getFragmentOnNewPage( Page newPage, PortletRegistry registry )
+ throws PortletPlacementException
+ {
+ Fragment newPageRootFragment = newPage.getRootFragment();
+
+ int depth = fragmentLevels.size();
+
+ Fragment nextFragment = newPageRootFragment;
+ for ( int i = depth -1; i >= 0 ; i-- )
+ {
+ NestedFragmentLevel level = (NestedFragmentLevel)fragmentLevels.get(i);
+ PortletPlacementContextImpl placement = new PortletPlacementContextImpl( newPage, registry, nextFragment );
+ try
+ {
+ nextFragment = placement.getFragmentAtOldCoordinate( new CoordinateImpl( level.getChildCol(), level.getChildRow() ) );
+
+ }
+ catch ( PortletPlacementException ppex )
+ {
+ log.error( "getFragmentOnNewPage failure to locate fragment on new page (index=" + i + ") :" + eol + this.toString() + ( placement != null ? ( eol + placement.dumpFragments(null) ) : "" ) + eol, ppex );
+ throw ppex;
+ }
+ catch ( RuntimeException ex )
+ {
+ log.error( "getFragmentOnNewPage failure to locate fragment on new page (index=" + i + ") :" + eol + this.toString() + ( placement != null ? ( eol + placement.dumpFragments(null) ) : "" ) + eol, ex );
+ throw ex;
+ }
+ if ( nextFragment == null )
+ {
+ throw new PortletPlacementException( "Cannot locate copy of fragment " + targetFragment.getId() + " in the new page structure :" + eol + this.toString() + ( placement != null ? ( eol + placement.dumpFragments(null) ) : "" ));
+ }
+ }
+ return nextFragment;
+ }
+
+ public String toString()
+ {
+ StringBuffer out = new StringBuffer();
+ int depth = fragmentLevels.size();
+ int ldepth = 0;
+ for ( int i = depth -1; i >= 0 ; i-- )
+ {
+ NestedFragmentLevel level = (NestedFragmentLevel)fragmentLevels.get(i);
+ if ( ldepth > 0 )
+ {
+ out.append( eol );
+ for ( int j = 0 ; j < ldepth ; j++ )
+ out.append( " " );
+ }
+ ldepth++;
+ out.append( level.toString() );
+ }
+ return out.toString();
+ }
+
+ class NestedFragmentLevel
+ {
+ private int childRow;
+ private int childCol;
+ private Fragment child;
+ private Fragment parent;
+
+ NestedFragmentLevel( Fragment child, Fragment parent, PortletRegistry registry )
+ throws PortletPlacementException
+ {
+ this.child = child;
+ this.parent = parent;
+ PortletPlacementContextImpl placement = new PortletPlacementContextImpl( page, registry, parent );
+ this.childRow = placement.getFragmentRow( child );
+ this.childCol = placement.getFragmentCol( child );
+ }
+
+ protected int getChildRow()
+ {
+ return this.childRow;
+ }
+ protected int getChildCol()
+ {
+ return this.childCol;
+ }
+ protected Fragment getChild()
+ {
+ return this.child;
+ }
+ protected Fragment getParent()
+ {
+ return this.parent;
+ }
+ public String toString()
+ {
+ return child.getType() + " col=" + childCol + " row=" + childRow + " id=" + child.getId() + " parent-id=" + parent.getId() ;
+ }
+ }
+
+ public static Fragment getParentFragmentById( String id, Fragment parent )
+ {
+ // find fragment by id, tracking fragment parent
+ if ( id == null )
+ {
+ return null;
+ }
+
+ Fragment matchedParent = null;
+ if( parent != null )
+ {
+ // process the children
+ List children = parent.getFragments();
+ for( int i = 0, cSize = children.size() ; i < cSize ; i++)
+ {
+ Fragment childFrag = (Fragment)children.get( i );
+ if ( childFrag != null )
+ {
+ if ( id.equals( childFrag.getId() ) )
+ {
+ matchedParent = parent;
+ break;
+ }
+ else
+ {
+ matchedParent = NestedFragmentContext.getParentFragmentById( id, childFrag );
+ if ( matchedParent != null )
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+ return matchedParent;
+ }
+}
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/NestedFragmentContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityConstraintsBehavior.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityConstraintsBehavior.java?rev=725977&r1=725976&r2=725977&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityConstraintsBehavior.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityConstraintsBehavior.java Fri Dec 12 04:06:29 2008
@@ -1,75 +1,75 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.layout.impl;
-
-import java.security.Principal;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.Jetspeed;
-import org.apache.jetspeed.administration.PortalConfiguration;
-import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
-import org.apache.jetspeed.om.page.Page;
-import org.apache.jetspeed.page.PageManager;
-import org.apache.jetspeed.request.RequestContext;
-
-/**
- * Abstracted behavior of security checks for portlet actions
- *
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
- * @version $Id: $
- */
-public class PortletActionSecurityConstraintsBehavior
- extends PortletActionSecurityPathBehavior
- implements PortletActionSecurityBehavior
-{
- protected Log log = LogFactory.getLog(PortletActionSecurityConstraintsBehavior.class);
- protected String guest = "guest";
-
- public PortletActionSecurityConstraintsBehavior(PageManager pageManager)
- {
- this( pageManager, Boolean.FALSE );
- }
- public PortletActionSecurityConstraintsBehavior(PageManager pageManager, Boolean enableCreateUserPagesFromRolesOnEdit )
- {
- super( pageManager, enableCreateUserPagesFromRolesOnEdit );
- PortalConfiguration config = Jetspeed.getConfiguration();
- if (config != null)
- {
- guest = config.getString("default.user.principal");
- }
- }
-
- public boolean checkAccess(RequestContext context, String action)
- {
- Page page = context.getPage();
- try
- {
- page.checkAccess(action);
- }
- catch (Exception e)
- {
- Principal principal = context.getRequest().getUserPrincipal();
- String userName = this.guest;
- if (principal != null)
- userName = principal.getName();
- log.warn("Insufficient access to page " + page.getPath() + " by user " + userName);
- return false;
- }
- return true;
- }
-}
+ * 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.layout.impl;
+
+import java.security.Principal;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.administration.PortalConfiguration;
+import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Abstracted behavior of security checks for portlet actions
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class PortletActionSecurityConstraintsBehavior
+ extends PortletActionSecurityPathBehavior
+ implements PortletActionSecurityBehavior
+{
+ protected Log log = LogFactory.getLog(PortletActionSecurityConstraintsBehavior.class);
+ protected String guest = "guest";
+
+ public PortletActionSecurityConstraintsBehavior(PageManager pageManager)
+ {
+ this( pageManager, Boolean.FALSE );
+ }
+ public PortletActionSecurityConstraintsBehavior(PageManager pageManager, Boolean enableCreateUserPagesFromRolesOnEdit )
+ {
+ super( pageManager, enableCreateUserPagesFromRolesOnEdit );
+ PortalConfiguration config = Jetspeed.getConfiguration();
+ if (config != null)
+ {
+ guest = config.getString("default.user.principal");
+ }
+ }
+
+ public boolean checkAccess(RequestContext context, String action)
+ {
+ Page page = context.getPage();
+ try
+ {
+ page.checkAccess(action);
+ }
+ catch (Exception e)
+ {
+ Principal principal = context.getRequest().getUserPrincipal();
+ String userName = this.guest;
+ if (principal != null)
+ userName = principal.getName();
+ log.warn("Insufficient access to page " + page.getPath() + " by user " + userName);
+ return false;
+ }
+ return true;
+ }
+}
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityConstraintsBehavior.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityPathBehavior.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityPathBehavior.java?rev=725977&r1=725976&r2=725977&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityPathBehavior.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityPathBehavior.java Fri Dec 12 04:06:29 2008
@@ -1,114 +1,114 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.layout.impl;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.JetspeedActions;
-import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
-import org.apache.jetspeed.om.folder.Folder;
-import org.apache.jetspeed.om.page.ContentPageImpl;
-import org.apache.jetspeed.om.page.Page;
-import org.apache.jetspeed.page.PageManager;
-import org.apache.jetspeed.profiler.impl.ProfilerValveImpl;
-import org.apache.jetspeed.request.RequestContext;
-
-/**
- * Abstracted behavior of security checks for portlet actions
- *
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
- * @version $Id: $
- */
-public class PortletActionSecurityPathBehavior implements PortletActionSecurityBehavior
-{
- protected Log log = LogFactory.getLog(PortletActionSecurityPathBehavior.class);
- protected PageManager pageManager;
- private boolean enableCreateUserPagesFromRolesOnEdit;
-
- public PortletActionSecurityPathBehavior(PageManager pageManager )
- {
- this( pageManager, Boolean.FALSE ) ;
- }
- public PortletActionSecurityPathBehavior(PageManager pageManager, Boolean enableCreateUserPagesFromRolesOnEdit )
- {
- this.pageManager = pageManager;
- this.enableCreateUserPagesFromRolesOnEdit = ( enableCreateUserPagesFromRolesOnEdit == null ? false : enableCreateUserPagesFromRolesOnEdit.booleanValue() );
- }
-
- public boolean checkAccess(RequestContext context, String action)
- {
- Page page = context.getPage();
- String path = page.getPath();
- if (path == null)
- return false;
- if (path.indexOf(Folder.ROLE_FOLDER) > -1 || path.indexOf(Folder.GROUP_FOLDER) > -1)
- {
- if (action.equals(JetspeedActions.VIEW))
- return true;
- return false;
- }
- return true;
- }
-
- public boolean isCreateNewPageOnEditEnabled()
- {
- return enableCreateUserPagesFromRolesOnEdit;
- }
- public boolean isPageQualifiedForCreateNewPageOnEdit(RequestContext context)
- {
- if ( ! this.enableCreateUserPagesFromRolesOnEdit || context == null )
- return false ;
- return isPageQualifiedForCreateNewPageOnEdit( context.getPage().getPath() );
- }
-
- protected boolean isPageQualifiedForCreateNewPageOnEdit( String pagePath )
- {
- if (pagePath == null)
- return false;
- // page must be in role directory
- return (pagePath.indexOf(Folder.ROLE_FOLDER) == 0);
- }
-
- public boolean createNewPageOnEdit(RequestContext context)
- {
- if ( ! this.enableCreateUserPagesFromRolesOnEdit )
- return false ;
-
- Page page = context.getPage();
- String pagePath = page.getPath();
- try
- {
- if ( isPageQualifiedForCreateNewPageOnEdit( pagePath ) )
- {
- String pageName = page.getName();
- this.pageManager.createUserHomePagesFromRoles(context.getSubject());
- page = this.pageManager.getPage(Folder.USER_FOLDER
- + context.getRequest().getUserPrincipal().getName()
- + Folder.PATH_SEPARATOR
- + pageName); // was Folder.FALLBACK_DEFAULT_PAGE prior to 2007-11-06
- context.setPage(new ContentPageImpl(page));
- context.getRequest().getSession().removeAttribute(ProfilerValveImpl.PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY);
- }
- }
- catch (Exception e)
- {
- // already logged error
- return false;
- }
- return true;
- }
-}
+ * 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.layout.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.ContentPageImpl;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.profiler.impl.ProfilerValveImpl;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Abstracted behavior of security checks for portlet actions
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class PortletActionSecurityPathBehavior implements PortletActionSecurityBehavior
+{
+ protected Log log = LogFactory.getLog(PortletActionSecurityPathBehavior.class);
+ protected PageManager pageManager;
+ private boolean enableCreateUserPagesFromRolesOnEdit;
+
+ public PortletActionSecurityPathBehavior(PageManager pageManager )
+ {
+ this( pageManager, Boolean.FALSE ) ;
+ }
+ public PortletActionSecurityPathBehavior(PageManager pageManager, Boolean enableCreateUserPagesFromRolesOnEdit )
+ {
+ this.pageManager = pageManager;
+ this.enableCreateUserPagesFromRolesOnEdit = ( enableCreateUserPagesFromRolesOnEdit == null ? false : enableCreateUserPagesFromRolesOnEdit.booleanValue() );
+ }
+
+ public boolean checkAccess(RequestContext context, String action)
+ {
+ Page page = context.getPage();
+ String path = page.getPath();
+ if (path == null)
+ return false;
+ if (path.indexOf(Folder.ROLE_FOLDER) > -1 || path.indexOf(Folder.GROUP_FOLDER) > -1)
+ {
+ if (action.equals(JetspeedActions.VIEW))
+ return true;
+ return false;
+ }
+ return true;
+ }
+
+ public boolean isCreateNewPageOnEditEnabled()
+ {
+ return enableCreateUserPagesFromRolesOnEdit;
+ }
+ public boolean isPageQualifiedForCreateNewPageOnEdit(RequestContext context)
+ {
+ if ( ! this.enableCreateUserPagesFromRolesOnEdit || context == null )
+ return false ;
+ return isPageQualifiedForCreateNewPageOnEdit( context.getPage().getPath() );
+ }
+
+ protected boolean isPageQualifiedForCreateNewPageOnEdit( String pagePath )
+ {
+ if (pagePath == null)
+ return false;
+ // page must be in role directory
+ return (pagePath.indexOf(Folder.ROLE_FOLDER) == 0);
+ }
+
+ public boolean createNewPageOnEdit(RequestContext context)
+ {
+ if ( ! this.enableCreateUserPagesFromRolesOnEdit )
+ return false ;
+
+ Page page = context.getPage();
+ String pagePath = page.getPath();
+ try
+ {
+ if ( isPageQualifiedForCreateNewPageOnEdit( pagePath ) )
+ {
+ String pageName = page.getName();
+ this.pageManager.createUserHomePagesFromRoles(context.getSubject());
+ page = this.pageManager.getPage(Folder.USER_FOLDER
+ + context.getRequest().getUserPrincipal().getName()
+ + Folder.PATH_SEPARATOR
+ + pageName); // was Folder.FALLBACK_DEFAULT_PAGE prior to 2007-11-06
+ context.setPage(new ContentPageImpl(page));
+ context.getRequest().getSession().removeAttribute(ProfilerValveImpl.PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY);
+ }
+ }
+ catch (Exception e)
+ {
+ // already logged error
+ return false;
+ }
+ return true;
+ }
+}
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityPathBehavior.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityPathMergeBehavior.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityPathMergeBehavior.java?rev=725977&r1=725976&r2=725977&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityPathMergeBehavior.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityPathMergeBehavior.java Fri Dec 12 04:06:29 2008
@@ -1,82 +1,82 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.layout.impl;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
-import org.apache.jetspeed.page.PageManager;
-import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.security.Role;
-import org.apache.jetspeed.security.SubjectHelper;
-import org.apache.jetspeed.security.User;
-import org.apache.jetspeed.security.impl.TransientRole;
-
-/**
- * Abstracted behavior of security checks when used with the
- * profiling rule "user-rolecombo". This behavior merges
- * all roles into a single role combo.
- *
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
- * @version $Id: $
- */
-public class PortletActionSecurityPathMergeBehavior
- extends PortletActionSecurityPathBehavior
- implements PortletActionSecurityBehavior
-{
- protected Log log = LogFactory.getLog(PortletActionSecurityPathMergeBehavior.class);
-
- public PortletActionSecurityPathMergeBehavior( PageManager pageManager )
- {
- this( pageManager, Boolean.FALSE );
- }
- public PortletActionSecurityPathMergeBehavior( PageManager pageManager, Boolean enableCreateUserPagesFromRolesOnEdit )
- {
- super( pageManager, enableCreateUserPagesFromRolesOnEdit );
- }
-
- public Subject getSubject(RequestContext context)
- {
- Subject currentSubject = context.getSubject();
- Iterator roles = currentSubject.getPrincipals(Role.class).iterator();
- StringBuffer combo = new StringBuffer();
- int count = 0;
- while (roles.hasNext())
- {
- Role role = (Role)roles.next();
- if (count > 0)
- {
- combo.append("-");
- }
- combo.append(role.getName());
- count++;
- }
- Set principals = new HashSet();
- principals.add(SubjectHelper.getBestPrincipal(currentSubject, User.class));
- principals.add(new TransientRole(combo.toString()));
- Subject subject =
- new Subject(true, principals, new HashSet(), new HashSet());
- return subject;
- }
-
-}
+ * 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.layout.impl;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.Role;
+import org.apache.jetspeed.security.SubjectHelper;
+import org.apache.jetspeed.security.User;
+import org.apache.jetspeed.security.impl.TransientRole;
+
+/**
+ * Abstracted behavior of security checks when used with the
+ * profiling rule "user-rolecombo". This behavior merges
+ * all roles into a single role combo.
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class PortletActionSecurityPathMergeBehavior
+ extends PortletActionSecurityPathBehavior
+ implements PortletActionSecurityBehavior
+{
+ protected Log log = LogFactory.getLog(PortletActionSecurityPathMergeBehavior.class);
+
+ public PortletActionSecurityPathMergeBehavior( PageManager pageManager )
+ {
+ this( pageManager, Boolean.FALSE );
+ }
+ public PortletActionSecurityPathMergeBehavior( PageManager pageManager, Boolean enableCreateUserPagesFromRolesOnEdit )
+ {
+ super( pageManager, enableCreateUserPagesFromRolesOnEdit );
+ }
+
+ public Subject getSubject(RequestContext context)
+ {
+ Subject currentSubject = context.getSubject();
+ Iterator roles = currentSubject.getPrincipals(Role.class).iterator();
+ StringBuffer combo = new StringBuffer();
+ int count = 0;
+ while (roles.hasNext())
+ {
+ Role role = (Role)roles.next();
+ if (count > 0)
+ {
+ combo.append("-");
+ }
+ combo.append(role.getName());
+ count++;
+ }
+ Set principals = new HashSet();
+ principals.add(SubjectHelper.getBestPrincipal(currentSubject, User.class));
+ principals.add(new TransientRole(combo.toString()));
+ Subject subject =
+ new Subject(true, principals, new HashSet(), new HashSet());
+ return subject;
+ }
+
+}
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletActionSecurityPathMergeBehavior.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletInfo.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletInfo.java?rev=725977&r1=725976&r2=725977&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletInfo.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletInfo.java Fri Dec 12 04:06:29 2008
@@ -1,77 +1,77 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.layout.impl;
-
-/**
- * Portlet Info populated into AJAX XML response per portlet
- *
- * @author <a>David Gurney</a>
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
- * @version $Id: $
- */
-public class PortletInfo
-{
- private String name;
- private String displayName;
- private String description;
- private String image;
-
- public PortletInfo(String name, String displayName, String description, String image)
- {
- this.name = name;
- this.displayName = displayName;
- this.description = description;
- this.image = image;
- }
- /**
- * @return Returns the description.
- */
- public String getDescription()
- {
- return description;
- }
- /**
- * @return Returns the displayName.
- */
- public String getDisplayName()
- {
- return displayName;
- }
- /**
- * @return Returns the name.
- */
- public String getName()
- {
- return name;
- }
-
- /**
- * @return Returns the image.
- */
- public String getImage()
- {
- return image;
- }
-
- /**
- * @param image The image to set.
- */
- public void setImage(String image)
- {
- this.image = image;
- }
-}
+ * 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.layout.impl;
+
+/**
+ * Portlet Info populated into AJAX XML response per portlet
+ *
+ * @author <a>David Gurney</a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class PortletInfo
+{
+ private String name;
+ private String displayName;
+ private String description;
+ private String image;
+
+ public PortletInfo(String name, String displayName, String description, String image)
+ {
+ this.name = name;
+ this.displayName = displayName;
+ this.description = description;
+ this.image = image;
+ }
+ /**
+ * @return Returns the description.
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+ /**
+ * @return Returns the displayName.
+ */
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * @return Returns the image.
+ */
+ public String getImage()
+ {
+ return image;
+ }
+
+ /**
+ * @param image The image to set.
+ */
+ public void setImage(String image)
+ {
+ this.image = image;
+ }
+}
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/PortletPlacementContextImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/RemovePortletAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/RolesSecurityBehavior.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/RolesSecurityBehavior.java?rev=725977&r1=725976&r2=725977&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/RolesSecurityBehavior.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/RolesSecurityBehavior.java Fri Dec 12 04:06:29 2008
@@ -1,68 +1,68 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.layout.impl;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
-import org.apache.jetspeed.request.RequestContext;
-
-/**
- * Abstracted behavior of security checks for portlet actions
- *
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
- * @version $Id: $
- */
-public class RolesSecurityBehavior implements PortletActionSecurityBehavior
-{
- protected Log log = LogFactory.getLog(PortletActionSecurityPathBehavior.class);
- protected List roles;
-
- public RolesSecurityBehavior(List roles)
- {
- this.roles = roles;
- }
-
- public boolean checkAccess(RequestContext context, String action)
- {
- Iterator iterator = roles.iterator();
- while (iterator.hasNext())
- {
- String role = (String)iterator.next();
- if (context.getRequest().isUserInRole(role))
- return true;
- }
- return false;
- }
-
- public boolean isCreateNewPageOnEditEnabled()
- {
- return false;
- }
- public boolean isPageQualifiedForCreateNewPageOnEdit(RequestContext context)
- {
- return false ;
- }
-
- public boolean createNewPageOnEdit(RequestContext context)
- {
- return false;
- }
-}
+ * 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.layout.impl;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Abstracted behavior of security checks for portlet actions
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class RolesSecurityBehavior implements PortletActionSecurityBehavior
+{
+ protected Log log = LogFactory.getLog(PortletActionSecurityPathBehavior.class);
+ protected List roles;
+
+ public RolesSecurityBehavior(List roles)
+ {
+ this.roles = roles;
+ }
+
+ public boolean checkAccess(RequestContext context, String action)
+ {
+ Iterator iterator = roles.iterator();
+ while (iterator.hasNext())
+ {
+ String role = (String)iterator.next();
+ if (context.getRequest().isUserInRole(role))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isCreateNewPageOnEditEnabled()
+ {
+ return false;
+ }
+ public boolean isPageQualifiedForCreateNewPageOnEdit(RequestContext context)
+ {
+ return false ;
+ }
+
+ public boolean createNewPageOnEdit(RequestContext context)
+ {
+ return false;
+ }
+}
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/layout/impl/RolesSecurityBehavior.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org