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 wo...@apache.org on 2007/09/18 07:35:30 UTC
svn commit: r576707 - in /portals/jetspeed-2/branches/JETSPEED-2.1.3:
applications/demo/src/java/org/apache/jetspeed/demo/simple/
applications/demo/src/webapp/WEB-INF/
applications/demo/src/webapp/WEB-INF/demo/simple/
components/portal/src/java/org/apa...
Author: woonsan
Date: Mon Sep 17 22:35:28 2007
New Revision: 576707
URL: http://svn.apache.org/viewvc?rev=576707&view=rev
Log:
[JS2-634] edit_defaults custom portlet mode
Implemented edit_defaults and about custom portlet modes.
Only admin users can use edit_defaults mode, and the default preferences are stored in PSML pages.
To enable this feature, the portlet decoration properties should have 'actions.factory=CustomDecoratorActionsAdapter'. See /decorations/portlet/tigris/decorator.properties.
Implemented edit_defaults and about custom portlet modes for the PickANumber portlet.
Added:
portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumberAbout.jsp
portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumberEditDefaults.jsp
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/images/about.gif (with props)
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/images/edit_defaults.gif (with props)
Modified:
portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/java/org/apache/jetspeed/demo/simple/PickANumberPortlet.java
portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/portlet.xml
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions.properties
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_en.properties
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ja.properties
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ko.properties
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_nl.properties
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ua.properties
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_zh.properties
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_zh_TW.properties
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/JetspeedActions.java
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/registry.xml
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/theme-engine.xml
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/conf/jetspeed.properties
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/decorator.properties
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/java/org/apache/jetspeed/demo/simple/PickANumberPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/java/org/apache/jetspeed/demo/simple/PickANumberPortlet.java?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/java/org/apache/jetspeed/demo/simple/PickANumberPortlet.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/java/org/apache/jetspeed/demo/simple/PickANumberPortlet.java Mon Sep 17 22:35:28 2007
@@ -41,6 +41,8 @@
*/
public class PickANumberPortlet extends GenericServletPortlet
{
+ private static final PortletMode ABOUT_MODE = new PortletMode("about");
+ private static final PortletMode EDIT_DEFAULTS_MODE = new PortletMode("edit_defaults");
private static final PortletMode PRINT_MODE = new PortletMode("print");
/**
@@ -80,6 +82,16 @@
private static final String DEFAULT_VIEW_PAGE = "/WEB-INF/demo/simple/PickANumber.jsp";
/**
+ * Default about page when preference does not exist
+ */
+ private static final String DEFAULT_ABOUT_PAGE = "/WEB-INF/demo/simple/PickANumberAbout.jsp";
+
+ /**
+ * Default edit_defaults page when preference does not exist
+ */
+ private static final String DEFAULT_EDIT_DEFAULTS_PAGE = "/WEB-INF/demo/simple/PickANumberEditDefaults.jsp";
+
+ /**
* Attribute name of Guess Count
*/
private static final String GUESS_COUNT_NAME = "GuessCount";
@@ -121,12 +133,24 @@
{
if ( !request.getWindowState().equals(WindowState.MINIMIZED))
{
+ PortletMode curMode = request.getPortletMode();
+
// Handle custom PRINT_MODE ourselves as GenericPortlet nor GenericServletPortlet do
- if (PRINT_MODE.equals(request.getPortletMode()))
+ if (PRINT_MODE.equals(curMode))
{
// simply delegate to doView rendering
doView(request, response);
}
+ else if (ABOUT_MODE.equals(curMode))
+ {
+ request.setAttribute(PARAM_VIEW_PAGE, DEFAULT_ABOUT_PAGE);
+ doView(request, response);
+ }
+ else if (EDIT_DEFAULTS_MODE.equals(curMode))
+ {
+ request.setAttribute(PARAM_EDIT_PAGE, DEFAULT_EDIT_DEFAULTS_PAGE);
+ doEdit(request, response);
+ }
else
{
super.doDispatch(request, response);
@@ -288,6 +312,7 @@
return;
}
PortletPreferences prefs = request.getPreferences();
+
try
{
prefs.setValue(TOP_RANGE_NAME, topRange);
Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumberAbout.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumberAbout.jsp?rev=576707&view=auto
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumberAbout.jsp (added)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumberAbout.jsp Mon Sep 17 22:35:28 2007
@@ -0,0 +1,24 @@
+<%--
+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.
+--%>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
+<%@ taglib uri='/WEB-INF/portlet.tld' prefix='portlet'%>
+
+<h1>About PickANumber</h1>
+<hr/>
+
+<portlet:renderURL var="viewMe" portletMode='View'/>
+<a href='<%=viewMe%>'>View</a>
Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumberEditDefaults.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumberEditDefaults.jsp?rev=576707&view=auto
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumberEditDefaults.jsp (added)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumberEditDefaults.jsp Mon Sep 17 22:35:28 2007
@@ -0,0 +1,42 @@
+<%--
+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.
+--%>
+<%@ page language="java" session="true" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
+<%@ taglib uri='/WEB-INF/portlet.tld' prefix='portlet'%>
+<%@ page import="javax.portlet.PortletSession"%>
+<portlet:defineObjects/>
+<fmt:setBundle basename="org.apache.jetspeed.demo.simple.resources.PickANumberResources" />
+
+<portlet:actionURL var="editDefaultsAction">
+</portlet:actionURL>
+
+<%
+ String topRange = renderRequest.getPreferences().getValue("TopRange", "101");
+%>
+
+<div>
+ <br/>
+ <form action="<%=editDefaultsAction%>" method="POST">
+ <fmt:message key="pickanumber.edit.label.highendofguessrange"/>
+ <input type="text" name="TopRange" value="<%=topRange%>">
+ <input type="submit" value='<fmt:message key="pickanumber.edit.label.save"/>'>
+ </form>
+</div>
+
+<portlet:renderURL var="normalMe" portletMode='View'/>
+<a href='<%=normalMe%>'>View</a>
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/portlet.xml?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/portlet.xml Mon Sep 17 22:35:28 2007
@@ -266,6 +266,10 @@
<portlet-mode>VIEW</portlet-mode>
<portlet-mode>HELP</portlet-mode>
<portlet-mode>EDIT</portlet-mode>
+ <!-- support custom about mode -->
+ <portlet-mode>about</portlet-mode>
+ <!-- support custom edit_defaults mode -->
+ <portlet-mode>edit_defaults</portlet-mode>
<!-- support custom print mode -->
<portlet-mode>print</portlet-mode>
</supports>
@@ -1308,6 +1312,14 @@
</portlet>
+ <custom-portlet-mode>
+ <description>a Custom About Mode</description>
+ <portlet-mode>about</portlet-mode>
+ </custom-portlet-mode>
+ <custom-portlet-mode>
+ <description>a Custom Edit_defaults Mode</description>
+ <portlet-mode>edit_defaults</portlet-mode>
+ </custom-portlet-mode>
<custom-portlet-mode>
<description>a Custom Print Mode</description>
<portlet-mode>print</portlet-mode>
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java Mon Sep 17 22:35:28 2007
@@ -14,29 +14,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jetspeed.decoration;
-
-import java.util.ArrayList;
+package org.apache.jetspeed.decoration;
+
+import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
+import java.util.Iterator;
+import java.util.List;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-
-import javax.portlet.PortletMode;
-import javax.portlet.WindowState;
-import org.apache.jetspeed.JetspeedActions;
-import org.apache.jetspeed.container.url.PortalURL;
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.container.url.PortalURL;
import org.apache.jetspeed.om.common.portlet.PortletApplication;
import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
-import org.apache.jetspeed.om.page.ContentFragment;
+import org.apache.jetspeed.om.page.ContentFragment;
import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.security.SecurityAccessController;
-import org.apache.pluto.om.window.PortletWindow;
-
-public abstract class AbstractDecoratorActionsFactory implements DecoratorActionsFactory
+import org.apache.jetspeed.security.SecurityAccessController;
+import org.apache.pluto.om.window.PortletWindow;
+
+public abstract class AbstractDecoratorActionsFactory implements DecoratorActionsFactory
{
private static ThreadLocal actionResourcesMap = new ThreadLocal();
private boolean editMaximizesOption = false;
@@ -53,14 +53,14 @@
public List getDecoratorActions(RequestContext rc, PortletApplication pa, PortletWindow pw, PortletMode pm,
WindowState ws, Decoration decoration, List actionTemplates,PortletDefinitionComposite portlet,
ContentFragment fragment,SecurityAccessController accessController)
- {
+ {
DecoratorAction action;
boolean checkConstraints=false;
- ArrayList actions = new ArrayList();
-
- Iterator iter = actionTemplates.iterator();
- while (iter.hasNext())
- {
+ ArrayList actions = new ArrayList();
+
+ Iterator iter = actionTemplates.iterator();
+ while (iter.hasNext())
+ {
checkConstraints = false;
DecoratorActionTemplate template = (DecoratorActionTemplate)iter.next();
//checking the constraints only on EDIT and HELP Action, as VIEW will taken care with portlet view.
@@ -81,10 +81,10 @@
{
actions.add(action);
}
- }
- }
- return actions;
- }
+ }
+ }
+ return actions;
+ }
public List getDecoratorActions(RequestContext rc, PortletApplication pa, PortletWindow pw, PortletMode pm,
WindowState ws, Decoration decoration, List actionTemplates)
@@ -101,7 +101,7 @@
}
}
return actions;
- }
+ }
protected DecoratorAction createAction(RequestContext rc, PortletWindow pw, Decoration decoration,
DecoratorActionTemplate template)
@@ -157,14 +157,13 @@
template.getCustomState()));
HashMap resourcesMap = (HashMap)actionResourcesMap.get();
- ResourceBundle bundle = null;
+ ResourceBundle bundle = DecoratorAction.getResourceBundle(rc.getLocale());
String localizedName = null;
if (resourcesMap == null)
{
resourcesMap = new HashMap();
actionResourcesMap.set(resourcesMap);
- bundle = DecoratorAction.getResourceBundle(rc.getLocale());
resourcesMap.put(DecoratorAction.RESOURCE_BUNDLE, bundle);
localizedName = DecoratorAction.getResourceString(bundle, actionName, actionName);
resourcesMap.put(actionName,localizedName);
@@ -207,5 +206,5 @@
{
return this.editMaximizesOption;
}
-
-}
+
+}
Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java?rev=576707&view=auto
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java (added)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java Mon Sep 17 22:35:28 2007
@@ -0,0 +1,133 @@
+/*
+* 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.decoration;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.om.common.portlet.PortletApplication;
+import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
+import org.apache.jetspeed.om.page.ContentFragment;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.SecurityAccessController;
+import org.apache.pluto.om.window.PortletWindow;
+import org.apache.jetspeed.administration.PortalConfiguration;
+import org.apache.jetspeed.administration.PortalConfigurationConstants;
+
+public class CustomDecoratorActionsFactory extends AbstractDecoratorActionsFactory
+{
+ private static final DecoratorActionTemplate ABOUT_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.ABOUT_MODE);
+ private static final DecoratorActionTemplate EDIT_DEFAULTS_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.EDIT_DEFAULTS_MODE);
+ //private static final DecoratorActionTemplate PREVIEW_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.PREVIEW_MODE);
+ private static final DecoratorActionTemplate PRINT_MODE_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.PRINT_MODE);
+ private static final DecoratorActionTemplate SOLO_ACTION_TEMPLATE = new DecoratorActionTemplate(JetspeedActions.SOLO_STATE);
+
+ private final List supportedActions;
+ private final List supportedSoloActions;
+
+ private PortalConfiguration configuration;
+
+ public CustomDecoratorActionsFactory()
+ {
+ this(null);
+ }
+
+ public CustomDecoratorActionsFactory(PortalConfiguration configuration)
+ {
+ this.configuration = configuration;
+
+ ArrayList list = new ArrayList(JetspeedActions.getStandardPortletModes());
+ list.add(JetspeedActions.ABOUT_MODE);
+ list.add(JetspeedActions.EDIT_DEFAULTS_MODE);
+ //list.add(JetspeedActions.PREVIEW_MODE);
+ list.add(JetspeedActions.PRINT_MODE);
+ list.addAll(JetspeedActions.getStandardWindowStates());
+ list.add(JetspeedActions.SOLO_STATE);
+ supportedActions = Collections.unmodifiableList(list);
+
+ list = new ArrayList(JetspeedActions.getStandardPortletModes());
+ list.add(JetspeedActions.PRINT_MODE);
+ supportedSoloActions = Collections.unmodifiableList(list);
+ }
+
+ public List getSupportedActions(RequestContext rc, PortletApplication pa, PortletWindow pw, PortletMode cm,
+ WindowState ws, Decoration decoration)
+ {
+ // don't support any window state actions when in "solo" state
+ return JetspeedActions.SOLO_STATE.equals(ws) ? supportedSoloActions : supportedActions;
+ }
+
+ public List getDecoratorActions(RequestContext rc, PortletApplication pa, PortletWindow pw, PortletMode pm,
+ WindowState ws, Decoration decoration, List actionTemplates,
+ PortletDefinitionComposite portlet, ContentFragment fragment, SecurityAccessController accessController)
+ {
+ int printModeIndex = actionTemplates.indexOf(PRINT_MODE_TEMPLATE);
+ int soloStateIndex = actionTemplates.indexOf(SOLO_ACTION_TEMPLATE);
+
+ if ( printModeIndex != -1 && soloStateIndex != -1 )
+ {
+ // merge "solo" state with "print" mode
+ DecoratorActionTemplate soloStateTemplate = (DecoratorActionTemplate)actionTemplates.remove(soloStateIndex);
+ DecoratorActionTemplate printActionTemplate = (DecoratorActionTemplate)actionTemplates.get(printModeIndex);
+ printActionTemplate.setState(soloStateTemplate.getState());
+ printActionTemplate.setCustomState((soloStateTemplate.getCustomState()));
+ }
+ else if ( soloStateIndex != -1 )
+ {
+ // don't provide "solo" action separately without "print" mode
+ actionTemplates.remove(soloStateIndex);
+ }
+ // else if (printModeIndex != -1)
+ // support switching to different modes once in "solo" state, even back to "print"
+
+ String adminRoleName = "admin";
+
+ if (this.configuration != null)
+ {
+ adminRoleName = this.configuration.getString(PortalConfigurationConstants.ROLES_DEFAULT_ADMIN, adminRoleName);
+ }
+
+ // Remove editDefaultsMode if the user does not have admin role.
+ int editDefaultsModeIndex = actionTemplates.indexOf(EDIT_DEFAULTS_MODE_TEMPLATE);
+ if (editDefaultsModeIndex != -1)
+ {
+ if (!rc.getRequest().isUserInRole(adminRoleName))
+ {
+ actionTemplates.remove(editDefaultsModeIndex);
+ }
+ }
+
+ return super.getDecoratorActions(rc,pa,pw,pm,ws,decoration,actionTemplates, portlet, fragment, accessController);
+ }
+
+ protected DecoratorAction createAction(RequestContext rc, PortletWindow pw, Decoration decoration,
+ DecoratorActionTemplate template)
+ {
+ DecoratorAction action = super.createAction(rc,pw,decoration,template);
+ if ( template.getState() != null && JetspeedActions.SOLO_STATE.equals(template.getState()))
+ {
+ // "solo" opens in a new popup winodw
+ action.setTarget("_blank");
+ }
+ return action;
+ }
+}
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java Mon Sep 17 22:35:28 2007
@@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -79,19 +80,19 @@
private final PortletWindowAccessor windowAccessor;
- private HashMap decoratorActionsAdapterCache = new HashMap();
+ private Map decoratorActionsAdapterMap;
- private DecoratorActionsFactory defaultDecoratorActionsFactory;
+ private DecoratorActionsFactory defaultDecoratorActionsAdapter;
private JetspeedContentCache cache = null;
private boolean useSessionForThemeCaching = false;
private boolean maxOnEdit = false;
-
- /**
- * For security constraint checks
- */
+
+ /*
+ * For security constraint checks
+ */
protected SecurityAccessController accessController;
public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor,SecurityAccessController accessController)
@@ -105,17 +106,40 @@
this(decorationFactory, windowAccessor, accessController, cache, false);
}
- public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor,
- SecurityAccessController accessController, JetspeedContentCache cache,
- boolean useSessionForThemeCaching)
- {
+ public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor,
+ SecurityAccessController accessController, JetspeedContentCache cache,
+ boolean useSessionForThemeCaching)
+ {
+ this(decorationFactory, windowAccessor, accessController, cache, false, null);
+ }
+
+ public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor,
+ SecurityAccessController accessController, JetspeedContentCache cache,
+ boolean useSessionForThemeCaching, Map decoratorActionsAdapterMap)
+ {
+ this(decorationFactory, windowAccessor, accessController, cache, false, decoratorActionsAdapterMap, new DefaultDecoratorActionsFactory());
+ }
+
+ public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor,
+ SecurityAccessController accessController, JetspeedContentCache cache,
+ boolean useSessionForThemeCaching, Map decoratorActionsAdapterMap,
+ DecoratorActionsFactory defaultDecoratorActionsAdapter)
+ {
this.decorationFactory = decorationFactory;
this.windowAccessor = windowAccessor;
- this.defaultDecoratorActionsFactory = new DefaultDecoratorActionsFactory();
+
//added the accessController in portlet decorater for checking the actions
this.accessController = accessController;
this.cache = cache;
this.useSessionForThemeCaching = useSessionForThemeCaching;
+ this.decoratorActionsAdapterMap = decoratorActionsAdapterMap;
+
+ if (this.decoratorActionsAdapterMap == null)
+ {
+ this.decoratorActionsAdapterMap = new HashMap();
+ }
+
+ this.defaultDecoratorActionsAdapter = defaultDecoratorActionsAdapter;
}
public void invoke(RequestContext requestContext, ValveContext context) throws PipelineException
@@ -276,35 +300,36 @@
public DecoratorActionsFactory getDecoratorActionsAdapter(Decoration decoration)
{
+ DecoratorActionsFactory adapter = this.defaultDecoratorActionsAdapter;
+
// FIXME: why always get this property
- String decoratorActionsAdapterClassName = decoration.getProperty("actions.factory");
- if ( decoratorActionsAdapterClassName == null )
- {
- decoratorActionsAdapterClassName = defaultDecoratorActionsFactory.getClass().getName();
- }
- synchronized (decoratorActionsAdapterCache)
+ String decoratorActionsAdapterName = decoration.getProperty("actions.factory");
+
+ if ( decoratorActionsAdapterName != null )
{
- DecoratorActionsFactory adapter = (DecoratorActionsFactory)decoratorActionsAdapterCache.get(decoratorActionsAdapterClassName);
- if ( adapter == null )
+ adapter = (DecoratorActionsFactory) this.decoratorActionsAdapterMap.get(decoratorActionsAdapterName);
+
+ if (adapter == null)
{
try
{
- adapter = (DecoratorActionsFactory)Class.forName(decoratorActionsAdapterClassName).newInstance();
+ adapter = (DecoratorActionsFactory) Class.forName(decoratorActionsAdapterName).newInstance();
adapter.setMaximizeOnEdit(this.maxOnEdit);
}
catch (Exception e)
{
- log.error("Failed to instantiate custom DecoratorActionsAdaptor "+decoratorActionsAdapterClassName+", falling back to default.",e);
- adapter = (DecoratorActionsFactory)decoratorActionsAdapterCache.get(defaultDecoratorActionsFactory.getClass().getName());
- if ( adapter == null )
- {
- adapter = defaultDecoratorActionsFactory;
- }
+ log.error("Failed to instantiate custom DecoratorActionsAdaptor "+decoratorActionsAdapterName+", falling back to default.",e);
+ adapter = this.defaultDecoratorActionsAdapter;
+ }
+
+ synchronized (this.decoratorActionsAdapterMap)
+ {
+ this.decoratorActionsAdapterMap.put(decoratorActionsAdapterName,adapter);
}
- decoratorActionsAdapterCache.put(decoratorActionsAdapterClassName,adapter);
}
- return adapter;
}
+
+ return adapter;
}
/**
@@ -626,7 +651,7 @@
public void setMaximizeOnEdit(boolean maxOnEdit)
{
this.maxOnEdit = maxOnEdit;
- this.defaultDecoratorActionsFactory.setMaximizeOnEdit(maxOnEdit);
+ this.defaultDecoratorActionsAdapter.setMaximizeOnEdit(maxOnEdit);
}
public boolean getMaximizeOnEdit()
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions.properties?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions.properties (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions.properties Mon Sep 17 22:35:28 2007
@@ -22,5 +22,8 @@
maximized=Maximize
## extended actions
+about=About
+edit_defaults=Edit defaults
+preview=Preview
print=Print
solo=Solo
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_en.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_en.properties?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_en.properties (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_en.properties Mon Sep 17 22:35:28 2007
@@ -22,5 +22,8 @@
maximized=Maximize
## extended actions
+about=About
+edit_defaults=Edit defaults
+preview=Preview
print=Print
solo=Solo
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ja.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ja.properties?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ja.properties (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ja.properties Mon Sep 17 22:35:28 2007
@@ -22,5 +22,8 @@
maximized=\u6700\u5927\u5316
## extended actions
+about=About
+edit_defaults=Edit defaults
+preview=Preview
print=\u5370\u5237
solo=\u5358\u72ec\u8868\u793a
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ko.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ko.properties?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ko.properties (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ko.properties Mon Sep 17 22:35:28 2007
@@ -22,5 +22,8 @@
maximized=\ucd5c\ub300\ud654
## extended actions
+about=\uc815\ubcf4
+edit_defaults=\uae30\ubcf8\uac12 \ud3b8\uc9d1
+preview=\ubbf8\ub9ac\ubcf4\uae30
print=\uc778\uc1c4
solo=\ud31d\uc5c5
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_nl.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_nl.properties?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_nl.properties (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_nl.properties Mon Sep 17 22:35:28 2007
@@ -22,5 +22,8 @@
maximized=Maximaliseren
## extended actions
+about=About
+edit_defaults=Edit defaults
+preview=Preview
print=Printen
solo=Popup
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ua.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ua.properties?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ua.properties (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_ua.properties Mon Sep 17 22:35:28 2007
@@ -3,24 +3,27 @@
# 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.
-
-## standard actions
-view=\u041f\u0435\u0440\u0435\u0433\u043b\u044f\u043d\u0443\u0442\u0438
-edit=\u0420\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u0442\u0438
-help=\u0414\u043e\u043f\u043e\u043c\u043e\u0433\u0430
-normal=\u0412\u0456\u0434\u043d\u043e\u0432\u0438\u0442\u0438
-minimized=\u0417\u0433\u043e\u0440\u043d\u0443\u0442\u0438
-maximized=\u0417\u0431\u0456\u043b\u044c\u0448\u0438\u0442\u0438
-
-## extended actions
-print=\u0414\u0440\u0443\u043a
-solo=\u0421\u043e\u043b\u043e
+# 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.
+
+## standard actions
+view=\u041f\u0435\u0440\u0435\u0433\u043b\u044f\u043d\u0443\u0442\u0438
+edit=\u0420\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u0442\u0438
+help=\u0414\u043e\u043f\u043e\u043c\u043e\u0433\u0430
+normal=\u0412\u0456\u0434\u043d\u043e\u0432\u0438\u0442\u0438
+minimized=\u0417\u0433\u043e\u0440\u043d\u0443\u0442\u0438
+maximized=\u0417\u0431\u0456\u043b\u044c\u0448\u0438\u0442\u0438
+
+## extended actions
+about=About
+edit_defaults=Edit defaults
+preview=Preview
+print=\u0414\u0440\u0443\u043a
+solo=\u0421\u043e\u043b\u043e
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_zh.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_zh.properties?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_zh.properties (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_zh.properties Mon Sep 17 22:35:28 2007
@@ -24,5 +24,8 @@
maximized=\u6700\u5927\u5316
## extended actions
+about=About
+edit_defaults=Edit defaults
+preview=Preview
print=\u6253\u5370
solo=Solo
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_zh_TW.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_zh_TW.properties?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_zh_TW.properties (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/resources/DecoratorActions_zh_TW.properties Mon Sep 17 22:35:28 2007
@@ -24,5 +24,8 @@
maximized=\u6700\u5927\u5316
## extended actions
+about=About
+edit_defaults=Edit defaults
+preview=Preview
print=\u5217\u5370
solo=Solo
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java Mon Sep 17 22:35:28 2007
@@ -30,6 +30,7 @@
import org.apache.jetspeed.om.page.ContentFragment;
import org.apache.jetspeed.om.page.Fragment;
import org.apache.jetspeed.om.preference.impl.PrefsPreferenceSetImpl;
+import org.apache.jetspeed.page.PageManager;
import org.apache.jetspeed.request.RequestContextComponent;
import org.apache.jetspeed.util.JetspeedObjectID;
import org.apache.ojb.broker.query.Criteria;
@@ -88,12 +89,22 @@
PortletEntityImpl.rcc = rcc;
}
- public PersistenceBrokerPortletEntityAccess(PortletRegistry registry, RequestContextComponent rcc, boolean mergeSharedPreferences)
+ public PersistenceBrokerPortletEntityAccess(PortletRegistry registry, RequestContextComponent rcc, PageManager pageManager)
{
super();
this.registry = registry;
PortletEntityImpl.registry = registry;
PortletEntityImpl.rcc = rcc;
+ PortletEntityImpl.pm = pageManager;
+ }
+
+ public PersistenceBrokerPortletEntityAccess(PortletRegistry registry, RequestContextComponent rcc, PageManager pageManager, boolean mergeSharedPreferences)
+ {
+ super();
+ this.registry = registry;
+ PortletEntityImpl.registry = registry;
+ PortletEntityImpl.rcc = rcc;
+ PortletEntityImpl.pm = pageManager;
this.mergeSharedPreferences = mergeSharedPreferences;
}
@@ -101,6 +112,12 @@
{
PortletEntityImpl.pac = proxy;
}
+
+ public void setPageManager(PageManager pageManager)
+ {
+ PortletEntityImpl.pm = pageManager;
+ }
+
/**
*
* <p>
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java Mon Sep 17 22:35:28 2007
@@ -22,12 +22,16 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.ArrayList;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
+import javax.portlet.PortletMode;
+
+import org.apache.jetspeed.JetspeedActions;
import org.apache.jetspeed.aggregator.RenderTrackable;
import org.apache.jetspeed.components.persistence.store.PersistenceStore;
import org.apache.jetspeed.components.persistence.store.PersistenceStoreRuntimeExcpetion;
@@ -39,17 +43,21 @@
import org.apache.jetspeed.om.common.portlet.PrincipalAware;
import org.apache.jetspeed.om.page.Fragment;
import org.apache.jetspeed.om.portlet.impl.FragmentPortletDefinition;
+import org.apache.jetspeed.om.preference.FragmentPreference;
import org.apache.jetspeed.om.preference.impl.PrefsPreference;
import org.apache.jetspeed.om.preference.impl.PrefsPreferenceSetImpl;
import org.apache.jetspeed.om.window.impl.PortletWindowListImpl;
+import org.apache.jetspeed.page.PageManager;
import org.apache.jetspeed.request.RequestContext;
import org.apache.jetspeed.request.RequestContextComponent;
import org.apache.jetspeed.util.JetspeedObjectID;
import org.apache.pluto.om.common.Description;
import org.apache.pluto.om.common.ObjectID;
+import org.apache.pluto.om.common.Preference;
import org.apache.pluto.om.common.PreferenceSet;
import org.apache.pluto.om.entity.PortletApplicationEntity;
import org.apache.pluto.om.portlet.PortletDefinition;
+import org.apache.pluto.om.window.PortletWindow;
import org.apache.pluto.om.window.PortletWindowList;
import org.apache.pluto.util.StringUtils;
@@ -67,7 +75,9 @@
protected static PortletEntityAccessComponent pac;
protected static PortletRegistry registry;
protected static RequestContextComponent rcc;
+ protected static PageManager pm;
+ protected PrefsPreferenceSetImpl pagePreferenceSet;
protected Map perPrincipalPrefs = new HashMap();
protected Map originalValues;
private PortletApplicationEntity applicationEntity = null;
@@ -121,8 +131,15 @@
*/
public PreferenceSet getPreferenceSet()
{
- Principal currentUser = getPrincipal();
- return getPreferenceSet(currentUser);
+ if (isEditDefaultsMode())
+ {
+ return getPreferenceSetFromPage();
+ }
+ else
+ {
+ Principal currentUser = getPrincipal();
+ return getPreferenceSet(currentUser);
+ }
}
public PreferenceSet getPreferenceSet(Principal principal)
@@ -155,6 +172,47 @@
return preferenceSet;
}
+ private PreferenceSet getPreferenceSetFromPage()
+ {
+ PrefsPreferenceSetImpl preferenceSet = this.pagePreferenceSet;
+
+ try
+ {
+ if (preferenceSet == null || !dirty)
+ {
+ String prefNodePath = MutablePortletEntity.PORTLET_ENTITY_ROOT + "/" +
+ getId() +"/"+ PrefsPreference.PORTLET_PREFERENCES_ROOT;
+
+ Preferences prefNode = Preferences.systemRoot().node(prefNodePath);
+ preferenceSet = new PrefsPreferenceSetImpl(prefNode);
+ this.pagePreferenceSet = preferenceSet;
+
+ List fragmentPreferences = this.fragment.getPreferences();
+
+ if (fragmentPreferences != null)
+ {
+ for (Iterator it = fragmentPreferences.iterator(); it.hasNext(); )
+ {
+ FragmentPreference preference = (FragmentPreference) it.next();
+ List preferenceValues = preference.getValueList();
+ preferenceSet.add(preference.getName(), preferenceValues);
+ }
+ }
+
+ backupValues(preferenceSet);
+ dirty = true;
+ }
+ }
+ catch (BackingStoreException e)
+ {
+ String msg = "Preference backing store failed: " + e.toString();
+ IllegalStateException ise = new IllegalStateException(msg);
+ ise.initCause(e);
+ throw ise;
+ }
+ return preferenceSet;
+ }
+
private void mergePreferencesSet(PrefsPreferenceSetImpl userPrefSet)
throws BackingStoreException
{
@@ -254,7 +312,15 @@
*/
public void store() throws IOException
{
- store(getPrincipal());
+ if (isEditDefaultsMode())
+ {
+ storeToPage();
+ }
+ else
+ {
+ Principal currentUser = getPrincipal();
+ store(currentUser);
+ }
}
public void store(Principal principal) throws IOException
@@ -273,6 +339,51 @@
backupValues(preferenceSet);
}
}
+
+ private void storeToPage() throws IOException
+ {
+ if (pm == null)
+ {
+ throw new IllegalStateException("You must set pageManager before "
+ + "invoking PortletEntityImpl.store().");
+ }
+
+ PreferenceSet preferenceSet = this.pagePreferenceSet;
+ List preferences = new ArrayList();
+
+ for (Iterator it = preferenceSet.iterator(); it.hasNext(); )
+ {
+ Preference pref = (Preference) it.next();
+
+ FragmentPreference preference = pm.newFragmentPreference();
+ preference.setName(pref.getName());
+ List preferenceValues = new ArrayList();
+
+ for (Iterator iterVals = pref.getValues(); iterVals.hasNext(); )
+ {
+ preferenceValues.add(iterVals.next());
+ }
+
+ preference.setValueList(preferenceValues);
+ preferences.add(preference);
+ }
+
+ this.fragment.setPreferences(preferences);
+
+ try
+ {
+ pm.updatePage(rcc.getRequestContext().getPage());
+ }
+ catch (Exception e)
+ {
+ }
+
+ dirty = false;
+ if (preferenceSet != null)
+ {
+ backupValues(preferenceSet);
+ }
+ }
/**
*
@@ -587,4 +698,37 @@
this.timeoutCount = timeoutCount;
}
+ private boolean isEditDefaultsMode()
+ {
+ boolean editDefaultsMode = false;
+
+ PortletWindow curWindow = null;
+
+ if (this.portletWindows != null)
+ {
+ try
+ {
+ curWindow = (PortletWindow) this.portletWindows.iterator().next();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ if (rcc != null)
+ {
+ RequestContext context = rcc.getRequestContext();
+
+ try
+ {
+ PortletMode curMode = context.getPortalURL().getNavigationalState().getMode(curWindow);
+ editDefaultsMode = (JetspeedActions.EDIT_DEFAULTS_MODE.equals(curMode));
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ return editDefaultsMode;
+ }
}
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/JetspeedActions.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/JetspeedActions.java?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/JetspeedActions.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/JetspeedActions.java Mon Sep 17 22:35:28 2007
@@ -36,8 +36,11 @@
*/
public class JetspeedActions
{
- public static final PortletMode PRINT_MODE = new PortletMode("print");
- public static final WindowState SOLO_STATE = new WindowState("solo");
+ public static final PortletMode ABOUT_MODE = new PortletMode("about");
+ public static final PortletMode EDIT_DEFAULTS_MODE = new PortletMode("edit_defaults");
+ //public static final PortletMode PREVIEW_MODE = new PortletMode("preview");
+ public static final PortletMode PRINT_MODE = new PortletMode("print");
+ public static final WindowState SOLO_STATE = new WindowState("solo");
public static final int MASK_MINIMIZE = 0x01;
public static final int MASK_MAXIMIZE = 0x02;
@@ -46,14 +49,17 @@
public static final int MASK_EDIT = 0x10;
public static final int MASK_HELP = 0x20;
- static public final String VIEW = PortletMode.VIEW.toString();
- static public final String EDIT = PortletMode.EDIT.toString();
- static public final String HELP = PortletMode.HELP.toString();
- static public final String PRINT = PRINT_MODE.toString();
- static public final String NORMAL = WindowState.NORMAL.toString();
- static public final String MINIMIZE = WindowState.MINIMIZED.toString();
- static public final String MAXIMIZE = WindowState.MAXIMIZED.toString();
- static public final String SOLO = SOLO_STATE.toString();
+ public static final String VIEW = PortletMode.VIEW.toString();
+ public static final String EDIT = PortletMode.EDIT.toString();
+ public static final String HELP = PortletMode.HELP.toString();
+ public static final String ABOUT = ABOUT_MODE.toString();
+ public static final String EDIT_DEFAULTS = EDIT_DEFAULTS_MODE.toString();
+ //public static final String PREVIEW = PREVIEW_MODE.toString();
+ public static final String PRINT = PRINT_MODE.toString();
+ public static final String NORMAL = WindowState.NORMAL.toString();
+ public static final String MINIMIZE = WindowState.MINIMIZED.toString();
+ public static final String MAXIMIZE = WindowState.MAXIMIZED.toString();
+ public static final String SOLO = SOLO_STATE.toString();
private static final List standardPortletModes;
private static final List standardWindowStates;
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml Mon Sep 17 22:35:28 2007
@@ -316,12 +316,23 @@
<constructor-arg index='2'>
<ref bean="org.apache.jetspeed.security.SecurityAccessController" />
</constructor-arg>
- <!--
- <constructor-arg index='3'>
+ <constructor-arg index='3'>
+ <null/>
+ <!--
<ref bean="decorationContentCache"/>
- </constructor-arg>
- -->
- <!-- When clicking on Edit Mode, also switch to Maximize -->
+ -->
+ </constructor-arg>
+ <constructor-arg index='4'>
+ <value>false</value>
+ </constructor-arg>
+ <constructor-arg index='5'>
+ <map>
+ <entry key='CustomDecoratorActionsAdapter'>
+ <ref bean="CustomDecoratorActionsAdapter" />
+ </entry>
+ </map>
+ </constructor-arg>
+ <!-- When clicking on Edit Mode, also switch to Maximize -->
<property name="maximizeOnEdit"><value>false</value></property>
</bean>
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/registry.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/registry.xml?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/registry.xml (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/registry.xml Mon Sep 17 22:35:28 2007
@@ -84,6 +84,9 @@
but instead merge with them, where user prefs override.
boolean
-->
+ <constructor-arg>
+ <ref bean="org.apache.jetspeed.page.PageManager" />
+ </constructor-arg>
<constructor-arg type="boolean">
<value>false</value>
</constructor-arg>
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/theme-engine.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/theme-engine.xml?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/theme-engine.xml (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/theme-engine.xml Mon Sep 17 22:35:28 2007
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!--
-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
+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
@@ -32,5 +32,12 @@
<ref bean="ResourceValidator" />
</constructor-arg>
</bean>
-
+
+ <bean id="CustomDecoratorActionsAdapter"
+ class="org.apache.jetspeed.decoration.CustomDecoratorActionsFactory">
+ <constructor-arg index="0">
+ <ref bean="PortalConfiguration"/>
+ </constructor-arg>
+ </bean>
+
</beans>
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/conf/jetspeed.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/conf/jetspeed.properties?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/conf/jetspeed.properties (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/conf/jetspeed.properties Mon Sep 17 22:35:28 2007
@@ -74,6 +74,8 @@
supported.portletmode = edit
supported.portletmode = help
# extended
+supported.portletmode = about
+supported.portletmode = edit_defaults
supported.portletmode = print
supported.portletmode = secure # currently only used for testing purposes
Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/decorator.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/decorator.properties?rev=576707&r1=576706&r2=576707&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/decorator.properties (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/decorator.properties Mon Sep 17 22:35:28 2007
@@ -27,4 +27,5 @@
#: END uncomment for JSP
decorates=portlet
-actions.factory=org.apache.jetspeed.decoration.PrintSoloDecoratorActionsFactory
+#actions.factory=org.apache.jetspeed.decoration.PrintSoloDecoratorActionsFactory
+actions.factory=CustomDecoratorActionsAdapter
Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/images/about.gif
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/images/about.gif?rev=576707&view=auto
==============================================================================
Binary file - no diff available.
Propchange: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/images/about.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/images/edit_defaults.gif
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/images/edit_defaults.gif?rev=576707&view=auto
==============================================================================
Binary file - no diff available.
Propchange: portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/images/edit_defaults.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org