You are viewing a plain text version of this content. The canonical link for it is here.
Posted to graffito-commits@incubator.apache.org by cl...@apache.org on 2006/09/20 19:37:21 UTC
svn commit: r448311 [6/25] - in /incubator/graffito/trunk: ./ api/
api/src/java/org/apache/portals/graffito/context/
api/src/java/org/apache/portals/graffito/exception/
api/src/java/org/apache/portals/graffito/services/core/
api/src/java/org/apache/por...
Modified: incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/manager/PortletPageManager.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/manager/PortletPageManager.java?view=diff&rev=448311&r1=448310&r2=448311
==============================================================================
--- incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/manager/PortletPageManager.java (original)
+++ incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/manager/PortletPageManager.java Wed Sep 20 12:37:05 2006
@@ -1,435 +1,435 @@
-/*
- * 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.portals.graffito.portlets.page.manager;
-
-
-
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.Portlet;
-import javax.portlet.PortletException;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletResponse;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileUploadException;
-import org.apache.commons.jexl.Expression;
-import org.apache.commons.jexl.ExpressionFactory;
-import org.apache.commons.jexl.JexlContext;
-import org.apache.commons.jexl.JexlHelper;
-import org.apache.portals.graffito.portlets.GraffitoPortlet;
-import org.apache.portals.graffito.portlets.page.EditPortletPage;
-import org.apache.portals.graffito.portlets.page.PortletPageRef;
-import org.apache.portals.graffito.portlets.page.PortletPages;
-import org.apache.portals.graffito.portlets.page.ViewPortletPage;
-import org.apache.portals.graffito.portlets.page.action.PortletActionInfo;
-import org.apache.portals.graffito.portlets.page.tab.Tab;
-import org.apache.portals.graffito.portlets.page.tab.TabPage;
-import org.apache.portals.graffito.portlets.upload.PortletDiskFileUpload;
-import org.apache.portals.graffito.portlets.upload.PortletFileUploadBase;
-import org.apache.portals.graffito.portlets.util.ExpressionUtil;
-import org.apache.velocity.context.Context;
-
-
-/**
- * Portlet Page Manager. This manager provides a more cleaner code when the number of possible pages increase.
- *
- * @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
- * @version $Id: Exp $
- */
-public class PortletPageManager
-{
- private GraffitoPortlet portlet;
- private static final String ACTION_PREFIX = "portletAction_";
- private static final String FORWARD_PREFIX = "portletForward_";
-
- /** name of the page to forward to */
- public static final String FORWARD_TO_PAGE = "forwardToPage";
-
- private static final String SELECTED_VIEW_PAGE_ID = "selectedViewPageId";
- private static final String SELECTED_EDIT_PAGE_ID = "selectedEditPageId";
-
-
- private static final String REQUEST_PARAM_SELECT_PAGE = "selectPage";
- private static final String REQUEST_PARAM_SELECT_TAB = "selectTab";
-
- PortletPages portletPages;
-
-
- /**
- * Constructor.
- *
- * Build a Portlet Page Manager from an xml file. This xml file should contains all pages.
- *
- * @param xmlFile the xml file used to initialise the portlet page manager
- *
- * @throws PortletException
- *
- */
- public PortletPageManager(Portlet portlet, String xmlFile) throws PortletException
- {
- this.portlet = (GraffitoPortlet) portlet;
- portletPages = PortletPageReader.loadPages(xmlFile);
- }
-
-
- public GraffitoPortlet getPortlet()
- {
- return portlet;
- }
-
- public void addContextObject(RenderRequest request, String objectName, Object object)
- {
- // Add the object in the velocity context in order to use it in the template
- Context velocityContext = portlet.getContext(request);
- velocityContext.put(objectName, object);
-
- request.setAttribute(objectName, object);
- }
-
- public Object getContextObject(RenderRequest request, String objectName)
- {
- return request.getAttribute(objectName);
- }
-
- public Enumeration getAllContextObjectNames(RenderRequest request)
- {
- return request.getAttributeNames();
- }
-
- /**
- * Process the action used for the view mode on the selected page
- *
- * @param request The portlet request
- * @param response The portlet response
- *
- * @throws PortletException
- */
- public void doView(RenderRequest request, RenderResponse response) throws PortletException
- {
- ViewPortletPage portletPage = this.getSelectedViewPage(request);
- request.setAttribute( GraffitoPortlet.PARAM_VIEW_PAGE, portletPage.getTemplate());
- String actionName = portletPage.getAction();
- // process the portlet page action
- this.processAction(portlet, actionName, request, response);
-
- // For each tab, process action on the select tab page
- Map tabs = portletPage.getTabs();
- Iterator tabsIterator = tabs.values().iterator();
- while (tabsIterator.hasNext())
- {
- Tab tab = (Tab) tabsIterator.next();
- TabPage tabPage = tab.getSelectedPage(request);
- actionName = tabPage.getAction();
- this.processAction(portlet, actionName, request, response);
- }
-
- // Init the corresponding template used in the edit mode
- Collection editPortlePageRefs = portletPage.getEditPortletPages();
- Iterator editPortlePageRefsIterator = editPortlePageRefs.iterator();
- while(editPortlePageRefsIterator.hasNext())
- {
- PortletPageRef portletPageRef = (PortletPageRef) editPortlePageRefsIterator.next();
- String condition = portletPageRef.getCondition();
- if ( condition == null || condition.equals("") || ExpressionUtil.checkCondition(request, condition))
- {
- this.setSelectedEditPageId(request, portletPageRef.getPortletPageId());
- return ;
- }
- }
- this.setSelectedEditPageId(request, portletPages.getDefaultEditPageId());
-
-
- }
-
- /**
- * Process the action used for the edit mode on the selected page
- *
- * @param request The portlet request
- * @param response The portlet response
- *
- * @throws PortletException
- */
- public void doEdit(RenderRequest request, RenderResponse response) throws PortletException
- {
- EditPortletPage portletPage = this.getSelectedEditPage(request);
- String actionName = portletPage.getAction();
- request.setAttribute( GraffitoPortlet.PARAM_EDIT_PAGE, portletPage.getTemplate());
- // process the portlet page action
- this.processAction(portlet, actionName, request, response);
-
- // process action on each tab (selected paged in those tabs)
- Map tabs = portletPage.getTabs();
- Iterator tabsIterator = tabs.values().iterator();
- while (tabsIterator.hasNext())
- {
- Tab tab = (Tab) tabsIterator.next();
- TabPage tabPage = tab.getSelectedPage(request);
- actionName = tabPage.getAction();
- this.processAction(portlet, actionName, request, response);
- }
-
- // Init the corresponding template used in the edit mode
- Collection viewPortlePageRefs = portletPage.getViewPortletPages();
- Iterator viewPortlePageRefsIterator = viewPortlePageRefs.iterator();
- while(viewPortlePageRefsIterator.hasNext())
- {
- PortletPageRef portletPageRef = (PortletPageRef) viewPortlePageRefsIterator.next();
- String condition = portletPageRef.getCondition();
- if ( condition == null || condition.equals("") || ExpressionUtil.checkCondition(request, condition))
- {
- this.setSelectedViewPageId(request, portletPageRef.getPortletPageId());
- return ;
- }
- }
- this.setSelectedViewPageId(request, portletPages.getDefaultViewPageId());
-
- }
-
-
- public EditPortletPage getSelectedEditPage(PortletRequest request)
- {
- String selectedEditPageId = (String) request.getPortletSession().getAttribute(SELECTED_EDIT_PAGE_ID);
- if (selectedEditPageId == null)
- {
- selectedEditPageId = portletPages.getDefaultEditPageId();
- request.getPortletSession().setAttribute(SELECTED_EDIT_PAGE_ID, selectedEditPageId);
- }
- return (EditPortletPage) portletPages.getEditPages().get(selectedEditPageId);
- }
-
- public void setSelectedEditPageId(PortletRequest request, String selectedEdiPageId)
- {
- request.getPortletSession().setAttribute(SELECTED_EDIT_PAGE_ID, selectedEdiPageId);
- }
-
-
- public ViewPortletPage getSelectedViewPage(PortletRequest request)
- {
- String selectedViewPageId = (String) request.getPortletSession().getAttribute(SELECTED_VIEW_PAGE_ID);
- if (selectedViewPageId == null)
- {
- selectedViewPageId = portletPages.getDefaultViewPageId();
- request.getPortletSession().setAttribute(SELECTED_VIEW_PAGE_ID, selectedViewPageId);
- }
- return (ViewPortletPage) portletPages.getViewPages().get(selectedViewPageId);
- }
-
-
- public void setSelectedViewPageId(PortletRequest request, String selectedViewPageId)
- {
- request.getPortletSession().setAttribute(SELECTED_VIEW_PAGE_ID, selectedViewPageId);
- }
-
- /**
- * Process an action from a portlet. The action name is defined in the portlet request
- *
- * @param portlet The portlet from which the action has been triggered
- * @param request The portlet request
- * @param response The portlet response
- *
- * @return The portlet action info or null if no action has been executed
- * @throws PortletException
- */
- public PortletActionInfo processAction(Portlet portlet, PortletRequest request, PortletResponse response) throws PortletException
- {
-
- // Check if a new tab page has been selected
- String tabId = request.getParameter(REQUEST_PARAM_SELECT_TAB);
- if (tabId != null)
- {
-
- Map tabs = null;
- if (request.getPortletMode().equals(PortletMode.VIEW))
- {
- tabs = this.getSelectedViewPage(request).getTabs();
- }
- else
- {
- tabs = this.getSelectedEditPage(request).getTabs();
- }
-
- Tab tab = (Tab) tabs.get(tabId);
- if (tab == null)
- {
- throw new PortletException("Impossible to find the tab : " + tabId);
- }
-
- String pageId = request.getParameter(REQUEST_PARAM_SELECT_PAGE);
-
- if (pageId == null)
- {
- throw new PortletException("Impossible to find the selected page : " + pageId);
- }
-
- tab.setSelectedPage(request, pageId);
-
- }
-
- PortletActionInfo portletActionInfo = getSelectedAction(portlet, request, response);
- if (executePortletAction(portletActionInfo))
- {
- return portletActionInfo;
- }
- else
- {
- return null;
- }
- }
-
- /**
- * Process an action from a portlet
- *
- * @param portlet The portlet from which the action has been triggered
- * @param actionName the action to execute (eg. folder.retrieve)
- * @param request The portlet request
- * @param response The portlet response
- *
- * @return The portlet action info or null if no action has been executed
- * @throws PortletException
- */
- public PortletActionInfo processAction(Portlet portlet, String actionName, PortletRequest request, PortletResponse response) throws PortletException
- {
- if (actionName == null)
- {
- return null;
- }
-
- PortletActionInfo portletActionInfo = new PortletActionInfo(this, actionName, request, response);
- if (executePortletAction(portletActionInfo))
- {
- return portletActionInfo;
- }
- else
- {
- return null;
- }
- }
-
- /**
- * Get information the selected action
- * @param portlet The portlet from which the action has been triggered
- * @param request The portlet request
- * @param response The portlet response
- * @return information on the selected action ({@link PortletActionInfo})
- *
- * @throws PortletException
- */
- public PortletActionInfo getSelectedAction(Portlet portlet, PortletRequest request, PortletResponse response) throws PortletException
- {
- //-------------------------------------------------------------------------------------------
- // ! MULTIPART REQUEST
- //-------------------------------------------------------------------------------------------
- if (request instanceof RenderRequest || !PortletFileUploadBase.isMultipartContent((ActionRequest)request))
- {
- Enumeration parameterNames = request.getParameterNames();
- while (parameterNames.hasMoreElements())
- {
- String parameterName = (String) parameterNames.nextElement();
- if (parameterName.startsWith(ACTION_PREFIX))
- {
- String actionName = parameterName.substring(ACTION_PREFIX.length());
- return new PortletActionInfo(this, actionName, request, response);
- }
-
- if (parameterName.startsWith(FORWARD_PREFIX))
- {
- String forwardToPage = parameterName.substring(FORWARD_PREFIX.length());
- request.setAttribute(FORWARD_TO_PAGE, forwardToPage);
- return new PortletActionInfo(this, portletPages.getForwardActionId() + ".forward", request, response);
- }
-
- }
- return null;
- }
-
- //-------------------------------------------------------------------------------------------
- // MULTIPART REQUEST
- // ------------------------------------------------------------------------------------------
- else
- {
- try
- {
- PortletDiskFileUpload diskFileUpload = new PortletDiskFileUpload();
- Iterator fileItemIterator = diskFileUpload.getFileItems((ActionRequest)request).iterator();
- while(fileItemIterator.hasNext())
- {
- FileItem fileItem = (FileItem) fileItemIterator.next();
- if( (fileItem.isFormField()) && (fileItem.getFieldName().startsWith(ACTION_PREFIX)))
- {
- String actionName = fileItem.getFieldName().substring(ACTION_PREFIX.length());
- return new PortletActionInfo(this, actionName, request, response, diskFileUpload);
- }
- }
- return null;
- }
- catch (FileUploadException e)
- {
- throw new PortletException("Impossible to select the action portlet", e);
- }
-
- }
- }
-
- /**
- * Execute the desised action
- *
- * @param portletActionInfo
- * @return true if the action is executed correctly, false when portlet info is null or when the action class is not found
- * @throws PortletException when mainly a method invocation exception occurs
- */
- private boolean executePortletAction(PortletActionInfo portletActionInfo) throws PortletException
- {
- try
- {
- if (portletActionInfo == null)
- {
- return false;
- }
-
- String className = (String) portletPages.getActions().get(portletActionInfo.getId());
- Class actionClass = Class.forName(className);
-
- // No action found
- if (actionClass == null)
- {
- return false;
- }
-
- Object action = actionClass.newInstance();
- Class[] argClasses = {PortletActionInfo.class};
- Object[] args = {portletActionInfo};
- Method method = actionClass.getMethod(portletActionInfo.getActionMethod(), argClasses);
- method.invoke(action, args);
- return true;
- }
- catch(Exception e)
- {
- throw new PortletException("Failed to execute method :" + portletActionInfo.getId() + '.' + portletActionInfo.getActionMethod(), e);
- }
- }
-
-
-
-}
+/*
+ * 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.portals.graffito.portlets.page.manager;
+
+
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.Portlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.jexl.Expression;
+import org.apache.commons.jexl.ExpressionFactory;
+import org.apache.commons.jexl.JexlContext;
+import org.apache.commons.jexl.JexlHelper;
+import org.apache.portals.graffito.portlets.GraffitoPortlet;
+import org.apache.portals.graffito.portlets.page.EditPortletPage;
+import org.apache.portals.graffito.portlets.page.PortletPageRef;
+import org.apache.portals.graffito.portlets.page.PortletPages;
+import org.apache.portals.graffito.portlets.page.ViewPortletPage;
+import org.apache.portals.graffito.portlets.page.action.PortletActionInfo;
+import org.apache.portals.graffito.portlets.page.tab.Tab;
+import org.apache.portals.graffito.portlets.page.tab.TabPage;
+import org.apache.portals.graffito.portlets.upload.PortletDiskFileUpload;
+import org.apache.portals.graffito.portlets.upload.PortletFileUploadBase;
+import org.apache.portals.graffito.portlets.util.ExpressionUtil;
+import org.apache.velocity.context.Context;
+
+
+/**
+ * Portlet Page Manager. This manager provides a more cleaner code when the number of possible pages increase.
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
+ * @version $Id: Exp $
+ */
+public class PortletPageManager
+{
+ private GraffitoPortlet portlet;
+ private static final String ACTION_PREFIX = "portletAction_";
+ private static final String FORWARD_PREFIX = "portletForward_";
+
+ /** name of the page to forward to */
+ public static final String FORWARD_TO_PAGE = "forwardToPage";
+
+ private static final String SELECTED_VIEW_PAGE_ID = "selectedViewPageId";
+ private static final String SELECTED_EDIT_PAGE_ID = "selectedEditPageId";
+
+
+ private static final String REQUEST_PARAM_SELECT_PAGE = "selectPage";
+ private static final String REQUEST_PARAM_SELECT_TAB = "selectTab";
+
+ PortletPages portletPages;
+
+
+ /**
+ * Constructor.
+ *
+ * Build a Portlet Page Manager from an xml file. This xml file should contains all pages.
+ *
+ * @param xmlFile the xml file used to initialise the portlet page manager
+ *
+ * @throws PortletException
+ *
+ */
+ public PortletPageManager(Portlet portlet, String xmlFile) throws PortletException
+ {
+ this.portlet = (GraffitoPortlet) portlet;
+ portletPages = PortletPageReader.loadPages(xmlFile);
+ }
+
+
+ public GraffitoPortlet getPortlet()
+ {
+ return portlet;
+ }
+
+ public void addContextObject(RenderRequest request, String objectName, Object object)
+ {
+ // Add the object in the velocity context in order to use it in the template
+ Context velocityContext = portlet.getContext(request);
+ velocityContext.put(objectName, object);
+
+ request.setAttribute(objectName, object);
+ }
+
+ public Object getContextObject(RenderRequest request, String objectName)
+ {
+ return request.getAttribute(objectName);
+ }
+
+ public Enumeration getAllContextObjectNames(RenderRequest request)
+ {
+ return request.getAttributeNames();
+ }
+
+ /**
+ * Process the action used for the view mode on the selected page
+ *
+ * @param request The portlet request
+ * @param response The portlet response
+ *
+ * @throws PortletException
+ */
+ public void doView(RenderRequest request, RenderResponse response) throws PortletException
+ {
+ ViewPortletPage portletPage = this.getSelectedViewPage(request);
+ request.setAttribute( GraffitoPortlet.PARAM_VIEW_PAGE, portletPage.getTemplate());
+ String actionName = portletPage.getAction();
+ // process the portlet page action
+ this.processAction(portlet, actionName, request, response);
+
+ // For each tab, process action on the select tab page
+ Map tabs = portletPage.getTabs();
+ Iterator tabsIterator = tabs.values().iterator();
+ while (tabsIterator.hasNext())
+ {
+ Tab tab = (Tab) tabsIterator.next();
+ TabPage tabPage = tab.getSelectedPage(request);
+ actionName = tabPage.getAction();
+ this.processAction(portlet, actionName, request, response);
+ }
+
+ // Init the corresponding template used in the edit mode
+ Collection editPortlePageRefs = portletPage.getEditPortletPages();
+ Iterator editPortlePageRefsIterator = editPortlePageRefs.iterator();
+ while(editPortlePageRefsIterator.hasNext())
+ {
+ PortletPageRef portletPageRef = (PortletPageRef) editPortlePageRefsIterator.next();
+ String condition = portletPageRef.getCondition();
+ if ( condition == null || condition.equals("") || ExpressionUtil.checkCondition(request, condition))
+ {
+ this.setSelectedEditPageId(request, portletPageRef.getPortletPageId());
+ return ;
+ }
+ }
+ this.setSelectedEditPageId(request, portletPages.getDefaultEditPageId());
+
+
+ }
+
+ /**
+ * Process the action used for the edit mode on the selected page
+ *
+ * @param request The portlet request
+ * @param response The portlet response
+ *
+ * @throws PortletException
+ */
+ public void doEdit(RenderRequest request, RenderResponse response) throws PortletException
+ {
+ EditPortletPage portletPage = this.getSelectedEditPage(request);
+ String actionName = portletPage.getAction();
+ request.setAttribute( GraffitoPortlet.PARAM_EDIT_PAGE, portletPage.getTemplate());
+ // process the portlet page action
+ this.processAction(portlet, actionName, request, response);
+
+ // process action on each tab (selected paged in those tabs)
+ Map tabs = portletPage.getTabs();
+ Iterator tabsIterator = tabs.values().iterator();
+ while (tabsIterator.hasNext())
+ {
+ Tab tab = (Tab) tabsIterator.next();
+ TabPage tabPage = tab.getSelectedPage(request);
+ actionName = tabPage.getAction();
+ this.processAction(portlet, actionName, request, response);
+ }
+
+ // Init the corresponding template used in the edit mode
+ Collection viewPortlePageRefs = portletPage.getViewPortletPages();
+ Iterator viewPortlePageRefsIterator = viewPortlePageRefs.iterator();
+ while(viewPortlePageRefsIterator.hasNext())
+ {
+ PortletPageRef portletPageRef = (PortletPageRef) viewPortlePageRefsIterator.next();
+ String condition = portletPageRef.getCondition();
+ if ( condition == null || condition.equals("") || ExpressionUtil.checkCondition(request, condition))
+ {
+ this.setSelectedViewPageId(request, portletPageRef.getPortletPageId());
+ return ;
+ }
+ }
+ this.setSelectedViewPageId(request, portletPages.getDefaultViewPageId());
+
+ }
+
+
+ public EditPortletPage getSelectedEditPage(PortletRequest request)
+ {
+ String selectedEditPageId = (String) request.getPortletSession().getAttribute(SELECTED_EDIT_PAGE_ID);
+ if (selectedEditPageId == null)
+ {
+ selectedEditPageId = portletPages.getDefaultEditPageId();
+ request.getPortletSession().setAttribute(SELECTED_EDIT_PAGE_ID, selectedEditPageId);
+ }
+ return (EditPortletPage) portletPages.getEditPages().get(selectedEditPageId);
+ }
+
+ public void setSelectedEditPageId(PortletRequest request, String selectedEdiPageId)
+ {
+ request.getPortletSession().setAttribute(SELECTED_EDIT_PAGE_ID, selectedEdiPageId);
+ }
+
+
+ public ViewPortletPage getSelectedViewPage(PortletRequest request)
+ {
+ String selectedViewPageId = (String) request.getPortletSession().getAttribute(SELECTED_VIEW_PAGE_ID);
+ if (selectedViewPageId == null)
+ {
+ selectedViewPageId = portletPages.getDefaultViewPageId();
+ request.getPortletSession().setAttribute(SELECTED_VIEW_PAGE_ID, selectedViewPageId);
+ }
+ return (ViewPortletPage) portletPages.getViewPages().get(selectedViewPageId);
+ }
+
+
+ public void setSelectedViewPageId(PortletRequest request, String selectedViewPageId)
+ {
+ request.getPortletSession().setAttribute(SELECTED_VIEW_PAGE_ID, selectedViewPageId);
+ }
+
+ /**
+ * Process an action from a portlet. The action name is defined in the portlet request
+ *
+ * @param portlet The portlet from which the action has been triggered
+ * @param request The portlet request
+ * @param response The portlet response
+ *
+ * @return The portlet action info or null if no action has been executed
+ * @throws PortletException
+ */
+ public PortletActionInfo processAction(Portlet portlet, PortletRequest request, PortletResponse response) throws PortletException
+ {
+
+ // Check if a new tab page has been selected
+ String tabId = request.getParameter(REQUEST_PARAM_SELECT_TAB);
+ if (tabId != null)
+ {
+
+ Map tabs = null;
+ if (request.getPortletMode().equals(PortletMode.VIEW))
+ {
+ tabs = this.getSelectedViewPage(request).getTabs();
+ }
+ else
+ {
+ tabs = this.getSelectedEditPage(request).getTabs();
+ }
+
+ Tab tab = (Tab) tabs.get(tabId);
+ if (tab == null)
+ {
+ throw new PortletException("Impossible to find the tab : " + tabId);
+ }
+
+ String pageId = request.getParameter(REQUEST_PARAM_SELECT_PAGE);
+
+ if (pageId == null)
+ {
+ throw new PortletException("Impossible to find the selected page : " + pageId);
+ }
+
+ tab.setSelectedPage(request, pageId);
+
+ }
+
+ PortletActionInfo portletActionInfo = getSelectedAction(portlet, request, response);
+ if (executePortletAction(portletActionInfo))
+ {
+ return portletActionInfo;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Process an action from a portlet
+ *
+ * @param portlet The portlet from which the action has been triggered
+ * @param actionName the action to execute (eg. folder.retrieve)
+ * @param request The portlet request
+ * @param response The portlet response
+ *
+ * @return The portlet action info or null if no action has been executed
+ * @throws PortletException
+ */
+ public PortletActionInfo processAction(Portlet portlet, String actionName, PortletRequest request, PortletResponse response) throws PortletException
+ {
+ if (actionName == null)
+ {
+ return null;
+ }
+
+ PortletActionInfo portletActionInfo = new PortletActionInfo(this, actionName, request, response);
+ if (executePortletAction(portletActionInfo))
+ {
+ return portletActionInfo;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Get information the selected action
+ * @param portlet The portlet from which the action has been triggered
+ * @param request The portlet request
+ * @param response The portlet response
+ * @return information on the selected action ({@link PortletActionInfo})
+ *
+ * @throws PortletException
+ */
+ public PortletActionInfo getSelectedAction(Portlet portlet, PortletRequest request, PortletResponse response) throws PortletException
+ {
+ //-------------------------------------------------------------------------------------------
+ // ! MULTIPART REQUEST
+ //-------------------------------------------------------------------------------------------
+ if (request instanceof RenderRequest || !PortletFileUploadBase.isMultipartContent((ActionRequest)request))
+ {
+ Enumeration parameterNames = request.getParameterNames();
+ while (parameterNames.hasMoreElements())
+ {
+ String parameterName = (String) parameterNames.nextElement();
+ if (parameterName.startsWith(ACTION_PREFIX))
+ {
+ String actionName = parameterName.substring(ACTION_PREFIX.length());
+ return new PortletActionInfo(this, actionName, request, response);
+ }
+
+ if (parameterName.startsWith(FORWARD_PREFIX))
+ {
+ String forwardToPage = parameterName.substring(FORWARD_PREFIX.length());
+ request.setAttribute(FORWARD_TO_PAGE, forwardToPage);
+ return new PortletActionInfo(this, portletPages.getForwardActionId() + ".forward", request, response);
+ }
+
+ }
+ return null;
+ }
+
+ //-------------------------------------------------------------------------------------------
+ // MULTIPART REQUEST
+ // ------------------------------------------------------------------------------------------
+ else
+ {
+ try
+ {
+ PortletDiskFileUpload diskFileUpload = new PortletDiskFileUpload();
+ Iterator fileItemIterator = diskFileUpload.getFileItems((ActionRequest)request).iterator();
+ while(fileItemIterator.hasNext())
+ {
+ FileItem fileItem = (FileItem) fileItemIterator.next();
+ if( (fileItem.isFormField()) && (fileItem.getFieldName().startsWith(ACTION_PREFIX)))
+ {
+ String actionName = fileItem.getFieldName().substring(ACTION_PREFIX.length());
+ return new PortletActionInfo(this, actionName, request, response, diskFileUpload);
+ }
+ }
+ return null;
+ }
+ catch (FileUploadException e)
+ {
+ throw new PortletException("Impossible to select the action portlet", e);
+ }
+
+ }
+ }
+
+ /**
+ * Execute the desised action
+ *
+ * @param portletActionInfo
+ * @return true if the action is executed correctly, false when portlet info is null or when the action class is not found
+ * @throws PortletException when mainly a method invocation exception occurs
+ */
+ private boolean executePortletAction(PortletActionInfo portletActionInfo) throws PortletException
+ {
+ try
+ {
+ if (portletActionInfo == null)
+ {
+ return false;
+ }
+
+ String className = (String) portletPages.getActions().get(portletActionInfo.getId());
+ Class actionClass = Class.forName(className);
+
+ // No action found
+ if (actionClass == null)
+ {
+ return false;
+ }
+
+ Object action = actionClass.newInstance();
+ Class[] argClasses = {PortletActionInfo.class};
+ Object[] args = {portletActionInfo};
+ Method method = actionClass.getMethod(portletActionInfo.getActionMethod(), argClasses);
+ method.invoke(action, args);
+ return true;
+ }
+ catch(Exception e)
+ {
+ throw new PortletException("Failed to execute method :" + portletActionInfo.getId() + '.' + portletActionInfo.getActionMethod(), e);
+ }
+ }
+
+
+
+}
Propchange: incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/manager/PortletPageManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/manager/PortletPageReader.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/manager/PortletPageReader.java?view=diff&rev=448311&r1=448310&r2=448311
==============================================================================
--- incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/manager/PortletPageReader.java (original)
+++ incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/manager/PortletPageReader.java Wed Sep 20 12:37:05 2006
@@ -1,127 +1,127 @@
-/*
- * 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.portals.graffito.portlets.page.manager;
-
-import java.io.File;
-
-import javax.portlet.PortletException;
-
-import org.apache.commons.digester.Digester;
-
-import org.apache.portals.graffito.portlets.page.EditPortletPage;
-import org.apache.portals.graffito.portlets.page.PortletPageRef;
-import org.apache.portals.graffito.portlets.page.PortletPages;
-import org.apache.portals.graffito.portlets.page.ViewPortletPage;
-import org.apache.portals.graffito.portlets.page.tab.Tab;
-import org.apache.portals.graffito.portlets.page.tab.TabPage;
-
-/**
- * This utility class build a {@link org.apache.portals.graffito.portlets.page.PortletPages}
- * from a xml config file.
- *
- * @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
- * @version $Id: Exp $
- */
-public class PortletPageReader
-{
-
- /**
- * Load all edit/view pages found in the config file
- * @param xmlFile
- */
- public static PortletPages loadPages(String xmlFile) throws PortletException
- {
- try {
- Digester digester = new Digester();
- digester.setValidating( false );
-
- digester.addObjectCreate( "pages", PortletPages.class );
-
- // --------------------------------------------------------------------------------
- // Rules used for the actions
- // --------------------------------------------------------------------------------
- Class[] methodArgs = { String.class, String.class, Boolean.class};
- digester.addCallMethod("pages/actions/action", "addAction", 3, methodArgs);
- digester.addCallParam("pages/actions/action", 0, "id");
- digester.addCallParam("pages/actions/action", 1, "class");
- digester.addCallParam("pages/actions/action", 2, "forward");
-
- // --------------------------------------------------------------------------------
- // Rules used for the view pages
- // --------------------------------------------------------------------------------
- digester.addObjectCreate( "pages/view/page", ViewPortletPage.class );
- digester.addSetProperties( "pages/view/page", "id", "id" );
- digester.addSetProperties( "pages/view/page", "action", "action" );
- digester.addSetProperties( "pages/view/page", "template", "template" );
- digester.addSetProperties( "pages/view/page", "defaultPage", "isDefaultPage" );
- digester.addSetNext( "pages/view/page", "addViewPage" );
- digester.addObjectCreate( "pages/view/page/tab", Tab.class );
- digester.addSetProperties( "pages/view/page/tab", "id", "id" );
- digester.addSetNext( "pages/view/page/tab", "addTab" );
-
- digester.addObjectCreate( "pages/view/page/tab/page", TabPage.class );
- digester.addSetProperties( "pages/view/page/tab/page", "id", "id" );
- digester.addSetProperties( "pages/view/page/tab/page", "label", "label" );
- digester.addSetProperties( "pages/view/page/tab/page", "template", "template" );
- digester.addSetProperties( "pages/view/page/tab/page", "action", "action" );
- digester.addSetProperties( "pages/view/page/tab/page", "isDefaultTabPage", "defaultTabPage" );
- digester.addSetProperties( "pages/view/page/tab/page", "condition", "condition" );
- digester.addSetNext( "pages/view/page/tab/page", "addPage" );
-
- digester.addObjectCreate( "pages/view/page/editpage", PortletPageRef.class );
- digester.addSetProperties( "pages/view/page/editpage", "condition", "condition" );
- digester.addSetProperties( "pages/view/page/editpage", "portletPageId", "portletPageId" );
- digester.addSetNext( "pages/view/page/editpage", "addEditPortletPageReference" );
-
- // --------------------------------------------------------------------------------
- // Rules used for the edit pages
- // --------------------------------------------------------------------------------
- digester.addObjectCreate( "pages/edit/page", EditPortletPage.class );
- digester.addSetProperties( "pages/edit/page", "id", "id" );
- digester.addSetProperties( "pages/edit/page", "action", "action" );
- digester.addSetProperties( "pages/edit/page", "template", "template" );
- digester.addSetProperties( "pages/edit/page", "defaultPage", "isDefaultPage" );
- digester.addSetNext( "pages/edit/page", "addEditPage" );
-
- digester.addObjectCreate( "pages/edit/page/tab", Tab.class );
- digester.addSetProperties( "pages/edit/page/tab", "id", "id" );
- digester.addSetNext( "pages/edit/page/tab", "addTab" );
-
- digester.addObjectCreate( "pages/edit/page/tab/page", TabPage.class );
- digester.addSetProperties( "pages/edit/page/tab/page", "id", "id" );
- digester.addSetProperties( "pages/edit/page/tab/page", "label", "label" );
- digester.addSetProperties( "pages/edit/page/tab/page", "template", "template" );
- digester.addSetProperties( "pages/edit/page/tab/page", "action", "action" );
- digester.addSetProperties( "pages/edit/page/tab/page", "isDefaultTabPage", "defaultTabPage" );
- digester.addSetNext( "pages/edit/page/tab/page", "addPage" );
-
- digester.addObjectCreate( "pages/edit/page/viewpage", PortletPageRef.class );
- digester.addSetProperties( "pages/edit/page/viewpage", "condition", "condition" );
- digester.addSetProperties( "pages/edit/page/viewpage", "portletPageId", "portletPageId" );
- digester.addSetNext( "pages/edit/page/viewpage", "addViewPortletPageReference" );
-
-
- File input = new File(xmlFile);
- PortletPages portletPages = (PortletPages)digester.parse( input );
-
- return portletPages;
-
- } catch( Exception e )
- {
- throw new PortletException("Impossible to read the portlet pages from : " + xmlFile, e);
- }
-
- }
-
-
+/*
+ * 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.portals.graffito.portlets.page.manager;
+
+import java.io.File;
+
+import javax.portlet.PortletException;
+
+import org.apache.commons.digester.Digester;
+
+import org.apache.portals.graffito.portlets.page.EditPortletPage;
+import org.apache.portals.graffito.portlets.page.PortletPageRef;
+import org.apache.portals.graffito.portlets.page.PortletPages;
+import org.apache.portals.graffito.portlets.page.ViewPortletPage;
+import org.apache.portals.graffito.portlets.page.tab.Tab;
+import org.apache.portals.graffito.portlets.page.tab.TabPage;
+
+/**
+ * This utility class build a {@link org.apache.portals.graffito.portlets.page.PortletPages}
+ * from a xml config file.
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
+ * @version $Id: Exp $
+ */
+public class PortletPageReader
+{
+
+ /**
+ * Load all edit/view pages found in the config file
+ * @param xmlFile
+ */
+ public static PortletPages loadPages(String xmlFile) throws PortletException
+ {
+ try {
+ Digester digester = new Digester();
+ digester.setValidating( false );
+
+ digester.addObjectCreate( "pages", PortletPages.class );
+
+ // --------------------------------------------------------------------------------
+ // Rules used for the actions
+ // --------------------------------------------------------------------------------
+ Class[] methodArgs = { String.class, String.class, Boolean.class};
+ digester.addCallMethod("pages/actions/action", "addAction", 3, methodArgs);
+ digester.addCallParam("pages/actions/action", 0, "id");
+ digester.addCallParam("pages/actions/action", 1, "class");
+ digester.addCallParam("pages/actions/action", 2, "forward");
+
+ // --------------------------------------------------------------------------------
+ // Rules used for the view pages
+ // --------------------------------------------------------------------------------
+ digester.addObjectCreate( "pages/view/page", ViewPortletPage.class );
+ digester.addSetProperties( "pages/view/page", "id", "id" );
+ digester.addSetProperties( "pages/view/page", "action", "action" );
+ digester.addSetProperties( "pages/view/page", "template", "template" );
+ digester.addSetProperties( "pages/view/page", "defaultPage", "isDefaultPage" );
+ digester.addSetNext( "pages/view/page", "addViewPage" );
+ digester.addObjectCreate( "pages/view/page/tab", Tab.class );
+ digester.addSetProperties( "pages/view/page/tab", "id", "id" );
+ digester.addSetNext( "pages/view/page/tab", "addTab" );
+
+ digester.addObjectCreate( "pages/view/page/tab/page", TabPage.class );
+ digester.addSetProperties( "pages/view/page/tab/page", "id", "id" );
+ digester.addSetProperties( "pages/view/page/tab/page", "label", "label" );
+ digester.addSetProperties( "pages/view/page/tab/page", "template", "template" );
+ digester.addSetProperties( "pages/view/page/tab/page", "action", "action" );
+ digester.addSetProperties( "pages/view/page/tab/page", "isDefaultTabPage", "defaultTabPage" );
+ digester.addSetProperties( "pages/view/page/tab/page", "condition", "condition" );
+ digester.addSetNext( "pages/view/page/tab/page", "addPage" );
+
+ digester.addObjectCreate( "pages/view/page/editpage", PortletPageRef.class );
+ digester.addSetProperties( "pages/view/page/editpage", "condition", "condition" );
+ digester.addSetProperties( "pages/view/page/editpage", "portletPageId", "portletPageId" );
+ digester.addSetNext( "pages/view/page/editpage", "addEditPortletPageReference" );
+
+ // --------------------------------------------------------------------------------
+ // Rules used for the edit pages
+ // --------------------------------------------------------------------------------
+ digester.addObjectCreate( "pages/edit/page", EditPortletPage.class );
+ digester.addSetProperties( "pages/edit/page", "id", "id" );
+ digester.addSetProperties( "pages/edit/page", "action", "action" );
+ digester.addSetProperties( "pages/edit/page", "template", "template" );
+ digester.addSetProperties( "pages/edit/page", "defaultPage", "isDefaultPage" );
+ digester.addSetNext( "pages/edit/page", "addEditPage" );
+
+ digester.addObjectCreate( "pages/edit/page/tab", Tab.class );
+ digester.addSetProperties( "pages/edit/page/tab", "id", "id" );
+ digester.addSetNext( "pages/edit/page/tab", "addTab" );
+
+ digester.addObjectCreate( "pages/edit/page/tab/page", TabPage.class );
+ digester.addSetProperties( "pages/edit/page/tab/page", "id", "id" );
+ digester.addSetProperties( "pages/edit/page/tab/page", "label", "label" );
+ digester.addSetProperties( "pages/edit/page/tab/page", "template", "template" );
+ digester.addSetProperties( "pages/edit/page/tab/page", "action", "action" );
+ digester.addSetProperties( "pages/edit/page/tab/page", "isDefaultTabPage", "defaultTabPage" );
+ digester.addSetNext( "pages/edit/page/tab/page", "addPage" );
+
+ digester.addObjectCreate( "pages/edit/page/viewpage", PortletPageRef.class );
+ digester.addSetProperties( "pages/edit/page/viewpage", "condition", "condition" );
+ digester.addSetProperties( "pages/edit/page/viewpage", "portletPageId", "portletPageId" );
+ digester.addSetNext( "pages/edit/page/viewpage", "addViewPortletPageReference" );
+
+
+ File input = new File(xmlFile);
+ PortletPages portletPages = (PortletPages)digester.parse( input );
+
+ return portletPages;
+
+ } catch( Exception e )
+ {
+ throw new PortletException("Impossible to read the portlet pages from : " + xmlFile, e);
+ }
+
+ }
+
+
}
Propchange: incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/manager/PortletPageReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/tab/Tab.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/tab/Tab.java?view=diff&rev=448311&r1=448310&r2=448311
==============================================================================
--- incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/tab/Tab.java (original)
+++ incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/tab/Tab.java Wed Sep 20 12:37:05 2006
@@ -1,124 +1,124 @@
-/*
- * 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.portals.graffito.portlets.page.tab;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import javax.portlet.PortletRequest;
-
-import org.apache.portals.graffito.portlets.util.ExpressionUtil;
-
-/**
- * Velocity Tab contains a set of {@link org.apache.portals.graffito.portlets.page.tab.TabPage}
- *
- * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
- * @version $Id: Exp $
- */
-public class Tab
-{
-
- private static String SELECTED_TAB_PAGE_ID ="selectedTabPageId";
-
- private HashMap tabPages = new HashMap();
- private String id;
-
-
- public String getId()
- {
- return id;
- }
-
- public void setId(String id)
- {
- this.id = id;
- }
-
- public void addPage(TabPage page)
- {
- tabPages.put(page.getId(), page);
- }
-
- public TabPage[] getPages(PortletRequest request)
- {
- ArrayList result = new ArrayList();
- Iterator tabPageIterator = tabPages.values().iterator();
- while (tabPageIterator.hasNext())
- {
- TabPage tabPage = (TabPage) tabPageIterator.next();
- String condition = tabPage.getCondition();
- if ((condition == null) || (condition.equals("")) ||
- (ExpressionUtil.checkCondition(request, tabPage.getCondition())))
- {
- result.add(tabPage);
- }
- }
-
- return (TabPage[]) result.toArray(new TabPage[result.size()]);
- }
-
- public TabPage getSelectedPage(PortletRequest request)
- {
- TabPage tabPage = null;
-
- String selectedPageId = (String) request.getPortletSession().getAttribute(SELECTED_TAB_PAGE_ID);
- if (selectedPageId != null)
- {
- // Check if the selected tab page can be display for the current cms object
- tabPage = (TabPage) tabPages.get(selectedPageId);
- if (tabPage != null)
- {
- String condition = tabPage.getCondition();
- if ((condition != null) && (!condition.equals(""))
- && (!ExpressionUtil.checkCondition(request, tabPage.getCondition())))
- {
- tabPage = null;
- }
- }
-
- }
-
- if (tabPage == null )
- {
- TabPage[] tabPages = this.getPages(request);
- for (int tabPageIndex =0; tabPageIndex <tabPages.length; tabPageIndex++)
- {
- if (tabPages[tabPageIndex].isDefaultTabPage())
- {
- selectedPageId = tabPages[tabPageIndex].getId();
- tabPage = tabPages[tabPageIndex];
- break;
- }
- }
-
- request.getPortletSession().setAttribute(SELECTED_TAB_PAGE_ID, selectedPageId);
- }
-
- return tabPage;
- }
-
- public void setSelectedPage(PortletRequest request, String pageId)
- {
- request.getPortletSession().setAttribute(SELECTED_TAB_PAGE_ID, pageId);
-
- }
-
- public boolean isSelected(PortletRequest request, TabPage page)
- {
- return page.getId().equals(this.getSelectedPage(request).getId());
- }
-}
+/*
+ * 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.portals.graffito.portlets.page.tab;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.portlet.PortletRequest;
+
+import org.apache.portals.graffito.portlets.util.ExpressionUtil;
+
+/**
+ * Velocity Tab contains a set of {@link org.apache.portals.graffito.portlets.page.tab.TabPage}
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @version $Id: Exp $
+ */
+public class Tab
+{
+
+ private static String SELECTED_TAB_PAGE_ID ="selectedTabPageId";
+
+ private HashMap tabPages = new HashMap();
+ private String id;
+
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public void addPage(TabPage page)
+ {
+ tabPages.put(page.getId(), page);
+ }
+
+ public TabPage[] getPages(PortletRequest request)
+ {
+ ArrayList result = new ArrayList();
+ Iterator tabPageIterator = tabPages.values().iterator();
+ while (tabPageIterator.hasNext())
+ {
+ TabPage tabPage = (TabPage) tabPageIterator.next();
+ String condition = tabPage.getCondition();
+ if ((condition == null) || (condition.equals("")) ||
+ (ExpressionUtil.checkCondition(request, tabPage.getCondition())))
+ {
+ result.add(tabPage);
+ }
+ }
+
+ return (TabPage[]) result.toArray(new TabPage[result.size()]);
+ }
+
+ public TabPage getSelectedPage(PortletRequest request)
+ {
+ TabPage tabPage = null;
+
+ String selectedPageId = (String) request.getPortletSession().getAttribute(SELECTED_TAB_PAGE_ID);
+ if (selectedPageId != null)
+ {
+ // Check if the selected tab page can be display for the current cms object
+ tabPage = (TabPage) tabPages.get(selectedPageId);
+ if (tabPage != null)
+ {
+ String condition = tabPage.getCondition();
+ if ((condition != null) && (!condition.equals(""))
+ && (!ExpressionUtil.checkCondition(request, tabPage.getCondition())))
+ {
+ tabPage = null;
+ }
+ }
+
+ }
+
+ if (tabPage == null )
+ {
+ TabPage[] tabPages = this.getPages(request);
+ for (int tabPageIndex =0; tabPageIndex <tabPages.length; tabPageIndex++)
+ {
+ if (tabPages[tabPageIndex].isDefaultTabPage())
+ {
+ selectedPageId = tabPages[tabPageIndex].getId();
+ tabPage = tabPages[tabPageIndex];
+ break;
+ }
+ }
+
+ request.getPortletSession().setAttribute(SELECTED_TAB_PAGE_ID, selectedPageId);
+ }
+
+ return tabPage;
+ }
+
+ public void setSelectedPage(PortletRequest request, String pageId)
+ {
+ request.getPortletSession().setAttribute(SELECTED_TAB_PAGE_ID, pageId);
+
+ }
+
+ public boolean isSelected(PortletRequest request, TabPage page)
+ {
+ return page.getId().equals(this.getSelectedPage(request).getId());
+ }
+}
Propchange: incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/tab/Tab.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/tab/TabPage.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/tab/TabPage.java?view=diff&rev=448311&r1=448310&r2=448311
==============================================================================
--- incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/tab/TabPage.java (original)
+++ incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/tab/TabPage.java Wed Sep 20 12:37:05 2006
@@ -1,91 +1,91 @@
-/*
- * 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.portals.graffito.portlets.page.tab;
-
-/**
- * Information on one page in a Tab. See {@link org.apache.portals.graffito.portlets.page.tab.Tab}
- *
- * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
- * @version $Id: Exp $
- */
-public class TabPage
-{
- private String id;
- private String label;
- private String template;
- private String action;
- private String condition;
- private boolean isDefaultTabPage;
-
-
-
- public String getId()
- {
- return id;
- }
- public void setId(String id)
- {
- this.id = id;
- }
-
- public String getLabel()
- {
- return label;
- }
- public void setLabel(String label)
- {
- this.label = label;
- }
- public String getTemplate()
- {
- return template;
- }
- public void setTemplate(String template)
- {
- this.template = template;
- }
-
-
- public String getAction()
- {
- return action;
- }
- public void setAction(String action)
- {
- this.action = action;
- }
-
-
- public boolean isDefaultTabPage()
- {
- return isDefaultTabPage;
- }
-
- public void setDefaultTabPage(boolean isDefaultTabPage)
- {
- this.isDefaultTabPage = isDefaultTabPage;
- }
-
-
- public String getCondition()
- {
- return condition;
- }
- public void setCondition(String condition)
- {
- this.condition = condition;
- }
-}
+/*
+ * 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.portals.graffito.portlets.page.tab;
+
+/**
+ * Information on one page in a Tab. See {@link org.apache.portals.graffito.portlets.page.tab.Tab}
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @version $Id: Exp $
+ */
+public class TabPage
+{
+ private String id;
+ private String label;
+ private String template;
+ private String action;
+ private String condition;
+ private boolean isDefaultTabPage;
+
+
+
+ public String getId()
+ {
+ return id;
+ }
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public String getLabel()
+ {
+ return label;
+ }
+ public void setLabel(String label)
+ {
+ this.label = label;
+ }
+ public String getTemplate()
+ {
+ return template;
+ }
+ public void setTemplate(String template)
+ {
+ this.template = template;
+ }
+
+
+ public String getAction()
+ {
+ return action;
+ }
+ public void setAction(String action)
+ {
+ this.action = action;
+ }
+
+
+ public boolean isDefaultTabPage()
+ {
+ return isDefaultTabPage;
+ }
+
+ public void setDefaultTabPage(boolean isDefaultTabPage)
+ {
+ this.isDefaultTabPage = isDefaultTabPage;
+ }
+
+
+ public String getCondition()
+ {
+ return condition;
+ }
+ public void setCondition(String condition)
+ {
+ this.condition = condition;
+ }
+}
Propchange: incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/page/tab/TabPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/upload/PortletDiskFileUpload.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/upload/PortletDiskFileUpload.java?view=diff&rev=448311&r1=448310&r2=448311
==============================================================================
--- incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/upload/PortletDiskFileUpload.java (original)
+++ incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/upload/PortletDiskFileUpload.java Wed Sep 20 12:37:05 2006
@@ -1,202 +1,202 @@
-/*
- * 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.portals.graffito.portlets.upload;
-
-
-import java.io.File;
-import java.util.List;
-import javax.portlet.ActionRequest;
-
-import org.apache.commons.fileupload.DefaultFileItemFactory;
-import org.apache.commons.fileupload.FileItemFactory;
-import org.apache.commons.fileupload.FileUploadException;
-
-
-
-/**
- * <p>High level API for processing file uploads.</p>
- *
- * <p>This class handles multiple files per single HTML widget, sent using
- * <code>multipart/mixed</code> encoding type, as specified by
- * <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>. Use {@link
- * #parseRequest(HttpServletRequest)} to acquire a list of {@link
- * org.apache.commons.fileupload.FileItem}s associated with a given HTML
- * widget.</p>
- *
- * <p>Individual parts will be stored in temporary disk storage or in memory,
- * depending on their size, and will be available as {@link
- * org.apache.commons.fileupload.FileItem}s.</p>
- *
- * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
- * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
- * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
- * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
- * @author Sean C. Sullivan
- *
- * @version $Id: Exp $
- */
-public class PortletDiskFileUpload
- extends PortletFileUploadBase
- {
-
- // ----------------------------------------------------------- Data members
-
-
- /**
- * The factory to use to create new form items.
- */
- private DefaultFileItemFactory fileItemFactory;
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Constructs an instance of this class which uses the default factory to
- * create <code>FileItem</code> instances.
- *
- * @see #DiskFileUpload(DefaultFileItemFactory fileItemFactory)
- */
- public PortletDiskFileUpload()
- {
- super();
- this.fileItemFactory = new DefaultFileItemFactory();
- }
-
-
- /**
- * Constructs an instance of this class which uses the supplied factory to
- * create <code>FileItem</code> instances.
- *
- * @see #DiskFileUpload()
- */
- public PortletDiskFileUpload(DefaultFileItemFactory fileItemFactory)
- {
- super();
- this.fileItemFactory = fileItemFactory;
- }
-
-
- // ----------------------------------------------------- Property accessors
-
-
- /**
- * Returns the factory class used when creating file items.
- *
- * @return The factory class for new file items.
- */
- public FileItemFactory getFileItemFactory()
- {
- return fileItemFactory;
- }
-
-
- /**
- * Sets the factory class to use when creating file items. The factory must
- * be an instance of <code>DefaultFileItemFactory</code> or a subclass
- * thereof, or else a <code>ClassCastException</code> will be thrown.
- *
- * @param factory The factory class for new file items.
- */
- public void setFileItemFactory(FileItemFactory factory)
- {
- this.fileItemFactory = (DefaultFileItemFactory) factory;
- }
-
-
- /**
- * Returns the size threshold beyond which files are written directly to
- * disk.
- *
- * @return The size threshold, in bytes.
- *
- * @see #setSizeThreshold(int)
- */
- public int getSizeThreshold()
- {
- return fileItemFactory.getSizeThreshold();
- }
-
-
- /**
- * Sets the size threshold beyond which files are written directly to disk.
- *
- * @param sizeThreshold The size threshold, in bytes.
- *
- * @see #getSizeThreshold()
- */
- public void setSizeThreshold(int sizeThreshold)
- {
- fileItemFactory.setSizeThreshold(sizeThreshold);
- }
-
-
- /**
- * Returns the location used to temporarily store files that are larger
- * than the configured size threshold.
- *
- * @return The path to the temporary file location.
- *
- * @see #setRepositoryPath(String)
- */
- public String getRepositoryPath()
- {
- return fileItemFactory.getRepository().getPath();
- }
-
-
- /**
- * Sets the location used to temporarily store files that are larger
- * than the configured size threshold.
- *
- * @param repositoryPath The path to the temporary file location.
- *
- * @see #getRepositoryPath()
- */
- public void setRepositoryPath(String repositoryPath)
- {
- fileItemFactory.setRepository(new File(repositoryPath));
- }
-
-
- // --------------------------------------------------------- Public methods
-
-
- /**
- * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>
- * compliant <code>multipart/form-data</code> stream. If files are stored
- * on disk, the path is given by <code>getRepository()</code>.
- *
- * @param req The servlet request to be parsed. Must be non-null.
- * @param sizeThreshold The max size in bytes to be stored in memory.
- * @param sizeMax The maximum allowed upload size, in bytes.
- * @param path The location where the files should be stored.
- *
- * @return A list of <code>FileItem</code> instances parsed from the
- * request, in the order that they were transmitted.
- *
- * @exception FileUploadException if there are problems reading/parsing
- * the request or storing files.
- */
- public List parseRequest(ActionRequest req, int sizeThreshold, long sizeMax, String path)
- throws FileUploadException
- {
- setSizeThreshold(sizeThreshold);
- setSizeMax(sizeMax);
- setRepositoryPath(path);
- return parseRequest(req);
- }
-
-}
+/*
+ * 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.portals.graffito.portlets.upload;
+
+
+import java.io.File;
+import java.util.List;
+import javax.portlet.ActionRequest;
+
+import org.apache.commons.fileupload.DefaultFileItemFactory;
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.FileUploadException;
+
+
+
+/**
+ * <p>High level API for processing file uploads.</p>
+ *
+ * <p>This class handles multiple files per single HTML widget, sent using
+ * <code>multipart/mixed</code> encoding type, as specified by
+ * <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>. Use {@link
+ * #parseRequest(HttpServletRequest)} to acquire a list of {@link
+ * org.apache.commons.fileupload.FileItem}s associated with a given HTML
+ * widget.</p>
+ *
+ * <p>Individual parts will be stored in temporary disk storage or in memory,
+ * depending on their size, and will be available as {@link
+ * org.apache.commons.fileupload.FileItem}s.</p>
+ *
+ * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
+ * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
+ * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
+ * @author Sean C. Sullivan
+ *
+ * @version $Id: Exp $
+ */
+public class PortletDiskFileUpload
+ extends PortletFileUploadBase
+ {
+
+ // ----------------------------------------------------------- Data members
+
+
+ /**
+ * The factory to use to create new form items.
+ */
+ private DefaultFileItemFactory fileItemFactory;
+
+
+ // ----------------------------------------------------------- Constructors
+
+
+ /**
+ * Constructs an instance of this class which uses the default factory to
+ * create <code>FileItem</code> instances.
+ *
+ * @see #DiskFileUpload(DefaultFileItemFactory fileItemFactory)
+ */
+ public PortletDiskFileUpload()
+ {
+ super();
+ this.fileItemFactory = new DefaultFileItemFactory();
+ }
+
+
+ /**
+ * Constructs an instance of this class which uses the supplied factory to
+ * create <code>FileItem</code> instances.
+ *
+ * @see #DiskFileUpload()
+ */
+ public PortletDiskFileUpload(DefaultFileItemFactory fileItemFactory)
+ {
+ super();
+ this.fileItemFactory = fileItemFactory;
+ }
+
+
+ // ----------------------------------------------------- Property accessors
+
+
+ /**
+ * Returns the factory class used when creating file items.
+ *
+ * @return The factory class for new file items.
+ */
+ public FileItemFactory getFileItemFactory()
+ {
+ return fileItemFactory;
+ }
+
+
+ /**
+ * Sets the factory class to use when creating file items. The factory must
+ * be an instance of <code>DefaultFileItemFactory</code> or a subclass
+ * thereof, or else a <code>ClassCastException</code> will be thrown.
+ *
+ * @param factory The factory class for new file items.
+ */
+ public void setFileItemFactory(FileItemFactory factory)
+ {
+ this.fileItemFactory = (DefaultFileItemFactory) factory;
+ }
+
+
+ /**
+ * Returns the size threshold beyond which files are written directly to
+ * disk.
+ *
+ * @return The size threshold, in bytes.
+ *
+ * @see #setSizeThreshold(int)
+ */
+ public int getSizeThreshold()
+ {
+ return fileItemFactory.getSizeThreshold();
+ }
+
+
+ /**
+ * Sets the size threshold beyond which files are written directly to disk.
+ *
+ * @param sizeThreshold The size threshold, in bytes.
+ *
+ * @see #getSizeThreshold()
+ */
+ public void setSizeThreshold(int sizeThreshold)
+ {
+ fileItemFactory.setSizeThreshold(sizeThreshold);
+ }
+
+
+ /**
+ * Returns the location used to temporarily store files that are larger
+ * than the configured size threshold.
+ *
+ * @return The path to the temporary file location.
+ *
+ * @see #setRepositoryPath(String)
+ */
+ public String getRepositoryPath()
+ {
+ return fileItemFactory.getRepository().getPath();
+ }
+
+
+ /**
+ * Sets the location used to temporarily store files that are larger
+ * than the configured size threshold.
+ *
+ * @param repositoryPath The path to the temporary file location.
+ *
+ * @see #getRepositoryPath()
+ */
+ public void setRepositoryPath(String repositoryPath)
+ {
+ fileItemFactory.setRepository(new File(repositoryPath));
+ }
+
+
+ // --------------------------------------------------------- Public methods
+
+
+ /**
+ * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>
+ * compliant <code>multipart/form-data</code> stream. If files are stored
+ * on disk, the path is given by <code>getRepository()</code>.
+ *
+ * @param req The servlet request to be parsed. Must be non-null.
+ * @param sizeThreshold The max size in bytes to be stored in memory.
+ * @param sizeMax The maximum allowed upload size, in bytes.
+ * @param path The location where the files should be stored.
+ *
+ * @return A list of <code>FileItem</code> instances parsed from the
+ * request, in the order that they were transmitted.
+ *
+ * @exception FileUploadException if there are problems reading/parsing
+ * the request or storing files.
+ */
+ public List parseRequest(ActionRequest req, int sizeThreshold, long sizeMax, String path)
+ throws FileUploadException
+ {
+ setSizeThreshold(sizeThreshold);
+ setSizeMax(sizeMax);
+ setRepositoryPath(path);
+ return parseRequest(req);
+ }
+
+}
Propchange: incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/upload/PortletDiskFileUpload.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/upload/PortletFileUpload.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/upload/PortletFileUpload.java?view=diff&rev=448311&r1=448310&r2=448311
==============================================================================
--- incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/upload/PortletFileUpload.java (original)
+++ incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/upload/PortletFileUpload.java Wed Sep 20 12:37:05 2006
@@ -1,108 +1,108 @@
-/*
- * 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.portals.graffito.portlets.upload;
-
-import org.apache.commons.fileupload.FileItemFactory;
-
-
-/**
- * <p>High level API for processing file uploads.</p>
- *
- * <p>This class handles multiple files per single HTML widget, sent using
- * <code>multipart/mixed</code> encoding type, as specified by
- * <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>. Use {@link
- * #parseRequest(HttpServletRequest)} to acquire a list of {@link
- * org.apache.commons.fileupload.FileItem}s associated with a given HTML
- * widget.</p>
- *
- * <p>How the data for individual parts is stored is determined by the factory
- * used to create them; a given part may be in memory, on disk, or somewhere
- * else.</p>
- *
- * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
- * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
- * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
- * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
- * @author Sean C. Sullivan
- *
- * @version $Id: PortletFileUpload.java,v 1.1 2003/10/01 22:21:43 jsackett Exp $
- */
-public class PortletFileUpload
- extends PortletFileUploadBase
- {
-
- // ----------------------------------------------------------- Data members
-
-
- /**
- * The factory to use to create new form items.
- */
- private FileItemFactory fileItemFactory;
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Constructs an instance of this class which uses the default factory to
- * create <code>FileItem</code> instances.
- *
- * @see #FileUpload(FileItemFactory)
- */
- public PortletFileUpload()
- {
- super();
- }
-
-
- /**
- * Constructs an instance of this class which uses the supplied factory to
- * create <code>FileItem</code> instances.
- *
- * @see #FileUpload()
- */
- public PortletFileUpload(FileItemFactory fileItemFactory)
- {
- super();
- this.fileItemFactory = fileItemFactory;
- }
-
-
- // ----------------------------------------------------- Property accessors
-
-
- /**
- * Returns the factory class used when creating file items.
- *
- * @return The factory class for new file items.
- */
- public FileItemFactory getFileItemFactory()
- {
- return fileItemFactory;
- }
-
-
- /**
- * Sets the factory class to use when creating file items.
- *
- * @param factory The factory class for new file items.
- */
- public void setFileItemFactory(FileItemFactory factory)
- {
- this.fileItemFactory = factory;
- }
-
-
-}
+/*
+ * 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.portals.graffito.portlets.upload;
+
+import org.apache.commons.fileupload.FileItemFactory;
+
+
+/**
+ * <p>High level API for processing file uploads.</p>
+ *
+ * <p>This class handles multiple files per single HTML widget, sent using
+ * <code>multipart/mixed</code> encoding type, as specified by
+ * <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>. Use {@link
+ * #parseRequest(HttpServletRequest)} to acquire a list of {@link
+ * org.apache.commons.fileupload.FileItem}s associated with a given HTML
+ * widget.</p>
+ *
+ * <p>How the data for individual parts is stored is determined by the factory
+ * used to create them; a given part may be in memory, on disk, or somewhere
+ * else.</p>
+ *
+ * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
+ * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
+ * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
+ * @author Sean C. Sullivan
+ *
+ * @version $Id: PortletFileUpload.java,v 1.1 2003/10/01 22:21:43 jsackett Exp $
+ */
+public class PortletFileUpload
+ extends PortletFileUploadBase
+ {
+
+ // ----------------------------------------------------------- Data members
+
+
+ /**
+ * The factory to use to create new form items.
+ */
+ private FileItemFactory fileItemFactory;
+
+
+ // ----------------------------------------------------------- Constructors
+
+
+ /**
+ * Constructs an instance of this class which uses the default factory to
+ * create <code>FileItem</code> instances.
+ *
+ * @see #FileUpload(FileItemFactory)
+ */
+ public PortletFileUpload()
+ {
+ super();
+ }
+
+
+ /**
+ * Constructs an instance of this class which uses the supplied factory to
+ * create <code>FileItem</code> instances.
+ *
+ * @see #FileUpload()
+ */
+ public PortletFileUpload(FileItemFactory fileItemFactory)
+ {
+ super();
+ this.fileItemFactory = fileItemFactory;
+ }
+
+
+ // ----------------------------------------------------- Property accessors
+
+
+ /**
+ * Returns the factory class used when creating file items.
+ *
+ * @return The factory class for new file items.
+ */
+ public FileItemFactory getFileItemFactory()
+ {
+ return fileItemFactory;
+ }
+
+
+ /**
+ * Sets the factory class to use when creating file items.
+ *
+ * @param factory The factory class for new file items.
+ */
+ public void setFileItemFactory(FileItemFactory factory)
+ {
+ this.fileItemFactory = factory;
+ }
+
+
+}
Propchange: incubator/graffito/trunk/applications/framework-portlets/src/java/org/apache/portals/graffito/portlets/upload/PortletFileUpload.java
------------------------------------------------------------------------------
svn:eol-style = native