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 cz...@apache.org on 2009/03/02 09:56:22 UTC
svn commit: r749240 - in /portals/pluto/trunk:
pluto-container/src/main/java/org/apache/pluto/internal/impl/
pluto-container/src/main/java/org/apache/pluto/util/
pluto-container/src/test/java/org/apache/pluto/util/
pluto-portal-driver-impl/src/main/jav...
Author: cziegeler
Date: Mon Mar 2 08:56:21 2009
New Revision: 749240
URL: http://svn.apache.org/viewvc?rev=749240&view=rev
Log:
String[].clone can be directly used - no need for utility method.
Modified:
portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/BaseURLImpl.java
portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java
portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/StateAwareResponseImpl.java
portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java
portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/util/StringUtilsTest.java
portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLImpl.java
portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/BaseURLImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/BaseURLImpl.java?rev=749240&r1=749239&r2=749240&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/BaseURLImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/BaseURLImpl.java Mon Mar 2 08:56:21 2009
@@ -44,7 +44,6 @@
import org.apache.pluto.spi.PortletURLListener;
import org.apache.pluto.spi.PortletURLProvider;
import org.apache.pluto.util.StringManager;
-import org.apache.pluto.util.StringUtils;
/**
* Implementation of JSR-286 <code>BaseURL</code>, which includes a refactoring
@@ -128,14 +127,14 @@
List<String> publicRenderParameterNames = portletWindow.getPortletEntity().getPortletDefinition().getSupportedPublicRenderParameters();
if (publicRenderParameterNames == null){
- parameters.put(name, StringUtils.copy(values));
+ parameters.put(name, values.clone());
}
else{
if (publicRenderParameterNames.contains(name)&& !this.isAction && !this.isResourceServing){
- publicRenderParameters.put(name,StringUtils.copy(values));
+ publicRenderParameters.put(name, values.clone());
}
else{
- parameters.put(name, StringUtils.copy(values));
+ parameters.put(name, values.clone());
}
}
}
Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java?rev=749240&r1=749239&r2=749240&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java Mon Mar 2 08:56:21 2009
@@ -28,12 +28,10 @@
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Set;
import java.util.Vector;
import javax.ccpp.Profile;
@@ -71,7 +69,6 @@
import org.apache.pluto.spi.optional.PortletEnvironmentService;
import org.apache.pluto.spi.optional.RequestAttributeService;
import org.apache.pluto.util.ArgumentUtility;
-import org.apache.pluto.util.Enumerator;
import org.apache.pluto.util.StringManager;
import org.apache.pluto.util.StringUtils;
@@ -82,19 +79,19 @@
*
*/
public abstract class PortletRequestImpl extends HttpServletRequestWrapper
- implements PortletRequest, InternalPortletRequest
+ implements PortletRequest, InternalPortletRequest
{
private static final Log LOG = LogFactory.getLog(PortletRequestImpl.class);
-
+
private static final StringManager EXCEPTIONS =
StringManager.getManager(PortletRequestImpl.class.getPackage().getName());
-
+
private static final List<String> EMPTY_STRING_LIST = Collections.unmodifiableList(new ArrayList<String>(0));
/**
* Cache for parsed dateHeader values.
*/
protected static final HashMap<String,Long> dateHeaderParseCache = new HashMap<String,Long>();
-
+
/**
* The set of SimpleDateFormat formats to use in getDateHeader().
*
@@ -106,12 +103,12 @@
new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
};
-
+
// Private Member Variables ------------------------------------------------
-
+
/** The parent container within which this request was created. */
protected PortletContainer container;
-
+
/** The portlet window which is the target of this portlet request. */
protected PortletWindow portletWindow;
@@ -129,38 +126,38 @@
/** Response content types. */
protected Vector<String> contentTypes;
-
+
/** FIXME: do we really need this?
* Flag indicating if the HTTP-Body has been accessed. */
protected boolean bodyAccessed = false;
/** True if we are in an include call. */
protected boolean included = false;
-
+
/** True if we are in an forwarded call. */
protected boolean forwarded = false;
-
+
protected boolean namedRequestDispatcher;
-
+
/** The corresponding servlet request. */
protected HttpServletRequest servletRequest = null;
-
+
protected PortletPreferences portletPreferences;
protected PortletURLProvider urlProvider;
-
+
protected Map<String, String[]> parameters = null;
-
+
protected Map<String, String[]> requestProperties = null;
protected List<String> requestPropertyNames = null;
-
+
protected Cookie[] requestCookies = null;
-
+
protected String queryString = null;
-
+
// Constructors ------------------------------------------------------------
- public PortletRequestImpl(InternalPortletRequest internalPortletRequest)
+ public PortletRequestImpl(InternalPortletRequest internalPortletRequest)
{
this(internalPortletRequest.getPortletContainer(),
internalPortletRequest.getPortletWindow(),
@@ -175,7 +172,7 @@
*/
public PortletRequestImpl(PortletContainer container,
PortletWindow portletWindow,
- HttpServletRequest servletRequest)
+ HttpServletRequest servletRequest)
{
super(servletRequest);
this.container = container;
@@ -185,9 +182,9 @@
this.urlProvider = container
.getRequiredContainerServices()
.getPortalCallbackService()
- .getPortletURLProvider(getHttpServletRequest(), portletWindow);
+ .getPortletURLProvider(getHttpServletRequest(), portletWindow);
}
-
+
protected abstract Integer getRequestMethod();
// PortletRequest Impl -----------------------------------------------------
@@ -195,11 +192,11 @@
/* (non-Javadoc)
* @see javax.portlet.PortletRequest#getWindowId()
*/
- public String getWindowId()
+ public String getWindowId()
{
return portletWindow.getId().getStringId();
}
-
+
/**
* Determine whether or not the specified WindowState is allowed for this
* portlet.
@@ -207,40 +204,40 @@
* @param state the state in question
* @return true if the state is allowed.
*/
- public boolean isWindowStateAllowed(WindowState state)
+ public boolean isWindowStateAllowed(WindowState state)
{
for (Enumeration<WindowState> en = portalContext.getSupportedWindowStates();
- en.hasMoreElements(); )
+ en.hasMoreElements(); )
{
- if (en.nextElement().toString().equalsIgnoreCase(state.toString()))
+ if (en.nextElement().toString().equalsIgnoreCase(state.toString()))
{
return true;
}
}
return false;
}
-
- public boolean isPortletModeAllowed(PortletMode mode)
+
+ public boolean isPortletModeAllowed(PortletMode mode)
{
return (isPortletModeAllowedByPortlet(mode)
&& isPortletModeAllowedByPortal(mode));
}
-
- public PortletMode getPortletMode()
+
+ public PortletMode getPortletMode()
{
return portletWindow.getPortletMode();
}
-
- public WindowState getWindowState()
+
+ public WindowState getWindowState()
{
return portletWindow.getWindowState();
}
-
- public PortletSession getPortletSession()
+
+ public PortletSession getPortletSession()
{
return getPortletSession(true);
}
-
+
/**
* Returns the portlet session.
* <p>
@@ -249,9 +246,9 @@
* by the request instance is also re-created for each incoming request.
* </p>
*/
- public PortletSession getPortletSession(boolean create)
+ public PortletSession getPortletSession(boolean create)
{
- if (LOG.isDebugEnabled())
+ if (LOG.isDebugEnabled())
{
LOG.debug("Retreiving portlet session (create=" + create + ")");
}
@@ -261,7 +258,7 @@
// having a cached version which is invalid for the context within
// which it exists.
//
- if (portletContext == null)
+ if (portletContext == null)
{
throw new IllegalStateException(
EXCEPTIONS.getString("error.session.illegalState"));
@@ -277,18 +274,18 @@
// javax.servlet.http.HttpSession!
//
HttpSession httpSession = getHttpServletRequest().getSession(create);
- if (httpSession != null)
+ if (httpSession != null)
{
// HttpSession is not null does NOT mean that it is valid.
int maxInactiveInterval = httpSession.getMaxInactiveInterval();
long lastAccesstime = httpSession.getLastAccessedTime();//lastAccesstime checks added for PLUTO-436
- if (maxInactiveInterval >= 0 && lastAccesstime > 0)
+ if (maxInactiveInterval >= 0 && lastAccesstime > 0)
{ // < 0 => Never expires.
long maxInactiveTime = httpSession.getMaxInactiveInterval() * 1000L;
long currentInactiveTime = System.currentTimeMillis() - lastAccesstime;
- if (currentInactiveTime > maxInactiveTime)
+ if (currentInactiveTime > maxInactiveTime)
{
- if (LOG.isDebugEnabled())
+ if (LOG.isDebugEnabled())
{
LOG.debug("The underlying HttpSession is expired and "
+ "should be invalidated.");
@@ -302,9 +299,9 @@
}
}
}
- if (httpSession == null)
+ if (httpSession == null)
{
- if (LOG.isDebugEnabled())
+ if (LOG.isDebugEnabled())
{
LOG.debug("The underlying HttpSession is not available: "
+ "no session will be returned.");
@@ -316,24 +313,24 @@
// available. If we haven't created and cached a portlet session
// instance, we will create and cache one now.
//
- if (portletSession == null)
+ if (portletSession == null)
{
- if (LOG.isDebugEnabled())
+ if (LOG.isDebugEnabled())
{
LOG.debug("Creating new portlet session...");
}
final OptionalContainerServices optionalContainerServices = container.getOptionalContainerServices();
final PortletEnvironmentService portletEnvironmentService = optionalContainerServices.getPortletEnvironmentService();
-
- portletSession = portletEnvironmentService.createPortletSession(container,
+
+ portletSession = portletEnvironmentService.createPortletSession(container,
getHttpServletRequest(),
- portletContext,
- httpSession,
+ portletContext,
+ httpSession,
portletWindow);
- }
+ }
return portletSession;
}
-
+
protected void retrieveRequestProperties()
{
PropertyManager propertyManager = container.getRequiredContainerServices().getPortalCallbackService().getPropertyManager();
@@ -346,7 +343,7 @@
requestProperties.put(entry.getKey().toLowerCase(), entry.getValue());
}
}
-
+
public String getProperty(String name)
{
ArgumentUtility.validateNotNull("propertyName", name);
@@ -356,14 +353,14 @@
}
String property = null;
String[] properties = requestProperties.get(name.toLowerCase());
- if (properties != null && properties.length > 0)
+ if (properties != null && properties.length > 0)
{
property = properties[0];
}
return property;
}
- public Enumeration<String> getProperties(String name)
+ public Enumeration<String> getProperties(String name)
{
ArgumentUtility.validateNotNull("propertyName", name);
if (requestProperties == null)
@@ -378,7 +375,7 @@
return Collections.enumeration(Arrays.asList(properties));
}
- public Enumeration<String> getPropertyNames()
+ public Enumeration<String> getPropertyNames()
{
if (requestProperties == null)
{
@@ -387,27 +384,27 @@
return Collections.enumeration(requestPropertyNames);
}
- public PortalContext getPortalContext()
+ public PortalContext getPortalContext()
{
return container.getRequiredContainerServices().getPortalContext();
}
- public String getAuthType()
+ public String getAuthType()
{
return this.getHttpServletRequest().getAuthType();
}
- public String getContextPath()
+ public String getContextPath()
{
return portletContext.getContextPath();
}
- public String getRemoteUser()
+ public String getRemoteUser()
{
return this.getHttpServletRequest().getRemoteUser();
}
- public Principal getUserPrincipal()
+ public Principal getUserPrincipal()
{
return this.getHttpServletRequest().getUserPrincipal();
}
@@ -422,17 +419,17 @@
* @param roleName the name of the role
* @return true if it is determined the user has the given role.
*/
- public boolean isUserInRole(String roleName)
+ public boolean isUserInRole(String roleName)
{
PortletEntity entity = portletWindow.getPortletEntity();
PortletDefinition def = entity.getPortletDefinition();
SecurityRoleRef ref = null;
Iterator refs = def.getSecurityRoleRefs().iterator();
- while (refs.hasNext())
+ while (refs.hasNext())
{
SecurityRoleRef r = (SecurityRoleRef) refs.next();
- if (r.getRoleName().equals(roleName))
+ if (r.getRoleName().equals(roleName))
{
ref = r;
break;
@@ -440,17 +437,17 @@
}
String link;
- if (ref != null && ref.getRoleLink() != null)
+ if (ref != null && ref.getRoleLink() != null)
{
link = ref.getRoleLink();
- } else
+ } else
{
link = roleName;
}
return this.getHttpServletRequest().isUserInRole(link);
}
- public Object getAttribute(String name)
+ public Object getAttribute(String name)
{
ArgumentUtility.validateNotNull("attributeName", name);
@@ -471,20 +468,20 @@
return null;
}
}
-
+
final OptionalContainerServices optionalContainerServices = container.getOptionalContainerServices();
final RequestAttributeService requestAttributeService = optionalContainerServices.getRequestAttributeService();
return requestAttributeService.getAttribute(this, this.getHttpServletRequest(), this.portletWindow, name);
}
- public Enumeration<String> getAttributeNames()
+ public Enumeration<String> getAttributeNames()
{
final OptionalContainerServices optionalContainerServices = container.getOptionalContainerServices();
final RequestAttributeService requestAttributeService = optionalContainerServices.getRequestAttributeService();
return requestAttributeService.getAttributeNames(this, this.getHttpServletRequest(), this.portletWindow);
}
-
- public String getParameter(String name)
+
+ public String getParameter(String name)
{
ArgumentUtility.validateNotNull("parameterName", name);
String[] values = null;
@@ -500,29 +497,29 @@
if (publicRenderParameterNames.contains(name))
values = urlProvider.getPublicRenderParameters(name);
else
- values = (String[]) baseGetParameterMap().get(name);
+ values = baseGetParameterMap().get(name);
}
else
{
- values = (String[]) baseGetParameterMap().get(name);
+ values = baseGetParameterMap().get(name);
}
}
- if (values != null && values.length > 0)
+ if (values != null && values.length > 0)
{
return values[0];
- }
- else
+ }
+ else
{
return null;
}
}
- public Enumeration<String> getParameterNames()
+ public Enumeration<String> getParameterNames()
{
return Collections.enumeration(baseGetParameterMap().keySet());
}
- public String[] getParameterValues(String name)
+ public String[] getParameterValues(String name)
{
ArgumentUtility.validateNotNull("parameterName", name);
String[] values = null;
@@ -531,41 +528,41 @@
values = parameters.get(name);
}
else
- {
- List<String> publicRenderParameterNames = portletWindow.getPortletEntity().getPortletDefinition().getSupportedPublicRenderParameters();
+ {
+ List<String> publicRenderParameterNames = portletWindow.getPortletEntity().getPortletDefinition().getSupportedPublicRenderParameters();
if (publicRenderParameterNames != null)
{
if (publicRenderParameterNames.contains(name))
values = urlProvider.getPublicRenderParameters(name);
else
- values = (String[]) baseGetParameterMap().get(name);
+ values = baseGetParameterMap().get(name);
}
else
{
- values = (String[]) baseGetParameterMap().get(name);
+ values = baseGetParameterMap().get(name);
}
}
- if (values != null)
+ if (values != null)
{
- values = StringUtils.copy(values);
+ values = values.clone();
}
return values;
}
-
- public Map<String, String[]> getParameterMap()
+
+ public Map<String, String[]> getParameterMap()
{
if (parameters != null)
{
return parameters;
}
else
- {
+ {
String[] values = null;
Map<String, String[]>map = StringUtils.copyParameters(baseGetParameterMap());
List<String> publicRenderParameterNames = portletWindow.getPortletEntity().getPortletDefinition().getSupportedPublicRenderParameters();
if (publicRenderParameterNames!=null)
{
- for (String string : publicRenderParameterNames)
+ for (String string : publicRenderParameterNames)
{
values = urlProvider.getPublicRenderParameters(string);
if (values != null)
@@ -575,16 +572,16 @@
}
}
parameters = Collections.unmodifiableMap(map);
- return parameters;
+ return parameters;
}
}
- public boolean isSecure()
+ public boolean isSecure()
{
return this.getHttpServletRequest().isSecure();
}
- public void setAttribute(String name, Object value)
+ public void setAttribute(String name, Object value)
{
ArgumentUtility.validateNotNull("attributeName", name);
final OptionalContainerServices optionalContainerServices = container.getOptionalContainerServices();
@@ -592,52 +589,52 @@
requestAttributeService.setAttribute(this, this.getHttpServletRequest(), this.portletWindow, name, value);
}
- public void removeAttribute(String name)
+ public void removeAttribute(String name)
{
ArgumentUtility.validateNotNull("attributeName", name);
-
+
final OptionalContainerServices optionalContainerServices = container.getOptionalContainerServices();
final RequestAttributeService requestAttributeService = optionalContainerServices.getRequestAttributeService();
requestAttributeService.removeAttribute(this, this.getHttpServletRequest(), this.portletWindow, name);
}
- public String getRequestedSessionId()
+ public String getRequestedSessionId()
{
return this.getHttpServletRequest().getRequestedSessionId();
}
- public boolean isRequestedSessionIdValid()
+ public boolean isRequestedSessionIdValid()
{
- if (LOG.isDebugEnabled())
+ if (LOG.isDebugEnabled())
{
LOG.debug(" ***** IsRequestedSessionIdValid? "+getHttpServletRequest().isRequestedSessionIdValid());
}
return getHttpServletRequest().isRequestedSessionIdValid();
}
- public String getResponseContentType()
+ public String getResponseContentType()
{
Enumeration<String> enumeration = getResponseContentTypes();
- while (enumeration.hasMoreElements())
+ while (enumeration.hasMoreElements())
{
- return (String) enumeration.nextElement();
+ return enumeration.nextElement();
}
return "text/html";
}
- public Enumeration<String> getResponseContentTypes()
+ public Enumeration<String> getResponseContentTypes()
{
- if (contentTypes == null)
+ if (contentTypes == null)
{
contentTypes = new Vector<String>();
PortletDefinition dd = portletWindow.getPortletEntity().getPortletDefinition();
Iterator supports = dd.getSupports().iterator();
- while (supports.hasNext())
+ while (supports.hasNext())
{
Supports sup = (Supports) supports.next();
contentTypes.add(sup.getMimeType());
}
- if (contentTypes.size() < 1)
+ if (contentTypes.size() < 1)
{
contentTypes.add("text/html");
}
@@ -645,58 +642,58 @@
return contentTypes.elements();
}
- public Locale getLocale()
+ public Locale getLocale()
{
return this.getHttpServletRequest().getLocale();
}
@SuppressWarnings("unchecked")
- public Enumeration<Locale> getLocales()
+ public Enumeration<Locale> getLocales()
{
return this.getHttpServletRequest().getLocales();
}
- public String getScheme()
+ public String getScheme()
{
return this.getHttpServletRequest().getScheme();
}
- public String getServerName()
+ public String getServerName()
{
return this.getHttpServletRequest().getServerName();
}
- public int getServerPort()
+ public int getServerPort()
{
return this.getHttpServletRequest().getServerPort();
}
-
-
+
+
// Protected Methods -------------------------------------------------------
-
- protected void setBodyAccessed()
+
+ protected void setBodyAccessed()
{
bodyAccessed = true;
}
-
+
// InternalPortletRequest Impl ---------------------------------------------
- public PortletWindow getPortletWindow()
+ public PortletWindow getPortletWindow()
{
return portletWindow;
}
- public PortletContainer getPortletContainer()
+ public PortletContainer getPortletContainer()
{
return container;
}
- public HttpServletRequest getHttpServletRequest()
+ public HttpServletRequest getHttpServletRequest()
{
return (HttpServletRequest) super.getRequest();
}
-
- public void init(InternalPortletContext portletContext, HttpServletRequest req)
+
+ public void init(InternalPortletContext portletContext, HttpServletRequest req)
{
this.portletContext = portletContext;
setRequest(req);
@@ -704,9 +701,9 @@
setLifecyclePhase();
}
- public PortletPreferences getPreferences()
+ public PortletPreferences getPreferences()
{
- if (portletPreferences == null)
+ if (portletPreferences == null)
{
portletPreferences = new PortletPreferencesImpl(
getPortletContainer(),
@@ -716,20 +713,20 @@
}
return portletPreferences;
}
-
+
/**
* TODO: Implement this properly. Not required now
*/
- public void release()
+ public void release()
{
// FIXME: This needs to be implemented
}
-
-
+
+
// TODO: Additional Methods of HttpServletRequestWrapper -------------------
-
+
public BufferedReader getReader()
- throws UnsupportedEncodingException, IOException
+ throws UnsupportedEncodingException, IOException
{
// the super class will ensure that a IllegalStateException is thrown
// if getInputStream() was called earlier
@@ -737,36 +734,36 @@
bodyAccessed = true;
return reader;
}
-
- public ServletInputStream getInputStream() throws IOException
+
+ public ServletInputStream getInputStream() throws IOException
{
ServletInputStream stream = getHttpServletRequest().getInputStream();
bodyAccessed = true;
return stream;
}
- public RequestDispatcher getRequestDispatcher(String path)
+ public RequestDispatcher getRequestDispatcher(String path)
{
return new ServletRequestDispatcher(getHttpServletRequest().getRequestDispatcher(path));
}
-
+
/**
* TODO: why check bodyAccessed?
*/
public void setCharacterEncoding(String encoding)
- throws UnsupportedEncodingException
+ throws UnsupportedEncodingException
{
- if (bodyAccessed)
+ if (bodyAccessed)
{
throw new IllegalStateException("Cannot set character encoding "
+ "after HTTP body is accessed.");
}
super.setCharacterEncoding(encoding);
}
-
+
// Private Methods ---------------------------------------------------------
-
- private boolean isPortletModeAllowedByPortlet(PortletMode mode)
+
+ private boolean isPortletModeAllowedByPortlet(PortletMode mode)
{
if(PortletMode.VIEW.equals(mode))
{
@@ -777,13 +774,13 @@
.getPortletDefinition();
Iterator mimes = dd.getSupports().iterator();
- while (mimes.hasNext())
+ while (mimes.hasNext())
{
Iterator modes = ((Supports) mimes.next()).getPortletModes().iterator();
- while (modes.hasNext())
+ while (modes.hasNext())
{
String m = (String) modes.next();
- if (m.equalsIgnoreCase(mode.toString()))
+ if (m.equalsIgnoreCase(mode.toString()))
{
return true;
}
@@ -792,13 +789,13 @@
return false;
}
- private boolean isPortletModeAllowedByPortal(PortletMode mode)
+ private boolean isPortletModeAllowedByPortal(PortletMode mode)
{
Enumeration supportedModes = portalContext.getSupportedPortletModes();
- while (supportedModes.hasMoreElements())
+ while (supportedModes.hasMoreElements())
{
if (supportedModes.nextElement().toString().equalsIgnoreCase(
- (mode.toString())))
+ (mode.toString())))
{
return true;
}
@@ -812,8 +809,8 @@
{
return super.getMethod();
}
-
-
+
+
public boolean isForwarded()
{
return forwarded;
@@ -845,7 +842,7 @@
{
return included;
}
-
+
/**
* The base method that returns the parameter map in this portlet request.
* All parameter-related methods call this base method. Subclasses may just
@@ -853,8 +850,8 @@
* related methods.
* @return the base parameter map from which parameters are retrieved.
*/
- protected Map<String, String[]> baseGetParameterMap()
- {
+ protected Map<String, String[]> baseGetParameterMap()
+ {
if (isIncluded())
{
setBodyAccessed();
@@ -864,24 +861,24 @@
{
if (getRequestMethod().equals(Constants.METHOD_RENDER) || getRequestMethod().equals(Constants.METHOD_EVENT))
{
- parameters = urlProvider.parseRenderParameters(this.getHttpServletRequest().getParameterMap(), queryString);
+ parameters = urlProvider.parseRenderParameters(this.getHttpServletRequest().getParameterMap(), queryString);
queryString = null;
}
else
{
- parameters = urlProvider.parseRenderParameters(this.getHttpServletRequest().getParameterMap(), null);
+ parameters = urlProvider.parseRenderParameters(this.getHttpServletRequest().getParameterMap(), null);
}
}
return parameters;
}
-
+
public void setForwardedQueryString(String queryString)
{
- if (!forwarded)
- {
+ if (!forwarded)
+ {
throw new IllegalStateException(
"Parameters cannot be appended to "
- + "render request which is not included in a dispatch.");
+ + "render request which is not included in a dispatch.");
}
this.parameters = null;
this.queryString = queryString;
@@ -892,15 +889,15 @@
public void setIncludedQueryString(String queryString)
throws IllegalStateException
{
- if (!included)
- {
+ if (!included)
+ {
throw new IllegalStateException(
"Parameters cannot be appended to "
- + "render request which is not included in a dispatch.");
+ + "render request which is not included in a dispatch.");
}
this.parameters = null;
this.queryString = queryString;
-// this.urlProvider.parseRenderParameters(super.getParameterMap(), queryString);
+// this.urlProvider.parseRenderParameters(super.getParameterMap(), queryString);
this.urlProvider.parseRenderParameters(null,null);
}
@@ -1188,7 +1185,7 @@
Long dateValue = null;
try
{
- dateValue = (Long) dateHeaderParseCache.get(value);
+ dateValue = dateHeaderParseCache.get(value);
}
catch (Exception e)
{
@@ -1265,5 +1262,5 @@
{
dispatcher.include(arg0, arg1);
}
-
+
}
Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java?rev=749240&r1=749239&r2=749240&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java Mon Mar 2 08:56:21 2009
@@ -21,7 +21,6 @@
import javax.portlet.ResourceRequest;
import javax.servlet.ServletInputStream;
-import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
@@ -30,17 +29,16 @@
import org.apache.pluto.PortletContainer;
import org.apache.pluto.PortletWindow;
import org.apache.pluto.internal.InternalResourceRequest;
-import org.apache.pluto.util.StringUtils;
public class ResourceRequestImpl extends ClientDataRequestImpl
implements ResourceRequest, InternalResourceRequest {
/** Logger. */
private static final Log LOG = LogFactory.getLog(ResourceRequestImpl.class);
-
-
+
+
// Constructor -------------------------------------------------------------
-
+
public ResourceRequestImpl(PortletContainer container,
PortletWindow portletWindow,
HttpServletRequest servletRequest) {
@@ -54,18 +52,18 @@
protected Integer getRequestMethod()
{
- return Constants.METHOD_RESOURCE;
+ return Constants.METHOD_RESOURCE;
}
-
+
public String getResponseContentType(){
return super.getResponseContentType();
}
-
+
@SuppressWarnings("unchecked")
public java.util.Enumeration getResponseContentTypes(){
return super.getResponseContentTypes();
}
-
+
public String[] getParameterValues(String name) {
String values1[] = super.getParameterValues(name);
String values2[] = urlProvider.getPrivateRenderParameters(name);
@@ -82,7 +80,7 @@
else if (length1>0){
values = new String[length1];
}
-
+
if (length1>0){
System.arraycopy(values1, 0, values, 0, length1);
}
@@ -90,11 +88,11 @@
values = null;
}
if (values != null) {
- values = StringUtils.copy(values);
+ values = values.clone();
}
return values;
}
-
+
public String getParameter(String name) {
String value = super.getParameter(name);
if (value == null){
@@ -107,15 +105,15 @@
}
return value;
}
-
+
// PortletRequestImpl impl -------------------------------------------------
-
+
public String getETag() {
// TODO: get ETag
return null;
}
- public String getLifecyclePhase()
+ public String getLifecyclePhase()
{
return RESOURCE_PHASE;
}
@@ -123,7 +121,7 @@
public String getResourceID() {
return getParameter("resourceID");
}
-
+
public ServletInputStream getInputStream() throws IOException {
return (super.isIncluded() || super.isForwarded()) ? (ServletInputStream)getPortletInputStream() : super.getInputStream();
}
Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/StateAwareResponseImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/StateAwareResponseImpl.java?rev=749240&r1=749239&r2=749240&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/StateAwareResponseImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/StateAwareResponseImpl.java Mon Mar 2 08:56:21 2009
@@ -50,7 +50,6 @@
import org.apache.pluto.spi.ResourceURLProvider;
import org.apache.pluto.util.DummyPrintWriter;
import org.apache.pluto.util.DummyServletOutputStream;
-import org.apache.pluto.util.StringUtils;
/**
* Implementation of JSR-286 <code>StateAwareResponse</code>.
@@ -59,24 +58,24 @@
*/
public class StateAwareResponseImpl extends PortletResponseImpl implements
StateAwareResponse {
-
+
/** Logger. */
private static final Log LOG = LogFactory.getLog(StateAwareResponseImpl.class);
boolean redirectAllowed = true;
protected boolean redirected;
private String redirectLocation;
-
+
private Map<String, String[]> publicRenderParameter = new HashMap<String, String[]>();
-
+
private Map<String, String[]> renderParameters = new HashMap<String, String[]>();
private WindowState windowState = null;
private PortletMode portletMode = null;
protected PortalCallbackService callback;
private PortalContext context;
private EventRequest eventRequest;
-
+
public StateAwareResponseImpl(PortletContainer container,
PortletWindow portletWindow,
HttpServletRequest servletRequest,
@@ -86,7 +85,7 @@
context = container.getRequiredContainerServices().getPortalContext();
callback = container.getRequiredContainerServices().getPortalCallbackService();
}
-
+
/* (non-Javadoc)
* @see javax.portlet.StateAwareResponse#setEvent(javax.xml.namespace.QName, java.lang.Object)
*/
@@ -94,10 +93,10 @@
if (qname == null) {
throw new IllegalArgumentException();
}
-
+
EventProvider provider = callback.getEventProvider(
getHttpServletRequest(),getPortletWindow());
-
+
provider.registerToFireEvent(qname, value);
redirectAllowed = false;
}
@@ -150,7 +149,7 @@
}
}
-
+
public String getRedirectLocation() {
return redirectLocation;
@@ -173,7 +172,7 @@
}
redirectAllowed = false;
}
-
+
public void setPortletMode(PortletMode portletMode)
throws PortletModeException {
if (redirected) {
@@ -196,7 +195,7 @@
redirectAllowed = false;
}
-
+
public void setRenderParameters(java.util.Map<String, String[]> parameters) {
if (redirected) {
throw new IllegalStateException(
@@ -217,18 +216,18 @@
"Value must not be null and of type java.lang.String[].");
}
}
-
+
renderParameters.clear();
publicRenderParameter.clear();
if (parameters.keySet()!= null){
for (Object key : parameters.keySet()) {
- this.setRenderParameter((String)key, (String[])parameters.get(key));
+ this.setRenderParameter((String)key, parameters.get(key));
}
}
-
+
redirectAllowed = false;
}
-
+
public void setRenderParameter(String key, String value) {
if (redirected) {
throw new IllegalStateException(
@@ -253,13 +252,13 @@
}
redirectAllowed = false;
}
-
+
public void setRenderParameter(String key, String[] values) {
if (redirected) {
throw new IllegalStateException(
"Can't invoke setRenderParameter() after sendRedirect() has been called");
- }
-
+ }
+
if (key == null || values == null) {
throw new IllegalArgumentException(
"name and values must not be null or values be an empty array");
@@ -267,27 +266,27 @@
List<String> publicRenderParameterNames = super.getPortletWindow().getPortletEntity().getPortletDefinition().getSupportedPublicRenderParameters();
if (publicRenderParameterNames != null){
if (publicRenderParameterNames.contains(key)){
- publicRenderParameter.put(key,StringUtils.copy(values));
+ publicRenderParameter.put(key, values.clone());
}
else{
- renderParameters.put(key, StringUtils.copy(values));
+ renderParameters.put(key, values.clone());
}
}
else{
- renderParameters.put(key, StringUtils.copy(values));
+ renderParameters.put(key, values.clone());
}
}
// --------------------------------------------------------------------------------------------
-
+
// org.apache.pluto.core.InternalActionResponse implementation --------------------------------
public Map getRenderParameters() {
return renderParameters;
}
-
+
public Map<String, String[]> getRenderParameterMap() {
return renderParameters;
}
-
+
public Map<String, String[]> getPublicRenderParameter(){
return publicRenderParameter;
}
@@ -295,7 +294,7 @@
public PortletMode getChangedPortletMode() {
return this.portletMode;
}
-
+
public PortletMode getPortletMode() {
return getChangedPortletMode();
}
@@ -303,23 +302,23 @@
public WindowState getChangedWindowState() {
return this.windowState;
}
-
+
public WindowState getWindowState() {
return getChangedWindowState();
}
-
+
protected boolean isPortletModeAllowed(PortletMode mode) {
return isPortletModeAllowedByPortlet(mode)
&& isPortletModeAllowedByPortal(mode);
}
protected boolean isPortletModeAllowedByPortlet(PortletMode mode) {
-
+
//Not checking for VIEW mode in portetlDefinition, as VIEW mode is default
// as per specs.
if(PortletMode.VIEW.equals(mode))
return true;
-
+
PortletDefinition dd = getPortletWindow().getPortletEntity()
.getPortletDefinition();
@@ -360,9 +359,9 @@
}
return false;
}
-
+
// access to a limited set of HttpServletResponse methods ------------------
-
+
@Override
public void reset() {
if (super.isForwarded() || super.isIncluded()){
@@ -594,5 +593,5 @@
public void setEventRequest(EventRequest eventRequest) {
this.eventRequest = eventRequest;
}
-
+
}
Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java?rev=749240&r1=749239&r2=749240&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/util/StringUtils.java Mon Mar 2 08:56:21 2009
@@ -37,21 +37,6 @@
// Static Utility Methods --------------------------------------------------
/**
- * TODO: can't we just use String[].clone()?
- * @param source
- * @return The copied array
- */
- public static String[] copy(String[] source) {
- if (source == null) {
- return null;
- }
- int length = source.length;
- String[] result = new String[length];
- System.arraycopy(source, 0, result, 0, length);
- return result;
- }
-
- /**
* Deep-clones a parameter map. The key is the parameter name as a String
* instance, while the value is a String array (String[]) instance.
* @param parameters the parameter map to deep-clone.
@@ -60,7 +45,7 @@
public static Map<String, String[]> copyParameters(Map<String, String[]> parameters) {
final Map<String, String[]> result = new HashMap<String, String[]>(parameters);
for( final Map.Entry<String, String[]> entry : result.entrySet()) {
- entry.setValue(copy(entry.getValue()));
+ entry.setValue(entry.getValue().clone());
}
return result;
}
Modified: portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/util/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/util/StringUtilsTest.java?rev=749240&r1=749239&r2=749240&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/util/StringUtilsTest.java (original)
+++ portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/util/StringUtilsTest.java Mon Mar 2 08:56:21 2009
@@ -27,14 +27,6 @@
*/
public class StringUtilsTest extends PlutoTestCase {
- public void testCopy() {
- String[] original = new String[] {"one", "two", "three", "four", "five"};
- String[] results = StringUtils.copy(original);
- for(int i=0;i<original.length;i++) {
- assertEquals(original[i], results[i]);
- }
- }
-
public void testCopyMap() {
Map original = new java.util.HashMap();
original.put("one", new String[] { "two"});
Modified: portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLImpl.java?rev=749240&r1=749239&r2=749240&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLImpl.java (original)
+++ portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/PortalURLImpl.java Mon Mar 2 08:56:21 2009
@@ -33,7 +33,6 @@
import org.apache.pluto.driver.services.portal.PageConfig;
import org.apache.pluto.driver.url.PortalURL;
import org.apache.pluto.driver.url.PortalURLParameter;
-import org.apache.pluto.util.StringUtils;
/**
* The portal URL.
@@ -163,7 +162,7 @@
values[i+1] = tmp[i];
}
publicParameterCurrent.remove(parameterName);
- publicParameterCurrent.put(parameterName, StringUtils.copy(values));
+ publicParameterCurrent.put(parameterName, values.clone());
}
else
publicParameterCurrent.put(parameterName, new String[]{value});
Modified: portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java?rev=749240&r1=749239&r2=749240&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java (original)
+++ portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/url/impl/RelativePortalURLImpl.java Mon Mar 2 08:56:21 2009
@@ -34,7 +34,6 @@
import org.apache.pluto.driver.url.PortalURL;
import org.apache.pluto.driver.url.PortalURLParameter;
import org.apache.pluto.driver.url.PortalURLParser;
-import org.apache.pluto.util.StringUtils;
/**
* The portal URL.
@@ -249,7 +248,7 @@
values[i+1] = tmp[i];
}
publicParameterCurrent.remove(parameterName);
- publicParameterCurrent.put(parameterName, StringUtils.copy(values));
+ publicParameterCurrent.put(parameterName, values.clone());
}
else
publicParameterCurrent.put(parameterName, new String[]{value});