You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by ms...@apache.org on 2015/02/25 09:58:39 UTC
[2/9] portals-pluto git commit: Completed implementation of the V3
URL APIs. Introduce inheritance heirarchy for the URL - BaseURLImpl,
PortletURLImpl, RenderURLImpl, ActionURLImpl, and ResourceURLImpl.
Completed implementation of the V3 URL APIs. Introduce inheritance
heirarchy for the URL - BaseURLImpl, PortletURLImpl, RenderURLImpl,
ActionURLImpl, and ResourceURLImpl.
Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/260318f9
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/260318f9
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/260318f9
Branch: refs/heads/V3Prototype
Commit: 260318f9d2815efe667d391fef51de09342e8016
Parents: 7b13130
Author: Scott Nicklous <ms...@apache.org>
Authored: Sun Feb 22 19:01:09 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Sun Feb 22 19:01:09 2015 +0100
----------------------------------------------------------------------
.../PortletResourceResponseContext.java | 61 +--
.../pluto/container/PortletURLProvider.java | 39 +-
.../pluto/container/impl/ActionURLImpl.java | 50 ++
.../pluto/container/impl/BaseURLImpl.java | 321 +++++++++++++
.../pluto/container/impl/EventResponseImpl.java | 97 ++--
.../pluto/container/impl/MimeResponseImpl.java | 416 ++++++++---------
.../pluto/container/impl/PortletURLImpl.java | 467 +++++--------------
.../pluto/container/impl/RenderURLImpl.java | 54 +++
.../container/impl/ResourceResponseImpl.java | 323 +++++++------
.../pluto/container/impl/ResourceURLImpl.java | 108 +++++
.../PortletResourceResponseContextImpl.java | 153 +++---
.../PortletStateAwareResponseContextImpl.java | 6 -
.../container/PortletURLProviderImpl.java | 45 +-
.../driver/url/impl/PortalURLParserImpl.java | 27 ++
.../driver/url/impl/RelativePortalURLImpl.java | 70 +--
.../org/apache/pluto/driver/url/PortalURL.java | 12 +-
.../src/main/java/javax/portlet/ActionURL.java | 63 +++
.../src/main/java/javax/portlet/BaseURL.java | 92 +++-
.../main/java/javax/portlet/MimeResponse.java | 236 +++++++++-
.../src/main/java/javax/portlet/PortletURL.java | 82 +---
.../portlet/PortletURLGenerationListener.java | 7 +-
.../src/main/java/javax/portlet/RenderURL.java | 94 ++++
.../java/javax/portlet/ResourceResponse.java | 47 +-
.../main/java/javax/portlet/ResourceURL.java | 39 +-
.../portlet/filter/RenderResponseWrapper.java | 24 +-
.../portlet/filter/ResourceResponseWrapper.java | 35 +-
26 files changed, 1947 insertions(+), 1021 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-container-api/src/main/java/org/apache/pluto/container/PortletResourceResponseContext.java
----------------------------------------------------------------------
diff --git a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletResourceResponseContext.java b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletResourceResponseContext.java
index d388070..e14ea1e 100644
--- a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletResourceResponseContext.java
+++ b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletResourceResponseContext.java
@@ -1,30 +1,31 @@
-/*
- * 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.pluto.container;
-
-import java.util.Locale;
-
-/**
- * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
- * @version $Id$
- */
-public interface PortletResourceResponseContext extends PortletMimeResponseContext
-{
- void setLocale(Locale locale);
- void setCharacterEncoding(String charset);
- void setContentLength(int len);
-}
+/*
+ * 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.pluto.container;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id$
+ */
+public interface PortletResourceResponseContext extends PortletMimeResponseContext
+{
+ void setLocale(Locale locale);
+ void setCharacterEncoding(String charset);
+ void setContentLength(int len);
+ void setStatus(int sc);
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
----------------------------------------------------------------------
diff --git a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
index 310c018..699db30 100644
--- a/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
+++ b/pluto-container-api/src/main/java/org/apache/pluto/container/PortletURLProvider.java
@@ -26,6 +26,8 @@ import javax.portlet.PortletMode;
import javax.portlet.PortletSecurityException;
import javax.portlet.WindowState;
+import org.apache.pluto.container.PortletURLProvider.ParamType;
+
/**
* Defines the interface used by the portlet container to create Portlet URLs.
* This provider must be implemented by the Portal and provided via the
@@ -44,6 +46,7 @@ public interface PortletURLProvider {
ACTION,
RENDER,
RESOURCE,
+ PUBLIC
}
/**
@@ -177,10 +180,44 @@ public interface PortletURLProvider {
String toURL();
void write(Writer out, boolean escapeXML) throws IOException;
-
+
+ Appendable append(Appendable out, boolean escapeXML) throws IOException;
+
/**
* Gets the mutable map of vendor-specific properties as set on the BaseURL
* @return parameters a map containing the name and value(s) of the properties (may return null)
*/
public Map<String, List<String>> getProperties();
+
+ /**
+ * Marks the URL for authenticated access
+ *
+ * @param authenticated
+ */
+ void setAuthenticated(boolean authenticated);
+
+ /**
+ * Returns current authenticated setting
+ *
+ * @return
+ */
+ boolean getAuthenticated();
+
+ /**
+ * Sets the fragment identifier on a render URL
+ * @param fragment
+ */
+ void setFragmentIdentifier(String fragment);
+
+ /**
+ * Gets the current fragment identifier for the render URL
+ * @return
+ */
+ String getFragmentIdentifier();
+
+ /**
+ * Cears parameters of specified type
+ * @param type
+ */
+ void clearParameters(String WindowId, ParamType paramType);
}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-container/src/main/java/org/apache/pluto/container/impl/ActionURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/ActionURLImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/ActionURLImpl.java
new file mode 100644
index 0000000..61923b5
--- /dev/null
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/ActionURLImpl.java
@@ -0,0 +1,50 @@
+package org.apache.pluto.container.impl;
+
+import javax.portlet.ActionURL;
+import javax.portlet.MimeResponse.ParameterCopyOption;
+import javax.portlet.MutableActionParameters;
+
+import org.apache.pluto.container.PortletMimeResponseContext;
+import org.apache.pluto.container.PortletURLProvider;
+
+/* 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.
+ */
+
+/**
+ * @author nick
+ *
+ */
+public class ActionURLImpl extends PortletURLImpl implements ActionURL {
+
+ /**
+ * @param responseContext
+ * @param urlProvider
+ */
+ public ActionURLImpl(PortletMimeResponseContext responseContext, ParameterCopyOption copy) {
+ super(responseContext,
+ responseContext.getPortletURLProvider(PortletURLProvider.TYPE.ACTION), copy);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.ActionURL#getActionParameters()
+ */
+ public MutableActionParameters getActionParameters() {
+ return new MutableActionParametersImpl(urlProvider, windowId);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-container/src/main/java/org/apache/pluto/container/impl/BaseURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/BaseURLImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/BaseURLImpl.java
new file mode 100644
index 0000000..c17a0d8
--- /dev/null
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/BaseURLImpl.java
@@ -0,0 +1,321 @@
+/* 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.pluto.container.impl;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.portlet.ActionURL;
+import javax.portlet.BaseURL;
+import javax.portlet.MimeResponse.ParameterCopyOption;
+import javax.portlet.PortalContext;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.PortletURLGenerationListener;
+import javax.portlet.RenderParameters;
+import javax.portlet.RenderURL;
+import javax.portlet.ResourceURL;
+import javax.portlet.WindowState;
+
+import org.apache.pluto.container.PortletMimeResponseContext;
+import org.apache.pluto.container.PortletResponseContext;
+import org.apache.pluto.container.PortletURLListenerService;
+import org.apache.pluto.container.PortletURLProvider;
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.container.util.ArgumentUtility;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Scott Nicklous
+ *
+ */
+public abstract class BaseURLImpl implements BaseURL {
+ private static final Logger LOGGER = LoggerFactory.getLogger(BaseURLImpl.class);
+ private static final boolean isDebug = LOGGER.isDebugEnabled();
+
+ protected PortletResponseContext responseContext;
+ protected PortalContext portalContext;
+ protected boolean filtering;
+ protected boolean renderURL;
+
+ protected final String windowId;
+ protected PortletURLProvider urlProvider;
+
+ // Constructor
+ // ------------------------------------------------------------
+
+ protected BaseURLImpl(PortletResponseContext responseContext, PortletURLProvider urlProvider) {
+ this.responseContext = responseContext;
+ this.portalContext = responseContext.getContainer()
+ .getContainerServices().getPortalContext();
+ this.windowId = responseContext.getPortletWindow().getId().getStringId();
+ this.urlProvider = urlProvider;
+ renderURL = PortletURLProvider.TYPE.RENDER == urlProvider.getType();
+ if (isDebug) {
+ StringBuilder txt = new StringBuilder();
+ txt.append("URL provider type=").append(urlProvider.getType());
+ txt.append(", isRender=").append(renderURL);
+ LOGGER.debug(txt.toString());
+ }
+ }
+
+ public BaseURLImpl(PortletMimeResponseContext responseContext,
+ PortletURLProvider portletURLProvider, ParameterCopyOption copy) {
+ this(responseContext, portletURLProvider);
+
+ switch (copy) {
+ case COPY_NO_PARAMETERS:
+ urlProvider.clearParameters(windowId, PortletURLProvider.ParamType.PUBLIC);
+ case COPY_PUBLIC_RENDER_PARAMETERS:
+ urlProvider.clearParameters(windowId, PortletURLProvider.ParamType.RENDER);
+ break;
+ case COPY_RENDER_PARAMETERS:
+ }
+ }
+
+ // Private methods
+ // ------------------------------------------------------------
+
+ /**
+ * implements the filter mechanism when the URLs are generated.
+ */
+ private void filterURL() {
+ if (filtering) {
+ throw new IllegalStateException(
+ "Calling PortletURL toString or write methods from a PortletURLGenerationListener not allowed");
+ }
+ filtering = true;
+ try {
+ PortletURLListenerService service = responseContext.getContainer()
+ .getContainerServices().getPortletURLListenerService();
+ PortletApplicationDefinition portletApp = responseContext
+ .getPortletWindow().getPortletDefinition().getApplication();
+ for (PortletURLGenerationListener listener : service
+ .getPortletURLGenerationListeners(portletApp)) {
+ if (this instanceof ActionURL) {
+ listener.filterActionURL((ActionURL)this);
+ } else if (this instanceof ResourceURL) {
+ listener.filterResourceURL((ResourceURL)this);
+ } else if (this instanceof RenderURL) {
+ listener.filterRenderURL((RenderURL)this);
+ } else {
+ LOGGER.warn("Could not filter URL. Bad URL type: " + this.getClass().getSimpleName());
+ }
+ }
+ } finally {
+ filtering = false;
+ }
+ }
+
+ // BaseURL implementation
+ // ------------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#write(java.io.Writer, boolean)
+ */
+ public void write(Writer out, boolean escapeXML) throws IOException {
+ filterURL();
+ urlProvider.write(out, escapeXML);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#write(java.io.Writer)
+ */
+ public void write(Writer out) throws IOException {
+ write(out, true);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#toString()
+ */
+ public String toString() {
+ filterURL();
+ return urlProvider.toURL();
+ }
+
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#append(java.lang.Appendable)
+ */
+ public Appendable append(Appendable out) throws IOException {
+ return append(out, true);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#append(java.lang.Appendable, boolean)
+ */
+ public Appendable append(Appendable out, boolean escapeXML) throws IOException {
+ filterURL();
+ urlProvider.append(out, escapeXML);
+ return out;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletState#getRenderParameters()
+ */
+ public RenderParameters getRenderParameters() {
+ return new RenderParametersImpl(urlProvider, windowId);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletState#getPortletMode()
+ */
+ public PortletMode getPortletMode() {
+ return urlProvider.getPortletMode();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletState#getWindowState()
+ */
+ public WindowState getWindowState() {
+ return urlProvider.getWindowState();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#getParameterMap()
+ */
+ public Map<String, String[]> getParameterMap() {
+ Map<String, String[]> parameters = new HashMap<String, String[]>();
+ Set<String> names = urlProvider.getPrivateParameterNames(windowId);
+ for (String name : names) {
+ String[] vals = urlProvider.getParameterValues(windowId, name);
+ parameters.put(name, vals);
+ }
+ return parameters;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#setParameter(java.lang.String, java.lang.String)
+ */
+ public void setParameter(String name, String value) {
+ ArgumentUtility.validateNotEmpty("name", name);
+ if (value == null) {
+ urlProvider.removeParameter(windowId, name);
+ } else {
+ String[] values = new String[] { value };
+ urlProvider.setParameter(windowId, name, values);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#setParameter(java.lang.String, java.lang.String[])
+ */
+ public void setParameter(String name, String... values) {
+ ArgumentUtility.validateNotEmpty("name", name);
+ ArgumentUtility.validateNotNull("values", values);
+ if (values == null) {
+ urlProvider.removeParameter(windowId, name);
+ } else {
+ urlProvider.setParameter(windowId, name, values.clone());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#setParameters(java.util.Map)
+ */
+ public void setParameters(Map<String, String[]> parameters) {
+ ArgumentUtility.validateNotNull("parameters", parameters);
+
+ // validate map first
+ for (String key : parameters.keySet()) {
+ String[] vals = parameters.get(key);
+ if (key == null || vals == null) {
+ throw new IllegalArgumentException(
+ "parameters map contains a null key or values array");
+ }
+ }
+
+ // Remove the parameters that are gone
+ Set<String> currNames = urlProvider.getPrivateParameterNames(windowId);
+ currNames.removeAll(parameters.keySet());
+ for (String name : currNames) {
+ urlProvider.removeParameter(windowId, name);
+ }
+
+ // Now set the new values
+ for (String key : parameters.keySet()) {
+ urlProvider.setParameter(windowId, key, parameters.get(key));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#addProperty(java.lang.String, java.lang.String)
+ */
+ public void addProperty(String key, String value) {
+ ArgumentUtility.validateNotEmpty("key", key);
+ if (value != null) {
+ Map<String, List<String>> properties = urlProvider.getProperties();
+ List<String> values = properties.get(key);
+ if (values == null) {
+ values = new ArrayList<String>();
+ urlProvider.getProperties().put(key, values);
+ }
+ values.add(value);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#setProperty(java.lang.String, java.lang.String)
+ */
+ public void setProperty(String key, String value) {
+ ArgumentUtility.validateNotEmpty("key", key);
+ Map<String, List<String>> properties = urlProvider.getProperties();
+ if (value == null) {
+ properties.remove(key);
+ } else {
+ List<String> values = properties.get(key);
+ if (values == null) {
+ values = new ArrayList<String>();
+ properties.put(key, values);
+ } else {
+ values.clear();
+ }
+ values.add(value);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#setSecure(boolean)
+ */
+ public void setSecure(boolean secure) throws PortletSecurityException {
+ urlProvider.setSecure(secure);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#setAuthenticated(boolean)
+ */
+ public void setAuthenticated(boolean authenticated) {
+ urlProvider.setAuthenticated(authenticated);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.BaseURL#getAuthenticated()
+ */
+ public boolean getAuthenticated() {
+ return urlProvider.getAuthenticated();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-container/src/main/java/org/apache/pluto/container/impl/EventResponseImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/EventResponseImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/EventResponseImpl.java
index a210e66..4452189 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/EventResponseImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/EventResponseImpl.java
@@ -1,48 +1,49 @@
-/*
- * 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.pluto.container.impl;
-
-import javax.portlet.EventRequest;
-import javax.portlet.EventResponse;
-
-import org.apache.pluto.container.PortletEventResponseContext;
-import org.apache.pluto.container.util.ArgumentUtility;
-
-/**
- * Implementation of JSR-286 <code>EventResponse</code>.
- *
- * @since 2.0
- */
-
-public class EventResponseImpl extends StateAwareResponseImpl implements EventResponse
-{
- public EventResponseImpl(PortletEventResponseContext responseContext)
- {
- super(responseContext);
- }
-
- protected void checkSetStateChanged()
- {
- // nothing to check or do for EventResponse
- }
-
- public void setRenderParameters(EventRequest request)
- {
- ArgumentUtility.validateNotNull("request", request);
- setRenderParameters(request.getParameterMap());
- }
-}
+/*
+ * 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.pluto.container.impl;
+
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+
+import org.apache.pluto.container.PortletEventResponseContext;
+import org.apache.pluto.container.util.ArgumentUtility;
+
+/**
+ * Implementation of JSR-286 <code>EventResponse</code>.
+ *
+ * @since 2.0
+ */
+
+public class EventResponseImpl extends StateAwareResponseImpl implements EventResponse
+{
+ public EventResponseImpl(PortletEventResponseContext responseContext)
+ {
+ super(responseContext);
+ }
+
+ protected void checkSetStateChanged()
+ {
+ // nothing to check or do for EventResponse
+ }
+
+ @SuppressWarnings("deprecation")
+ public void setRenderParameters(EventRequest request)
+ {
+ ArgumentUtility.validateNotNull("request", request);
+ setRenderParameters(request.getParameterMap());
+ }
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-container/src/main/java/org/apache/pluto/container/impl/MimeResponseImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/MimeResponseImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/MimeResponseImpl.java
index c57b275..8fbe40c 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/MimeResponseImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/MimeResponseImpl.java
@@ -1,222 +1,194 @@
-/*
- * 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.pluto.container.impl;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.portlet.CacheControl;
-import javax.portlet.MimeResponse;
-import javax.portlet.PortletURL;
-import javax.portlet.ResourceURL;
-
-import org.apache.pluto.container.PortletMimeResponseContext;
-import org.apache.pluto.container.PortletURLProvider;
-import org.apache.pluto.container.om.portlet.PortletDefinition;
-import org.apache.pluto.container.om.portlet.Supports;
-
-public class MimeResponseImpl extends PortletResponseImpl implements MimeResponse
-{
- /** Response content types. */
- private ArrayList<String> responseContentTypes;
-
- private boolean usingWriter;
- private boolean usingStream;
- private boolean committed;
- private String contentType;
-
- private PortletMimeResponseContext responseContext;
-
- public MimeResponseImpl(PortletMimeResponseContext responseContext)
- {
- super(responseContext);
- this.responseContext = responseContext;
- PortletDefinition portletDefinition = getPortletWindow().getPortletDefinition();
- getCacheControl().setExpirationTime(portletDefinition.getExpirationCache());
- getCacheControl().setPublicScope(PUBLIC_SCOPE.equals(portletDefinition.getCacheScope()));
- }
-
- protected List<String> getResponseContentTypes()
- {
- if (responseContentTypes == null)
- {
- responseContentTypes = new ArrayList<String>();
- PortletDefinition dd = getPortletWindow().getPortletDefinition();
- for (Supports sup : dd.getSupports())
- {
- responseContentTypes.add(sup.getMimeType());
- }
- if (responseContentTypes.isEmpty())
- {
- responseContentTypes.add("text/html");
- }
- }
- return responseContentTypes;
- }
-
- public PortletURL createActionURL()
- {
- return new PortletURLImpl(responseContext, PortletURLProvider.TYPE.ACTION);
- }
-
- public PortletURL createRenderURL()
- {
- return new PortletURLImpl(responseContext, PortletURLProvider.TYPE.RENDER);
- }
-
-
- public ResourceURL createResourceURL()
- {
- return new PortletURLImpl(responseContext, PortletURLProvider.TYPE.RESOURCE);
- }
-
- public void flushBuffer() throws IOException
- {
- committed = true;
- responseContext.flushBuffer();
- }
-
- public int getBufferSize()
- {
- return responseContext.getBufferSize();
- }
-
- public CacheControl getCacheControl() {
- return responseContext.getCacheControl();
- }
-
- public String getCharacterEncoding()
- {
- return responseContext.getCharacterEncoding();
- }
-
- public String getContentType()
- {
- return contentType;
- }
-
- public Locale getLocale()
- {
- return responseContext.getLocale();
- }
-
- public OutputStream getPortletOutputStream()
- throws IllegalStateException, IOException
- {
- if (usingWriter)
- {
- throw new IllegalStateException("getPortletOutputStream can't be used after getWriter was invoked.");
- }
- if (getContentType() == null)
- {
- setContentType(getResponseContentTypes().get(0));
- }
- usingStream = true;
- return responseContext.getOutputStream();
- }
-
- public PrintWriter getWriter()
- throws IllegalStateException, IOException
- {
- if (usingStream)
- {
- throw new IllegalStateException("getWriter can't be used after getOutputStream was invoked.");
- }
- if (getContentType() == null)
- {
- setContentType(getResponseContentTypes().get(0));
- }
- usingWriter = true;
- return responseContext.getWriter();
- }
-
- public boolean isCommitted()
- {
- return committed ? true : responseContext.isCommitted();
- }
-
- public void reset()
- {
- if (isCommitted())
- {
- throw new IllegalStateException("Response is already committed");
- }
- responseContext.reset();
- }
-
- public void resetBuffer()
- {
- if (isCommitted())
- {
- throw new IllegalStateException("Response is already committed");
- }
- responseContext.resetBuffer();
- }
-
- public void setBufferSize(int size)
- {
- if (isCommitted())
- {
- throw new IllegalStateException("Response is already committed");
- }
- responseContext.setBufferSize(size);
- }
-
- public void setContentType(String contentType)
- {
- this.contentType = contentType;
- responseContext.setContentType(contentType);
- }
-
- @Override
- public void setProperty(String name, String value)
- {
- if (USE_CACHED_CONTENT.equals(name))
- {
- getCacheControl().setUseCachedContent(value != null);
- }
- else if (EXPIRATION_CACHE.equals(name))
- {
- int expirationTime;
- try
- {
- expirationTime = Integer.parseInt(value);
- }
- catch (NumberFormatException e)
- {
- expirationTime = 0;
- }
- getCacheControl().setExpirationTime(expirationTime);
- }
- else if (ETAG.equals(name))
- {
- getCacheControl().setETag(value);
- }
- else if (CACHE_SCOPE.equals(name))
- {
- getCacheControl().setPublicScope(PUBLIC_SCOPE.equals(value));
- }
- else
- {
- super.setProperty(name, value);
- }
- }
-}
+/*
+ * 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.pluto.container.impl;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import javax.portlet.CacheControl;
+import javax.portlet.MimeResponse;
+import static javax.portlet.MimeResponse.ParameterCopyOption.*;
+import javax.portlet.RenderURL;
+import javax.portlet.ActionURL;
+import javax.portlet.ResourceURL;
+
+import org.apache.pluto.container.PortletMimeResponseContext;
+import org.apache.pluto.container.om.portlet.PortletDefinition;
+import org.apache.pluto.container.om.portlet.Supports;
+
+public class MimeResponseImpl extends PortletResponseImpl implements
+ MimeResponse {
+ /** Response content types. */
+ private ArrayList<String> responseContentTypes;
+
+ private boolean usingWriter;
+ private boolean usingStream;
+ private boolean committed;
+ private String contentType;
+
+ private PortletMimeResponseContext responseContext;
+
+ public MimeResponseImpl(PortletMimeResponseContext responseContext) {
+ super(responseContext);
+ this.responseContext = responseContext;
+ PortletDefinition portletDefinition = getPortletWindow()
+ .getPortletDefinition();
+ getCacheControl().setExpirationTime(
+ portletDefinition.getExpirationCache());
+ getCacheControl().setPublicScope(
+ PUBLIC_SCOPE.equals(portletDefinition.getCacheScope()));
+ }
+
+ protected List<String> getResponseContentTypes() {
+ if (responseContentTypes == null) {
+ responseContentTypes = new ArrayList<String>();
+ PortletDefinition dd = getPortletWindow().getPortletDefinition();
+ for (Supports sup : dd.getSupports()) {
+ responseContentTypes.add(sup.getMimeType());
+ }
+ if (responseContentTypes.isEmpty()) {
+ responseContentTypes.add("text/html");
+ }
+ }
+ return responseContentTypes;
+ }
+
+ public ActionURL createActionURL() {
+ return new ActionURLImpl(responseContext, COPY_PUBLIC_RENDER_PARAMETERS);
+ }
+
+ public RenderURL createRenderURL() {
+ return new RenderURLImpl(responseContext, COPY_PUBLIC_RENDER_PARAMETERS);
+ }
+
+ public ActionURL createActionURL(ParameterCopyOption option) {
+ return new ActionURLImpl(responseContext, option);
+ }
+
+ public RenderURL createRenderURL(ParameterCopyOption option) {
+ return new RenderURLImpl(responseContext, option);
+ }
+
+ public ResourceURL createResourceURL() {
+ return new ResourceURLImpl(responseContext);
+ }
+
+ public void flushBuffer() throws IOException {
+ committed = true;
+ responseContext.flushBuffer();
+ }
+
+ public int getBufferSize() {
+ return responseContext.getBufferSize();
+ }
+
+ public CacheControl getCacheControl() {
+ return responseContext.getCacheControl();
+ }
+
+ public String getCharacterEncoding() {
+ return responseContext.getCharacterEncoding();
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public Locale getLocale() {
+ return responseContext.getLocale();
+ }
+
+ public OutputStream getPortletOutputStream() throws IllegalStateException,
+ IOException {
+ if (usingWriter) {
+ throw new IllegalStateException(
+ "getPortletOutputStream can't be used after getWriter was invoked.");
+ }
+ if (getContentType() == null) {
+ setContentType(getResponseContentTypes().get(0));
+ }
+ usingStream = true;
+ return responseContext.getOutputStream();
+ }
+
+ public PrintWriter getWriter() throws IllegalStateException, IOException {
+ if (usingStream) {
+ throw new IllegalStateException(
+ "getWriter can't be used after getOutputStream was invoked.");
+ }
+ if (getContentType() == null) {
+ setContentType(getResponseContentTypes().get(0));
+ }
+ usingWriter = true;
+ return responseContext.getWriter();
+ }
+
+ public boolean isCommitted() {
+ return committed ? true : responseContext.isCommitted();
+ }
+
+ public void reset() {
+ if (isCommitted()) {
+ throw new IllegalStateException("Response is already committed");
+ }
+ responseContext.reset();
+ }
+
+ public void resetBuffer() {
+ if (isCommitted()) {
+ throw new IllegalStateException("Response is already committed");
+ }
+ responseContext.resetBuffer();
+ }
+
+ public void setBufferSize(int size) {
+ if (isCommitted()) {
+ throw new IllegalStateException("Response is already committed");
+ }
+ responseContext.setBufferSize(size);
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ responseContext.setContentType(contentType);
+ }
+
+ @Override
+ public void setProperty(String name, String value) {
+ if (USE_CACHED_CONTENT.equals(name)) {
+ getCacheControl().setUseCachedContent(value != null);
+ } else if (EXPIRATION_CACHE.equals(name)) {
+ int expirationTime;
+ try {
+ expirationTime = Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ expirationTime = 0;
+ }
+ getCacheControl().setExpirationTime(expirationTime);
+ } else if (ETAG.equals(name)) {
+ getCacheControl().setETag(value);
+ } else if (CACHE_SCOPE.equals(name)) {
+ getCacheControl().setPublicScope(PUBLIC_SCOPE.equals(value));
+ } else {
+ super.setProperty(name, value);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java
index 1505bd5..5b5a25f 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java
@@ -16,387 +16,134 @@
*/
package org.apache.pluto.container.impl;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.portlet.PortalContext;
+import javax.portlet.MimeResponse.ParameterCopyOption;
+import javax.portlet.MutableRenderParameters;
import javax.portlet.PortletMode;
import javax.portlet.PortletModeException;
-import javax.portlet.PortletSecurityException;
import javax.portlet.PortletURL;
-import javax.portlet.PortletURLGenerationListener;
-import javax.portlet.ResourceURL;
import javax.portlet.WindowState;
import javax.portlet.WindowStateException;
-import javax.xml.namespace.QName;
import org.apache.pluto.container.PortletMimeResponseContext;
import org.apache.pluto.container.PortletResponseContext;
-import org.apache.pluto.container.PortletURLListenerService;
import org.apache.pluto.container.PortletURLProvider;
import org.apache.pluto.container.om.portlet.CustomPortletMode;
-import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
import org.apache.pluto.container.om.portlet.PortletDefinition;
-import org.apache.pluto.container.om.portlet.PublicRenderParameter;
import org.apache.pluto.container.om.portlet.Supports;
import org.apache.pluto.container.util.ArgumentUtility;
/**
- * Refactoring where functionality was pushed into JSR-286 <code>BaseURL</code>.
- *
+ * Refactoring to implement class hierarchy among various URL types
+ *
* @since 2.0
*/
-public class PortletURLImpl implements PortletURL, ResourceURL {
- private static final Logger LOGGER = LoggerFactory.getLogger(PortletURLImpl.class);
- private static final boolean isDebug = LOGGER.isDebugEnabled();
-
- private PortletResponseContext responseContext;
- private PortalContext portalContext;
- private PortletURLProvider urlProvider;
- private String cacheLevel = ResourceURL.PAGE;
- private boolean filtering;
- private boolean renderURL;
- private final String windowId;
-
- // Called to force class loading in Container thread
- public static final void load() {
- if (isDebug) {
- LOGGER.debug("Loaded.");
- }
- };
-
- public PortletURLImpl(PortletResponseContext responseContext, PortletURLProvider urlProvider)
- {
- this.responseContext = responseContext;
- this.portalContext = responseContext.getContainer().getContainerServices().getPortalContext();
- this.windowId = responseContext.getPortletWindow().getId().getStringId();
- this.urlProvider = urlProvider;
- renderURL = PortletURLProvider.TYPE.RENDER == urlProvider.getType();
- if (isDebug) {
- StringBuilder txt = new StringBuilder();
- txt.append("URL provider type=").append(urlProvider.getType());
- txt.append(", isRender=").append(renderURL);
- LOGGER.debug(txt.toString());
- }
- }
-
- public PortletURLImpl(PortletMimeResponseContext responseContext, PortletURLProvider.TYPE type)
- {
- this(responseContext, responseContext.getPortletURLProvider(type));
- }
-
- public PortletURLImpl(PortletMimeResponseContext responseContext, String cacheLevel)
- {
- this(responseContext, PortletURLProvider.TYPE.RESOURCE);
- if (cacheLevel != null)
- {
- this.cacheLevel = cacheLevel;
- }
- urlProvider.setCacheability(this.cacheLevel);
- }
-
- private boolean isPortletModeAllowed(PortletMode mode)
- {
- if(PortletMode.VIEW.equals(mode))
- {
- return true;
- }
-
- String modeName = mode.toString();
-
- PortletDefinition dd = responseContext.getPortletWindow().getPortletDefinition();
-
- for (Supports sup : dd.getSupports())
- {
- for (String m : sup.getPortletModes())
- {
- if (m.equalsIgnoreCase(modeName))
- {
- // check if a portlet managed mode which is always allowed.
- CustomPortletMode cpm = dd.getApplication().getCustomPortletMode(modeName);
- if (cpm != null && !cpm.isPortalManaged())
- {
- return true;
- }
- Enumeration<PortletMode> supportedModes = portalContext.getSupportedPortletModes();
- while (supportedModes.hasMoreElements())
- {
- if (supportedModes.nextElement().equals(mode))
- {
- return true;
- }
- }
- return false;
- }
- }
- }
- return false;
- }
-
- private boolean isWindowStateAllowed(WindowState state)
- {
- Enumeration<WindowState> supportedStates = portalContext.getSupportedWindowStates();
- while (supportedStates.hasMoreElements()) {
- if (supportedStates.nextElement().equals(state))
- {
- return true;
- }
- }
- return false;
- }
-
- public void filterURL()
- {
- if (filtering)
- {
- throw new IllegalStateException("Calling PortletURL toString or write methods from a PortletURLGenerationListener not allowed");
- }
- filtering = true;
- try
- {
- PortletURLListenerService service = responseContext.getContainer().getContainerServices().getPortletURLListenerService();
- PortletApplicationDefinition portletApp = responseContext.getPortletWindow().getPortletDefinition().getApplication();
- for (PortletURLGenerationListener listener : service.getPortletURLGenerationListeners(portletApp))
- {
- if (PortletURLProvider.TYPE.ACTION == urlProvider.getType())
- {
- listener.filterActionURL(this);
- }
- else if (PortletURLProvider.TYPE.RESOURCE == urlProvider.getType())
- {
- listener.filterResourceURL(this);
- }
- else
- {
- listener.filterRenderURL(this);
- }
- }
- }
- finally
- {
- filtering = false;
- }
- }
-
-
- // BaseURL impl ------------------------------------------------------------
-
- public void addProperty(String key, String value)
- {
- ArgumentUtility.validateNotEmpty("key", key);
- if (value != null)
- {
- Map<String, List<String>> properties = urlProvider.getProperties();
- List<String> values = properties.get(key);
- if (values == null)
- {
- values = new ArrayList<String>();
- urlProvider.getProperties().put(key, values);
- }
- values.add(value);
- }
- }
-
- public Map<String, String[]> getParameterMap()
- {
- Map<String, String[]> parameters = new HashMap<String, String[]>();
- Set<String> names = urlProvider.getPrivateParameterNames(windowId);
- for (String name : names) {
- String[] vals = urlProvider.getParameterValues(windowId, name);
- parameters.put(name, vals);
- }
- return parameters;
- }
-
- public void setParameter(String name, String value)
- {
- ArgumentUtility.validateNotEmpty("name", name);
- if (value == null) {
- urlProvider.removeParameter(windowId, name);
- } else {
- String[] values = new String[] { value };
- urlProvider.setParameter(windowId, name, values);
- }
- }
-
- public void setParameter(String name, String... values)
- {
- ArgumentUtility.validateNotEmpty("name", name);
- ArgumentUtility.validateNotNull("values", values);
- if (values == null) {
- urlProvider.removeParameter(windowId, name);
- } else {
- urlProvider.setParameter(windowId, name, values.clone());
- }
- }
-
- public void setParameters(Map<String, String[]> parameters)
- {
- ArgumentUtility.validateNotNull("parameters", parameters);
-
- // validate map first
- for (String key : parameters.keySet()) {
- String[] vals = parameters.get(key);
- if (key == null || vals == null) {
- throw new IllegalArgumentException("parameters map contains a null key or values array");
- }
- }
-
- // Remove the parameters that are gone
- Set<String> currNames = urlProvider.getPrivateParameterNames(windowId);
- currNames.removeAll(parameters.keySet());
- for (String name : currNames) {
- urlProvider.removeParameter(windowId, name);
- }
-
- // Now set the new values
- for (String key : parameters.keySet()) {
- urlProvider.setParameter(windowId, key, parameters.get(key));
- }
- }
-
- public void setProperty(String key, String value)
- {
- ArgumentUtility.validateNotEmpty("key", key);
- Map<String, List<String>> properties = urlProvider.getProperties();
- if (value == null)
- {
- properties.remove(key);
- }
- else
- {
- List<String> values = properties.get(key);
- if (values == null)
- {
- values = new ArrayList<String>();
- properties.put(key,values);
+public abstract class PortletURLImpl extends BaseURLImpl implements PortletURL {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PortletURLImpl.class);
+ private static final boolean isDebug = LOGGER.isDebugEnabled();
+
+ // Called to force class loading in Container thread
+ public static final void load() {
+ if (isDebug) {
+ LOGGER.debug("Loaded.");
+ }
+ };
+
+ // Constructors
+ // ------------------------------------------------------------
+
+ public PortletURLImpl(PortletResponseContext responseContext, PortletURLProvider urlProvider) {
+ super(responseContext, urlProvider);
+ }
+
+ public PortletURLImpl(PortletMimeResponseContext responseContext,
+ PortletURLProvider portletURLProvider, ParameterCopyOption copy) {
+ super(responseContext, portletURLProvider, copy);
+ }
+
+ // Private methods
+ // ------------------------------------------------------------
+
+ private boolean isPortletModeAllowed(PortletMode mode) {
+ if (PortletMode.VIEW.equals(mode)) {
+ return true;
+ }
+
+ String modeName = mode.toString();
+
+ PortletDefinition dd = responseContext.getPortletWindow()
+ .getPortletDefinition();
+
+ for (Supports sup : dd.getSupports()) {
+ for (String m : sup.getPortletModes()) {
+ if (m.equalsIgnoreCase(modeName)) {
+ // check if a portlet managed mode which is always allowed.
+ CustomPortletMode cpm = dd.getApplication()
+ .getCustomPortletMode(modeName);
+ if (cpm != null && !cpm.isPortalManaged()) {
+ return true;
+ }
+ Enumeration<PortletMode> supportedModes = portalContext
+ .getSupportedPortletModes();
+ while (supportedModes.hasMoreElements()) {
+ if (supportedModes.nextElement().equals(mode)) {
+ return true;
+ }
+ }
+ return false;
}
- else
- {
- values.clear();
- }
- values.add(value);
- }
- }
-
- public void setSecure(boolean secure) throws PortletSecurityException
- {
- urlProvider.setSecure(secure);
- }
-
- public void write(Writer out, boolean escapeXML) throws IOException
- {
- filterURL();
- urlProvider.write(out, escapeXML);
- }
-
- public void write(Writer out) throws IOException
- {
- write(out, true);
- }
-
- public String toString()
- {
- filterURL();
- return urlProvider.toURL();
- }
-
- // PortletURL impl ------------------------------------------------------------
-
- public PortletMode getPortletMode()
- {
- return urlProvider.getPortletMode();
- }
-
- public WindowState getWindowState()
- {
- return urlProvider.getWindowState();
- }
-
- public void setPortletMode(PortletMode portletMode) throws PortletModeException
- {
- ArgumentUtility.validateNotNull("portletMode", portletMode);
- if (isPortletModeAllowed(portletMode))
- {
- urlProvider.setPortletMode(portletMode);
- }
- else
- {
- throw new PortletModeException("Can't set this PortletMode", portletMode);
- }
- }
-
- public void setWindowState(WindowState windowState) throws WindowStateException
- {
- ArgumentUtility.validateNotNull("windowState", windowState);
- if (isWindowStateAllowed(windowState))
- {
- urlProvider.setWindowState(windowState);
- }
- else
- {
- throw new WindowStateException("Can't set this WindowState", windowState);
- }
- }
-
- public void removePublicRenderParameter(String name)
- {
- ArgumentUtility.validateNotEmpty("name", name);
- urlProvider.removePublicRenderParameter(windowId, name);
- }
-
- // ResourceURL impl ------------------------------------------------------------
-
- public String getCacheability()
- {
- return urlProvider.getCacheability();
- }
-
- public void setCacheability(String cacheLevel)
- {
- ArgumentUtility.validateNotEmpty("cachelevel", cacheLevel);
- if (FULL.equals(cacheLevel))
- {
- // always OK
- }
- else if (PORTLET.equals(cacheLevel))
- {
- if (FULL.equals(this.cacheLevel))
- {
- throw new IllegalStateException("Current request cacheablility is FULL: URLs with cacheability PORTLET not allowed");
- }
-
- }
- else if (PAGE.equals(cacheLevel))
- {
- if (FULL.equals(this.cacheLevel))
- {
- throw new IllegalStateException("Current request cacheablility is FULL: URLs with cacheability PORTLET not allowed");
- }
- else if (PORTLET.equals(this.cacheLevel))
- {
- throw new IllegalStateException("Current request cacheablility is PORTLET: URLs with cacheability PAGE not allowed");
- }
- }
- else
- {
- throw new IllegalArgumentException("Unknown cacheLevel: "+cacheLevel);
- }
- urlProvider.setCacheability(cacheLevel);
- }
-
- public void setResourceID(String resourceID)
- {
- urlProvider.setResourceID(resourceID);
- }
+ }
+ }
+ return false;
+ }
+
+ private boolean isWindowStateAllowed(WindowState state) {
+ Enumeration<WindowState> supportedStates = portalContext
+ .getSupportedWindowStates();
+ while (supportedStates.hasMoreElements()) {
+ if (supportedStates.nextElement().equals(state)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // PortletURL impl
+ // ------------------------------------------------------------
+
+ public void setPortletMode(PortletMode portletMode)
+ throws PortletModeException {
+ ArgumentUtility.validateNotNull("portletMode", portletMode);
+ if (isPortletModeAllowed(portletMode)) {
+ urlProvider.setPortletMode(portletMode);
+ } else {
+ throw new PortletModeException("Can't set this PortletMode",
+ portletMode);
+ }
+ }
+
+ public void setWindowState(WindowState windowState)
+ throws WindowStateException {
+ ArgumentUtility.validateNotNull("windowState", windowState);
+ if (isWindowStateAllowed(windowState)) {
+ urlProvider.setWindowState(windowState);
+ } else {
+ throw new WindowStateException("Can't set this WindowState",
+ windowState);
+ }
+ }
+
+ public void removePublicRenderParameter(String name) {
+ ArgumentUtility.validateNotEmpty("name", name);
+ urlProvider.removePublicRenderParameter(windowId, name);
+ }
+
+ @Override
+ public MutableRenderParameters getRenderParameters() {
+ return new MutableRenderParametersImpl(urlProvider, windowId);
+ }
}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-container/src/main/java/org/apache/pluto/container/impl/RenderURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/RenderURLImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/RenderURLImpl.java
new file mode 100644
index 0000000..9ddd985
--- /dev/null
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/RenderURLImpl.java
@@ -0,0 +1,54 @@
+/* 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.pluto.container.impl;
+
+import javax.portlet.MimeResponse.ParameterCopyOption;
+import javax.portlet.RenderURL;
+
+import org.apache.pluto.container.PortletMimeResponseContext;
+import org.apache.pluto.container.PortletURLProvider;
+import org.apache.pluto.container.util.ArgumentUtility;
+
+/**
+ * @author Scott Nicklous
+ *
+ */
+public class RenderURLImpl extends PortletURLImpl implements RenderURL {
+
+ /**
+ * @param responseContext
+ * @param copy
+ * @param urlProvider
+ */
+ public RenderURLImpl(PortletMimeResponseContext responseContext, ParameterCopyOption copy) {
+ super(responseContext,
+ responseContext.getPortletURLProvider(PortletURLProvider.TYPE.RENDER), copy);
+ }
+
+ public void setFragmentIdentifier(String fragment) {
+ ArgumentUtility.validateNotNull("fragment identifier", fragment);
+ urlProvider.setFragmentIdentifier(fragment);
+ }
+
+ public String getFragmentIdentifier() {
+ return urlProvider.getFragmentIdentifier();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceResponseImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceResponseImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceResponseImpl.java
index 31eea45..ddc13d7 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceResponseImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceResponseImpl.java
@@ -1,148 +1,175 @@
-/*
- * 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.pluto.container.impl;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Locale;
-
-import javax.portlet.PortletURL;
-import javax.portlet.ResourceResponse;
-import javax.portlet.ResourceURL;
-
-import org.apache.pluto.container.PortletResourceResponseContext;
-import org.apache.pluto.container.PortletURLProvider;
-
-public class ResourceResponseImpl extends MimeResponseImpl implements ResourceResponse
-{
- private static final String DEFAULT_CONTAINER_CHARSET = "UTF-8";
-
- private boolean canSetLocaleEncoding = true;
- private String charset;
- private String requestCacheLevel;
- private PortletResourceResponseContext responseContext;
-
- public ResourceResponseImpl(PortletResourceResponseContext responseContext, String requestCacheLevel)
- {
- super(responseContext);
- this.responseContext = responseContext;
- this.requestCacheLevel = requestCacheLevel == null ? ResourceURL.PAGE : requestCacheLevel;
- }
-
- @Override
- public PortletURL createActionURL()
- {
- if (ResourceURL.PAGE.equals(requestCacheLevel))
- {
- return new PortletURLImpl(responseContext, PortletURLProvider.TYPE.ACTION);
- }
- throw new IllegalStateException("Not allowed to create an ActionURL with current request cacheability level "+requestCacheLevel);
- }
-
- @Override
- public PortletURL createRenderURL()
- {
- if (ResourceURL.PAGE.equals(requestCacheLevel))
- {
- return new PortletURLImpl(responseContext, PortletURLProvider.TYPE.RENDER);
- }
- throw new IllegalStateException("Not allowed to create a RenderURL with current request cacheability level "+requestCacheLevel);
- }
-
- @Override
- public ResourceURL createResourceURL()
- {
- return new PortletURLImpl(responseContext, requestCacheLevel);
- }
-
- @Override
- public PrintWriter getWriter()
- throws IllegalStateException, IOException
- {
- if (charset == null)
- {
- // enforce the default Container encoding == UTF-8 if encoding hasn't been set yet.
- setCharacterEncoding(DEFAULT_CONTAINER_CHARSET);
- }
- return super.getWriter();
- }
-
- @Override
- public String getCharacterEncoding()
- {
- return charset != null ? charset : DEFAULT_CONTAINER_CHARSET;
- }
-
- public void setCharacterEncoding(String encoding)
- {
- // ensure client hasn't passed us the full name/value pair; i.e
- // charset=utf-8
- int index = encoding.indexOf('=');
- if (index != -1 && index < encoding.length()-1)
- {
- encoding = encoding.substring(index+1).trim();
- }
-
- if (encoding != null && encoding.length() > 0)
- {
- this.charset = encoding;
- responseContext.setCharacterEncoding(charset);
- canSetLocaleEncoding = false;
- }
- }
-
- @Override
- public void setContentType(String contentType)
- {
- if (contentType != null)
- {
- int index = contentType.indexOf(';');
- if (index != -1 && index < contentType.length()-1)
- {
- String encoding = contentType.substring(index+1).trim();
- if (encoding.length() > 0)
- {
- setCharacterEncoding(encoding);
- }
- }
- super.setContentType(contentType);
- }
- }
-
- public void setContentLength(int len)
- {
- responseContext.setContentLength(len);
- }
-
- public void setLocale(Locale locale)
- {
- if (locale != null)
- {
- responseContext.setLocale(locale);
- if (canSetLocaleEncoding)
- {
- String encoding = getPortletWindow().getPortletDefinition().getApplication().getLocaleEncodingMappings().get(locale);
- if (encoding != null)
- {
- setCharacterEncoding(encoding);
- // allow repeated setLocale usage for characterEncoding
- canSetLocaleEncoding = true;
- }
- }
- }
- }
-}
+/*
+ * 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.pluto.container.impl;
+
+import static javax.portlet.MimeResponse.ParameterCopyOption.COPY_PUBLIC_RENDER_PARAMETERS;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.portlet.ActionURL;
+import javax.portlet.RenderURL;
+import javax.portlet.ResourceResponse;
+import javax.portlet.ResourceURL;
+
+import org.apache.pluto.container.PortletResourceResponseContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ResourceResponseImpl extends MimeResponseImpl implements ResourceResponse
+{
+
+ private static final String DEFAULT_CONTAINER_CHARSET = "UTF-8";
+
+ private boolean canSetLocaleEncoding = true;
+ private String charset;
+ private String requestCacheLevel;
+ private PortletResourceResponseContext responseContext;
+
+ public ResourceResponseImpl(PortletResourceResponseContext responseContext, String requestCacheLevel)
+ {
+ super(responseContext);
+ this.responseContext = responseContext;
+ this.requestCacheLevel = requestCacheLevel == null ? ResourceURL.PAGE : requestCacheLevel;
+ }
+
+ @Override
+ public ActionURL createActionURL(ParameterCopyOption option) {
+ if (ResourceURL.PAGE.equals(requestCacheLevel)) {
+ return new ActionURLImpl(responseContext, option);
+ } else {
+ throw new IllegalStateException("Not allowed to create an ActionURL with current request cacheability level "+requestCacheLevel);
+ }
+ }
+
+ @Override
+ public RenderURL createRenderURL(ParameterCopyOption option) {
+ if (ResourceURL.PAGE.equals(requestCacheLevel)) {
+ return new RenderURLImpl(responseContext, option);
+ } else {
+ throw new IllegalStateException("Not allowed to create a RenderURL with current request cacheability level "+requestCacheLevel);
+ }
+ }
+
+ @Override
+ public ActionURL createActionURL()
+ {
+ if (ResourceURL.PAGE.equals(requestCacheLevel))
+ {
+ return new ActionURLImpl(responseContext, COPY_PUBLIC_RENDER_PARAMETERS);
+ }
+ throw new IllegalStateException("Not allowed to create an ActionURL with current request cacheability level "+requestCacheLevel);
+ }
+
+ @Override
+ public RenderURL createRenderURL()
+ {
+ if (ResourceURL.PAGE.equals(requestCacheLevel))
+ {
+ return new RenderURLImpl(responseContext, COPY_PUBLIC_RENDER_PARAMETERS);
+ }
+ throw new IllegalStateException("Not allowed to create a RenderURL with current request cacheability level "+requestCacheLevel);
+ }
+
+ @Override
+ public ResourceURL createResourceURL()
+ {
+ return new ResourceURLImpl(responseContext, requestCacheLevel);
+ }
+
+ @Override
+ public PrintWriter getWriter()
+ throws IllegalStateException, IOException
+ {
+ if (charset == null)
+ {
+ // enforce the default Container encoding == UTF-8 if encoding hasn't been set yet.
+ setCharacterEncoding(DEFAULT_CONTAINER_CHARSET);
+ }
+ return super.getWriter();
+ }
+
+ @Override
+ public String getCharacterEncoding()
+ {
+ return charset != null ? charset : DEFAULT_CONTAINER_CHARSET;
+ }
+
+ public void setCharacterEncoding(String encoding)
+ {
+ // ensure client hasn't passed us the full name/value pair; i.e
+ // charset=utf-8
+ int index = encoding.indexOf('=');
+ if (index != -1 && index < encoding.length()-1)
+ {
+ encoding = encoding.substring(index+1).trim();
+ }
+
+ if (encoding != null && encoding.length() > 0)
+ {
+ this.charset = encoding;
+ responseContext.setCharacterEncoding(charset);
+ canSetLocaleEncoding = false;
+ }
+ }
+
+ @Override
+ public void setContentType(String contentType)
+ {
+ if (contentType != null)
+ {
+ int index = contentType.indexOf(';');
+ if (index != -1 && index < contentType.length()-1)
+ {
+ String encoding = contentType.substring(index+1).trim();
+ if (encoding.length() > 0)
+ {
+ setCharacterEncoding(encoding);
+ }
+ }
+ super.setContentType(contentType);
+ }
+ }
+
+ public void setContentLength(int len)
+ {
+ responseContext.setContentLength(len);
+ }
+
+ public void setLocale(Locale locale)
+ {
+ if (locale != null)
+ {
+ responseContext.setLocale(locale);
+ if (canSetLocaleEncoding)
+ {
+ String encoding = getPortletWindow().getPortletDefinition().getApplication().getLocaleEncodingMappings().get(locale);
+ if (encoding != null)
+ {
+ setCharacterEncoding(encoding);
+ // allow repeated setLocale usage for characterEncoding
+ canSetLocaleEncoding = true;
+ }
+ }
+ }
+ }
+
+ public void setStatus(int sc) {
+ responseContext.setStatus(sc);
+ }
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceURLImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceURLImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceURLImpl.java
new file mode 100644
index 0000000..ee9d6b9
--- /dev/null
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/ResourceURLImpl.java
@@ -0,0 +1,108 @@
+/* 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.pluto.container.impl;
+
+import javax.portlet.MutableResourceParameters;
+import javax.portlet.ResourceURL;
+
+import org.apache.pluto.container.PortletMimeResponseContext;
+import org.apache.pluto.container.PortletURLProvider;
+import org.apache.pluto.container.util.ArgumentUtility;
+
+/**
+ * @author nick
+ *
+ */
+public class ResourceURLImpl extends BaseURLImpl implements ResourceURL {
+
+ private String cacheLevel = ResourceURL.PAGE;
+
+ /**
+ * @param responseContext
+ * @param type
+ */
+ public ResourceURLImpl(PortletMimeResponseContext responseContext) {
+ super(responseContext,
+ responseContext.getPortletURLProvider(PortletURLProvider.TYPE.RESOURCE));
+ }
+
+ /**
+ * @param responseContext
+ * @param cacheLevel
+ */
+ public ResourceURLImpl(PortletMimeResponseContext responseContext,
+ String cacheLevel) {
+ this(responseContext);
+ if (cacheLevel != null) {
+ this.cacheLevel = cacheLevel;
+ }
+ urlProvider.setCacheability(this.cacheLevel);
+ }
+
+ public String getCacheability() {
+ return urlProvider.getCacheability();
+ }
+
+ public void setCacheability(String cacheLevel) {
+ ArgumentUtility.validateNotEmpty("cachelevel", cacheLevel);
+ if (FULL.equals(cacheLevel)) {
+ // always OK
+ } else if (PORTLET.equals(cacheLevel)) {
+ if (FULL.equals(this.cacheLevel)) {
+ throw new IllegalStateException(
+ "Current request cacheablility is FULL: URLs with cacheability PORTLET not allowed");
+ }
+
+ } else if (PAGE.equals(cacheLevel)) {
+ if (FULL.equals(this.cacheLevel)) {
+ throw new IllegalStateException(
+ "Current request cacheablility is FULL: URLs with cacheability PORTLET not allowed");
+ } else if (PORTLET.equals(this.cacheLevel)) {
+ throw new IllegalStateException(
+ "Current request cacheablility is PORTLET: URLs with cacheability PAGE not allowed");
+ }
+ } else {
+ throw new IllegalArgumentException("Unknown cacheLevel: " + cacheLevel);
+ }
+ urlProvider.setCacheability(cacheLevel);
+ }
+
+ public void setResourceID(String resourceID) {
+ urlProvider.setResourceID(resourceID);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.portlet.ResourceURL#getResourceParameters()
+ */
+ public MutableResourceParameters getResourceParameters() {
+ return new MutableResourceParametersImpl(urlProvider, windowId);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.portlet.ResourceURL#getResourceID()
+ */
+ public String getResourceID() {
+ return urlProvider.getResourceID();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletResourceResponseContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletResourceResponseContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletResourceResponseContextImpl.java
index 9c6e8bf..e098316 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletResourceResponseContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletResourceResponseContextImpl.java
@@ -1,65 +1,88 @@
-/*
- * 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.pluto.driver.services.container;
-
-import java.util.Locale;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.pluto.container.PortletContainer;
-import org.apache.pluto.container.PortletResourceResponseContext;
-import org.apache.pluto.container.PortletWindow;
-
-/**
- * @version $Id$
- *
- */
-public class PortletResourceResponseContextImpl extends PortletMimeResponseContextImpl implements
- PortletResourceResponseContext
-{
-
- public PortletResourceResponseContextImpl(PortletContainer container, HttpServletRequest containerRequest,
- HttpServletResponse containerResponse, PortletWindow window)
- {
- super(container, containerRequest, containerResponse, window);
- }
-
- public void setCharacterEncoding(String charset)
- {
- if (!isClosed())
- {
- getServletResponse().setCharacterEncoding(charset);
- }
- }
-
- public void setContentLength(int len)
- {
- if (!isClosed())
- {
- getServletResponse().setContentLength(len);
- }
- }
-
- public void setLocale(Locale locale)
- {
- if (!isClosed())
- {
- getServletResponse().setLocale(locale);
- }
- }
-}
+/*
+ * 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.pluto.driver.services.container;
+
+import java.util.Locale;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.pluto.container.PortletContainer;
+import org.apache.pluto.container.PortletResourceResponseContext;
+import org.apache.pluto.container.PortletWindow;
+import org.apache.pluto.container.impl.ResourceResponseImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @version $Id$
+ *
+ */
+public class PortletResourceResponseContextImpl extends PortletMimeResponseContextImpl implements
+ PortletResourceResponseContext
+{
+ private static final Logger LOGGER = LoggerFactory.getLogger(PortletResourceResponseContextImpl.class);
+ private static final boolean isDebug = LOGGER.isDebugEnabled();
+
+ public PortletResourceResponseContextImpl(PortletContainer container, HttpServletRequest containerRequest,
+ HttpServletResponse containerResponse, PortletWindow window)
+ {
+ super(container, containerRequest, containerResponse, window);
+ }
+
+ public void setCharacterEncoding(String charset)
+ {
+ if (isDebug) {
+ StringBuilder txt = new StringBuilder("Setting character encoding.");
+ txt.append(" charset: ").append(charset);
+ txt.append(" isClosed: ").append(isClosed());
+ LOGGER.debug(txt.toString());
+ }
+ if (!isClosed())
+ {
+ getServletResponse().setCharacterEncoding(charset);
+ }
+ }
+
+ public void setContentLength(int len)
+ {
+ if (!isClosed())
+ {
+ getServletResponse().setContentLength(len);
+ }
+ }
+
+ public void setLocale(Locale locale)
+ {
+ if (!isClosed())
+ {
+ getServletResponse().setLocale(locale);
+ }
+ }
+
+ public void setStatus(int sc) {
+ if (isDebug) {
+ StringBuilder txt = new StringBuilder("Setting character encoding.");
+ txt.append(" status code: ").append(sc);
+ txt.append(" isClosed: ").append(isClosed());
+ LOGGER.debug(txt.toString());
+ }
+ if (!isClosed()) {
+ getServletResponse().setStatus(sc);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
index 65731ba..1a34d33 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletStateAwareResponseContextImpl.java
@@ -79,12 +79,6 @@ public abstract class PortletStateAwareResponseContextImpl extends PortletRespon
super.close();
if (isDebug) {
- LOGGER.debug("Filtering the URL.");
- }
-
- new PortletURLImpl(this, portletURLProvider).filterURL();
-
- if (isDebug) {
LOGGER.debug("Applying the changes.");
}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/260318f9/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
index 3225566..da2e5c0 100644
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
+++ b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
@@ -69,6 +69,7 @@ public class PortletURLProviderImpl implements PortletURLProvider {
paramTypeMap.put(ParamType.ACTION, PortalURLParameter.PARAM_TYPE_ACTION);
paramTypeMap.put(ParamType.RENDER, PortalURLParameter.PARAM_TYPE_RENDER);
paramTypeMap.put(ParamType.RESOURCE, PortalURLParameter.PARAM_TYPE_RESOURCE);
+ paramTypeMap.put(ParamType.PUBLIC, PortalURLParameter.PARAM_TYPE_PUBLIC);
}
private final static HashMap<URLType, TYPE> urlTypeMap = new HashMap<PortalURL.URLType, PortletURLProvider.TYPE>();
@@ -128,23 +129,20 @@ public class PortletURLProviderImpl implements PortletURLProvider {
}
this.url.setTargetWindow(window);
+ this.url.clearParameters(window, PortalURLParameter.PARAM_TYPE_RESOURCE);
+ this.url.clearParameters(window, PortalURLParameter.PARAM_TYPE_ACTION);
switch (type) {
case ACTION:
this.url.setType(URLType.Action);
break;
case RESOURCE:
this.url.setType(URLType.Resource);
- this.url.clearParameters(window, PortalURLParameter.PARAM_TYPE_RESOURCE);
- this.url.clearParameters(window, PortalURLParameter.PARAM_TYPE_ACTION);
this.url.setCacheability(ResourceURL.PAGE);
break;
default:
this.url.setType(URLType.Render);
- if (url.isVersion3(window)) {
- this.url.clearParameters(window, PortalURLParameter.PARAM_TYPE_RESOURCE);
- this.url.clearParameters(window, PortalURLParameter.PARAM_TYPE_ACTION);
- } else {
- this.url.clearParameters(window);
+ if (!url.isVersion3(window)) {
+ this.url.clearParameters(window, PortalURLParameter.PARAM_TYPE_RENDER);
}
}
@@ -277,6 +275,19 @@ public class PortletURLProviderImpl implements PortletURLProvider {
out.write(result);
}
+ public Appendable append(Appendable out, boolean escapeXML) throws IOException {
+ String result = apply().toURL(false);
+ if (escapeXML) {
+ result = result.replaceAll("&", "&");
+ result = result.replaceAll("<", "<");
+ result = result.replaceAll(">", ">");
+ result = result.replaceAll("\'", "'");
+ result = result.replaceAll("\"", """);
+ }
+ out.append(result);
+ return out;
+ }
+
public Map<String, List<String>> getProperties() {
if (properties == null) {
properties = new HashMap<String, List<String>>();
@@ -353,4 +364,24 @@ public class PortletURLProviderImpl implements PortletURLProvider {
return paramFactory.getPublicParameterNames(windowId);
}
+ public void setAuthenticated(boolean authenticated) {
+ url.setAuthenticated(authenticated);
+ }
+
+ public boolean getAuthenticated() {
+ return url.getAuthenticated();
+ }
+
+ public void setFragmentIdentifier(String fragment) {
+ url.setFragmentIdentifier(fragment);
+ }
+
+ public String getFragmentIdentifier() {
+ return url.getFragmentIdentifier();
+ }
+
+ public void clearParameters(String windowId, ParamType type) {
+ url.clearParameters(windowId, paramTypeMap.get(type));
+ }
+
}