JBoss Portal SVN: r9610 - in modules/portlet/trunk/portlet/src: main/java/org/jboss/portal/portlet/cache and 7 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-25 14:59:07 -0500 (Fri, 25 Jan 2008)
New Revision: 9610
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/ContentRef.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftContentRef.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongContentRef.java
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftTimedContent.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongTimedContent.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/TimedContent.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheControl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/CacheControlImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractPortletInvocationContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractRenderContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/RenderInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/RenderContextSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java
Log:
started to implement cache etag and cache control interface
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -25,8 +25,8 @@
import org.jboss.portal.portlet.invocation.PortletInterceptor;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.response.cache.TimedContent;
-import org.jboss.portal.portlet.invocation.response.cache.StrongTimedContent;
+import org.jboss.portal.portlet.invocation.response.cache.ContentRef;
+import org.jboss.portal.portlet.invocation.response.cache.StrongContentRef;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.StateString;
@@ -72,65 +72,61 @@
CacheEntry cachedEntry = (CacheEntry)resolver.getAttribute(scopeKey);
//
- FragmentResponse fragment = null;
if (cachedEntry != null)
{
- long currentTimeMillis = System.currentTimeMillis();
-
// Check time validity for fragment
boolean useEntry = false;
- if (currentTimeMillis < cachedEntry.getExpirationTimeMillis())
- {
- StateString entryNavState = cachedEntry.getNavigationalState();
+ StateString entryNavState = cachedEntry.navigationalState;
- // Then check nav state equality
- if (navState == null)
+ // Then check nav state equality
+ if (navState == null)
+ {
+ if (entryNavState == null)
{
- if (entryNavState == null)
- {
- useEntry = true;
- }
- else if (entryNavState instanceof ParametersStateString)
- {
- // We consider a parameters state string empty equivalent to a null value
- useEntry = ((ParametersStateString)entryNavState).getSize() == 0;
- }
+ useEntry = true;
}
- else if (entryNavState == null)
+ else if (entryNavState instanceof ParametersStateString)
{
- if (navState instanceof ParametersStateString)
- {
- useEntry = ((ParametersStateString)navState).getSize() == 0;
- }
+ // We consider a parameters state string empty equivalent to a null value
+ useEntry = ((ParametersStateString)entryNavState).getSize() == 0;
}
- else
+ }
+ else if (entryNavState == null)
+ {
+ if (navState instanceof ParametersStateString)
{
- useEntry = navState.equals(entryNavState);
+ useEntry = ((ParametersStateString)navState).getSize() == 0;
}
-
- // Then check window state equality
- useEntry &= windowState.equals(cachedEntry.getWindowState());
-
- // Then check mode equality
- useEntry &= mode.equals(cachedEntry.getMode());
}
-
- // Use the entry
- if (useEntry)
+ else
{
- fragment = cachedEntry.getContent();
+ useEntry = navState.equals(entryNavState);
}
+ // Then check window state equality
+ useEntry &= windowState.equals(cachedEntry.windowState);
+
+ // Then check mode equality
+ useEntry &= mode.equals(cachedEntry.mode);
+
// Clean if it is null
- if (fragment == null)
+ if (!useEntry)
{
+ cachedEntry = null;
resolver.setAttribute(scopeKey, null);
}
}
- // If no fragment we must invoke
- if (fragment == null)
+ FragmentResponse fragment = cachedEntry != null ? cachedEntry.contentRef.getContent() : null;
+
+ // If no valid fragment we must invoke
+ if (fragment == null || cachedEntry.expirationTimeMillis < System.currentTimeMillis())
{
+ RenderInvocation render = (RenderInvocation)invocation;
+
+ // Set validation token for revalidation if any
+ render.setValidationToken(cachedEntry != null ? cachedEntry.validationToken : null);
+
// Invoke
PortletInvocationResponse response = (PortletInvocationResponse)invocation.invokeNext();
@@ -159,7 +155,7 @@
// Cache if we can
if (expirationTimeMillis > 0)
{
- CacheEntry cacheEntry = new CacheEntry(navState, windowState, mode, renderResult, expirationTimeMillis);
+ CacheEntry cacheEntry = new CacheEntry(navState, windowState, mode, renderResult, expirationTimeMillis, control.getValidationToken());
resolver.setAttribute(scopeKey, cacheEntry);
}
}
@@ -187,27 +183,34 @@
/**
* Encapsulate cache information.
*/
- public static class CacheEntry implements Serializable
+ private static class CacheEntry implements Serializable
{
/** The entry navigational state. */
private final StateString navigationalState;
/** . */
- private WindowState windowState;
+ private final WindowState windowState;
/** . */
- private Mode mode;
+ private final Mode mode;
/** The timed content. */
- private final TimedContent cachedResult;
+ private final ContentRef contentRef;
+ /** . */
+ private final long expirationTimeMillis;
+
+ /** . */
+ private final String validationToken;
+
public CacheEntry(
StateString navigationalState,
WindowState windowState,
Mode mode,
- FragmentResponse result,
- long expirationTimeMillis)
+ FragmentResponse content,
+ long expirationTimeMillis,
+ String validationToken)
{
if (expirationTimeMillis <= 0)
{
@@ -216,32 +219,9 @@
this.navigationalState = navigationalState;
this.windowState = windowState;
this.mode = mode;
- this.cachedResult = new StrongTimedContent(result, expirationTimeMillis);
+ this.contentRef = new StrongContentRef(content);
+ this.expirationTimeMillis = expirationTimeMillis;
+ this.validationToken = validationToken;
}
-
- public StateString getNavigationalState()
- {
- return navigationalState;
- }
-
- public WindowState getWindowState()
- {
- return windowState;
- }
-
- public Mode getMode()
- {
- return mode;
- }
-
- public long getExpirationTimeMillis()
- {
- return cachedResult.getExpirationTimeMillis();
- }
-
- public FragmentResponse getContent()
- {
- return cachedResult.getContent();
- }
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheControl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheControl.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheControl.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -36,13 +36,13 @@
private CacheScope cacheScope;
/** The validation token. */
- private String token;
+ private String validationToken;
- public CacheControl(int expirationSecs, CacheScope cacheScope, String token)
+ public CacheControl(int expirationSecs, CacheScope cacheScope, String validationToken)
{
this.expirationSecs = expirationSecs;
this.cacheScope = cacheScope;
- this.token = token;
+ this.validationToken = validationToken;
}
public int getExpirationSecs()
@@ -65,26 +65,26 @@
this.cacheScope = cacheScope;
}
- public String getToken()
+ public String getValidationToken()
{
- return token;
+ return validationToken;
}
- public void setToken(String token)
+ public void setValidationToken(String validationToken)
{
- this.token = token;
+ this.validationToken = validationToken;
}
public CacheControl unmodifiable()
{
- return new CacheControl(expirationSecs, cacheScope, token)
+ return new CacheControl(expirationSecs, cacheScope, validationToken)
{
public void setCacheScope(CacheScope cacheScope)
{
throw new UnsupportedOperationException("Not modifiable");
}
- public void setToken(String token)
+ public void setValidationToken(String token)
{
throw new UnsupportedOperationException("Not modifiable");
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/CacheControlImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/CacheControlImpl.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/CacheControlImpl.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -66,12 +66,12 @@
public String getETag()
{
- return delegate.getToken();
+ return delegate.getValidationToken();
}
public void setETag(String etag)
{
- delegate.setToken(etag);
+ delegate.setValidationToken(etag);
}
public boolean useCachedContent()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -215,27 +215,32 @@
{
if (MimeResponse.EXPIRATION_CACHE.equals(key))
{
- if (value == null)
+ if (value != null)
{
- return;
- }
-
- //
- try
- {
- int expirationSecs = Integer.parseInt(value);
- fragment.getCacheControl().setExpirationSecs(expirationSecs);
- }
- catch (NumberFormatException e)
- {
- // todo: Make the portlet log instead
+ try
+ {
+ int expirationSecs = Integer.parseInt(value);
+ fragment.getCacheControl().setExpirationSecs(expirationSecs);
+ }
+ catch (NumberFormatException e)
+ {
+ // todo: Make the portlet log instead
// log.warn("Portlet " + invocation.getTarget() +
// " set a non integer cache value override during render " + value, e);
+ }
}
}
-
- //
- super.addProperty(key, value);
+ else if (MimeResponse.ETAG.equals(key))
+ {
+ if (value != null)
+ {
+ fragment.getCacheControl().setValidationToken(value);
+ }
+ }
+ else
+ {
+ super.addProperty(key, value);
+ }
}
public CacheControl getCacheControl()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -25,6 +25,8 @@
import org.apache.log4j.Logger;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.util.MultiValuedPropertyMap;
+import org.jboss.portal.common.util.SimpleMultiValuedPropertyMap;
import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.portlet.container.PortletContainerInvoker;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
@@ -91,6 +93,9 @@
protected ContainerNavigationInfo navigationInfo;
/** . */
+ private MultiValuedPropertyMap<String> properties;
+
+ /** . */
protected final PortletRequestAttributes attributes;
/** . */
@@ -221,17 +226,7 @@
}
//
- List<String> properties = clientContext.getProperties(name);
-
- //
- if (properties == null || properties.size() == 0)
- {
- return null;
- }
- else
- {
- return properties.get(0);
- }
+ return getProperties().getValue(name);
}
public Enumeration<String> getProperties(String name)
@@ -242,7 +237,7 @@
}
//
- List<String> properties = clientContext.getProperties(name);
+ List<String> properties = getProperties().getValues(name);
//
if (properties == null)
@@ -257,7 +252,7 @@
public Enumeration<String> getPropertyNames()
{
- Set<String> names = clientContext.getPropertyNames();
+ Set<String> names = getProperties().keySet();
//
return Collections.enumeration(names);
@@ -506,4 +501,24 @@
return Collections.emptyMap();
}
}
+
+ private MultiValuedPropertyMap<String> getProperties()
+ {
+ if (properties == null)
+ {
+ SimpleMultiValuedPropertyMap<String> properties = new SimpleMultiValuedPropertyMap<String>();
+ properties.append(clientContext.getProperties());
+ initProperties(properties);
+
+ //
+ this.properties = properties;
+ }
+
+ //
+ return properties;
+ }
+
+ protected void initProperties(MultiValuedPropertyMap<String> properties)
+ {
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -24,6 +24,7 @@
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.util.MultiValuedPropertyMap;
import javax.portlet.RenderRequest;
@@ -35,13 +36,27 @@
public class RenderRequestImpl extends PortletRequestImpl implements RenderRequest
{
+ /** . */
+ private final String validationToken;
+
public RenderRequestImpl(RenderInvocation invocation)
{
super(invocation);
+
+ //
+ this.validationToken = invocation.getValidationToken();
}
public String getETag()
{
- throw new NotYetImplemented();
+ return validationToken;
}
+
+ protected void initProperties(MultiValuedPropertyMap<String> properties)
+ {
+ if (validationToken != null)
+ {
+ properties.setValue(ETAG, validationToken);
+ }
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -25,6 +25,7 @@
import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.spi.ResourceInvocationContext;
import org.jboss.portal.portlet.impl.jsr168.ResourceRequestParameterMap;
+import org.jboss.portal.common.util.MultiValuedPropertyMap;
import javax.portlet.ResourceRequest;
import java.util.Map;
@@ -39,19 +40,18 @@
/** . */
private final ResourceInvocationContext resourceContext;
+ /** . */
+ private final String validationToken;
+
public ResourceRequestImpl(ResourceInvocation invocation)
{
super(invocation);
//
this.resourceContext = invocation.getContext();
+ this.validationToken = invocation.getValidationToken();
}
- public String getETag()
- {
- throw new UnsupportedOperationException();
- }
-
public String getResourceID()
{
return resourceContext.getResourceId();
@@ -64,6 +64,19 @@
public String getCacheability()
{
- return ResourceURLImpl.toJSR168(resourceContext.getCacheability());
+ return ResourceURLImpl.toJSR168(resourceContext.getCacheLevel());
}
+
+ public String getETag()
+ {
+ return validationToken;
+ }
+
+ protected void initProperties(MultiValuedPropertyMap<String> properties)
+ {
+ if (validationToken != null)
+ {
+ properties.setValue(ETAG, validationToken);
+ }
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -44,7 +44,7 @@
super(invocation, preq);
//
- this.cacheability = invocation.getContext().getCacheability();
+ this.cacheability = invocation.getContext().getCacheLevel();
}
public void setLocale(Locale locale)
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -78,7 +78,7 @@
//
if (invocation instanceof ResourceInvocation)
{
- url.parentCacheLevel = ((ResourceInvocation)invocation).getContext().getCacheability();
+ url.parentCacheLevel = ((ResourceInvocation)invocation).getContext().getCacheLevel();
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractClientContext.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -23,17 +23,15 @@
package org.jboss.portal.portlet.impl.spi;
import org.jboss.portal.portlet.spi.ClientContext;
+import org.jboss.portal.common.util.MultiValuedPropertyMap;
+import org.jboss.portal.common.util.SimpleMultiValuedPropertyMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.Cookie;
import java.util.List;
-import java.util.Set;
-import java.util.Map;
-import java.util.HashMap;
import java.util.Enumeration;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Arrays;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -49,7 +47,7 @@
private final String method;
/** . */
- private final Map<String, List<String>> headers;
+ private final MultiValuedPropertyMap<String> headers;
/** . */
private final List<Cookie> cookies;
@@ -61,31 +59,14 @@
public AbstractClientContext(HttpServletRequest request, List<Cookie> additionalCookies)
{
- Map<String, List<String>> headers = new HashMap<String, List<String>>();
+ MultiValuedPropertyMap<String> headers = new SimpleMultiValuedPropertyMap<String>();
for (Enumeration e = request.getHeaderNames();e.hasMoreElements();)
{
String headerName = (String)e.nextElement();
- Enumeration f = request.getHeaders(headerName);
- if (f.hasMoreElements())
+ for (Enumeration f = request.getHeaders(headerName);f.hasMoreElements();)
{
- List<String> headerValues;
String headerValue = (String)f.nextElement();
- if (f.hasMoreElements())
- {
- headerValues = new ArrayList<String>(4);
- headerValues.add(headerValue);
- headerValues.add((String)f.nextElement());
- while (f.hasMoreElements())
- {
- headerValue = (String)f.nextElement();
- headerValues.add(headerValue);
- }
- }
- else
- {
- headerValues = Collections.singletonList(headerValue);
- }
- headers.put(headerName, headerValues);
+ headers.addValue(headerName, headerValue);
}
}
@@ -123,20 +104,11 @@
return method;
}
- public List<String> getProperties(String name)
+ public MultiValuedPropertyMap<String> getProperties()
{
- if (name == null)
- {
- throw new IllegalArgumentException("No null name accepted");
- }
- return headers.get(name);
+ return headers;
}
- public Set<String> getPropertyNames()
- {
- return headers.keySet();
- }
-
public List<Cookie> getCookies()
{
return cookies;
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractPortletInvocationContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractPortletInvocationContext.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractPortletInvocationContext.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -43,19 +43,19 @@
{
/** . */
- protected MarkupInfo markupInfo;
+ protected final MarkupInfo markupInfo;
/** . */
- protected Mode mode;
+ protected final Mode mode;
/** . */
- protected WindowState windowState;
+ protected final WindowState windowState;
/** . */
- protected StateString navigationalState;
+ protected final StateString navigationalState;
/** . */
- protected ParameterMap publicNavigationalState;
+ protected final ParameterMap publicNavigationalState;
protected AbstractPortletInvocationContext(
Mode mode,
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractRenderContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractRenderContext.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractRenderContext.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -35,6 +35,7 @@
*/
public abstract class AbstractRenderContext extends AbstractPortletInvocationContext implements RenderContext
{
+
protected AbstractRenderContext(
Mode mode,
WindowState windowState,
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -38,16 +38,16 @@
{
/** . */
- private final String resourceId;
+ protected final String resourceId;
/** . */
- private final CacheLevel cacheLevel;
+ protected final StateString resourceState;
/** . */
- private final StateString resourceState;
+ protected final ParameterMap form;
/** . */
- private final ParameterMap form;
+ protected final CacheLevel cacheLevel;
public AbstractResourceContext(
String resourceId,
@@ -64,9 +64,9 @@
//
this.resourceId = resourceId;
- this.cacheLevel = cacheLevel;
this.resourceState = resourceState;
this.form = form;
+ this.cacheLevel = cacheLevel;
}
public String getResourceId()
@@ -74,11 +74,6 @@
return resourceId;
}
- public CacheLevel getCacheability()
- {
- return cacheLevel;
- }
-
public StateString getResourceState()
{
return resourceState;
@@ -88,4 +83,9 @@
{
return form;
}
+
+ public CacheLevel getCacheLevel()
+ {
+ return cacheLevel;
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/RenderInvocation.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/RenderInvocation.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/RenderInvocation.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -34,6 +34,9 @@
/** . */
private final RenderContext ctx;
+ /** . */
+ private String validationToken;
+
public RenderInvocation(RenderContext ctx) throws IllegalArgumentException
{
super(ctx);
@@ -46,4 +49,14 @@
{
return ctx;
}
+
+ public String getValidationToken()
+ {
+ return validationToken;
+ }
+
+ public void setValidationToken(String validationToken)
+ {
+ this.validationToken = validationToken;
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -36,8 +36,11 @@
private final ResourceInvocationContext ctx;
/** The request context. */
- protected RequestContext requestContext;
+ private RequestContext requestContext;
+ /** . */
+ private String validationToken;
+
public ResourceInvocation(ResourceInvocationContext ctx) throws IllegalArgumentException
{
super(ctx);
@@ -51,6 +54,16 @@
return ctx;
}
+ public String getValidationToken()
+ {
+ return validationToken;
+ }
+
+ public void setValidationToken(String validationToken)
+ {
+ this.validationToken = validationToken;
+ }
+
public RequestContext getRequestContext()
{
return requestContext;
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/ContentRef.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/ContentRef.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/ContentRef.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.invocation.response.cache;
+
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+
+import java.io.Serializable;
+
+/**
+ * A fragment result + its expiration date.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public abstract class ContentRef implements Serializable
+{
+
+ /**
+ * Returns the content, possibly null.
+ *
+ * @return the content
+ */
+ public abstract FragmentResponse getContent();
+}
Property changes on: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/ContentRef.java
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftContentRef.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftContentRef.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftContentRef.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.invocation.response.cache;
+
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+
+import java.lang.ref.WeakReference;
+
+/**
+ * Use soft reference.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision:5417 $
+ */
+public class SoftContentRef extends ContentRef
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -8166044526732362286L;
+
+ /** The content. */
+ private transient WeakReference<FragmentResponse> content;
+
+ /**
+ * @param content the content
+ * @throws IllegalArgumentException if the content is null
+ */
+ public SoftContentRef(FragmentResponse content) throws IllegalArgumentException
+ {
+ if (content == null)
+ {
+ throw new IllegalArgumentException("Content must not be null");
+ }
+ this.content = new WeakReference<FragmentResponse>(content);
+ }
+
+ public FragmentResponse getContent()
+ {
+ return content.get();
+ }
+}
Property changes on: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftContentRef.java
___________________________________________________________________
Name: svn:executable
+ *
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftTimedContent.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftTimedContent.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/SoftTimedContent.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -1,59 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.invocation.response.cache;
-
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-
-import java.lang.ref.WeakReference;
-
-/**
- * Use soft reference.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision:5417 $
- */
-public class SoftTimedContent extends TimedContent
-{
-
- /** The serialVersionUID */
- private static final long serialVersionUID = -8166044526732362286L;
-
- /** The content. */
- private transient WeakReference content;
-
- /** @throws IllegalArgumentException if the content is null */
- public SoftTimedContent(FragmentResponse content, long expirationTimeMillis) throws IllegalArgumentException
- {
- super(expirationTimeMillis);
- if (content == null)
- {
- throw new IllegalArgumentException("Content must not be null");
- }
- this.content = new WeakReference(content);
- }
-
- public FragmentResponse getContent()
- {
- return (FragmentResponse)content.get();
- }
-}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongContentRef.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongContentRef.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongContentRef.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.invocation.response.cache;
+
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+
+/**
+ * Use strong references.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class StrongContentRef extends ContentRef
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -8194245397756941208L;
+
+ /** The content. */
+ private transient FragmentResponse content;
+
+ /**
+ * @param content the content
+ * @throws IllegalArgumentException if the content is null
+ */
+ public StrongContentRef(FragmentResponse content) throws IllegalArgumentException
+ {
+ if (content == null)
+ {
+ throw new IllegalArgumentException("Content must not be null");
+ }
+ this.content = content;
+ }
+
+ public FragmentResponse getContent()
+ {
+ return content;
+ }
+}
Property changes on: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongContentRef.java
___________________________________________________________________
Name: svn:executable
+ *
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongTimedContent.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongTimedContent.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/StrongTimedContent.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.invocation.response.cache;
-
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-
-/**
- * Use strong references.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 5448 $
- */
-public class StrongTimedContent extends TimedContent
-{
-
- /** The serialVersionUID */
- private static final long serialVersionUID = -8194245397756941208L;
- /** The content. */
- private transient FragmentResponse content;
-
- /** @throws IllegalArgumentException if the content is null */
- public StrongTimedContent(FragmentResponse content, long expirationTimeMillis) throws IllegalArgumentException
- {
- super(expirationTimeMillis);
- if (content == null)
- {
- throw new IllegalArgumentException("Content must not be null");
- }
- this.content = content;
- }
-
- public FragmentResponse getContent()
- {
- return content;
- }
-}
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/TimedContent.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/TimedContent.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/cache/TimedContent.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.invocation.response.cache;
-
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-
-import java.io.Serializable;
-
-/**
- * A fragment result + its expiration date.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 5448 $
- */
-public abstract class TimedContent implements Serializable
-{
-
- /** Expiration date. */
- private final long expirationTimeMillis;
-
- public TimedContent(long expirationTimeMillis)
- {
- this.expirationTimeMillis = expirationTimeMillis;
- }
-
- /** Return the content, possibly null. */
- public abstract FragmentResponse getContent();
-
- /**
- *
- */
- public long getExpirationTimeMillis()
- {
- return expirationTimeMillis;
- }
-}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ClientContext.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -22,9 +22,9 @@
******************************************************************************/
package org.jboss.portal.portlet.spi;
+import org.jboss.portal.common.util.MultiValuedPropertyMap;
+
import javax.servlet.http.Cookie;
-import java.util.Iterator;
-import java.util.Set;
import java.util.List;
/**
@@ -37,16 +37,11 @@
String getMethod();
/**
- * Returns the list of values of a specified property as seen by the client.
+ * Returns the properties as seen by the client.
*
- * @param name the property
- * @return the list of properties
- * @throws IllegalArgumentException if the name is null
+ * @return the properties
*/
- List<String> getProperties(String name) throws IllegalArgumentException;
+ MultiValuedPropertyMap<String> getProperties();
- Set<String> getPropertyNames();
-
List<Cookie> getCookies();
-
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -41,13 +41,6 @@
String getResourceId();
/**
- * Returns the cacheability.
- *
- * @return the cacheability
- */
- CacheLevel getCacheability();
-
- /**
* Returns the resource state of the request.
*
* @return the resource state
@@ -61,4 +54,10 @@
*/
ParameterMap getForm();
+ /**
+ * Returns the cache level.
+ *
+ * @return the cache level
+ */
+ CacheLevel getCacheLevel();
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/ClientContextSupport.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -23,6 +23,7 @@
package org.jboss.portal.portlet.support.spi;
import org.jboss.portal.portlet.spi.ClientContext;
+import org.jboss.portal.common.util.MultiValuedPropertyMap;
import javax.servlet.http.Cookie;
import java.util.List;
@@ -39,16 +40,11 @@
throw new UnsupportedOperationException();
}
- public List<String> getProperties(String name)
+ public MultiValuedPropertyMap<String> getProperties()
{
throw new UnsupportedOperationException();
}
- public Set<String> getPropertyNames()
- {
- throw new UnsupportedOperationException();
- }
-
public List<Cookie> getCookies()
{
throw new UnsupportedOperationException();
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/RenderContextSupport.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/RenderContextSupport.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/RenderContextSupport.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -30,4 +30,5 @@
*/
public class RenderContextSupport extends PortletInvocationContextSupport implements RenderContext
{
+
}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java 2008-01-25 19:53:26 UTC (rev 9609)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java 2008-01-25 19:59:07 UTC (rev 9610)
@@ -97,6 +97,7 @@
// Should be called
calls.add("2");
response.setProperty(RenderResponse.EXPIRATION_CACHE, "5");
+ response.setProperty(RenderResponse.ETAG, "xyz");
// Refresh
return new InvokeGetResponse(url);
@@ -155,6 +156,8 @@
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
{
+ assertEquals("xyz", request.getETag());
+
// Should be called
calls.add("5");
response.setProperty(RenderResponse.EXPIRATION_CACHE, "5");
18 years, 3 months
JBoss Portal SVN: r9609 - modules/common/trunk/common/src/main/java/org/jboss/portal/common/util.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-25 14:53:26 -0500 (Fri, 25 Jan 2008)
New Revision: 9609
Added:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java
Log:
added missing interface in hte previous commit
Added: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java (rev 0)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java 2008-01-25 19:53:26 UTC (rev 9609)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.util;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A property map with multi valued properties.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface MultiValuedPropertyMap<T>
+{
+ T getValue(String key) throws IllegalArgumentException;
+ List<T> getValues(String key) throws IllegalArgumentException;
+ void addValue(String key, T value) throws IllegalArgumentException;
+ void setValue(String key, T value) throws IllegalArgumentException;
+ Set<String> keySet();
+ void clear();
+ int size();
+ void append(MultiValuedPropertyMap<T> appended) throws IllegalArgumentException;
+}
18 years, 3 months
JBoss Portal SVN: r9608 - in branches/JBoss_Portal_Branch_2_6: core-admin/src/bin/portal-admin-war and 3 other directories.
by portal-commits@lists.jboss.org
Author: wesleyhales
Date: 2008-01-25 11:03:46 -0500 (Fri, 25 Jan 2008)
New Revision: 9608
Added:
branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/
branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/domLib.js
branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/domTT.js
branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/domTT_drag.js
branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/fadomatic.js
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/css/style.css
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-war/WEB-INF/jsp/content/portlet_editor.jsp
Log:
Added tool tip to instance window and cleanup ui
Modified: branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-war/WEB-INF/jsp/content/portlet_editor.jsp
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-war/WEB-INF/jsp/content/portlet_editor.jsp 2008-01-25 15:55:50 UTC (rev 9607)
+++ branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-war/WEB-INF/jsp/content/portlet_editor.jsp 2008-01-25 16:03:46 UTC (rev 9608)
@@ -17,55 +17,22 @@
<%@page import="org.jboss.portal.core.portlet.info.PortletIconInfo"%>
<%@page import="org.jboss.portal.core.ui.content.portlet.PortletContentEditorPortlet"%>
<portlet:defineObjects/>
+<script type='text/javascript' src='/portal-admin/js/domLib.js'></script>
+<script type="text/javascript" src="/portal-admin/js/fadomatic.js"></script>
+<script type='text/javascript' src='/portal-admin/js/domTT.js'></script>
+<script type="text/javascript">
-<span class="portlet-font">Portlet instance associated to this window:</span>
+ //<![CDATA[
+ var domTT_styleClass = 'domTTOverlib';
+ var domTT_maxWidth = false;
+ //]]>
-<div style="height:300px; width:300px; overflow: auto; overflow-x: hidden; border: 1px solid #333;">
- <table style="width:100%;" cellspacing="0" cellpadding="0">
- <%
- for (IteratorStatus i = new IteratorStatus(instances); i.hasNext();)
- {
- Instance instance = (Instance)i.next();
- String rowClass = instance == selectedInstance ? "portlet-section-selected" : (i.getIndex() % 2 == 0 ? "portlet-section-body" : "portlet-section-alternate");
- String displayName = instance.getDisplayName().getString(renderRequest.getLocale(), true);
- if (displayName == null)
- {
- displayName = instance.getId();
- }
-
- PortletInfo info = instance.getPortlet().getInfo();
+</script>
- String iconLocation = null;
- if (info instanceof CorePortletInfo)
- {
- CorePortletInfo cInfo = (CorePortletInfo)info;
- PortletInfoInfo portletInfo = cInfo.getPortletInfo();
- if (portletInfo != null && portletInfo.getPortletIconInfo() != null && portletInfo.getPortletIconInfo().getIconLocation(PortletIconInfo.SMALL) != null)
- {
- iconLocation = portletInfo.getPortletIconInfo().getIconLocation(PortletIconInfo.SMALL);
- }
- }
- if (iconLocation == null)
- {
- iconLocation = PortletContentEditorPortlet.DEFAULT_PORTLET_ICON;
- }
-
- %>
- <portlet:actionURL var="url">
- <portlet:param name="content.action.select" value="true"/>
- <portlet:param name="content.uri" value="<%= instance.getId() %>"/>
- </portlet:actionURL>
- <tr class="<%= rowClass %>">
- <td>
- <img src="<%= iconLocation %>" align="middle" style="margin:0 4px 0 0"/>
- <a href="<%= url %>"><%= displayName %></a></td>
- </tr>
- <%
- }
- %>
- </table>
-</div>
-
+<table style="width:500px;">
+<tr>
+ <td><h3 class="sectionTitle tenpx-top-bottom">Portlet instance associated to this window:</h3></td>
+</tr>
<%
if (selectedInstance != null)
{
@@ -75,16 +42,9 @@
displayName = selectedInstance.getId();
}
%>
-<div class="portlet-font">
- <div><span class="portlet-form-field-label">Portlet instance:</span><%= displayName %>
- </div>
- <%
-
-
-
-
+ <%
Portlet portlet = null;
try
{
@@ -98,37 +58,109 @@
{
MetaInfo metaInfo = portlet.getInfo().getMeta();
+ PortletInfo info = portlet.getInfo();
+ String iconLocation = getIcon(info);
+ %>
+<tr class="portlet-section-selected">
+ <td >
+ <img src="<%= iconLocation %>" align="middle" style="margin:0 4px 0 0"/>
+ <span><%= displayName %></span>
-
-
- %>
- <div><span
- class="portlet-form-field-label">Portlet name:</span><%= metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString() %>
+ <div>
+ <span class="portlet-form-field-label">Portlet name:</span><%= metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString() %>
</div>
- <div><span
- class="portlet-form-field-label">Portlet description:</span><%= metaInfo.getMetaValue(MetaInfo.DESCRIPTION).getDefaultString() %>
+ <div>
+ <span class="portlet-form-field-label">Portlet description:</span><%= metaInfo.getMetaValue(MetaInfo.DESCRIPTION).getDefaultString() %>
</div>
- <div><span
- class="portlet-form-field-label">Portlet title:</span><%= metaInfo.getMetaValue(MetaInfo.TITLE).getDefaultString() %>
- </div>
- <div><span
- class="portlet-form-field-label">Portlet keywords:</span><%= metaInfo.getMetaValue(MetaInfo.KEYWORDS).getDefaultString() %>
- </div>
+
+ </td>
+ </tr>
<%
+ }
+ }
+ %>
+ <tr>
+<td>
+<div style="height:300px; width:500px; overflow: auto; overflow-x: hidden; border: 1px solid #333;">
+ <table style="width:100%;" cellspacing="0" cellpadding="0">
+ <%
+ for (IteratorStatus i = new IteratorStatus(instances); i.hasNext();)
+ {
+ Instance instance = (Instance)i.next();
+ String rowClass = instance == selectedInstance ? "portlet-section-selected" : (i.getIndex() % 2 == 0 ? "portlet-section-body" : "portlet-section-alternate");
+ String displayName = instance.getDisplayName().getString(renderRequest.getLocale(), true);
+ MetaInfo portletMetaInfo = instance.getPortlet().getInfo().getMeta();
+ if (displayName == null)
+ {
+ displayName = instance.getId();
+ }
+
+ PortletInfo info = instance.getPortlet().getInfo();
- }
- }
+ String iconLocation = getIcon(info);
+ %>
+ <portlet:actionURL var="url">
+ <portlet:param name="content.action.select" value="true"/>
+ <portlet:param name="content.uri" value="<%= instance.getId() %>"/>
+ </portlet:actionURL>
+ <div style="display:none">
+ <div class="darktip" id="info-container-<%= displayName %>">
+ <div class="toolbar" style="width: 250px;">
+ <div class="title"><%= portletMetaInfo.getMetaValue(MetaInfo.TITLE).getDefaultString() %></div>
+ </div>
+ <div class="content">
+ <div>
+ <span class="portlet-form-field-label">Portlet name:</span><%= portletMetaInfo.getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString() %>
+ </div>
+ <div>
+ <span class="portlet-form-field-label">Portlet description:</span><%= portletMetaInfo.getMetaValue(MetaInfo.DESCRIPTION).getDefaultString() %>
+ </div>
+ </div>
+ </div>
+
+ </div>
+ <tr class="<%= rowClass %>" >
+ <td >
+ <img src="<%= iconLocation %>" align="middle" style="margin:0 4px 0 0"/>
+ <span onmouseover="domTT_activate(this, event, 'content', document.getElementById('info-container-<%= displayName %>'),'delay', 0, 'trail', false, 'fade', 'both', 'fadeMax', 95, 'styleClass', 'none');"><a href="<%= url %>" id="portlet-instance-link"><%= displayName %></a></span></td>
+ </tr>
+ <%
+ }
+ %>
+ </table>
+</div>
+ </td>
+ </tr>
+</table>
-
- %>
+<%!
+ private String getIcon(PortletInfo info)
+ {
+ String iconLocation = null;
+ if (info instanceof CorePortletInfo)
+ {
+ CorePortletInfo cInfo = (CorePortletInfo)info;
+ PortletInfoInfo portletInfo = cInfo.getPortletInfo();
+ if (portletInfo != null && portletInfo.getPortletIconInfo() != null && portletInfo.getPortletIconInfo().getIconLocation(PortletIconInfo.SMALL) != null)
+ {
+ iconLocation = portletInfo.getPortletIconInfo().getIconLocation(PortletIconInfo.SMALL);
+ }
+ }
+ if (iconLocation == null)
+ {
+ iconLocation = PortletContentEditorPortlet.DEFAULT_PORTLET_ICON;
+ }
+ return iconLocation;
+ }
+%>
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/css/style.css
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/css/style.css 2008-01-25 15:55:50 UTC (rev 9607)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/css/style.css 2008-01-25 16:03:46 UTC (rev 9608)
@@ -1,6 +1,6 @@
/* Redefine spacing for tables. */
-@import url(basestyles.css);
+@import url( basestyles.css );
a {
color: #446688;
@@ -21,27 +21,25 @@
.admin-ui table {
border: 0;
- border-collapse:collapse;
+ border-collapse: collapse;
}
-.admin-ui table.datatable{
+.admin-ui table.datatable {
border-right: 1px solid #B3C0C7;
border-left: 1px solid #B3C0C7;
border-bottom: 1px solid #B3C0C7;
}
-.admin-ui table tbody{
-
+.admin-ui table tbody {
+
}
.admin-ui th {
text-align: left;
padding-bottom: 2px;
padding-top: 2px;
- font-size: 11px;
- /*border-bottom: 1px solid #B3C0C7;*/
- background-color:#fafafa;
- /*border-top: 1px solid #B3C0C7;*/
+ font-size: 11px; /*border-bottom: 1px solid #B3C0C7;*/
+ background-color: #fafafa; /*border-top: 1px solid #B3C0C7;*/
}
/*.admin-ui thead tr th {
@@ -65,10 +63,10 @@
}
.admin-ui dd {
- margin:0;
+ margin: 0;
}
-.admin-ui .panelGrid-basic{
+.admin-ui .panelGrid-basic {
width: 100%;
}
@@ -80,7 +78,7 @@
.admin-ui ul.pagination {
margin: 0 auto 0 auto;
- width:98%;
+ width: 98%;
padding: .2em;
}
@@ -224,18 +222,17 @@
/* Area header. */
.admin-ui .portlet-area-header,
-.sectionTitle-blue{
+ .sectionTitle-blue {
font-weight: bold;
color: #5e5e5e;
- font-size: 13px;
- /*background-color: #5986b3;*/
- /*background-color: #ebf2f5;*/
- background-image:url(../img/section-header-bg.gif);
- background-position:left top;
- background-repeat:repeat-x;
+ font-size: 13px; /*background-color: #5986b3;*/
+/*background-color: #ebf2f5;*/
+ background-image: url( ../img/section-header-bg.gif );
+ background-position: left top;
+ background-repeat: repeat-x;
padding: 2px 2px 2px 4px;
margin: 0;
- border:1px solid #dbdbdb;
+ border: 1px solid #dbdbdb;
}
.admin-ui .portlet-area-body {
@@ -252,18 +249,17 @@
/* Styles updated and enhanced from the main portal css */
.admin-ui th.portlet-section-title,
-.admin-ui h3.sectionTitle{
+ .admin-ui h3.sectionTitle {
font-weight: bold;
color: #315896;
font-size: 11px;
padding: 3px 0 3px 3px;
- background-image:url(../img/section-subHeader-bg.gif);
- background-position:left top;
- background-repeat:repeat-x;
- border:1px solid #b9c6d7;
+ background-image: url( ../img/section-subHeader-bg.gif );
+ background-position: left top;
+ background-repeat: repeat-x;
+ border: 1px solid #b9c6d7;
}
-
.admin-ui .portlet-section-header {
background-image: url( ../img/pathBackground.png );
background-position: left;
@@ -289,8 +285,7 @@
}
.admin-ui .portlet-section-body {
- color: #656565;
- /*border: 1px solid #d5d5d5;*/
+ color: #656565; /*border: 1px solid #d5d5d5;*/
border-top: 0px;
}
@@ -550,11 +545,42 @@
}
.property-container,
-.portlet-def-table {
- width:98%;
+ .portlet-def-table {
+ width: 98%;
margin: 0 auto 0 auto;
}
-.cms-tab-container th{
- background:none;
+.cms-tab-container th {
+ background: none;
}
+/*--------------------------ToolTip*/
+.darktip {
+ width: 250px;
+ border: 5px solid #e3e9f6;
+}
+
+.darktip .toolbar {
+ background: #95a7ca;
+ color: #fff;
+ font: normal 14px Verdana, Arial, serif;
+}
+
+.darktip .toolbar a.close {
+ background: url( ../img/close_hover.gif );
+}
+
+.darktip .toolbar a.close:hover {
+ background: url( ../img/close.gif );
+}
+
+.darktip .title {
+ padding: 5px;
+}
+
+.darktip .content {
+ background: #d2daeb;
+ color: #224d83;
+ font: 11px Verdana, Arial, Helvetica, sans-serif;
+ padding: 5px;
+}
+
Added: branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/domLib.js
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/domLib.js (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/domLib.js 2008-01-25 16:03:46 UTC (rev 9608)
@@ -0,0 +1,706 @@
+/** $Id: domLib.js 2321 2006-06-12 06:45:41Z dallen $ */
+// {{{ license
+
+/*
+ * Copyright 2002-2005 Dan Allen, Mojavelinux.com (dan.allen(a)mojavelinux.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// }}}
+// {{{ intro
+
+/**
+ * Title: DOM Library Core
+ * Version: 0.70
+ *
+ * Summary:
+ * A set of commonly used functions that make it easier to create javascript
+ * applications that rely on the DOM.
+ *
+ * Updated: 2005/05/17
+ *
+ * Maintainer: Dan Allen <dan.allen(a)mojavelinux.com>
+ * Maintainer: Jason Rust <jrust(a)rustyparts.com>
+ *
+ * License: Apache 2.0
+ */
+
+// }}}
+// {{{ global constants (DO NOT EDIT)
+
+// -- Browser Detection --
+var domLib_userAgent = navigator.userAgent.toLowerCase();
+var domLib_isMac = navigator.appVersion.indexOf('Mac') != -1;
+var domLib_isWin = domLib_userAgent.indexOf('windows') != -1;
+// NOTE: could use window.opera for detecting Opera
+var domLib_isOpera = domLib_userAgent.indexOf('opera') != -1;
+var domLib_isOpera7up = domLib_userAgent.match(/opera.(7|8)/i);
+var domLib_isSafari = domLib_userAgent.indexOf('safari') != -1;
+var domLib_isKonq = domLib_userAgent.indexOf('konqueror') != -1;
+// Both konqueror and safari use the khtml rendering engine
+var domLib_isKHTML = (domLib_isKonq || domLib_isSafari || domLib_userAgent.indexOf('khtml') != -1);
+var domLib_isIE = (!domLib_isKHTML && !domLib_isOpera && (domLib_userAgent.indexOf('msie 5') != -1 || domLib_userAgent.indexOf('msie 6') != -1 || domLib_userAgent.indexOf('msie 7') != -1));
+var domLib_isIE5up = domLib_isIE;
+var domLib_isIE50 = (domLib_isIE && domLib_userAgent.indexOf('msie 5.0') != -1);
+var domLib_isIE55 = (domLib_isIE && domLib_userAgent.indexOf('msie 5.5') != -1);
+var domLib_isIE5 = (domLib_isIE50 || domLib_isIE55);
+// safari and konq may use string "khtml, like gecko", so check for destinctive /
+var domLib_isGecko = domLib_userAgent.indexOf('gecko/') != -1;
+var domLib_isMacIE = (domLib_isIE && domLib_isMac);
+var domLib_isIE55up = domLib_isIE5up && !domLib_isIE50 && !domLib_isMacIE;
+var domLib_isIE6up = domLib_isIE55up && !domLib_isIE55;
+
+// -- Browser Abilities --
+var domLib_standardsMode = (document.compatMode && document.compatMode == 'CSS1Compat');
+var domLib_useLibrary = (domLib_isOpera7up || domLib_isKHTML || domLib_isIE5up || domLib_isGecko || domLib_isMacIE || document.defaultView);
+// fixed in Konq3.2
+var domLib_hasBrokenTimeout = (domLib_isMacIE || (domLib_isKonq && domLib_userAgent.match(/konqueror\/3.([2-9])/) == null));
+var domLib_canFade = (domLib_isGecko || domLib_isIE || domLib_isSafari || domLib_isOpera);
+var domLib_canDrawOverSelect = (domLib_isMac || domLib_isOpera || domLib_isGecko);
+var domLib_canDrawOverFlash = (domLib_isMac || domLib_isWin);
+
+// -- Event Variables --
+var domLib_eventTarget = domLib_isIE ? 'srcElement' : 'currentTarget';
+var domLib_eventButton = domLib_isIE ? 'button' : 'which';
+var domLib_eventTo = domLib_isIE ? 'toElement' : 'relatedTarget';
+var domLib_stylePointer = domLib_isIE ? 'hand' : 'pointer';
+// NOTE: a bug exists in Opera that prevents maxWidth from being set to 'none', so we make it huge
+var domLib_styleNoMaxWidth = domLib_isOpera ? '10000px' : 'none';
+var domLib_hidePosition = '-1000px';
+var domLib_scrollbarWidth = 14;
+var domLib_autoId = 1;
+var domLib_zIndex = 100;
+
+// -- Detection --
+var domLib_collisionElements;
+var domLib_collisionsCached = false;
+
+var domLib_timeoutStateId = 0;
+var domLib_timeoutStates = new Hash();
+
+// }}}
+// {{{ DOM enhancements
+
+if (!document.ELEMENT_NODE)
+{
+ document.ELEMENT_NODE = 1;
+ document.ATTRIBUTE_NODE = 2;
+ document.TEXT_NODE = 3;
+ document.DOCUMENT_NODE = 9;
+ document.DOCUMENT_FRAGMENT_NODE = 11;
+}
+
+function domLib_clone(obj)
+{
+ var copy = {};
+ for (var i in obj)
+ {
+ var value = obj[i];
+ try
+ {
+ if (value != null && typeof(value) == 'object' && value != window && !value.nodeType)
+ {
+ copy[i] = domLib_clone(value);
+ }
+ else
+ {
+ copy[i] = value;
+ }
+ }
+ catch(e)
+ {
+ copy[i] = value;
+ }
+ }
+
+ return copy;
+}
+
+// }}}
+// {{{ class Hash()
+
+function Hash()
+{
+ this.length = 0;
+ this.numericLength = 0;
+ this.elementData = [];
+ for (var i = 0; i < arguments.length; i += 2)
+ {
+ if (typeof(arguments[i + 1]) != 'undefined')
+ {
+ this.elementData[arguments[i]] = arguments[i + 1];
+ this.length++;
+ if (arguments[i] == parseInt(arguments[i]))
+ {
+ this.numericLength++;
+ }
+ }
+ }
+}
+
+// using prototype as opposed to inner functions saves on memory
+Hash.prototype.get = function(in_key)
+{
+ if (typeof(this.elementData[in_key]) != 'undefined') {
+ return this.elementData[in_key];
+ }
+
+ return null;
+}
+
+Hash.prototype.set = function(in_key, in_value)
+{
+ if (typeof(in_value) != 'undefined')
+ {
+ if (typeof(this.elementData[in_key]) == 'undefined')
+ {
+ this.length++;
+ if (in_key == parseInt(in_key))
+ {
+ this.numericLength++;
+ }
+ }
+
+ return this.elementData[in_key] = in_value;
+ }
+
+ return false;
+}
+
+Hash.prototype.remove = function(in_key)
+{
+ var tmp_value;
+ if (typeof(this.elementData[in_key]) != 'undefined')
+ {
+ this.length--;
+ if (in_key == parseInt(in_key))
+ {
+ this.numericLength--;
+ }
+
+ tmp_value = this.elementData[in_key];
+ delete this.elementData[in_key];
+ }
+
+ return tmp_value;
+}
+
+Hash.prototype.size = function()
+{
+ return this.length;
+}
+
+Hash.prototype.has = function(in_key)
+{
+ return typeof(this.elementData[in_key]) != 'undefined';
+}
+
+Hash.prototype.find = function(in_obj)
+{
+ for (var tmp_key in this.elementData)
+ {
+ if (this.elementData[tmp_key] == in_obj)
+ {
+ return tmp_key;
+ }
+ }
+
+ return null;
+}
+
+Hash.prototype.merge = function(in_hash)
+{
+ for (var tmp_key in in_hash.elementData)
+ {
+ if (typeof(this.elementData[tmp_key]) == 'undefined')
+ {
+ this.length++;
+ if (tmp_key == parseInt(tmp_key))
+ {
+ this.numericLength++;
+ }
+ }
+
+ this.elementData[tmp_key] = in_hash.elementData[tmp_key];
+ }
+}
+
+Hash.prototype.compare = function(in_hash)
+{
+ if (this.length != in_hash.length)
+ {
+ return false;
+ }
+
+ for (var tmp_key in this.elementData)
+ {
+ if (this.elementData[tmp_key] != in_hash.elementData[tmp_key])
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+// }}}
+// {{{ domLib_isDescendantOf()
+
+function domLib_isDescendantOf(in_object, in_ancestor, in_bannedTags)
+{
+ if (in_object == null)
+ {
+ return false;
+ }
+
+ if (in_object == in_ancestor)
+ {
+ return true;
+ }
+
+ if (typeof(in_bannedTags) != 'undefined' &&
+ (',' + in_bannedTags.join(',') + ',').indexOf(',' + in_object.tagName + ',') != -1)
+ {
+ return false;
+ }
+
+ while (in_object != document.documentElement)
+ {
+ try
+ {
+ if ((tmp_object = in_object.offsetParent) && tmp_object == in_ancestor)
+ {
+ return true;
+ }
+ else if ((tmp_object = in_object.parentNode) == in_ancestor)
+ {
+ return true;
+ }
+ else
+ {
+ in_object = tmp_object;
+ }
+ }
+ // in case we get some wierd error, assume we left the building
+ catch(e)
+ {
+ return false;
+ }
+ }
+
+ return false;
+}
+
+// }}}
+// {{{ domLib_detectCollisions()
+
+/**
+ * For any given target element, determine if elements on the page
+ * are colliding with it that do not obey the rules of z-index.
+ */
+function domLib_detectCollisions(in_object, in_recover, in_useCache)
+{
+ // the reason for the cache is that if the root menu is built before
+ // the page is done loading, then it might not find all the elements.
+ // so really the only time you don't use cache is when building the
+ // menu as part of the page load
+ if (!domLib_collisionsCached)
+ {
+ var tags = [];
+
+ if (!domLib_canDrawOverFlash)
+ {
+ tags[tags.length] = 'object';
+ }
+
+ if (!domLib_canDrawOverSelect)
+ {
+ tags[tags.length] = 'select';
+ }
+
+ domLib_collisionElements = domLib_getElementsByTagNames(tags, true);
+ domLib_collisionsCached = in_useCache;
+ }
+
+ // if we don't have a tip, then unhide selects
+ if (in_recover)
+ {
+ for (var cnt = 0; cnt < domLib_collisionElements.length; cnt++)
+ {
+ var thisElement = domLib_collisionElements[cnt];
+
+ if (!thisElement.hideList)
+ {
+ thisElement.hideList = new Hash();
+ }
+
+ thisElement.hideList.remove(in_object.id);
+ if (!thisElement.hideList.length)
+ {
+ domLib_collisionElements[cnt].style.visibility = 'visible';
+ if (domLib_isKonq)
+ {
+ domLib_collisionElements[cnt].style.display = '';
+ }
+ }
+ }
+
+ return;
+ }
+ else if (domLib_collisionElements.length == 0)
+ {
+ return;
+ }
+
+ // okay, we have a tip, so hunt and destroy
+ var objectOffsets = domLib_getOffsets(in_object);
+
+ for (var cnt = 0; cnt < domLib_collisionElements.length; cnt++)
+ {
+ var thisElement = domLib_collisionElements[cnt];
+
+ // if collision element is in active element, move on
+ // WARNING: is this too costly?
+ if (domLib_isDescendantOf(thisElement, in_object))
+ {
+ continue;
+ }
+
+ // konqueror only has trouble with multirow selects
+ if (domLib_isKonq &&
+ thisElement.tagName == 'SELECT' &&
+ (thisElement.size <= 1 && !thisElement.multiple))
+ {
+ continue;
+ }
+
+ if (!thisElement.hideList)
+ {
+ thisElement.hideList = new Hash();
+ }
+
+ var selectOffsets = domLib_getOffsets(thisElement);
+ var center2centerDistance = Math.sqrt(Math.pow(selectOffsets.get('leftCenter') - objectOffsets.get('leftCenter'), 2) + Math.pow(selectOffsets.get('topCenter') - objectOffsets.get('topCenter'), 2));
+ var radiusSum = selectOffsets.get('radius') + objectOffsets.get('radius');
+ // the encompassing circles are overlapping, get in for a closer look
+ if (center2centerDistance < radiusSum)
+ {
+ // tip is left of select
+ if ((objectOffsets.get('leftCenter') <= selectOffsets.get('leftCenter') && objectOffsets.get('right') < selectOffsets.get('left')) ||
+ // tip is right of select
+ (objectOffsets.get('leftCenter') > selectOffsets.get('leftCenter') && objectOffsets.get('left') > selectOffsets.get('right')) ||
+ // tip is above select
+ (objectOffsets.get('topCenter') <= selectOffsets.get('topCenter') && objectOffsets.get('bottom') < selectOffsets.get('top')) ||
+ // tip is below select
+ (objectOffsets.get('topCenter') > selectOffsets.get('topCenter') && objectOffsets.get('top') > selectOffsets.get('bottom')))
+ {
+ thisElement.hideList.remove(in_object.id);
+ if (!thisElement.hideList.length)
+ {
+ thisElement.style.visibility = 'visible';
+ if (domLib_isKonq)
+ {
+ thisElement.style.display = '';
+ }
+ }
+ }
+ else
+ {
+ thisElement.hideList.set(in_object.id, true);
+ thisElement.style.visibility = 'hidden';
+ if (domLib_isKonq)
+ {
+ thisElement.style.display = 'none';
+ }
+ }
+ }
+ }
+}
+
+// }}}
+// {{{ domLib_getOffsets()
+
+function domLib_getOffsets(in_object, in_preserveScroll)
+{
+ if (typeof(in_preserveScroll) == 'undefined') {
+ in_preserveScroll = false;
+ }
+
+ var originalObject = in_object;
+ var originalWidth = in_object.offsetWidth;
+ var originalHeight = in_object.offsetHeight;
+ var offsetLeft = 0;
+ var offsetTop = 0;
+
+ while (in_object)
+ {
+ offsetLeft += in_object.offsetLeft;
+ offsetTop += in_object.offsetTop;
+ in_object = in_object.offsetParent;
+ // consider scroll offset of parent elements
+ if (in_object && !in_preserveScroll)
+ {
+ offsetLeft -= in_object.scrollLeft;
+ offsetTop -= in_object.scrollTop;
+ }
+ }
+
+ // MacIE misreports the offsets (even with margin: 0 in body{}), still not perfect
+ if (domLib_isMacIE) {
+ offsetLeft += 10;
+ offsetTop += 10;
+ }
+
+ return new Hash(
+ 'left', offsetLeft,
+ 'top', offsetTop,
+ 'right', offsetLeft + originalWidth,
+ 'bottom', offsetTop + originalHeight,
+ 'leftCenter', offsetLeft + originalWidth/2,
+ 'topCenter', offsetTop + originalHeight/2,
+ 'radius', Math.max(originalWidth, originalHeight)
+ );
+}
+
+// }}}
+// {{{ domLib_setTimeout()
+
+function domLib_setTimeout(in_function, in_timeout, in_args)
+{
+ if (typeof(in_args) == 'undefined')
+ {
+ in_args = [];
+ }
+
+ if (in_timeout == -1)
+ {
+ // timeout event is disabled
+ return 0;
+ }
+ else if (in_timeout == 0)
+ {
+ in_function(in_args);
+ return 0;
+ }
+
+ // must make a copy of the arguments so that we release the reference
+ var args = domLib_clone(in_args);
+
+ if (!domLib_hasBrokenTimeout)
+ {
+ return setTimeout(function() { in_function(args); }, in_timeout);
+ }
+ else
+ {
+ var id = domLib_timeoutStateId++;
+ var data = new Hash();
+ data.set('function', in_function);
+ data.set('args', args);
+ domLib_timeoutStates.set(id, data);
+
+ data.set('timeoutId', setTimeout('domLib_timeoutStates.get(' + id + ').get(\'function\')(domLib_timeoutStates.get(' + id + ').get(\'args\')); domLib_timeoutStates.remove(' + id + ');', in_timeout));
+ return id;
+ }
+}
+
+// }}}
+// {{{ domLib_clearTimeout()
+
+function domLib_clearTimeout(in_id)
+{
+ if (!domLib_hasBrokenTimeout)
+ {
+ if (in_id > 0) {
+ clearTimeout(in_id);
+ }
+ }
+ else
+ {
+ if (domLib_timeoutStates.has(in_id))
+ {
+ clearTimeout(domLib_timeoutStates.get(in_id).get('timeoutId'))
+ domLib_timeoutStates.remove(in_id);
+ }
+ }
+}
+
+// }}}
+// {{{ domLib_getEventPosition()
+
+function domLib_getEventPosition(in_eventObj)
+{
+ var eventPosition = new Hash('x', 0, 'y', 0, 'scrollX', 0, 'scrollY', 0);
+
+ // IE varies depending on standard compliance mode
+ if (domLib_isIE)
+ {
+ var doc = (domLib_standardsMode ? document.documentElement : document.body);
+ // NOTE: events may fire before the body has been loaded
+ if (doc)
+ {
+ eventPosition.set('x', in_eventObj.clientX + doc.scrollLeft);
+ eventPosition.set('y', in_eventObj.clientY + doc.scrollTop);
+ eventPosition.set('scrollX', doc.scrollLeft);
+ eventPosition.set('scrollY', doc.scrollTop);
+ }
+ }
+ else
+ {
+ eventPosition.set('x', in_eventObj.pageX);
+ eventPosition.set('y', in_eventObj.pageY);
+ eventPosition.set('scrollX', in_eventObj.pageX - in_eventObj.clientX);
+ eventPosition.set('scrollY', in_eventObj.pageY - in_eventObj.clientY);
+ }
+
+ return eventPosition;
+}
+
+// }}}
+// {{{ domLib_cancelBubble()
+
+function domLib_cancelBubble(in_event)
+{
+ var eventObj = in_event ? in_event : window.event;
+ eventObj.cancelBubble = true;
+}
+
+// }}}
+// {{{ domLib_getIFrameReference()
+
+function domLib_getIFrameReference(in_frame)
+{
+ if (domLib_isGecko || domLib_isIE)
+ {
+ return in_frame.frameElement;
+ }
+ else
+ {
+ // we could either do it this way or require an id on the frame
+ // equivalent to the name
+ var name = in_frame.name;
+ if (!name || !in_frame.parent)
+ {
+ return null;
+ }
+
+ var candidates = in_frame.parent.document.getElementsByTagName('iframe');
+ for (var i = 0; i < candidates.length; i++)
+ {
+ if (candidates[i].name == name)
+ {
+ return candidates[i];
+ }
+ }
+
+ return null;
+ }
+}
+
+// }}}
+// {{{ domLib_getElementsByClass()
+
+function domLib_getElementsByClass(in_class)
+{
+ var elements = domLib_isIE5 ? document.all : document.getElementsByTagName('*');
+ var matches = [];
+ var cnt = 0;
+ for (var i = 0; i < elements.length; i++)
+ {
+ if ((" " + elements[i].className + " ").indexOf(" " + in_class + " ") != -1)
+ {
+ matches[cnt++] = elements[i];
+ }
+ }
+
+ return matches;
+}
+
+// }}}
+// {{{ domLib_getElementsByTagNames()
+
+function domLib_getElementsByTagNames(in_list, in_excludeHidden)
+{
+ var elements = [];
+ for (var i = 0; i < in_list.length; i++)
+ {
+ var matches = document.getElementsByTagName(in_list[i]);
+ for (var j = 0; j < matches.length; j++)
+ {
+ // skip objects that have nested embeds, or else we get "flashing"
+ if (matches[j].tagName == 'OBJECT' && domLib_isGecko)
+ {
+ var kids = matches[j].childNodes;
+ var skip = false;
+ for (var k = 0; k < kids.length; k++)
+ {
+ if (kids[k].tagName == 'EMBED')
+ {
+ skip = true;
+ break;
+ }
+ }
+ if (skip) continue;
+ }
+
+ if (in_excludeHidden && domLib_getComputedStyle(matches[j], 'visibility') == 'hidden')
+ {
+ continue;
+ }
+
+ elements[elements.length] = matches[j];
+ }
+ }
+
+ return elements;
+}
+
+// }}}
+// {{{ domLib_getComputedStyle()
+
+function domLib_getComputedStyle(in_obj, in_property)
+{
+ if (domLib_isIE)
+ {
+ var humpBackProp = in_property.replace(/-(.)/, function (a, b) { return b.toUpperCase(); });
+ return eval('in_obj.currentStyle.' + humpBackProp);
+ }
+ // getComputedStyle() is broken in konqueror, so let's go for the style object
+ else if (domLib_isKonq)
+ {
+ //var humpBackProp = in_property.replace(/-(.)/, function (a, b) { return b.toUpperCase(); });
+ return eval('in_obj.style.' + in_property);
+ }
+ else
+ {
+ return document.defaultView.getComputedStyle(in_obj, null).getPropertyValue(in_property);
+ }
+}
+
+// }}}
+// {{{ makeTrue()
+
+function makeTrue()
+{
+ return true;
+}
+
+// }}}
+// {{{ makeFalse()
+
+function makeFalse()
+{
+ return false;
+}
+
+// }}}
Added: branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/domTT.js
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/domTT.js (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/domTT.js 2008-01-25 16:03:46 UTC (rev 9608)
@@ -0,0 +1,1132 @@
+/** $Id: domTT.js 2324 2006-06-12 07:06:39Z dallen $ */
+// {{{ license
+
+/*
+ * Copyright 2002-2005 Dan Allen, Mojavelinux.com (dan.allen(a)mojavelinux.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// }}}
+// {{{ intro
+
+/**
+ * Title: DOM Tooltip Library
+ * Version: 0.7.3
+ *
+ * Summary:
+ * Allows developers to add custom tooltips to the webpages. Tooltips are
+ * generated using the domTT_activate() function and customized by setting
+ * a handful of options.
+ *
+ * Maintainer: Dan Allen <dan.allen(a)mojavelinux.com>
+ * Contributors:
+ * Josh Gross <josh(a)jportalhome.com>
+ * Jason Rust <jason(a)rustyparts.com>
+ *
+ * License: Apache 2.0
+ * However, if you use this library, you earn the position of official bug
+ * reporter :) Please post questions or problem reports to the newsgroup:
+ *
+ * http://groups-beta.google.com/group/dom-tooltip
+ *
+ * If you are doing this for commercial work, perhaps you could send me a few
+ * Starbucks Coffee gift dollars or PayPal bucks to encourage future
+ * developement (NOT REQUIRED). E-mail me for my snail mail address.
+
+ *
+ * Homepage: http://www.mojavelinux.com/projects/domtooltip/
+ *
+ * Newsgroup: http://groups-beta.google.com/group/dom-tooltip
+ *
+ * Freshmeat Project: http://freshmeat.net/projects/domtt/?topic_id=92
+ *
+ * Updated: 2005/07/16
+ *
+ * Supported Browsers:
+ * Mozilla (Gecko), IE 5.5+, IE on Mac, Safari, Konqueror, Opera 7
+ *
+ * Usage:
+ * Please see the HOWTO documentation.
+**/
+
+// }}}
+// {{{ settings (editable)
+
+// IE mouse events seem to be off by 2 pixels
+var domTT_offsetX = (domLib_isIE ? -2 : 0);
+var domTT_offsetY = (domLib_isIE ? 4 : 2);
+var domTT_direction = 'southeast';
+var domTT_mouseHeight = domLib_isIE ? 13 : 19;
+var domTT_closeLink = 'X';
+var domTT_closeAction = 'hide';
+var domTT_activateDelay = 500;
+var domTT_maxWidth = false;
+var domTT_styleClass = 'domTT';
+var domTT_fade = 'neither';
+var domTT_lifetime = 0;
+var domTT_grid = 0;
+var domTT_trailDelay = 200;
+var domTT_useGlobalMousePosition = true;
+var domTT_postponeActivation = false;
+var domTT_tooltipIdPrefix = '[domTT]';
+var domTT_screenEdgeDetection = true;
+var domTT_screenEdgePadding = 4;
+var domTT_oneOnly = false;
+var domTT_cloneNodes = false;
+var domTT_detectCollisions = true;
+var domTT_bannedTags = ['OPTION'];
+var domTT_draggable = false;
+if (typeof(domTT_dragEnabled) == 'undefined')
+{
+ domTT_dragEnabled = false;
+}
+
+// }}}
+// {{{ globals (DO NOT EDIT)
+
+var domTT_predefined = new Hash();
+// tooltips are keyed on both the tip id and the owner id,
+// since events can originate on either object
+var domTT_tooltips = new Hash();
+var domTT_lastOpened = 0;
+var domTT_documentLoaded = false;
+var domTT_mousePosition = null;
+
+// }}}
+// {{{ document.onmousemove
+
+if (domLib_useLibrary && domTT_useGlobalMousePosition)
+{
+ document.onmousemove = function(in_event)
+ {
+ if (typeof(in_event) == 'undefined') { in_event = window.event; }
+
+ domTT_mousePosition = domLib_getEventPosition(in_event);
+ if (domTT_dragEnabled && domTT_dragMouseDown)
+ {
+ domTT_dragUpdate(in_event);
+ }
+ }
+}
+
+// }}}
+// {{{ domTT_activate()
+
+function domTT_activate(in_this, in_event)
+{
+ if (!domLib_useLibrary || (domTT_postponeActivation && !domTT_documentLoaded)) { return false; }
+
+ // make sure in_event is set (for IE, some cases we have to use window.event)
+ if (typeof(in_event) == 'undefined') { in_event = window.event; }
+
+ // don't allow tooltips on banned tags (such as OPTION)
+ if (in_event != null) {
+ var target = in_event.srcElement ? in_event.srcElement : in_event.target;
+ if (target != null && (',' + domTT_bannedTags.join(',') + ',').indexOf(',' + target.tagName + ',') != -1)
+ {
+ return false;
+ }
+ }
+
+ var owner = document.body;
+ // we have an active event so get the owner
+ if (in_event != null && in_event.type.match(/key|mouse|click|contextmenu/i))
+ {
+ // make sure we have nothing higher than the body element
+ if (in_this.nodeType && in_this.nodeType != document.DOCUMENT_NODE)
+ {
+ owner = in_this;
+ }
+ }
+ // non active event (make sure we were passed a string id)
+ else
+ {
+ if (typeof(in_this) != 'object' && !(owner = domTT_tooltips.get(in_this)))
+ {
+ // NOTE: two steps to avoid "flashing" in gecko
+ var embryo = document.createElement('div');
+ owner = document.body.appendChild(embryo);
+ owner.style.display = 'none';
+ owner.id = in_this;
+ }
+ }
+
+ // make sure the owner has a unique id
+ if (!owner.id)
+ {
+ owner.id = '__autoId' + domLib_autoId++;
+ }
+
+ // see if we should only be opening one tip at a time
+ // NOTE: this is not "perfect" yet since it really steps on any other
+ // tip working on fade out or delayed close, but it get's the job done
+ if (domTT_oneOnly && domTT_lastOpened)
+ {
+ domTT_deactivate(domTT_lastOpened);
+ }
+
+ domTT_lastOpened = owner.id;
+
+ var tooltip = domTT_tooltips.get(owner.id);
+ if (tooltip)
+ {
+ if (tooltip.get('eventType') != in_event.type)
+ {
+ if (tooltip.get('type') == 'greasy')
+ {
+ tooltip.set('closeAction', 'destroy');
+ domTT_deactivate(owner.id);
+ }
+ else if (tooltip.get('status') != 'inactive')
+ {
+ return owner.id;
+ }
+ }
+ else
+ {
+ if (tooltip.get('status') == 'inactive')
+ {
+ tooltip.set('status', 'pending');
+ tooltip.set('activateTimeout', domLib_setTimeout(domTT_runShow, tooltip.get('delay'), [owner.id, in_event]));
+
+ return owner.id;
+ }
+ // either pending or active, let it be
+ else
+ {
+ return owner.id;
+ }
+ }
+ }
+
+ // setup the default options hash
+ var options = new Hash(
+ 'caption', '',
+ 'content', '',
+ 'clearMouse', true,
+ 'closeAction', domTT_closeAction,
+ 'closeLink', domTT_closeLink,
+ 'delay', domTT_activateDelay,
+ 'direction', domTT_direction,
+ 'draggable', domTT_draggable,
+ 'fade', domTT_fade,
+ 'fadeMax', 100,
+ 'grid', domTT_grid,
+ 'id', domTT_tooltipIdPrefix + owner.id,
+ 'inframe', false,
+ 'lifetime', domTT_lifetime,
+ 'offsetX', domTT_offsetX,
+ 'offsetY', domTT_offsetY,
+ 'parent', document.body,
+ 'position', 'absolute',
+ 'styleClass', domTT_styleClass,
+ 'type', 'greasy',
+ 'trail', false,
+ 'lazy', false
+ );
+
+ // load in the options from the function call
+ for (var i = 2; i < arguments.length; i += 2)
+ {
+ // load in predefined
+ if (arguments[i] == 'predefined')
+ {
+ var predefinedOptions = domTT_predefined.get(arguments[i + 1]);
+ for (var j in predefinedOptions.elementData)
+ {
+ options.set(j, predefinedOptions.get(j));
+ }
+ }
+ // set option
+ else
+ {
+ options.set(arguments[i], arguments[i + 1]);
+ }
+ }
+
+ options.set('eventType', in_event != null ? in_event.type : null);
+
+ // immediately set the status text if provided
+ if (options.has('statusText'))
+ {
+ try { window.status = options.get('statusText'); } catch(e) {}
+ }
+
+ // if we didn't give content...assume we just wanted to change the status and return
+ if (!options.has('content') || options.get('content') == '' || options.get('content') == null)
+ {
+ if (typeof(owner.onmouseout) != 'function')
+ {
+ owner.onmouseout = function(in_event) { domTT_mouseout(this, in_event); };
+ }
+
+ return owner.id;
+ }
+
+ options.set('owner', owner);
+
+ domTT_create(options);
+
+ // determine the show delay
+ options.set('delay', (in_event != null && in_event.type.match(/click|mousedown|contextmenu/i)) ? 0 : parseInt(options.get('delay')));
+ domTT_tooltips.set(owner.id, options);
+ domTT_tooltips.set(options.get('id'), options);
+ options.set('status', 'pending');
+ options.set('activateTimeout', domLib_setTimeout(domTT_runShow, options.get('delay'), [owner.id, in_event]));
+
+ return owner.id;
+}
+
+// }}}
+// {{{ domTT_create()
+
+function domTT_create(in_options)
+{
+ var tipOwner = in_options.get('owner');
+ var parentObj = in_options.get('parent');
+ var parentDoc = parentObj.ownerDocument || parentObj.document;
+
+ // create the tooltip and hide it
+ // NOTE: two steps to avoid "flashing" in gecko
+ var embryo = parentDoc.createElement('div');
+ var tipObj = parentObj.appendChild(embryo);
+ tipObj.style.position = 'absolute';
+ tipObj.style.left = '0px';
+ tipObj.style.top = '0px';
+ tipObj.style.visibility = 'hidden';
+ tipObj.id = in_options.get('id');
+ tipObj.className = in_options.get('styleClass');
+
+ var contentBlock;
+ var tableLayout = false;
+
+ if (in_options.get('caption') || (in_options.get('type') == 'sticky' && in_options.get('caption') !== false))
+ {
+ tableLayout = true;
+ // layout the tip with a hidden formatting table
+ var tipLayoutTable = tipObj.appendChild(parentDoc.createElement('table'));
+ tipLayoutTable.style.borderCollapse = 'collapse';
+ if (domLib_isKHTML)
+ {
+ tipLayoutTable.cellSpacing = 0;
+ }
+
+ var tipLayoutTbody = tipLayoutTable.appendChild(parentDoc.createElement('tbody'));
+
+ var numCaptionCells = 0;
+ var captionRow = tipLayoutTbody.appendChild(parentDoc.createElement('tr'));
+ var captionCell = captionRow.appendChild(parentDoc.createElement('td'));
+ captionCell.style.padding = '0px';
+ var caption = captionCell.appendChild(parentDoc.createElement('div'));
+ caption.className = 'caption';
+ if (domLib_isIE50)
+ {
+ caption.style.height = '100%';
+ }
+
+ if (in_options.get('caption').nodeType)
+ {
+ caption.appendChild(domTT_cloneNodes ? in_options.get('caption').cloneNode(1) : in_options.get('caption'));
+ }
+ else
+ {
+ caption.innerHTML = in_options.get('caption');
+ }
+
+ if (in_options.get('type') == 'sticky')
+ {
+ var numCaptionCells = 2;
+ var closeLinkCell = captionRow.appendChild(parentDoc.createElement('td'));
+ closeLinkCell.style.padding = '0px';
+ var closeLink = closeLinkCell.appendChild(parentDoc.createElement('div'));
+ closeLink.className = 'caption';
+ if (domLib_isIE50)
+ {
+ closeLink.style.height = '100%';
+ }
+
+ closeLink.style.textAlign = 'right';
+ closeLink.style.cursor = domLib_stylePointer;
+ // merge the styles of the two cells
+ closeLink.style.borderLeftWidth = caption.style.borderRightWidth = '0px';
+ closeLink.style.paddingLeft = caption.style.paddingRight = '0px';
+ closeLink.style.marginLeft = caption.style.marginRight = '0px';
+ if (in_options.get('closeLink').nodeType)
+ {
+ closeLink.appendChild(in_options.get('closeLink').cloneNode(1));
+ }
+ else
+ {
+ closeLink.innerHTML = in_options.get('closeLink');
+ }
+
+ closeLink.onclick = function()
+ {
+ domTT_deactivate(tipOwner.id);
+ };
+ closeLink.onmousedown = function(in_event)
+ {
+ if (typeof(in_event) == 'undefined') { in_event = window.event; }
+ in_event.cancelBubble = true;
+ };
+ // MacIE has to have a newline at the end and must be made with createTextNode()
+ if (domLib_isMacIE)
+ {
+ closeLinkCell.appendChild(parentDoc.createTextNode("\n"));
+ }
+ }
+
+ // MacIE has to have a newline at the end and must be made with createTextNode()
+ if (domLib_isMacIE)
+ {
+ captionCell.appendChild(parentDoc.createTextNode("\n"));
+ }
+
+ var contentRow = tipLayoutTbody.appendChild(parentDoc.createElement('tr'));
+ var contentCell = contentRow.appendChild(parentDoc.createElement('td'));
+ contentCell.style.padding = '0px';
+ if (numCaptionCells)
+ {
+ if (domLib_isIE || domLib_isOpera)
+ {
+ contentCell.colSpan = numCaptionCells;
+ }
+ else
+ {
+ contentCell.setAttribute('colspan', numCaptionCells);
+ }
+ }
+
+ contentBlock = contentCell.appendChild(parentDoc.createElement('div'));
+ if (domLib_isIE50)
+ {
+ contentBlock.style.height = '100%';
+ }
+ }
+ else
+ {
+ contentBlock = tipObj.appendChild(parentDoc.createElement('div'));
+ }
+
+ contentBlock.className = 'contents';
+
+ var content = in_options.get('content');
+ // allow content has a function to return the actual content
+ if (typeof(content) == 'function') {
+ content = content(in_options.get('id'));
+ }
+
+ if (content != null && content.nodeType)
+ {
+ contentBlock.appendChild(domTT_cloneNodes ? content.cloneNode(1) : content);
+ }
+ else
+ {
+ contentBlock.innerHTML = content;
+ }
+
+ // adjust the width if specified
+ if (in_options.has('width'))
+ {
+ tipObj.style.width = parseInt(in_options.get('width')) + 'px';
+ }
+
+ // check if we are overridding the maxWidth
+ // if the browser supports maxWidth, the global setting will be ignored (assume stylesheet)
+ var maxWidth = domTT_maxWidth;
+ if (in_options.has('maxWidth'))
+ {
+ if ((maxWidth = in_options.get('maxWidth')) === false)
+ {
+ tipObj.style.maxWidth = domLib_styleNoMaxWidth;
+ }
+ else
+ {
+ maxWidth = parseInt(in_options.get('maxWidth'));
+ tipObj.style.maxWidth = maxWidth + 'px';
+ }
+ }
+
+ // HACK: fix lack of maxWidth in CSS for KHTML and IE
+ if (maxWidth !== false && (domLib_isIE || domLib_isKHTML) && tipObj.offsetWidth > maxWidth)
+ {
+ tipObj.style.width = maxWidth + 'px';
+ }
+
+ in_options.set('offsetWidth', tipObj.offsetWidth);
+ in_options.set('offsetHeight', tipObj.offsetHeight);
+
+ // konqueror miscalcuates the width of the containing div when using the layout table based on the
+ // border size of the containing div
+ if (domLib_isKonq && tableLayout && !tipObj.style.width)
+ {
+ var left = document.defaultView.getComputedStyle(tipObj, '').getPropertyValue('border-left-width');
+ var right = document.defaultView.getComputedStyle(tipObj, '').getPropertyValue('border-right-width');
+
+ left = left.substring(left.indexOf(':') + 2, left.indexOf(';'));
+ right = right.substring(right.indexOf(':') + 2, right.indexOf(';'));
+ var correction = 2 * ((left ? parseInt(left) : 0) + (right ? parseInt(right) : 0));
+ tipObj.style.width = (tipObj.offsetWidth - correction) + 'px';
+ }
+
+ // if a width is not set on an absolutely positioned object, both IE and Opera
+ // will attempt to wrap when it spills outside of body...we cannot have that
+ if (domLib_isIE || domLib_isOpera)
+ {
+ if (!tipObj.style.width)
+ {
+ // HACK: the correction here is for a border
+ tipObj.style.width = (tipObj.offsetWidth - 2) + 'px';
+ }
+
+ // HACK: the correction here is for a border
+ tipObj.style.height = (tipObj.offsetHeight - 2) + 'px';
+ }
+
+ // store placement offsets from event position
+ var offsetX, offsetY;
+
+ // tooltip floats
+ if (in_options.get('position') == 'absolute' && !(in_options.has('x') && in_options.has('y')))
+ {
+ // determine the offset relative to the pointer
+ switch (in_options.get('direction'))
+ {
+ case 'northeast':
+ offsetX = in_options.get('offsetX');
+ offsetY = 0 - tipObj.offsetHeight - in_options.get('offsetY');
+ break;
+ case 'northwest':
+ offsetX = 0 - tipObj.offsetWidth - in_options.get('offsetX');
+ offsetY = 0 - tipObj.offsetHeight - in_options.get('offsetY');
+ break;
+ case 'north':
+ offsetX = 0 - parseInt(tipObj.offsetWidth/2);
+ offsetY = 0 - tipObj.offsetHeight - in_options.get('offsetY');
+ break;
+ case 'southwest':
+ offsetX = 0 - tipObj.offsetWidth - in_options.get('offsetX');
+ offsetY = in_options.get('offsetY');
+ break;
+ case 'southeast':
+ offsetX = in_options.get('offsetX');
+ offsetY = in_options.get('offsetY');
+ break;
+ case 'south':
+ offsetX = 0 - parseInt(tipObj.offsetWidth/2);
+ offsetY = in_options.get('offsetY');
+ break;
+ }
+
+ // if we are in an iframe, get the offsets of the iframe in the parent document
+ if (in_options.get('inframe'))
+ {
+ var iframeObj = domLib_getIFrameReference(window);
+ if (iframeObj)
+ {
+ var frameOffsets = domLib_getOffsets(iframeObj);
+ offsetX += frameOffsets.get('left');
+ offsetY += frameOffsets.get('top');
+ }
+ }
+ }
+ // tooltip is fixed
+ else
+ {
+ offsetX = 0;
+ offsetY = 0;
+ in_options.set('trail', false);
+ }
+
+ // set the direction-specific offsetX/Y
+ in_options.set('offsetX', offsetX);
+ in_options.set('offsetY', offsetY);
+ if (in_options.get('clearMouse') && in_options.get('direction').indexOf('south') != -1)
+ {
+ in_options.set('mouseOffset', domTT_mouseHeight);
+ }
+ else
+ {
+ in_options.set('mouseOffset', 0);
+ }
+
+ if (domLib_canFade && typeof(Fadomatic) == 'function')
+ {
+ if (in_options.get('fade') != 'neither')
+ {
+ var fadeHandler = new Fadomatic(tipObj, 10, 0, 0, in_options.get('fadeMax'));
+ in_options.set('fadeHandler', fadeHandler);
+ }
+ }
+ else
+ {
+ in_options.set('fade', 'neither');
+ }
+
+ // setup mouse events
+ if (in_options.get('trail') && typeof(tipOwner.onmousemove) != 'function')
+ {
+ tipOwner.onmousemove = function(in_event) { domTT_mousemove(this, in_event); };
+ }
+
+ if (typeof(tipOwner.onmouseout) != 'function')
+ {
+ tipOwner.onmouseout = function(in_event) { domTT_mouseout(this, in_event); };
+ }
+
+ if (in_options.get('type') == 'sticky')
+ {
+ if (in_options.get('position') == 'absolute' && domTT_dragEnabled && in_options.get('draggable'))
+ {
+ if (domLib_isIE)
+ {
+ captionRow.onselectstart = function() { return false; };
+ }
+
+ // setup drag
+ captionRow.onmousedown = function(in_event) { domTT_dragStart(tipObj, in_event); };
+ captionRow.onmousemove = function(in_event) { domTT_dragUpdate(in_event); };
+ captionRow.onmouseup = function() { domTT_dragStop(); };
+ }
+ }
+ else if (in_options.get('type') == 'velcro')
+ {
+ /* can use once we have deactivateDelay
+ tipObj.onmouseover = function(in_event)
+ {
+ if (typeof(in_event) == 'undefined') { in_event = window.event; }
+ var tooltip = domTT_tooltips.get(tipObj.id);
+ if (in_options.get('lifetime')) {
+ domLib_clearTimeout(in_options.get('lifetimeTimeout');
+ }
+ };
+ */
+ tipObj.onmouseout = function(in_event)
+ {
+ if (typeof(in_event) == 'undefined') { in_event = window.event; }
+ if (!domLib_isDescendantOf(in_event[domLib_eventTo], tipObj, domTT_bannedTags)) {
+ domTT_deactivate(tipOwner.id);
+ }
+ };
+ // NOTE: this might interfere with links in the tip
+ tipObj.onclick = function(in_event)
+ {
+ domTT_deactivate(tipOwner.id);
+ };
+ }
+
+ if (in_options.get('position') == 'relative')
+ {
+ tipObj.style.position = 'relative';
+ }
+
+ in_options.set('node', tipObj);
+ in_options.set('status', 'inactive');
+}
+
+// }}}
+// {{{ domTT_show()
+
+// in_id is either tip id or the owner id
+function domTT_show(in_id, in_event)
+{
+
+ // should always find one since this call would be cancelled if tip was killed
+ var tooltip = domTT_tooltips.get(in_id);
+ var status = tooltip.get('status');
+ var tipObj = tooltip.get('node');
+
+ if (tooltip.get('position') == 'absolute')
+ {
+ var mouseX, mouseY;
+
+ if (tooltip.has('x') && tooltip.has('y'))
+ {
+ mouseX = tooltip.get('x');
+ mouseY = tooltip.get('y');
+ }
+ else if (!domTT_useGlobalMousePosition || domTT_mousePosition == null || status == 'active' || tooltip.get('delay') == 0)
+ {
+ var eventPosition = domLib_getEventPosition(in_event);
+ var eventX = eventPosition.get('x');
+ var eventY = eventPosition.get('y');
+ if (tooltip.get('inframe'))
+ {
+ eventX -= eventPosition.get('scrollX');
+ eventY -= eventPosition.get('scrollY');
+ }
+
+ // only move tip along requested trail axis when updating position
+ if (status == 'active' && tooltip.get('trail') !== true)
+ {
+ var trail = tooltip.get('trail');
+ if (trail == 'x')
+ {
+ mouseX = eventX;
+ mouseY = tooltip.get('mouseY');
+ }
+ else if (trail == 'y')
+ {
+ mouseX = tooltip.get('mouseX');
+ mouseY = eventY;
+ }
+ }
+ else
+ {
+ mouseX = eventX;
+ mouseY = eventY;
+ }
+ }
+ else
+ {
+ mouseX = domTT_mousePosition.get('x');
+ mouseY = domTT_mousePosition.get('y');
+ if (tooltip.get('inframe'))
+ {
+ mouseX -= domTT_mousePosition.get('scrollX');
+ mouseY -= domTT_mousePosition.get('scrollY');
+ }
+ }
+
+ // we are using a grid for updates
+ if (tooltip.get('grid'))
+ {
+ // if this is not a mousemove event or it is a mousemove event on an active tip and
+ // the movement is bigger than the grid
+ if (in_event.type != 'mousemove' || (status == 'active' && (Math.abs(tooltip.get('lastX') - mouseX) > tooltip.get('grid') || Math.abs(tooltip.get('lastY') - mouseY) > tooltip.get('grid'))))
+ {
+ tooltip.set('lastX', mouseX);
+ tooltip.set('lastY', mouseY);
+ }
+ // did not satisfy the grid movement requirement
+ else
+ {
+ return false;
+ }
+ }
+
+ // mouseX and mouseY store the last acknowleged mouse position,
+ // good for trailing on one axis
+ tooltip.set('mouseX', mouseX);
+ tooltip.set('mouseY', mouseY);
+
+ var coordinates;
+ if (domTT_screenEdgeDetection)
+ {
+ coordinates = domTT_correctEdgeBleed(
+ tooltip.get('offsetWidth'),
+ tooltip.get('offsetHeight'),
+ mouseX,
+ mouseY,
+ tooltip.get('offsetX'),
+ tooltip.get('offsetY'),
+ tooltip.get('mouseOffset'),
+ tooltip.get('inframe') ? window.parent : window
+ );
+ }
+ else
+ {
+ coordinates = {
+ 'x' : mouseX + tooltip.get('offsetX'),
+ 'y' : mouseY + tooltip.get('offsetY') + tooltip.get('mouseOffset')
+ };
+ }
+
+ // update the position
+ tipObj.style.left = coordinates.x + 'px';
+ tipObj.style.top = coordinates.y + 'px';
+
+ // increase the tip zIndex so it goes over previously shown tips
+ tipObj.style.zIndex = domLib_zIndex++;
+ }
+
+ // if tip is not active, active it now and check for a fade in
+ if (status == 'pending')
+ {
+ // unhide the tooltip
+ tooltip.set('status', 'active');
+ tipObj.style.display = '';
+ tipObj.style.visibility = 'visible';
+
+ var fade = tooltip.get('fade');
+ if (fade != 'neither')
+ {
+ var fadeHandler = tooltip.get('fadeHandler');
+ if (fade == 'out' || fade == 'both')
+ {
+ fadeHandler.haltFade();
+ if (fade == 'out')
+ {
+ fadeHandler.halt();
+ }
+ }
+
+ if (fade == 'in' || fade == 'both')
+ {
+ fadeHandler.fadeIn();
+ }
+ }
+
+ if (tooltip.get('type') == 'greasy' && tooltip.get('lifetime') != 0)
+ {
+ tooltip.set('lifetimeTimeout', domLib_setTimeout(domTT_runDeactivate, tooltip.get('lifetime'), [tipObj.id]));
+ }
+ }
+
+ if (tooltip.get('position') == 'absolute' && domTT_detectCollisions)
+ {
+ // utilize original collision element cache
+ domLib_detectCollisions(tipObj, false, true);
+ }
+}
+
+// }}}
+// {{{ domTT_close()
+
+// in_handle can either be an child object of the tip, the tip id or the owner id
+function domTT_close(in_handle)
+{
+ var id;
+ if (typeof(in_handle) == 'object' && in_handle.nodeType)
+ {
+ var obj = in_handle;
+ while (!obj.id || !domTT_tooltips.get(obj.id))
+ {
+ obj = obj.parentNode;
+
+ if (obj.nodeType != document.ELEMENT_NODE) { return; }
+ }
+
+ id = obj.id;
+ }
+ else
+ {
+ id = in_handle;
+ }
+
+ domTT_deactivate(id);
+}
+
+// }}}
+// {{{ domTT_closeAll()
+
+// run through the tooltips and close them all
+function domTT_closeAll()
+{
+ // NOTE: this will iterate 2x # of tooltips
+ for (var id in domTT_tooltips.elementData) {
+ domTT_close(id);
+ }
+}
+
+// }}}
+// {{{ domTT_deactivate()
+
+// in_id is either the tip id or the owner id
+function domTT_deactivate(in_id)
+{
+ var tooltip = domTT_tooltips.get(in_id);
+ if (tooltip)
+ {
+ var status = tooltip.get('status');
+ if (status == 'pending')
+ {
+ // cancel the creation of this tip if it is still pending
+ domLib_clearTimeout(tooltip.get('activateTimeout'));
+ tooltip.set('status', 'inactive');
+ }
+ else if (status == 'active')
+ {
+ if (tooltip.get('lifetime'))
+ {
+ domLib_clearTimeout(tooltip.get('lifetimeTimeout'));
+ }
+
+ var tipObj = tooltip.get('node');
+ if (tooltip.get('closeAction') == 'hide')
+ {
+ var fade = tooltip.get('fade');
+ if (fade != 'neither')
+ {
+ var fadeHandler = tooltip.get('fadeHandler');
+ if (fade == 'out' || fade == 'both')
+ {
+ fadeHandler.fadeOut();
+ }
+ else
+ {
+ fadeHandler.hide();
+ }
+ }
+ else
+ {
+ tipObj.style.display = 'none';
+ }
+ }
+ else
+ {
+ tooltip.get('parent').removeChild(tipObj);
+ domTT_tooltips.remove(tooltip.get('owner').id);
+ domTT_tooltips.remove(tooltip.get('id'));
+ }
+
+ tooltip.set('status', 'inactive');
+ if (domTT_detectCollisions) {
+ // unhide all of the selects that are owned by this object
+ // utilize original collision element cache
+ domLib_detectCollisions(tipObj, true, true);
+ }
+ }
+ }
+}
+
+// }}}
+// {{{ domTT_mouseout()
+
+function domTT_mouseout(in_owner, in_event)
+{
+ if (!domLib_useLibrary) { return false; }
+
+ if (typeof(in_event) == 'undefined') { in_event = window.event; }
+
+ var toChild = domLib_isDescendantOf(in_event[domLib_eventTo], in_owner, domTT_bannedTags);
+ var tooltip = domTT_tooltips.get(in_owner.id);
+ if (tooltip && (tooltip.get('type') == 'greasy' || tooltip.get('status') != 'active'))
+ {
+ // deactivate tip if exists and we moved away from the owner
+ if (!toChild)
+ {
+ domTT_deactivate(in_owner.id);
+ try { window.status = window.defaultStatus; } catch(e) {}
+ }
+ }
+ else if (!toChild)
+ {
+ try { window.status = window.defaultStatus; } catch(e) {}
+ }
+}
+
+// }}}
+// {{{ domTT_mousemove()
+
+function domTT_mousemove(in_owner, in_event)
+{
+ if (!domLib_useLibrary) { return false; }
+
+ if (typeof(in_event) == 'undefined') { in_event = window.event; }
+
+ var tooltip = domTT_tooltips.get(in_owner.id);
+ if (tooltip && tooltip.get('trail') && tooltip.get('status') == 'active')
+ {
+ // see if we are trailing lazy
+ if (tooltip.get('lazy'))
+ {
+ domLib_setTimeout(domTT_runShow, domTT_trailDelay, [in_owner.id, in_event]);
+ }
+ else
+ {
+ domTT_show(in_owner.id, in_event);
+ }
+ }
+}
+
+// }}}
+// {{{ domTT_addPredefined()
+
+function domTT_addPredefined(in_id)
+{
+ var options = new Hash();
+ for (var i = 1; i < arguments.length; i += 2)
+ {
+ options.set(arguments[i], arguments[i + 1]);
+ }
+
+ domTT_predefined.set(in_id, options);
+}
+
+// }}}
+// {{{ domTT_correctEdgeBleed()
+
+function domTT_correctEdgeBleed(in_width, in_height, in_x, in_y, in_offsetX, in_offsetY, in_mouseOffset, in_window)
+{
+ var win, doc;
+ var bleedRight, bleedBottom;
+ var pageHeight, pageWidth, pageYOffset, pageXOffset;
+
+ var x = in_x + in_offsetX;
+ var y = in_y + in_offsetY + in_mouseOffset;
+
+ win = (typeof(in_window) == 'undefined' ? window : in_window);
+
+ // Gecko and IE swaps values of clientHeight, clientWidth properties when
+ // in standards compliance mode from documentElement to document.body
+ doc = ((domLib_standardsMode && (domLib_isIE || domLib_isGecko)) ? win.document.documentElement : win.document.body);
+
+ // for IE in compliance mode
+ if (domLib_isIE)
+ {
+ pageHeight = doc.clientHeight;
+ pageWidth = doc.clientWidth;
+ pageYOffset = doc.scrollTop;
+ pageXOffset = doc.scrollLeft;
+ }
+ else
+ {
+ pageHeight = doc.clientHeight;
+ pageWidth = doc.clientWidth;
+
+ if (domLib_isKHTML)
+ {
+ pageHeight = win.innerHeight;
+ }
+
+ pageYOffset = win.pageYOffset;
+ pageXOffset = win.pageXOffset;
+ }
+
+ // we are bleeding off the right, move tip over to stay on page
+ // logic: take x position, add width and subtract from effective page width
+ if ((bleedRight = (x - pageXOffset) + in_width - (pageWidth - domTT_screenEdgePadding)) > 0)
+ {
+ x -= bleedRight;
+ }
+
+ // we are bleeding to the left, move tip over to stay on page
+ // if tip doesn't fit, we will go back to bleeding off the right
+ // logic: take x position and check if less than edge padding
+ if ((x - pageXOffset) < domTT_screenEdgePadding)
+ {
+ x = domTT_screenEdgePadding + pageXOffset;
+ }
+
+ // if we are bleeding off the bottom, flip to north
+ // logic: take y position, add height and subtract from effective page height
+ if ((bleedBottom = (y - pageYOffset) + in_height - (pageHeight - domTT_screenEdgePadding)) > 0)
+ {
+ y = in_y - in_height - in_offsetY;
+ }
+
+ // if we are bleeding off the top, flip to south
+ // if tip doesn't fit, we will go back to bleeding off the bottom
+ // logic: take y position and check if less than edge padding
+ if ((y - pageYOffset) < domTT_screenEdgePadding)
+ {
+ y = in_y + domTT_mouseHeight + in_offsetY;
+ }
+
+ return {'x' : x, 'y' : y};
+}
+
+// }}}
+// {{{ domTT_isActive()
+
+// in_id is either the tip id or the owner id
+function domTT_isActive(in_id)
+{
+ var tooltip = domTT_tooltips.get(in_id);
+ if (!tooltip || tooltip.get('status') != 'active')
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
+
+// }}}
+// {{{ domTT_runXXX()
+
+// All of these domMenu_runXXX() methods are used by the event handling sections to
+// avoid the circular memory leaks caused by inner functions
+function domTT_runDeactivate(args) { domTT_deactivate(args[0]); }
+function domTT_runShow(args) { domTT_show(args[0], args[1]); }
+
+// }}}
+// {{{ domTT_replaceTitles()
+
+function domTT_replaceTitles(in_decorator)
+{
+ var elements = domLib_getElementsByClass('tooltip');
+ for (var i = 0; i < elements.length; i++)
+ {
+ if (elements[i].title)
+ {
+ var content;
+ if (typeof(in_decorator) == 'function')
+ {
+ content = in_decorator(elements[i]);
+ }
+ else
+ {
+ content = elements[i].title;
+ }
+
+ content = content.replace(new RegExp('\'', 'g'), '\\\'');
+ elements[i].onmouseover = new Function('in_event', "domTT_activate(this, in_event, 'content', '" + content + "')");
+ elements[i].title = '';
+ }
+ }
+}
+
+// }}}
+// {{{ domTT_update()
+
+// Allow authors to update the contents of existing tips using the DOM
+// Unfortunately, the tip must already exist, or else no work is done.
+// TODO: make getting at content or caption cleaner
+function domTT_update(handle, content, type)
+{
+ // type defaults to 'content', can also be 'caption'
+ if (typeof(type) == 'undefined')
+ {
+ type = 'content';
+ }
+
+ var tip = domTT_tooltips.get(handle);
+ if (!tip)
+ {
+ return;
+ }
+
+ var tipObj = tip.get('node');
+ var updateNode;
+ if (type == 'content')
+ {
+ // <div class="contents">...
+ updateNode = tipObj.firstChild;
+ if (updateNode.className != 'contents')
+ {
+ // <table><tbody><tr>...</tr><tr><td><div class="contents">...
+ updateNode = updateNode.firstChild.firstChild.nextSibling.firstChild.firstChild;
+ }
+ }
+ else
+ {
+ updateNode = tipObj.firstChild;
+ if (updateNode.className == 'contents')
+ {
+ // missing caption
+ return;
+ }
+
+ // <table><tbody><tr><td><div class="caption">...
+ updateNode = updateNode.firstChild.firstChild.firstChild.firstChild;
+ }
+
+ // TODO: allow for a DOM node as content
+ updateNode.innerHTML = content;
+}
+
+// }}}
Added: branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/domTT_drag.js
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/domTT_drag.js (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/domTT_drag.js 2008-01-25 16:03:46 UTC (rev 9608)
@@ -0,0 +1,102 @@
+/** $Id: domTT_drag.js 2315 2006-06-12 05:45:36Z dallen $ */
+// {{{ license
+
+/*
+ * Copyright 2002-2005 Dan Allen, Mojavelinux.com (dan.allen(a)mojavelinux.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// }}}
+// {{{ globals (DO NOT EDIT)
+
+var domTT_dragEnabled = true;
+var domTT_currentDragTarget;
+var domTT_dragMouseDown;
+var domTT_dragOffsetLeft;
+var domTT_dragOffsetTop;
+
+// }}}
+// {{{ domTT_dragStart()
+
+function domTT_dragStart(in_this, in_event)
+{
+ if (typeof(in_event) == 'undefined') { in_event = window.event; }
+
+ var eventButton = in_event[domLib_eventButton];
+ if (eventButton != 1 && !domLib_isKHTML)
+ {
+ return;
+ }
+
+ domTT_currentDragTarget = in_this;
+ in_this.style.cursor = 'move';
+
+ // upgrade our z-index
+ in_this.style.zIndex = ++domLib_zIndex;
+
+ var eventPosition = domLib_getEventPosition(in_event);
+
+ var targetPosition = domLib_getOffsets(in_this);
+ domTT_dragOffsetLeft = eventPosition.get('x') - targetPosition.get('left');
+ domTT_dragOffsetTop = eventPosition.get('y') - targetPosition.get('top');
+ domTT_dragMouseDown = true;
+}
+
+// }}}
+// {{{ domTT_dragUpdate()
+
+function domTT_dragUpdate(in_event)
+{
+ if (domTT_dragMouseDown)
+ {
+ if (domLib_isGecko)
+ {
+ window.getSelection().removeAllRanges()
+ }
+
+ if (domTT_useGlobalMousePosition && domTT_mousePosition != null)
+ {
+ var eventPosition = domTT_mousePosition;
+ }
+ else
+ {
+ if (typeof(in_event) == 'undefined') { in_event = window.event; }
+ var eventPosition = domLib_getEventPosition(in_event);
+ }
+
+ domTT_currentDragTarget.style.left = (eventPosition.get('x') - domTT_dragOffsetLeft) + 'px';
+ domTT_currentDragTarget.style.top = (eventPosition.get('y') - domTT_dragOffsetTop) + 'px';
+
+ // update the collision detection
+ domLib_detectCollisions(domTT_currentDragTarget);
+ }
+}
+
+// }}}
+// {{{ domTT_dragStop()
+
+function domTT_dragStop()
+{
+ if (domTT_dragMouseDown) {
+ domTT_dragMouseDown = false;
+ domTT_currentDragTarget.style.cursor = 'default';
+ domTT_currentDragTarget = null;
+ if (domLib_isGecko)
+ {
+ window.getSelection().removeAllRanges()
+ }
+ }
+}
+
+// }}}
Added: branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/fadomatic.js
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/fadomatic.js (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/bin/portal-admin-war/js/fadomatic.js 2008-01-25 16:03:46 UTC (rev 9608)
@@ -0,0 +1,180 @@
+/** $Id$ */
+// Title: Fadomatic
+// Version: 1.2
+// Homepage: http://chimpen.com/fadomatic
+// Author: Philip McCarthy <fadomatic(a)chimpen.com>
+
+// Fade interval in milliseconds
+// Make this larger if you experience performance issues
+Fadomatic.INTERVAL_MILLIS = 50;
+
+// Creates a fader
+// element - The element to fade
+// speed - The speed to fade at, from 0.0 to 100.0
+// initialOpacity (optional, default 100) - element's starting opacity, 0 to 100
+// minOpacity (optional, default 0) - element's minimum opacity, 0 to 100
+// maxOpacity (optional, default 0) - element's minimum opacity, 0 to 100
+function Fadomatic (element, rate, initialOpacity, minOpacity, maxOpacity) {
+ this._element = element;
+ this._intervalId = null;
+ this._rate = rate;
+ this._isFadeOut = true;
+
+ // Set initial opacity and bounds
+ // NB use 99 instead of 100 to avoid flicker at start of fade
+ this._minOpacity = 0;
+ this._maxOpacity = 99;
+ this._opacity = 99;
+
+ if (typeof minOpacity != 'undefined') {
+ if (minOpacity < 0) {
+ this._minOpacity = 0;
+ } else if (minOpacity > 99) {
+ this._minOpacity = 99;
+ } else {
+ this._minOpacity = minOpacity;
+ }
+ }
+
+ if (typeof maxOpacity != 'undefined') {
+ if (maxOpacity < 0) {
+ this._maxOpacity = 0;
+ } else if (maxOpacity > 99) {
+ this._maxOpacity = 99;
+ } else {
+ this._maxOpacity = maxOpacity;
+ }
+
+ if (this._maxOpacity < this._minOpacity) {
+ this._maxOpacity = this._minOpacity;
+ }
+ }
+
+ if (typeof initialOpacity != 'undefined') {
+ if (initialOpacity > this._maxOpacity) {
+ this._opacity = this._maxOpacity;
+ } else if (initialOpacity < this._minOpacity) {
+ this._opacity = this._minOpacity;
+ } else {
+ this._opacity = initialOpacity;
+ }
+ }
+
+ // See if we're using W3C opacity, MSIE filter, or just
+ // toggling visiblity
+ if(typeof element.style.opacity != 'undefined') {
+
+ this._updateOpacity = this._updateOpacityW3c;
+
+ } else if(typeof element.style.filter != 'undefined') {
+
+ // If there's not an alpha filter on the element already,
+ // add one
+ if (element.style.filter.indexOf("alpha") == -1) {
+
+ // Attempt to preserve existing filters
+ var existingFilters="";
+ if (element.style.filter) {
+ existingFilters = element.style.filter+" ";
+ }
+ element.style.filter = existingFilters+"alpha(opacity="+this._opacity+")";
+ }
+
+ this._updateOpacity = this._updateOpacityMSIE;
+
+ } else {
+
+ this._updateOpacity = this._updateVisibility;
+ }
+
+ this._updateOpacity();
+}
+
+// Initiates a fade out
+Fadomatic.prototype.fadeOut = function () {
+ this._isFadeOut = true;
+ this._beginFade();
+}
+
+// Initiates a fade in
+Fadomatic.prototype.fadeIn = function () {
+ this._isFadeOut = false;
+ this._beginFade();
+}
+
+// Makes the element completely opaque, stops any fade in progress
+Fadomatic.prototype.show = function () {
+ this.haltFade();
+ this._opacity = this._maxOpacity;
+ this._updateOpacity();
+}
+
+// Makes the element completely transparent, stops any fade in progress
+Fadomatic.prototype.hide = function () {
+ this.haltFade();
+ this._opacity = 0;
+ this._updateOpacity();
+}
+
+// Halts any fade in progress
+Fadomatic.prototype.haltFade = function () {
+
+ clearInterval(this._intervalId);
+}
+
+// Resumes a fade where it was halted
+Fadomatic.prototype.resumeFade = function () {
+
+ this._beginFade();
+}
+
+// Pseudo-private members
+
+Fadomatic.prototype._beginFade = function () {
+
+ this.haltFade();
+ var objref = this;
+ this._intervalId = setInterval(function() { objref._tickFade(); },Fadomatic.INTERVAL_MILLIS);
+}
+
+Fadomatic.prototype._tickFade = function () {
+
+ if (this._isFadeOut) {
+ this._opacity -= this._rate;
+ if (this._opacity < this._minOpacity) {
+ this._opacity = this._minOpacity;
+ this.haltFade();
+ }
+ } else {
+ this._opacity += this._rate;
+ if (this._opacity > this._maxOpacity ) {
+ this._opacity = this._maxOpacity;
+ this.haltFade();
+ }
+ }
+
+ this._updateOpacity();
+}
+
+Fadomatic.prototype._updateVisibility = function () {
+
+ if (this._opacity > 0) {
+ this._element.style.visibility = 'visible';
+ } else {
+ this._element.style.visibility = 'hidden';
+ }
+}
+
+Fadomatic.prototype._updateOpacityW3c = function () {
+
+ this._element.style.opacity = this._opacity/100;
+ this._updateVisibility();
+}
+
+Fadomatic.prototype._updateOpacityMSIE = function () {
+
+ this._element.filters.alpha.opacity = this._opacity;
+ this._updateVisibility();
+}
+
+Fadomatic.prototype._updateOpacity = null;
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml 2008-01-25 15:55:50 UTC (rev 9607)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml 2008-01-25 16:03:46 UTC (rev 9608)
@@ -10,7 +10,8 @@
<ui:define name="content">
<!-- -->
- <div>
+
+ <div class="clear">
<jbp:portlet
actionListener="#{portalobjectmgr.processEvent}"
portletId="#{portalobjectmgr.selectedContentEditorInstance}"
18 years, 3 months
JBoss Portal SVN: r9607 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet and 6 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-25 10:55:50 -0500 (Fri, 25 Jan 2008)
New Revision: 9607
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheControl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheLevel.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheScope.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/CacheControlImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/RevalidateMarkupResponse.java
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/CacheabilityType.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java
Log:
refactor to start to add support for cache control
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/CacheabilityType.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/CacheabilityType.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/CacheabilityType.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -1,34 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public enum CacheabilityType
-{
-
- FULL, PORTLET, PAGE
-
-}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet;
+import org.jboss.portal.portlet.cache.CacheLevel;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
@@ -48,6 +50,6 @@
*
* @return the resource cacheability
*/
- CacheabilityType getCacheability();
+ CacheLevel getCacheability();
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -31,6 +31,7 @@
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.cache.CacheControl;
import org.jboss.portal.portlet.spi.RenderContext;
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.invocation.AttributeResolver;
@@ -138,22 +139,29 @@
{
FragmentResponse renderResult = (FragmentResponse)response;
- // Compute expiration time, i.e when it will expire
- long expirationTimeMillis = 0;
- if (renderResult.getExpirationSecs() == -1)
+ //
+ CacheControl control = renderResult.getCacheControl();
+
+ //
+ if (control != null)
{
- expirationTimeMillis = Long.MAX_VALUE;
- }
- else if (renderResult.getExpirationSecs() > 0)
- {
- expirationTimeMillis = System.currentTimeMillis() + renderResult.getExpirationSecs() * 1000;
- }
+ // Compute expiration time, i.e when it will expire
+ long expirationTimeMillis = 0;
+ if (control.getExpirationSecs() == -1)
+ {
+ expirationTimeMillis = Long.MAX_VALUE;
+ }
+ else if (control.getExpirationSecs() > 0)
+ {
+ expirationTimeMillis = System.currentTimeMillis() + control.getExpirationSecs() * 1000;
+ }
- // Cache if we can
- if (expirationTimeMillis > 0)
- {
- CacheEntry cacheEntry = new CacheEntry(navState, windowState, mode, renderResult, expirationTimeMillis);
- resolver.setAttribute(scopeKey, cacheEntry);
+ // Cache if we can
+ if (expirationTimeMillis > 0)
+ {
+ CacheEntry cacheEntry = new CacheEntry(navState, windowState, mode, renderResult, expirationTimeMillis);
+ resolver.setAttribute(scopeKey, cacheEntry);
+ }
}
}
@@ -194,7 +202,12 @@
/** The timed content. */
private final TimedContent cachedResult;
- public CacheEntry(StateString navigationalState, WindowState windowState, Mode mode, FragmentResponse result, long expirationTimeMillis)
+ public CacheEntry(
+ StateString navigationalState,
+ WindowState windowState,
+ Mode mode,
+ FragmentResponse result,
+ long expirationTimeMillis)
{
if (expirationTimeMillis <= 0)
{
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -23,19 +23,8 @@
package org.jboss.portal.portlet.aspects.portlet;
import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.portlet.info.CacheInfo;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInterceptor;
import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.EventInvocation;
-import org.jboss.portal.portlet.invocation.ResourceInvocation;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.ResponseProperties;
-import org.jboss.portal.portlet.container.PortletContainerInvoker;
-import org.jboss.portal.portlet.container.PortletContainer;
import org.apache.log4j.Logger;
/**
@@ -50,70 +39,6 @@
protected Object invoke(PortletInvocation invocation) throws Exception, InvocationException
{
- if (invocation instanceof ActionInvocation)
- {
- // Invoke
- return invocation.invokeNext();
- }
- else if (invocation instanceof EventInvocation)
- {
- // Invoke
- return invocation.invokeNext();
- }
- else if (invocation instanceof ResourceInvocation)
- {
- // Invoke
- return invocation.invokeNext();
- }
- else if (invocation instanceof RenderInvocation)
- {
- // Invoke
- PortletInvocationResponse response = (PortletInvocationResponse)invocation.invokeNext();
-
- //
- if (response instanceof FragmentResponse)
- {
- FragmentResponse fragmentResult = (FragmentResponse)response;
-
- // Get config
- PortletContainer container = (PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE, PortletContainerInvoker.PORTLET_CONTAINER);
- PortletInfo info = container.getInfo();
- CacheInfo cacheInfo = info.getCache();
-
- // Update the fragment cache info from the meta info
- fragmentResult.setExpirationSecs(cacheInfo.getExpirationSecs());
-
- // Override with value provided by portlet if any
- String portletValue = null;
- ResponseProperties props = fragmentResult.getProperties();
- if (props != null)
- {
- portletValue = props.getTransportHeaders().getValue("portlet.expiration-cache");
- }
-
- //
- if (portletValue != null)
- {
- try
- {
- int expirationSecs = Integer.parseInt(portletValue);
- fragmentResult.setExpirationSecs(expirationSecs);
- }
- catch (NumberFormatException e)
- {
- log.warn("Portlet " + invocation.getTarget() +
- " set a non integer cache value override during render " + portletValue, e);
- }
- }
-
- }
-
- //
- return response;
- }
- else
- {
- throw new InvocationException("impossible");
- }
+ return invocation.invokeNext();
}
}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheControl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheControl.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheControl.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.cache;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CacheControl
+{
+
+ /** Number of seconds this result remains valid, a value of -1 indicates that it never expires. */
+ private int expirationSecs;
+
+ /** The cache scope for this fragment. */
+ private CacheScope cacheScope;
+
+ /** The validation token. */
+ private String token;
+
+ public CacheControl(int expirationSecs, CacheScope cacheScope, String token)
+ {
+ this.expirationSecs = expirationSecs;
+ this.cacheScope = cacheScope;
+ this.token = token;
+ }
+
+ public int getExpirationSecs()
+ {
+ return expirationSecs;
+ }
+
+ public void setExpirationSecs(int expirationSecs)
+ {
+ this.expirationSecs = expirationSecs;
+ }
+
+ public CacheScope getCacheScope()
+ {
+ return cacheScope;
+ }
+
+ public void setCacheScope(CacheScope cacheScope)
+ {
+ this.cacheScope = cacheScope;
+ }
+
+ public String getToken()
+ {
+ return token;
+ }
+
+ public void setToken(String token)
+ {
+ this.token = token;
+ }
+
+ public CacheControl unmodifiable()
+ {
+ return new CacheControl(expirationSecs, cacheScope, token)
+ {
+ public void setCacheScope(CacheScope cacheScope)
+ {
+ throw new UnsupportedOperationException("Not modifiable");
+ }
+
+ public void setToken(String token)
+ {
+ throw new UnsupportedOperationException("Not modifiable");
+ }
+
+ public void setExpirationSecs(int expirationSecs)
+ {
+ throw new UnsupportedOperationException("Not modifiable");
+ }
+ };
+ }
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheLevel.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheLevel.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheLevel.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.cache;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public enum CacheLevel
+{
+
+ FULL, PORTLET, PAGE
+
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheScope.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheScope.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/cache/CacheScope.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.cache;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public enum CacheScope
+{
+
+ PUBLIC, PRIVATE
+
+}
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/CacheControlImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/CacheControlImpl.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/CacheControlImpl.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.portlet.cache.CacheScope;
+
+import javax.portlet.CacheControl;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CacheControlImpl implements CacheControl
+{
+
+ /** . */
+ private org.jboss.portal.portlet.cache.CacheControl delegate;
+
+ /** . */
+ private boolean useCachedContent;
+
+ public CacheControlImpl(org.jboss.portal.portlet.cache.CacheControl delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public int getExpirationTime()
+ {
+ return delegate.getExpirationSecs();
+ }
+
+ public void setExpirationTime(int expirationTime)
+ {
+ delegate.setExpirationSecs(expirationTime);
+ }
+
+ public boolean isPublicScope()
+ {
+ return delegate.getCacheScope() == CacheScope.PUBLIC;
+ }
+
+ public void setPublicScope(boolean publicScope)
+ {
+ delegate.setCacheScope(publicScope ? CacheScope.PUBLIC : CacheScope.PRIVATE);
+ }
+
+ public String getETag()
+ {
+ return delegate.getToken();
+ }
+
+ public void setETag(String etag)
+ {
+ delegate.setToken(etag);
+ }
+
+ public boolean useCachedContent()
+ {
+ return useCachedContent;
+ }
+
+ public void setUseCachedContent(boolean useCachedContent)
+ {
+ this.useCachedContent = useCachedContent;
+ }
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -25,9 +25,12 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.RevalidateMarkupResponse;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.CacheInfo;
+import org.jboss.portal.portlet.cache.CacheScope;
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.ContentInfo;
-import org.jboss.portal.common.NotYetImplemented;
import javax.portlet.MimeResponse;
import javax.portlet.PortletURL;
@@ -47,31 +50,57 @@
{
/** The fragment result. */
- protected FragmentResponse result;
+ protected FragmentResponse fragment;
/** Not really used but we need it to memorize what the client set optionally. */
protected int bufferSize;
+ /** The cache control. */
+ protected CacheControlImpl cacheControl;
+
public MimeResponseImpl(PortletInvocation invocation, PortletRequestImpl preq)
{
super(invocation, preq);
+ //
+ FragmentResponse fragment = new FragmentResponse();
+
+ // Configure expiration value
+ PortletInfo info = preq.container.getInfo();
+ CacheInfo cacheInfo = info.getCache();
+
+ org.jboss.portal.portlet.cache.CacheControl cc = new org.jboss.portal.portlet.cache.CacheControl(
+ cacheInfo.getExpirationSecs(),
+ CacheScope.PRIVATE,
+ null
+ );
+
+ //
+ fragment.setCacheControl(cc);
+
// 0 means no buffering - we say no buffering
this.bufferSize = 0;
- this.result = new FragmentResponse();
+ this.fragment = fragment;
}
public PortletInvocationResponse getResponse()
{
- result.setProperties(getProperties(false));
+ if (cacheControl != null && cacheControl.useCachedContent())
+ {
+ return new RevalidateMarkupResponse(fragment.getCacheControl());
+ }
+ else
+ {
+ fragment.setProperties(getProperties(false));
- //
- return result;
+ //
+ return fragment;
+ }
}
public String getContentType()
{
- return result.getContentType();
+ return fragment.getContentType();
}
public void setContentType(String contentType)
@@ -99,7 +128,7 @@
}
// Set the content type
- result.setContentType(contentType);
+ fragment.setContentType(contentType);
}
catch (MimeTypeParseException e)
{
@@ -111,12 +140,12 @@
public PrintWriter getWriter() throws IOException
{
- return result.getWriter();
+ return fragment.getWriter();
}
public OutputStream getPortletOutputStream() throws IOException
{
- return result.getOutputStream();
+ return fragment.getOutputStream();
}
public PortletURL createRenderURL()
@@ -159,7 +188,7 @@
public void resetBuffer()
{
// Clear the buffer
- result.resetBuffer();
+ fragment.resetBuffer();
}
public void reset()
@@ -182,8 +211,39 @@
return ResourceURLImpl.createResourceURL(invocation, preq);
}
+ public void addProperty(String key, String value) throws IllegalArgumentException
+ {
+ if (MimeResponse.EXPIRATION_CACHE.equals(key))
+ {
+ if (value == null)
+ {
+ return;
+ }
+
+ //
+ try
+ {
+ int expirationSecs = Integer.parseInt(value);
+ fragment.getCacheControl().setExpirationSecs(expirationSecs);
+ }
+ catch (NumberFormatException e)
+ {
+ // todo: Make the portlet log instead
+// log.warn("Portlet " + invocation.getTarget() +
+// " set a non integer cache value override during render " + value, e);
+ }
+ }
+
+ //
+ super.addProperty(key, value);
+ }
+
public CacheControl getCacheControl()
{
- throw new NotYetImplemented();
+ if (cacheControl == null)
+ {
+ cacheControl = new CacheControlImpl(fragment.getCacheControl());
+ }
+ return cacheControl;
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -91,17 +91,7 @@
public void setProperty(String key, String value) throws IllegalArgumentException
{
- if (key == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (value == null)
- {
- throw new IllegalArgumentException("Value cannot be null");
- }
-
- //
- getProperties().getTransportHeaders().setValue(key, value);
+ addProperty(key, value);
}
public void addProperty(Cookie cookie)
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -43,7 +43,7 @@
public void setTitle(String s)
{
- result.setTitle(s);
+ fragment.setTitle(s);
}
public void setNextPossiblePortletModes(Collection<PortletMode> portletModes)
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -22,9 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.api;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.ResourceInvocation;
-import org.jboss.portal.portlet.CacheabilityType;
+import org.jboss.portal.portlet.cache.CacheLevel;
import javax.portlet.ResourceResponse;
import javax.portlet.PortletURL;
@@ -38,7 +37,7 @@
{
/** . */
- private final CacheabilityType cacheability;
+ private final CacheLevel cacheability;
public ResourceResponseImpl(ResourceInvocation invocation, PortletRequestImpl preq)
{
@@ -65,10 +64,10 @@
public PortletURL createActionURL()
{
- if (cacheability != CacheabilityType.PAGE)
+ if (cacheability != CacheLevel.PAGE)
{
throw new IllegalStateException("Cannot create action URL because the current cache level " + cacheability +
- " is not " + CacheabilityType.PAGE);
+ " is not " + CacheLevel.PAGE);
}
//
@@ -77,10 +76,10 @@
public PortletURL createRenderURL()
{
- if (cacheability != CacheabilityType.PAGE)
+ if (cacheability != CacheLevel.PAGE)
{
throw new IllegalStateException("Cannot create render URL because the current cache level " + cacheability +
- " is not " + CacheabilityType.PAGE);
+ " is not " + CacheLevel.PAGE);
}
//
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -24,7 +24,7 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.ResourceInvocation;
-import org.jboss.portal.portlet.CacheabilityType;
+import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ParametersStateString;
@@ -40,26 +40,26 @@
{
/** . */
- private static final Map<String, CacheabilityType> jsr168ToType = new HashMap<String, CacheabilityType>();
+ private static final Map<String, CacheLevel> jsr168ToType = new HashMap<String, CacheLevel>();
/** . */
- private static final Map<CacheabilityType, String> typetoJSR168 = new HashMap<CacheabilityType, String>();
+ private static final Map<CacheLevel, String> typetoJSR168 = new HashMap<CacheLevel, String>();
static
{
- jsr168ToType.put(ResourceURL.FULL, CacheabilityType.FULL);
- jsr168ToType.put(ResourceURL.PAGE, CacheabilityType.PAGE);
- jsr168ToType.put(ResourceURL.PORTLET, CacheabilityType.PORTLET);
+ jsr168ToType.put(ResourceURL.FULL, CacheLevel.FULL);
+ jsr168ToType.put(ResourceURL.PAGE, CacheLevel.PAGE);
+ jsr168ToType.put(ResourceURL.PORTLET, CacheLevel.PORTLET);
//
- typetoJSR168.put(CacheabilityType.FULL, ResourceURL.FULL);
- typetoJSR168.put(CacheabilityType.PAGE, ResourceURL.PAGE);
- typetoJSR168.put(CacheabilityType.PORTLET, ResourceURL.PORTLET);
+ typetoJSR168.put(CacheLevel.FULL, ResourceURL.FULL);
+ typetoJSR168.put(CacheLevel.PAGE, ResourceURL.PAGE);
+ typetoJSR168.put(CacheLevel.PORTLET, ResourceURL.PORTLET);
}
- public static String toJSR168(CacheabilityType cacheabilityType)
+ public static String toJSR168(CacheLevel cacheLevel)
{
- return typetoJSR168.get(cacheabilityType);
+ return typetoJSR168.get(cacheLevel);
}
/** . */
@@ -78,7 +78,7 @@
//
if (invocation instanceof ResourceInvocation)
{
- url.parentCacheabilityType = ((ResourceInvocation)invocation).getContext().getCacheability();
+ url.parentCacheLevel = ((ResourceInvocation)invocation).getContext().getCacheability();
}
}
@@ -92,41 +92,41 @@
public String getCacheability()
{
- CacheabilityType cacheabilityType = url.getCacheability();
+ CacheLevel cacheLevel = url.getCacheability();
//
- return typetoJSR168.get(cacheabilityType);
+ return typetoJSR168.get(cacheLevel);
}
public void setCacheability(String s)
{
- CacheabilityType cacheabilityType = jsr168ToType.get(s);
+ CacheLevel cacheLevel = jsr168ToType.get(s);
//
- if (cacheabilityType != null)
+ if (cacheLevel != null)
{
- if (url.parentCacheabilityType == null)
+ if (url.parentCacheLevel == null)
{
- url.cacheabilityType = cacheabilityType;
+ url.cacheLevel = cacheLevel;
}
else
{
- switch (url.parentCacheabilityType)
+ switch (url.parentCacheLevel)
{
case FULL:
- if (cacheabilityType != CacheabilityType.FULL)
+ if (cacheLevel != CacheLevel.FULL)
{
throw new IllegalStateException();
}
break;
case PORTLET:
- if (cacheabilityType == CacheabilityType.PAGE)
+ if (cacheLevel == CacheLevel.PAGE)
{
throw new IllegalStateException();
}
break;
}
- url.cacheabilityType = cacheabilityType;
+ url.cacheLevel = cacheLevel;
}
}
}
@@ -143,10 +143,10 @@
private String id;
/** The cacheability constraining the url cacheability. */
- private CacheabilityType parentCacheabilityType;
+ private CacheLevel parentCacheLevel;
/** . */
- private CacheabilityType cacheabilityType;
+ private CacheLevel cacheLevel;
/** . */
private ParametersStateString parameters;
@@ -181,21 +181,21 @@
return id;
}
- public CacheabilityType getCacheability()
+ public CacheLevel getCacheability()
{
- if (cacheabilityType != null)
+ if (cacheLevel != null)
{
- return cacheabilityType;
+ return cacheLevel;
}
else
{
- if (parentCacheabilityType != null)
+ if (parentCacheLevel != null)
{
- return parentCacheabilityType;
+ return parentCacheLevel;
}
else
{
- return CacheabilityType.PAGE;
+ return CacheLevel.PAGE;
}
}
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -27,7 +27,7 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.CacheabilityType;
+import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.spi.ResourceInvocationContext;
/**
@@ -41,7 +41,7 @@
private final String resourceId;
/** . */
- private final CacheabilityType cacheabilityType;
+ private final CacheLevel cacheLevel;
/** . */
private final StateString resourceState;
@@ -51,7 +51,7 @@
public AbstractResourceContext(
String resourceId,
- CacheabilityType cacheabilityType,
+ CacheLevel cacheLevel,
Mode mode,
WindowState windowState,
StateString navigationalState,
@@ -64,7 +64,7 @@
//
this.resourceId = resourceId;
- this.cacheabilityType = cacheabilityType;
+ this.cacheLevel = cacheLevel;
this.resourceState = resourceState;
this.form = form;
}
@@ -74,9 +74,9 @@
return resourceId;
}
- public CacheabilityType getCacheability()
+ public CacheLevel getCacheability()
{
- return cacheabilityType;
+ return cacheLevel;
}
public StateString getResourceState()
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.invocation.response;
+import org.jboss.portal.portlet.cache.CacheControl;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -65,8 +67,8 @@
/** The title if any. */
private String title;
- /** Number of seconds this result remains valid, a value of -1 indicates that it never expires. */
- protected int expirationSecs;
+ /** . */
+ private CacheControl cacheControl;
public FragmentResponse()
{
@@ -75,7 +77,7 @@
this.writer = null;
this.contentType = null;
this.title = null;
- this.expirationSecs = 0;
+ this.cacheControl = null;
this.properties = null;
}
@@ -89,6 +91,16 @@
this.properties = properties;
}
+ public CacheControl getCacheControl()
+ {
+ return cacheControl;
+ }
+
+ public void setCacheControl(CacheControl cacheControl)
+ {
+ this.cacheControl = cacheControl;
+ }
+
public int getType()
{
if (bytes == null)
@@ -245,16 +257,6 @@
}
}
- public int getExpirationSecs()
- {
- return expirationSecs;
- }
-
- public void setExpirationSecs(int expirationSecs)
- {
- this.expirationSecs = expirationSecs;
- }
-
private class ClosableOutputStream extends OutputStream
{
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/RevalidateMarkupResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/RevalidateMarkupResponse.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/RevalidateMarkupResponse.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.invocation.response;
+
+import org.jboss.portal.portlet.cache.CacheControl;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class RevalidateMarkupResponse extends PortletInvocationResponse
+{
+
+ /** . */
+ private final CacheControl cacheControl;
+
+ public RevalidateMarkupResponse(CacheControl cacheControl)
+ {
+ if (cacheControl == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.cacheControl = cacheControl;
+ }
+
+ public CacheControl getCacheControl()
+ {
+ return cacheControl;
+ }
+}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -29,7 +29,6 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ContainerURL;
-import org.jboss.portal.portlet.CacheabilityType;
/**
* Contract that defines what input/services the caller of a portlet container must provide.
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.spi;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.CacheabilityType;
+import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.common.util.ParameterMap;
/**
@@ -45,7 +45,7 @@
*
* @return the cacheability
*/
- CacheabilityType getCacheability();
+ CacheLevel getCacheability();
/**
* Returns the resource state of the request.
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -25,7 +25,7 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.CacheabilityType;
+import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.spi.ResourceInvocationContext;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.EventInfo;
@@ -199,7 +199,7 @@
PageNavigationalState pageNS = null;
ParameterMap publicNS = null;
StateString portletNS = null;
- CacheabilityType cacheability;
+ CacheLevel cacheability;
//
if (portletResourceRequest instanceof PortletScopedPortletResourceRequest)
@@ -214,7 +214,7 @@
{
PageScopedFullPortletResourceRequest pageScopedRequest = (PageScopedFullPortletResourceRequest)portletResourceRequest;
pageNS = pageScopedRequest.pageState;
- cacheability = CacheabilityType.PAGE;
+ cacheability = CacheLevel.PAGE;
//
if (pageNS != null)
@@ -224,12 +224,12 @@
}
else
{
- cacheability = CacheabilityType.PORTLET;
+ cacheability = CacheLevel.PORTLET;
}
}
else
{
- cacheability = CacheabilityType.FULL;
+ cacheability = CacheLevel.FULL;
}
//
@@ -893,13 +893,13 @@
{
/** . */
- private static final Map<Class, CacheabilityType> cacheability = new HashMap<Class, CacheabilityType>();
+ private static final Map<Class, CacheLevel> cacheability = new HashMap<Class, CacheLevel>();
static
{
- cacheability.put(FullScopedCacheablePortletResourceRequest.class, CacheabilityType.FULL);
- cacheability.put(PortletScopedPortletResourceRequest.class, CacheabilityType.PORTLET);
- cacheability.put(PageScopedFullPortletResourceRequest.class, CacheabilityType.PAGE);
+ cacheability.put(FullScopedCacheablePortletResourceRequest.class, CacheLevel.FULL);
+ cacheability.put(PortletScopedPortletResourceRequest.class, CacheLevel.PORTLET);
+ cacheability.put(PageScopedFullPortletResourceRequest.class, CacheLevel.PAGE);
}
/** . */
@@ -927,7 +927,7 @@
this.bodyParameters = bodyParameters;
}
- public CacheabilityType getCacheabilityType()
+ public CacheLevel getCacheabilityType()
{
return cacheability.get(getClass());
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -33,7 +33,7 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.CacheabilityType;
+import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.web.Body;
@@ -149,10 +149,10 @@
}
//
- CacheabilityType resourceCacheabilityType = CacheabilityType.valueOf(req.getParameter(RESOURCE_CACHEABILITY));
+ CacheLevel resourceCacheLevel = CacheLevel.valueOf(req.getParameter(RESOURCE_CACHEABILITY));
//
- switch (resourceCacheabilityType)
+ switch (resourceCacheLevel)
{
case FULL:
request = new PortletController.FullScopedCacheablePortletResourceRequest(
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -29,7 +29,7 @@
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ResourceURL;
import org.jboss.portal.portlet.ContainerURL;
-import org.jboss.portal.portlet.CacheabilityType;
+import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.Tools;
@@ -203,11 +203,11 @@
}
//
- CacheabilityType cacheability = resourceURL.getCacheability();
+ CacheLevel cacheability = resourceURL.getCacheability();
parameters.put(RESOURCE_CACHEABILITY, cacheability.name());
//
- if (cacheability != CacheabilityType.FULL)
+ if (cacheability != CacheLevel.FULL)
{
if (windowNS != null)
{
@@ -224,7 +224,7 @@
parameters.put(WINDOW_STATE, windowNS.getWindowState().toString());
//
- if (cacheability == CacheabilityType.PAGE)
+ if (cacheability == CacheLevel.PAGE)
{
parameters.put(PAGE_STATE, pageState);
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java 2008-01-25 13:30:29 UTC (rev 9606)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java 2008-01-25 15:55:50 UTC (rev 9607)
@@ -24,7 +24,7 @@
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ContainerURL;
-import org.jboss.portal.portlet.CacheabilityType;
+import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.impl.spi.AbstractResourceContext;
import org.jboss.portal.Mode;
@@ -49,7 +49,7 @@
public ResourceTestContext(
String resourceId,
- CacheabilityType resourceCacheabilityType,
+ CacheLevel resourceCacheLevel,
PortletURLRenderer urlRenderer,
Mode mode,
WindowState windowState,
@@ -61,7 +61,7 @@
{
super(
resourceId,
- resourceCacheabilityType,
+ resourceCacheLevel,
mode,
windowState,
navigationalState,
18 years, 3 months
JBoss Portal SVN: r9606 - modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-25 08:30:29 -0500 (Fri, 25 Jan 2008)
New Revision: 9606
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
Log:
update controller to use WindowNavigationalState instead of (mode, windowState, portletNS)
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-25 12:53:59 UTC (rev 9605)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-25 13:30:29 UTC (rev 9606)
@@ -120,9 +120,9 @@
//
UpdateNavigationalStateResponse updateNavigationalState = new UpdateNavigationalStateResponse();
- updateNavigationalState.setMode(portletRenderRequest.mode);
- updateNavigationalState.setWindowState(portletRenderRequest.windowState);
- updateNavigationalState.setNavigationalState(portletRenderRequest.navigationalState);
+ updateNavigationalState.setMode(portletRenderRequest.windowNavigationalState.getMode());
+ updateNavigationalState.setWindowState(portletRenderRequest.windowNavigationalState.getWindowState());
+ updateNavigationalState.setNavigationalState(portletRenderRequest.windowNavigationalState.getPortletNavigationalState());
updateNavigationalState.setPublicNavigationalStateUpdates(portletRenderRequest.publicNavigationalStateChanges);
//
@@ -136,27 +136,24 @@
PageNavigationalState pageNS = portletActionRequest.pageState;
//
- Mode mode = portletActionRequest.mode;
+ Mode mode = portletActionRequest.windowNavigationalState.getMode();
if (mode == null)
{
mode = Mode.VIEW;
}
//
- WindowState windowState = portletActionRequest.windowState;
+ WindowState windowState = portletActionRequest.windowNavigationalState.getWindowState();
if (windowState == null)
{
windowState = WindowState.NORMAL;
}
//
- WindowNavigationalState windowNS = new WindowNavigationalState(portletActionRequest.navigationalState, mode, windowState);
-
- //
ParameterMap publicNS = pageNS.getPublicNavigationalState(portlet);
//
- PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS, portlet, req, resp);
+ PortletURLRenderer renderer = new PortletURLRenderer(pageNS, portletActionRequest.windowNavigationalState, portlet, req, resp);
//
TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
@@ -164,7 +161,7 @@
renderer,
mode,
windowState,
- portletActionRequest.navigationalState,
+ portletActionRequest.windowNavigationalState.getPortletNavigationalState(),
publicNS,
MARKUP_INFO,
portletActionRequest.interactionState,
@@ -208,9 +205,9 @@
if (portletResourceRequest instanceof PortletScopedPortletResourceRequest)
{
PortletScopedPortletResourceRequest portletScopedRequest = (PortletScopedPortletResourceRequest)portletResourceRequest;
- mode = portletScopedRequest.mode;
- windowState = portletScopedRequest.windowState;
- portletNS = portletScopedRequest.navigationalState;
+ mode = portletScopedRequest.windowNavigationalState.getMode();
+ windowState = portletScopedRequest.windowNavigationalState.getWindowState();
+ portletNS = portletScopedRequest.windowNavigationalState.getPortletNavigationalState();
//
if (portletResourceRequest instanceof PageScopedFullPortletResourceRequest)
@@ -876,28 +873,18 @@
final PageNavigationalState pageState;
/** . */
- final StateString navigationalState;
+ final WindowNavigationalState windowNavigationalState;
- /** . */
- final Mode mode;
-
- /** . */
- final WindowState windowState;
-
PortletRequest(
PortletControllerContext controllerContext,
String portletId,
- Mode mode,
- WindowState windowState,
- StateString navigationalState,
+ WindowNavigationalState windowNavigationalState,
PageNavigationalState pageState)
{
super(controllerContext, portletId);
//
- this.mode = mode;
- this.windowState = windowState;
- this.navigationalState = navigationalState;
+ this.windowNavigationalState = windowNavigationalState;
this.pageState = pageState;
}
}
@@ -963,30 +950,20 @@
{
/** . */
- final StateString navigationalState;
+ final WindowNavigationalState windowNavigationalState;
- /** . */
- final Mode mode;
-
- /** . */
- final WindowState windowState;
-
PortletScopedPortletResourceRequest(
PortletControllerContext controllerContext,
String portletId,
String resourceId,
StateString resourceState,
ParameterMap bodyParameters,
- StateString navigationalState,
- Mode mode,
- WindowState windowState)
+ WindowNavigationalState windowNavigationalState)
{
super(controllerContext, portletId, resourceId, resourceState, bodyParameters);
//
- this.mode = mode;
- this.windowState = windowState;
- this.navigationalState = navigationalState;
+ this.windowNavigationalState = windowNavigationalState;
}
}
@@ -1002,12 +979,10 @@
String resourceId,
StateString resourceState,
ParameterMap bodyParameters,
- StateString navigationalState,
PageNavigationalState pageState,
- Mode mode,
- WindowState windowState)
+ WindowNavigationalState windowNavigationalState)
{
- super(controllerContext, portletId, resourceId, resourceState, bodyParameters, navigationalState, mode, windowState);
+ super(controllerContext, portletId, resourceId, resourceState, bodyParameters, windowNavigationalState);
//
this.pageState = pageState;
@@ -1028,12 +1003,10 @@
String portletId,
StateString interactionState,
ParameterMap bodyParameters,
- StateString navigationalState,
- Mode mode,
- WindowState windowState,
+ WindowNavigationalState windowNavigationalState,
PageNavigationalState pageState)
{
- super(controllerContext, portletId, mode, windowState, navigationalState, pageState);
+ super(controllerContext, portletId, windowNavigationalState, pageState);
//
this.interactionState = interactionState;
@@ -1050,13 +1023,11 @@
public PortletRenderRequest(
PortletControllerContext controllerContext,
String portletId,
- StateString navigationalState,
+ WindowNavigationalState windowNavigationalState,
Map<String, String[]> publicNavigationalStateChanges,
- Mode mode,
- WindowState windowState,
PageNavigationalState pageState)
{
- super(controllerContext, portletId, mode, windowState, navigationalState, pageState);
+ super(controllerContext, portletId, windowNavigationalState, pageState);
//
this.publicNavigationalStateChanges = publicNavigationalStateChanges;
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-25 12:53:59 UTC (rev 9605)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-25 13:30:29 UTC (rev 9606)
@@ -131,6 +131,9 @@
}
//
+ WindowNavigationalState windowNavigationalState = new WindowNavigationalState(navigationalState, mode, windowState);
+
+ //
String type = req.getParameter(LIFECYCLE_TYPE);
if (RESOURCE_LIFECYCLE.equals(type))
{
@@ -166,9 +169,7 @@
resourceId,
resourceState,
formParameters,
- navigationalState,
- mode,
- windowState);
+ windowNavigationalState);
break;
case PAGE:
request = new PortletController.PageScopedFullPortletResourceRequest(
@@ -177,10 +178,8 @@
resourceId,
resourceState,
formParameters,
- navigationalState,
pageState,
- mode,
- windowState);
+ windowNavigationalState);
break;
}
}
@@ -203,9 +202,7 @@
targetId,
interactionState,
formParameters,
- navigationalState,
- mode,
- windowState,
+ windowNavigationalState,
pageState);
}
else
@@ -216,10 +213,8 @@
request = new PortletController.PortletRenderRequest(
this,
targetId,
- navigationalState,
+ windowNavigationalState,
publicNavigationalStateChanges,
- mode,
- windowState,
pageState);
}
}
18 years, 3 months
JBoss Portal SVN: r9605 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-25 07:53:59 -0500 (Fri, 25 Jan 2008)
New Revision: 9605
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ResponseProperties.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
fix portlet caching test case
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java 2008-01-25 12:46:46 UTC (rev 9604)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java 2008-01-25 12:53:59 UTC (rev 9605)
@@ -333,4 +333,23 @@
{
return "StateString[" + parameters + "]";
}
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof ParametersStateString)
+ {
+ ParametersStateString that = (ParametersStateString)obj;
+ return parameters.equals(that.parameters);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return parameters.hashCode();
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java 2008-01-25 12:46:46 UTC (rev 9604)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java 2008-01-25 12:53:59 UTC (rev 9605)
@@ -33,6 +33,7 @@
import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
import org.jboss.portal.portlet.container.PortletContainerInvoker;
import org.jboss.portal.portlet.container.PortletContainer;
import org.apache.log4j.Logger;
@@ -83,7 +84,14 @@
fragmentResult.setExpirationSecs(cacheInfo.getExpirationSecs());
// Override with value provided by portlet if any
- String portletValue = (String)invocation.getAttribute(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, "portlet.expiration-cache");
+ String portletValue = null;
+ ResponseProperties props = fragmentResult.getProperties();
+ if (props != null)
+ {
+ portletValue = props.getTransportHeaders().getValue("portlet.expiration-cache");
+ }
+
+ //
if (portletValue != null)
{
try
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2008-01-25 12:46:46 UTC (rev 9604)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2008-01-25 12:53:59 UTC (rev 9605)
@@ -86,7 +86,7 @@
}
//
- getProperties().getTransportHeaders().addProperty(key, value);
+ getProperties().getTransportHeaders().addValue(key, value);
}
public void setProperty(String key, String value) throws IllegalArgumentException
@@ -101,7 +101,7 @@
}
//
- getProperties().getTransportHeaders().setProperty(key, value);
+ getProperties().getTransportHeaders().setValue(key, value);
}
public void addProperty(Cookie cookie)
@@ -111,7 +111,7 @@
public void addProperty(String key, Element element)
{
- getProperties().getMarkupHeaders().addProperty(key, element);
+ getProperties().getMarkupHeaders().addValue(key, element);
}
public Element createElement(String tagName) throws DOMException
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ResponseProperties.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ResponseProperties.java 2008-01-25 12:46:46 UTC (rev 9604)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/ResponseProperties.java 2008-01-25 12:53:59 UTC (rev 9605)
@@ -23,15 +23,12 @@
package org.jboss.portal.portlet.invocation.response;
import org.jboss.portal.common.util.MultiValuedPropertyMap;
+import org.jboss.portal.common.util.SimpleMultiValuedPropertyMap;
import org.w3c.dom.Element;
import javax.servlet.http.Cookie;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.LinkedList;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -41,13 +38,13 @@
{
/** . */
- private MultiValuedPropertyMap<String> transportHeaders;
+ private MultiValuedPropertyMap<String> transportHeaders = new SimpleMultiValuedPropertyMap<String>();
/** . */
- private MultiValuedPropertyMap<Element> markupHeaders;
+ private MultiValuedPropertyMap<Element> markupHeaders = new SimpleMultiValuedPropertyMap<Element>();
/** . */
- private List<Cookie> cookies;
+ private List<Cookie> cookies = new LinkedList<Cookie>();
public ResponseProperties()
{
@@ -55,43 +52,16 @@
public MultiValuedPropertyMap<String> getTransportHeaders()
{
- return getTransportHeaders(true);
- }
-
- public MultiValuedPropertyMap<String> getTransportHeaders(boolean create)
- {
- if (transportHeaders == null && create)
- {
- transportHeaders = new MultiValuedPropertyMap<String>();
- }
return transportHeaders;
}
public MultiValuedPropertyMap<Element> getMarkupHeaders()
{
- return getMarkupHeaders(true);
- }
-
- public MultiValuedPropertyMap<Element> getMarkupHeaders(boolean create)
- {
- if (markupHeaders == null && create)
- {
- markupHeaders = new MultiValuedPropertyMap<Element>();
- }
return markupHeaders;
}
public List<Cookie> getCookies()
{
- return getCookies(true);
- }
-
- public List<Cookie> getCookies(boolean create)
- {
- if (cookies == null && create)
- {
- cookies = new ArrayList<Cookie>();
- }
return cookies;
}
@@ -101,17 +71,10 @@
{
throw new IllegalArgumentException();
}
- if (appended.transportHeaders != null)
- {
- getTransportHeaders().append(appended.transportHeaders);
- }
- if (appended.markupHeaders != null)
- {
- getMarkupHeaders().append(appended.markupHeaders);
- }
- if (appended.cookies != null)
- {
- getCookies().addAll(appended.cookies);
- }
+
+ //
+ transportHeaders.append(appended.transportHeaders);
+ markupHeaders.append(appended.markupHeaders);
+ cookies.addAll(appended.cookies);
}
}
\ No newline at end of file
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java 2008-01-25 12:46:46 UTC (rev 9604)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr168/ext/nocache/AbstractNoCacheTestCase.java 2008-01-25 12:53:59 UTC (rev 9605)
@@ -52,7 +52,7 @@
public abstract class AbstractNoCacheTestCase
{
- final Set calls = new HashSet();
+ final Set<String> calls = new HashSet<String>();
String url;
public AbstractNoCacheTestCase(
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-25 12:46:46 UTC (rev 9604)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-25 12:53:59 UTC (rev 9605)
@@ -718,10 +718,11 @@
// Render the head contributions
writer.print("<head>");
- MultiValuedPropertyMap<Element> markupHeaders = pageProperties.getMarkupHeaders(false);
- if (markupHeaders != null)
+ MultiValuedPropertyMap<Element> markupHeaders = pageProperties.getMarkupHeaders();
+ List<Element> headElement = markupHeaders.getValues("javax.portlet.markup.head.element");
+ if (headElement != null)
{
- for (Element headerValue : markupHeaders.getPropertyValues("javax.portlet.markup.head.element"))
+ for (Element headerValue : headElement)
{
try
{
@@ -750,27 +751,21 @@
private void renderCookies(ResponseProperties pageProperties, HttpServletResponse resp)
{
- List<Cookie> cookies = pageProperties.getCookies(false);
- if (cookies != null)
+ List<Cookie> cookies = pageProperties.getCookies();
+ for (Cookie cookie : cookies)
{
- for (Cookie cookie : cookies)
- {
- resp.addCookie(cookie);
- }
+ resp.addCookie(cookie);
}
}
private void renderTransportHeaders(ResponseProperties pageProperties, HttpServletResponse resp)
{
- MultiValuedPropertyMap<String> transportHeaders = pageProperties.getTransportHeaders(false);
- if (transportHeaders != null)
+ MultiValuedPropertyMap<String> transportHeaders = pageProperties.getTransportHeaders();
+ for (String headerName : transportHeaders.keySet())
{
- for (String headerName : transportHeaders.getPropertyNames())
+ for (String headerValue : transportHeaders.getValues(headerName))
{
- for (String headerValue : transportHeaders.getPropertyValues(headerName))
- {
- resp.addHeader(headerName, headerValue);
- }
+ resp.addHeader(headerName, headerValue);
}
}
}
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-25 12:46:46 UTC (rev 9604)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-01-25 12:53:59 UTC (rev 9605)
@@ -133,7 +133,6 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-session.war"/>
</generic>
-<!--
<generic>
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-expiringcache.war"/>
@@ -146,7 +145,6 @@
<class name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId" value="test-jsr168-ext-nocache.war"/>
</generic>
--->
<!--Spec TCK Assertions tests-->
<generic>
18 years, 3 months
JBoss Portal SVN: r9604 - in modules/common/trunk/common/src: test/java/org/jboss/portal/test/common/util and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-25 07:46:46 -0500 (Fri, 25 Jan 2008)
New Revision: 9604
Added:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/SimpleMultiValuedPropertyMap.java
Removed:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/Tools.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/MultiValuedPropertyMapTestCase.java
Log:
make MultiValuedMap an interface rather
Deleted: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java 2008-01-25 01:23:38 UTC (rev 9603)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java 2008-01-25 12:46:46 UTC (rev 9604)
@@ -1,230 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.common.util;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
-import java.util.Collections;
-import java.util.LinkedList;
-
-/**
- * A map of multi valued properties
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class MultiValuedPropertyMap<T>
-{
-
- /** . */
- private Map<String, LinkedList<T>> content;
-
- /**
- * @param name the property name
- * @param value the property value
- * @throws IllegalArgumentException if name or value is null
- */
- public void addProperty(String name, T value)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (value == null)
- {
- throw new IllegalArgumentException("Value cannot be null");
- }
- if (content == null)
- {
- content = new HashMap<String, LinkedList<T>>();
- }
-
- //
- LinkedList<T> values = content.get(name);
- if (values == null)
- {
- values = new LinkedList<T>();
- content.put(name, values);
- }
-
- //
- values.add(value);
- }
-
- /**
- * @param name the property name
- * @param value the property value
- * @throws IllegalArgumentException if name or value is null
- */
- public void setProperty(String name, T value)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (value == null)
- {
- throw new IllegalArgumentException("Value cannot be null");
- }
- if (content == null)
- {
- content = new HashMap<String, LinkedList<T>>();
- }
-
- //
- LinkedList<T> values = content.get(name);
- if (values == null)
- {
- values = new LinkedList<T>();
- content.put(name, values);
- }
- else
- {
- values.clear();
- }
-
- //
- values.add(value);
- }
-
- /**
- * Clear the properties.
- */
- public void clear()
- {
- if (content != null)
- {
- content.clear();
- }
- }
-
- /**
- * Returns the first property value or null if it cannot be found.
- *
- * @param name the property name
- * @return the property value
- * @throws IllegalArgumentException if the name argument is null
- */
- public T getPropertyValue(String name) throws IllegalArgumentException
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (content == null)
- {
- return null;
- }
-
- //
- LinkedList<T> values = content.get(name);
- if (values == null)
- {
- return null;
- }
- else
- {
- return values.get(0);
- }
- }
-
- /**
- * Returns the list of values for a specified property.
- *
- * @param name the property name
- * @return the list of properties for the specified name or null if it does not exist
- * @throws IllegalArgumentException if name argument is null
- */
- public List<T> getPropertyValues(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (content == null)
- {
- return null;
- }
- return content.get(name);
- }
-
- /**
- * Returns the set of property names.
- *
- * @return the set of property names
- */
- public Set<String> getPropertyNames()
- {
- if (content == null)
- {
- return Collections.emptySet();
- }
- return content.keySet();
- }
-
- /**
- * Append the multi valued property map to this one. Entries from the provided map that do not exist
- * in the current map are created, entries that exist in both maps are concatenated in the existing map
- * with the values of the existing map being before the values of the provided map.
- *
- * @param appended the property map to append
- * @throws IllegalArgumentException if the provided map is null
- */
- public void append(MultiValuedPropertyMap<T> appended) throws IllegalArgumentException
- {
- if (appended == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- if (appended.content != null)
- {
- for (Map.Entry<String, LinkedList<T>> entry : appended.content.entrySet())
- {
- String name = entry.getKey();
-
- //
- if (content == null)
- {
- content = new HashMap<String, LinkedList<T>>(appended.content.size());
- }
-
- //
- LinkedList<T> values = content.get(name);
-
- //
- if (values != null)
- {
- values.addAll(entry.getValue());
- }
- else
- {
- content.put(name, new LinkedList<T>(entry.getValue()));
- }
- }
- }
- }
-}
Copied: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/SimpleMultiValuedPropertyMap.java (from rev 9599, modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/MultiValuedPropertyMap.java)
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/SimpleMultiValuedPropertyMap.java (rev 0)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/SimpleMultiValuedPropertyMap.java 2008-01-25 12:46:46 UTC (rev 9604)
@@ -0,0 +1,268 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.util;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.Collections;
+import java.util.LinkedList;
+
+/**
+ * A map of multi valued properties.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class SimpleMultiValuedPropertyMap<T> implements MultiValuedPropertyMap<T>
+{
+
+ /** . */
+ private Map<String, LinkedList<T>> content;
+
+ /**
+ * @param key the property key
+ * @param value the property value
+ * @throws IllegalArgumentException if name or value is null
+ */
+ public void addValue(String key, T value)
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Name cannot be null");
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("Value cannot be null");
+ }
+ if (content == null)
+ {
+ content = new HashMap<String, LinkedList<T>>();
+ }
+
+ //
+ LinkedList<T> values = content.get(key);
+ if (values == null)
+ {
+ values = new LinkedList<T>();
+ content.put(key, values);
+ }
+
+ //
+ values.add(value);
+ }
+
+ /**
+ * @param key the property key
+ * @param value the property value
+ * @throws IllegalArgumentException if name or value is null
+ */
+ public void setValue(String key, T value)
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Name cannot be null");
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("Value cannot be null");
+ }
+ if (content == null)
+ {
+ content = new HashMap<String, LinkedList<T>>();
+ }
+
+ //
+ LinkedList<T> values = content.get(key);
+ if (values == null)
+ {
+ values = new LinkedList<T>();
+ content.put(key, values);
+ }
+ else
+ {
+ values.clear();
+ }
+
+ //
+ values.add(value);
+ }
+
+ /**
+ * Clear the properties.
+ */
+ public void clear()
+ {
+ if (content != null)
+ {
+ content.clear();
+ }
+ }
+
+ /**
+ * Returns the first property value or null if it cannot be found.
+ *
+ * @param key the property key
+ * @return the property value
+ * @throws IllegalArgumentException if the name argument is null
+ */
+ public T getValue(String key) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Name cannot be null");
+ }
+ if (content == null)
+ {
+ return null;
+ }
+
+ //
+ LinkedList<T> values = content.get(key);
+ if (values == null)
+ {
+ return null;
+ }
+ else
+ {
+ return values.get(0);
+ }
+ }
+
+ /**
+ * Returns the list of values for a specified property.
+ *
+ * @param key the property key
+ * @return the list of properties for the specified name or null if it does not exist
+ * @throws IllegalArgumentException if name argument is null
+ */
+ public List<T> getValues(String key)
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Name cannot be null");
+ }
+ if (content == null)
+ {
+ return null;
+ }
+ return content.get(key);
+ }
+
+ /**
+ * Returns the set of property keys.
+ *
+ * @return the set of property keys
+ */
+ public Set<String> keySet()
+ {
+ if (content == null)
+ {
+ return Collections.emptySet();
+ }
+ return content.keySet();
+ }
+
+ public int size()
+ {
+ if (content == null)
+ {
+ return 0;
+ }
+ return content.size();
+ }
+
+ /**
+ * Append the multi valued property map to this one. Entries from the provided map that do not exist
+ * in the current map are created, entries that exist in both maps are concatenated in the existing map
+ * with the values of the existing map being before the values of the provided map.
+ *
+ * @param appended the property map to append
+ * @throws IllegalArgumentException if the provided map is null
+ */
+ public void append(MultiValuedPropertyMap<T> appended) throws IllegalArgumentException
+ {
+ if (appended == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (appended instanceof SimpleMultiValuedPropertyMap)
+ {
+ Map<String, LinkedList<T>> appendedContent = ((SimpleMultiValuedPropertyMap<T>)appended).content;
+
+ //
+ if (appendedContent != null)
+ {
+ for (Map.Entry<String, LinkedList<T>> entry : appendedContent.entrySet())
+ {
+ String name = entry.getKey();
+
+ //
+ if (content == null)
+ {
+ content = new HashMap<String, LinkedList<T>>(appendedContent.size());
+ }
+
+ //
+ LinkedList<T> values = content.get(name);
+
+ //
+ if (values != null)
+ {
+ values.addAll(entry.getValue());
+ }
+ else
+ {
+ content.put(name, new LinkedList<T>(entry.getValue()));
+ }
+ }
+ }
+ }
+ else
+ {
+ for (String key : appended.keySet())
+ {
+ List<T> values = appended.getValues(key);
+
+ //
+ if (content == null)
+ {
+ content = new HashMap<String, LinkedList<T>>(appended.size());
+ }
+
+ //
+ if (values != null)
+ {
+ values.addAll(values);
+ }
+ else
+ {
+ content.put(key, new LinkedList<T>(values));
+ }
+ }
+ }
+ }
+}
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/Tools.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/Tools.java 2008-01-25 01:23:38 UTC (rev 9603)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/Tools.java 2008-01-25 12:46:46 UTC (rev 9604)
@@ -46,6 +46,7 @@
import java.util.NoSuchElementException;
import java.util.ResourceBundle;
import java.util.Set;
+import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -965,4 +966,59 @@
}
}
}
+
+ public static <T> MultiValuedPropertyMap<T> emptyMultiValuedPropertyMap()
+ {
+ return new MultiValuedPropertyMap<T>()
+ {
+ public T getValue(String key) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Key cannot be null");
+ }
+ return null;
+ }
+
+ public List<T> getValues(String key) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Key cannot be null");
+ }
+ return null;
+ }
+
+ public void addValue(String key, T value) throws IllegalArgumentException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setValue(String key, T value) throws IllegalArgumentException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Set<String> keySet()
+ {
+ return Collections.emptySet();
+ }
+
+ public int size()
+ {
+ return 0;
+ }
+
+ public void clear()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void append(MultiValuedPropertyMap<T> appended) throws IllegalArgumentException
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
}
\ No newline at end of file
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/MultiValuedPropertyMapTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/MultiValuedPropertyMapTestCase.java 2008-01-25 01:23:38 UTC (rev 9603)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/MultiValuedPropertyMapTestCase.java 2008-01-25 12:46:46 UTC (rev 9604)
@@ -23,7 +23,7 @@
package org.jboss.portal.test.common.util;
import junit.framework.TestCase;
-import org.jboss.portal.common.util.MultiValuedPropertyMap;
+import org.jboss.portal.common.util.SimpleMultiValuedPropertyMap;
import org.jboss.portal.common.util.Tools;
/**
@@ -44,56 +44,56 @@
public void testA()
{
- MultiValuedPropertyMap<String> props = new MultiValuedPropertyMap<String>();
+ SimpleMultiValuedPropertyMap<String> props = new SimpleMultiValuedPropertyMap<String>();
- props.setProperty("name1", "value1");
+ props.setValue("name1", "value1");
- props.addProperty("name2", "value2");
+ props.addValue("name2", "value2");
- props.setProperty("name3", "value3-1");
- props.addProperty("name3", "value3-2");
+ props.setValue("name3", "value3-1");
+ props.addValue("name3", "value3-2");
- props.addProperty("name4", "value4-1");
- props.addProperty("name4", "value4-2");
+ props.addValue("name4", "value4-1");
+ props.addValue("name4", "value4-2");
- props.setProperty("name5", "value5-1");
- props.setProperty("name5", "value5-2");
+ props.setValue("name5", "value5-1");
+ props.setValue("name5", "value5-2");
- props.addProperty("name6", "value6-1");
- props.setProperty("name6", "value6-2");
+ props.addValue("name6", "value6-1");
+ props.setValue("name6", "value6-2");
- assertEquals("value1", props.getPropertyValue("name1"));
- assertEquals(1, props.getPropertyValues("name1").size());
- assertEquals("value1", props.getPropertyValues("name1").get(0));
+ assertEquals("value1", props.getValue("name1"));
+ assertEquals(1, props.getValues("name1").size());
+ assertEquals("value1", props.getValues("name1").get(0));
- assertEquals("value2", props.getPropertyValue("name2"));
- assertEquals(1, props.getPropertyValues("name2").size());
- assertEquals("value2", props.getPropertyValues("name2").get(0));
+ assertEquals("value2", props.getValue("name2"));
+ assertEquals(1, props.getValues("name2").size());
+ assertEquals("value2", props.getValues("name2").get(0));
- assertEquals("value3-1", props.getPropertyValue("name3"));
- assertEquals(2, props.getPropertyValues("name3").size());
- assertEquals("value3-1", props.getPropertyValues("name3").get(0));
- assertEquals("value3-2", props.getPropertyValues("name3").get(1));
+ assertEquals("value3-1", props.getValue("name3"));
+ assertEquals(2, props.getValues("name3").size());
+ assertEquals("value3-1", props.getValues("name3").get(0));
+ assertEquals("value3-2", props.getValues("name3").get(1));
- assertEquals("value4-1", props.getPropertyValue("name4"));
- assertEquals(2, props.getPropertyValues("name4").size());
- assertEquals("value4-1", props.getPropertyValues("name4").get(0));
- assertEquals("value4-2", props.getPropertyValues("name4").get(1));
+ assertEquals("value4-1", props.getValue("name4"));
+ assertEquals(2, props.getValues("name4").size());
+ assertEquals("value4-1", props.getValues("name4").get(0));
+ assertEquals("value4-2", props.getValues("name4").get(1));
- assertEquals(1, props.getPropertyValues("name5").size());
- assertEquals("value5-2", props.getPropertyValues("name5").get(0));
+ assertEquals(1, props.getValues("name5").size());
+ assertEquals("value5-2", props.getValues("name5").get(0));
- assertEquals("value6-2", props.getPropertyValue("name6"));
- assertEquals(1, props.getPropertyValues("name6").size());
- assertEquals("value6-2", props.getPropertyValues("name6").get(0));
+ assertEquals("value6-2", props.getValue("name6"));
+ assertEquals(1, props.getValues("name6").size());
+ assertEquals("value6-2", props.getValues("name6").get(0));
- assertEquals(null, props.getPropertyValues("not here"));
- assertNull(props.getPropertyValue("not here"));
- assertEquals(Tools.toSet("name1", "name2", "name3", "name4", "name5", "name6"), props.getPropertyNames());
+ assertEquals(null, props.getValues("not here"));
+ assertNull(props.getValue("not here"));
+ assertEquals(Tools.toSet("name1", "name2", "name3", "name4", "name5", "name6"), props.keySet());
try
{
- props.setProperty(null, "not null");
+ props.setValue(null, "not null");
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e)
@@ -102,7 +102,7 @@
try
{
- props.setProperty("not null", null);
+ props.setValue("not null", null);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e)
@@ -111,7 +111,7 @@
try
{
- props.setProperty(null, null);
+ props.setValue(null, null);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e)
@@ -121,61 +121,61 @@
public void testAppend1()
{
- MultiValuedPropertyMap<String> props = new MultiValuedPropertyMap<String>();
- MultiValuedPropertyMap<String> appended = new MultiValuedPropertyMap<String>();
- appended.setProperty("foo", "bar");
+ SimpleMultiValuedPropertyMap<String> props = new SimpleMultiValuedPropertyMap<String>();
+ SimpleMultiValuedPropertyMap<String> appended = new SimpleMultiValuedPropertyMap<String>();
+ appended.setValue("foo", "bar");
props.append(appended);
//
- assertEquals(Tools.toSet("foo"), props.getPropertyNames());
- assertEquals(Tools.toList("bar"), props.getPropertyValues("foo"));
+ assertEquals(Tools.toSet("foo"), props.keySet());
+ assertEquals(Tools.toList("bar"), props.getValues("foo"));
}
public void testAppend2()
{
- MultiValuedPropertyMap<String> props = new MultiValuedPropertyMap<String>();
- props.setProperty("foo", "bar");
+ SimpleMultiValuedPropertyMap<String> props = new SimpleMultiValuedPropertyMap<String>();
+ props.setValue("foo", "bar");
//
- MultiValuedPropertyMap<String> appended = new MultiValuedPropertyMap<String>();
+ SimpleMultiValuedPropertyMap<String> appended = new SimpleMultiValuedPropertyMap<String>();
props.append(appended);
//
- assertEquals(Tools.toSet("foo"), props.getPropertyNames());
- assertEquals(Tools.toList("bar"), props.getPropertyValues("foo"));
+ assertEquals(Tools.toSet("foo"), props.keySet());
+ assertEquals(Tools.toList("bar"), props.getValues("foo"));
}
public void testAppend3()
{
- MultiValuedPropertyMap<String> props = new MultiValuedPropertyMap<String>();
- props.setProperty("foo", "foo1");
- props.setProperty("bar", "bar1");
- props.addProperty("bar", "bar2");
- props.setProperty("juu", "juu1");
- props.setProperty("daa", "daa1");
- props.addProperty("daa", "daa2");
+ SimpleMultiValuedPropertyMap<String> props = new SimpleMultiValuedPropertyMap<String>();
+ props.setValue("foo", "foo1");
+ props.setValue("bar", "bar1");
+ props.addValue("bar", "bar2");
+ props.setValue("juu", "juu1");
+ props.setValue("daa", "daa1");
+ props.addValue("daa", "daa2");
//
- MultiValuedPropertyMap<String> appended = new MultiValuedPropertyMap<String>();
- appended.setProperty("juu", "juu2");
- appended.addProperty("juu", "juu3");
- appended.setProperty("daa", "daa3");
- appended.setProperty("zoo", "zoo1");
- appended.setProperty("tee", "tee1");
- appended.addProperty("tee", "tee2");
+ SimpleMultiValuedPropertyMap<String> appended = new SimpleMultiValuedPropertyMap<String>();
+ appended.setValue("juu", "juu2");
+ appended.addValue("juu", "juu3");
+ appended.setValue("daa", "daa3");
+ appended.setValue("zoo", "zoo1");
+ appended.setValue("tee", "tee1");
+ appended.addValue("tee", "tee2");
//
props.append(appended);
//
- assertEquals(Tools.toSet("foo","bar","juu","daa","zoo","tee"), props.getPropertyNames());
- assertEquals(Tools.toList("foo1"), props.getPropertyValues("foo"));
- assertEquals(Tools.toList("bar1", "bar2"), props.getPropertyValues("bar"));
- assertEquals(Tools.toList("juu1", "juu2","juu3"), props.getPropertyValues("juu"));
- assertEquals(Tools.toList("daa1", "daa2","daa3"), props.getPropertyValues("daa"));
- assertEquals(Tools.toList("zoo1"), props.getPropertyValues("zoo"));
- assertEquals(Tools.toList("tee1","tee2"), props.getPropertyValues("tee"));
+ assertEquals(Tools.toSet("foo","bar","juu","daa","zoo","tee"), props.keySet());
+ assertEquals(Tools.toList("foo1"), props.getValues("foo"));
+ assertEquals(Tools.toList("bar1", "bar2"), props.getValues("bar"));
+ assertEquals(Tools.toList("juu1", "juu2","juu3"), props.getValues("juu"));
+ assertEquals(Tools.toList("daa1", "daa2","daa3"), props.getValues("daa"));
+ assertEquals(Tools.toList("zoo1"), props.getValues("zoo"));
+ assertEquals(Tools.toList("tee1","tee2"), props.getValues("tee"));
}
}
18 years, 3 months
JBoss Portal SVN: r9603 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-24 20:23:38 -0500 (Thu, 24 Jan 2008)
New Revision: 9603
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ReadTransportHeaderTestCase.java
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP6.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml
Log:
moved test case that read headers to 286/ext (since it is ext) and added testing for event and resource lifecycle
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP6.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP6.java 2008-01-25 01:05:08 UTC (rev 9602)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/framework/UTP6.java 2008-01-25 01:23:38 UTC (rev 9603)
@@ -46,6 +46,8 @@
public final static JoinPoint ACTION_JOIN_POINT = new JoinPoint(NAME, JoinPointType.PORTLET_ACTION);
+ public final static JoinPoint RESOURCE_JOIN_POINT = new JoinPoint(NAME, JoinPointType.PORTLET_RESOURCE);
+
/** Resets helper variables */
public void reset()
{
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ReadTransportHeaderTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ReadTransportHeaderTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletrequests/ReadTransportHeaderTestCase.java 2008-01-25 01:23:38 UTC (rev 9603)
@@ -0,0 +1,152 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.ext.portletrequests;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletActionTestAction;
+import org.jboss.portal.unit.actions.PortletEventTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.portal.test.portlet.framework.UTP6;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.assertFalse;
+import static org.jboss.unit.api.Assert.assertNull;
+import static org.jboss.unit.api.Assert.assertTrue;
+import static org.jboss.unit.api.Assert.assertEquals;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.PortletException;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.PortletRequest;
+import java.util.Set;
+import java.util.Enumeration;
+import java.io.IOException;
+
+/**
+ * Show that we can access request headers from the portlet request properties.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+@TestCase
+public class ReadTransportHeaderTestCase
+{
+ public ReadTransportHeaderTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP6.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ // Test the value is not there yet
+ Set propertyNames = Tools.toSet(request.getPropertyNames());
+ assertFalse(propertyNames.contains("myheader"));
+ assertNull(request.getProperty("myheader"));
+ assertFalse(request.getProperties("myheader").hasMoreElements());
+
+ // Invoke render with header
+ InvokeGetResponse render = new InvokeGetResponse(response.createRenderURL().toString());
+ render.addHeader("myheader").addElement("render-value");
+ return render;
+ }
+ });
+
+ seq.bindAction(1, UTP6.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ assertHeader(request, "render-value");
+
+ // Invoke action with header
+ InvokeGetResponse action = new InvokeGetResponse(response.createActionURL().toString());
+ action.addHeader("myheader").addElement("action-value");
+ return action;
+ }
+ });
+
+ seq.bindAction(2, UTP6.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context)
+ {
+ assertHeader(request, "action-value");
+
+ //
+ response.setEvent("Event", null);
+ }
+ });
+
+ seq.bindAction(2, UTP6.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertHeader(request, "action-value");
+ }
+ });
+
+ seq.bindAction(2, UTP6.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
+ {
+ // Invoke resource with header
+ InvokeGetResponse render = new InvokeGetResponse(response.createResourceURL().toString());
+ render.addHeader("myheader").addElement("resource-value");
+ return render;
+ }
+ });
+
+ seq.bindAction(3, UTP6.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertHeader(request, "resource-value");
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+
+ private void assertHeader(PortletRequest request, String value)
+ {
+ // Test the header is here
+ Set propertyNames = Tools.toSet(request.getPropertyNames());
+ assertTrue(propertyNames.contains("myheader"));
+ assertEquals(value, request.getProperty("myheader"));
+ Enumeration values = request.getProperties("myheader");
+ assertTrue(values.hasMoreElements());
+ assertEquals(value, values.nextElement());
+ assertFalse(values.hasMoreElements());
+ }
+}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-25 01:05:08 UTC (rev 9602)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-25 01:23:38 UTC (rev 9603)
@@ -542,12 +542,13 @@
ResponseProperties props = fragment.getProperties();
//
- renderTransportHeaders(props, resp);
+ if (props != null)
+ {
+ renderTransportHeaders(props, resp);
+ renderCookies(props, resp);
+ }
//
- renderCookies(props, resp);
-
- //
if (fragment.getType() == FragmentResponse.TYPE_EMPTY)
{
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
@@ -706,10 +707,8 @@
// Now we combine the render properties with the page properties
pageProperties.append(renderProperties);
- // Render the headers
+ // Render the headers and cookies
renderTransportHeaders(pageProperties, resp);
-
- // Render the cookies
renderCookies(pageProperties, resp);
//
Modified: modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml 2008-01-25 01:05:08 UTC (rev 9602)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletrequests-war/WEB-INF/portlet.xml 2008-01-25 01:23:38 UTC (rev 9603)
@@ -76,6 +76,20 @@
</supports>
</portlet>
+ <portlet>
+ <portlet-name>UniversalTestPortletF</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP6</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <name>Event</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Event</name>
+ </supported-publishing-event>
+ </portlet>
+
<event-definition>
<name>Event</name>
</event-definition>
18 years, 3 months
JBoss Portal SVN: r9602 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/unit and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-24 20:05:08 -0500 (Thu, 24 Jan 2008)
New Revision: 9602
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/WriteTransportHeaderTestCase.java
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/WriteCookiesTestCase.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/portlet.xml
Log:
- implemented cookie handling for resource serving
- test cookie handling for resource serving
- added test case for setting a response header in every lifeycle of a portlet
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/WriteCookiesTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/WriteCookiesTestCase.java 2008-01-24 22:28:21 UTC (rev 9601)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/WriteCookiesTestCase.java 2008-01-25 01:05:08 UTC (rev 9602)
@@ -28,6 +28,7 @@
import org.jboss.portal.unit.actions.PortletRenderTestAction;
import org.jboss.portal.unit.actions.PortletActionTestAction;
import org.jboss.portal.unit.actions.PortletEventTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
import org.jboss.portal.test.portlet.framework.UTP1;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.EndTestResponse;
@@ -42,6 +43,8 @@
import javax.portlet.ActionResponse;
import javax.portlet.EventRequest;
import javax.portlet.EventResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
import javax.servlet.http.Cookie;
import java.io.IOException;
import java.util.Map;
@@ -129,7 +132,6 @@
assertNull(cookieMap.get("event_cookie"));
//
- //
Cookie cookie = new Cookie("event_cookie", "event_cookie_value");
response.addProperty(cookie);
}
@@ -180,6 +182,37 @@
assertEquals("event_cookie_value", cookieMap.get("event_cookie"));
//
+ return new InvokeGetResponse(response.createResourceURL().toString());
+ }
+ });
+ seq.bindAction(4, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("render_cookie_value", cookieMap.get("render_cookie"));
+ assertEquals("action_cookie_value", cookieMap.get("action_cookie"));
+ assertEquals("event_cookie_value", cookieMap.get("event_cookie"));
+
+ //
+ Cookie cookie = new Cookie("resource_cookie", "resource_cookie_value");
+ response.addProperty(cookie);
+
+ //
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+ seq.bindAction(5, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ Map<String, String> cookieMap = createCookieMap(request);
+ assertEquals("render_cookie_value", cookieMap.get("render_cookie"));
+ assertEquals("action_cookie_value", cookieMap.get("action_cookie"));
+ assertEquals("event_cookie_value", cookieMap.get("event_cookie"));
+ assertEquals("resource_cookie_value", cookieMap.get("resource_cookie"));
+
+ //
return new EndTestResponse();
}
});
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/WriteTransportHeaderTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/WriteTransportHeaderTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/ext/portletresponses/WriteTransportHeaderTestCase.java 2008-01-25 01:05:08 UTC (rev 9602)
@@ -0,0 +1,166 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.ext.portletresponses;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletActionTestAction;
+import org.jboss.portal.unit.actions.PortletEventTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP2;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import org.jboss.unit.remote.http.HttpHeaders;
+import org.jboss.unit.remote.http.HttpHeader;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import java.io.IOException;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class WriteTransportHeaderTestCase
+{
+ public WriteTransportHeaderTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ response.setProperty("Foo", "Bar_render");
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+ seq.bindAction(1, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ HttpHeaders headers = context.getResponseHeaders();
+ HttpHeader header = headers.getHeader("Foo");
+ assertNotNull(header);
+ assertEquals("Bar_render", header.getValue());
+
+ //
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(2, UTP2.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ response.setProperty("Foo", "Bar_action");
+ }
+ });
+ seq.bindAction(2, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+ seq.bindAction(3, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ HttpHeaders headers = context.getResponseHeaders();
+ HttpHeader header = headers.getHeader("Foo");
+ assertNotNull(header);
+ assertEquals("Bar_action", header.getValue());
+
+ //
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(4, UTP2.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ response.setEvent("Event", null);
+ }
+ });
+ seq.bindAction(4, UTP2.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ response.setProperty("Foo", "Bar_event");
+ }
+ });
+ seq.bindAction(4, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+ seq.bindAction(5, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ HttpHeaders headers = context.getResponseHeaders();
+ HttpHeader header = headers.getHeader("Foo");
+ assertNotNull(header);
+ assertEquals("Bar_event", header.getValue());
+
+ //
+ return new InvokeGetResponse(response.createResourceURL().toString());
+ }
+ });
+ seq.bindAction(6, UTP2.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ response.setProperty("Foo", "Bar_resource");
+ return new InvokeGetResponse(response.createRenderURL().toString());
+ }
+ });
+ seq.bindAction(7, UTP2.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ HttpHeaders headers = context.getResponseHeaders();
+ HttpHeader header = headers.getHeader("Foo");
+ assertNotNull(header);
+ assertEquals("Bar_resource", header.getValue());
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java 2008-01-24 22:28:21 UTC (rev 9601)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/PortletTestContext.java 2008-01-25 01:05:08 UTC (rev 9602)
@@ -28,6 +28,7 @@
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.remote.RequestContext;
import org.jboss.unit.remote.ResponseContext;
+import org.jboss.unit.remote.http.HttpHeaders;
import java.net.MalformedURLException;
import java.io.Serializable;
@@ -109,4 +110,13 @@
return requestContext.getPayload();
}
+ public byte[] getResponseBody()
+ {
+ return (byte[])getPayload().get("http.response.body");
+ }
+
+ public HttpHeaders getResponseHeaders()
+ {
+ return (HttpHeaders)getPayload().get("http.response.headers");
+ }
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-24 22:28:21 UTC (rev 9601)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-25 01:05:08 UTC (rev 9602)
@@ -539,7 +539,15 @@
if (response instanceof FragmentResponse)
{
FragmentResponse fragment = (FragmentResponse)response;
+ ResponseProperties props = fragment.getProperties();
+ //
+ renderTransportHeaders(props, resp);
+
+ //
+ renderCookies(props, resp);
+
+ //
if (fragment.getType() == FragmentResponse.TYPE_EMPTY)
{
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
@@ -699,27 +707,10 @@
pageProperties.append(renderProperties);
// Render the headers
- MultiValuedPropertyMap<String> transportHeaders = pageProperties.getTransportHeaders(false);
- if (transportHeaders != null)
- {
- for (String headerName : transportHeaders.getPropertyNames())
- {
- for (String headerValue : transportHeaders.getPropertyValues(headerName))
- {
- resp.addHeader(headerName, headerValue);
- }
- }
- }
+ renderTransportHeaders(pageProperties, resp);
// Render the cookies
- List<Cookie> cookies = pageProperties.getCookies(false);
- if (cookies != null)
- {
- for (Cookie cookie : cookies)
- {
- resp.addCookie(cookie);
- }
- }
+ renderCookies(pageProperties, resp);
//
resp.setContentType("text/html");
@@ -758,6 +749,33 @@
writer.print("</body></html>");
}
+ private void renderCookies(ResponseProperties pageProperties, HttpServletResponse resp)
+ {
+ List<Cookie> cookies = pageProperties.getCookies(false);
+ if (cookies != null)
+ {
+ for (Cookie cookie : cookies)
+ {
+ resp.addCookie(cookie);
+ }
+ }
+ }
+
+ private void renderTransportHeaders(ResponseProperties pageProperties, HttpServletResponse resp)
+ {
+ MultiValuedPropertyMap<String> transportHeaders = pageProperties.getTransportHeaders(false);
+ if (transportHeaders != null)
+ {
+ for (String headerName : transportHeaders.getPropertyNames())
+ {
+ for (String headerValue : transportHeaders.getPropertyValues(headerName))
+ {
+ resp.addHeader(headerName, headerValue);
+ }
+ }
+ }
+ }
+
private void updateNavigationalState(
PortletControllerContext context,
String portletId,
Modified: modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/portlet.xml 2008-01-24 22:28:21 UTC (rev 9601)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/ext/portletresponses-war/WEB-INF/portlet.xml 2008-01-25 01:05:08 UTC (rev 9602)
@@ -41,6 +41,20 @@
</supported-publishing-event>
</portlet>
+ <portlet>
+ <portlet-name>UniversalTestPortletB</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP2</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <name>Event</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Event</name>
+ </supported-publishing-event>
+ </portlet>
+
<event-definition>
<name>Event</name>
</event-definition>
18 years, 3 months
JBoss Portal SVN: r9601 - in branches/JBoss_Portal_2_6_1_JBPORTAL-1872: common and 4 other directories.
by portal-commits@lists.jboss.org
Author: mmillson
Date: 2008-01-24 17:28:21 -0500 (Thu, 24 Jan 2008)
New Revision: 9601
Modified:
branches/JBoss_Portal_2_6_1_JBPORTAL-1872/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGet.java
branches/JBoss_Portal_2_6_1_JBPORTAL-1872/common/build.xml
branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core-cms/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java
branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core/src/main/org/jboss/portal/core/controller/classic/OtherResponseHandler.java
branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java
branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java
Log:
Fixes for dependent issues JBPORTAL-1867, JBPORTAL-1617, and JBPORTAL-1651.
Modified: branches/JBoss_Portal_2_6_1_JBPORTAL-1872/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGet.java
===================================================================
--- branches/JBoss_Portal_2_6_1_JBPORTAL-1872/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGet.java 2008-01-24 21:33:17 UTC (rev 9600)
+++ branches/JBoss_Portal_2_6_1_JBPORTAL-1872/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGet.java 2008-01-24 22:28:21 UTC (rev 9601)
@@ -1,125 +1,126 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.test.cms.commands;
-
-import junit.framework.TestSuite;
-import org.jboss.portal.cms.CMSException;
-import org.jboss.portal.cms.Command;
-import org.jboss.portal.cms.impl.ContentImpl;
-import org.jboss.portal.cms.impl.FileImpl;
-import org.jboss.portal.cms.model.Content;
-import org.jboss.portal.cms.model.File;
-
-import java.util.Locale;
-import java.util.Map;
-
-
-/**
- * @author <a href="mailto:roy@jboss.org">Roy Russo</a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @author <a href="mailto:sohil.shah@jboss.com">Sohil Shah</a>
- */
-public class TestFileGet extends AbstractCommandTestCase
-{
- String sFilePath = "/testdoc.gif";
-
- String sCopyToFilePath = "/testdoccopy.gif";
-
- // zip vars
- String sZipPath = "/poop";
-
- String sZipFile = "resources/test/jcr/ziptest.zip";
-
- String sJPG = "/hibernate_logo.gif";
-
- String sText = "/training.txt";
-
-
- /**
- *
- *
- */
- public TestFileGet()
- {
- }
-
- /**
- *
- *
- */
- public static TestSuite suite() throws Exception
- {
- return createTestSuite(TestFileGet.class);
- }
-
- /** Tests retrieval of the version labeled LIVE. */
- public void testFileGet() throws CMSException
- {
- createFile();
- Command getCMD = service.getCommandFactory().createFileGetCommand(sFilePath, Locale.ENGLISH);
- File newfile = (File)service.execute(getCMD);
-
- Content content = newfile.getContent();
- assertEquals("Encoding Incorrect", content.getEncoding(), "UTF-8");
- assertEquals("Mimetype Incorrect", content.getMimeType(), "image/gif");
- assertEquals("Language Incorrect", content.getLocale().getLanguage(), "en");
- assertEquals("Title Incorrect", content.getTitle(), "English Title");
- assertEquals("Desc Incorrect", content.getDescription(), "English Description");
- }
-
- /**
- *
- *
- */
- private void createFile() throws CMSException
- {
- // create file english
- File file = new FileImpl();
- file.setBasePath(sFilePath);
-
- Content content = new ContentImpl();
- content.setEncoding("UTF-8");
- content.setTitle("English Title");
- content.setDescription("English Description");
- content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
- content.setBytes("1234567890".getBytes());
- content.setMimeType("image/gif");
- file.setContent(Locale.ENGLISH, content);
-
- Command newFileCMD = service.getCommandFactory().createNewFileCommand(file, content);
- service.execute(newFileCMD);
-
- // create content spanish
- Content contentSP = new ContentImpl();
- contentSP.setEncoding("UTF-8");
- contentSP.setTitle("Spanish Title");
- contentSP.setDescription("Spanish Description");
- contentSP.setBasePath(sFilePath + "/es");
- contentSP.setBytes("0987654321".getBytes());
- contentSP.setMimeType("image/gif");
- file.setContent(new Locale("es"), contentSP);
-
- Command newFileSPCMD = service.getCommandFactory().createNewFileCommand(file, contentSP);
- service.execute(newFileSPCMD);
- }
-}
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.cms.commands;
+
+import junit.framework.TestSuite;
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.ContentImpl;
+import org.jboss.portal.cms.impl.FileImpl;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+
+import java.util.Locale;
+import java.util.Map;
+
+
+/**
+ * @author <a href="mailto:roy@jboss.org">Roy Russo</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah@jboss.com">Sohil Shah</a>
+ */
+public class TestFileGet extends AbstractCommandTestCase
+{
+ String sFilePath = "/testdoc.gif";
+
+ String sCopyToFilePath = "/testdoccopy.gif";
+
+ // zip vars
+ String sZipPath = "/poop";
+
+ String sZipFile = "resources/test/jcr/ziptest.zip";
+
+ String sJPG = "/hibernate_logo.gif";
+
+ String sText = "/training.txt";
+
+
+ /**
+ *
+ *
+ */
+ public TestFileGet()
+ {
+ }
+
+ /**
+ *
+ *
+ */
+ public static TestSuite suite() throws Exception
+ {
+ return createTestSuite(TestFileGet.class);
+ }
+
+ /** Tests retrieval of the version labeled LIVE. */
+ public void testFileGet() throws CMSException
+ {
+ createFile();
+ Command getCMD = service.getCommandFactory().createFileGetCommand(sFilePath, Locale.ENGLISH);
+ File newfile = (File)service.execute(getCMD);
+
+ Content content = newfile.getContent();
+ assertEquals("Encoding Incorrect", content.getEncoding(), "UTF-8");
+ assertEquals("Mimetype Incorrect", content.getMimeType(), "image/gif");
+ assertEquals("Language Incorrect", content.getLocale().getLanguage(), "en");
+ assertEquals("Title Incorrect", content.getTitle(), "English Title");
+ assertEquals("Desc Incorrect", content.getDescription(), "English Description");
+ assertNotNull("Last Modified Date Missing", content.getLastModified());
+ }
+
+ /**
+ *
+ *
+ */
+ private void createFile() throws CMSException
+ {
+ // create file english
+ File file = new FileImpl();
+ file.setBasePath(sFilePath);
+
+ Content content = new ContentImpl();
+ content.setEncoding("UTF-8");
+ content.setTitle("English Title");
+ content.setDescription("English Description");
+ content.setBasePath(sFilePath + "/" + Locale.ENGLISH.getLanguage());
+ content.setBytes("1234567890".getBytes());
+ content.setMimeType("image/gif");
+ file.setContent(Locale.ENGLISH, content);
+
+ Command newFileCMD = service.getCommandFactory().createNewFileCommand(file, content);
+ service.execute(newFileCMD);
+
+ // create content spanish
+ Content contentSP = new ContentImpl();
+ contentSP.setEncoding("UTF-8");
+ contentSP.setTitle("Spanish Title");
+ contentSP.setDescription("Spanish Description");
+ contentSP.setBasePath(sFilePath + "/es");
+ contentSP.setBytes("0987654321".getBytes());
+ contentSP.setMimeType("image/gif");
+ file.setContent(new Locale("es"), contentSP);
+
+ Command newFileSPCMD = service.getCommandFactory().createNewFileCommand(file, contentSP);
+ service.execute(newFileSPCMD);
+ }
+}
Modified: branches/JBoss_Portal_2_6_1_JBPORTAL-1872/common/build.xml
===================================================================
--- branches/JBoss_Portal_2_6_1_JBPORTAL-1872/common/build.xml 2008-01-24 21:33:17 UTC (rev 9600)
+++ branches/JBoss_Portal_2_6_1_JBPORTAL-1872/common/build.xml 2008-01-24 22:28:21 UTC (rev 9601)
@@ -143,7 +143,7 @@
<mkdir dir="${build.lib}"/>
- <jar jarfile="${build.lib}/portal-common-lib.jar" manifest="${build.etc}/portal-common-lib-jar.mf">
+ <jar jarfile="${build.lib}/portal-common-lib.jar" manifest="${build.etc}/portal-common-lib-jar.mf" duplicate="preserve">
<fileset dir="${build.classes}"/>
<fileset dir="${build.resources}/format/code"/>
<fileset dir="${build.classes}">
Modified: branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core/src/main/org/jboss/portal/core/controller/classic/OtherResponseHandler.java
===================================================================
--- branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core/src/main/org/jboss/portal/core/controller/classic/OtherResponseHandler.java 2008-01-24 21:33:17 UTC (rev 9600)
+++ branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core/src/main/org/jboss/portal/core/controller/classic/OtherResponseHandler.java 2008-01-24 22:28:21 UTC (rev 9601)
@@ -29,6 +29,7 @@
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.command.response.RedirectionResponse;
import org.jboss.portal.core.controller.command.response.SignOutResponse;
import org.jboss.portal.core.controller.command.response.StreamContentResponse;
import org.jboss.portal.core.controller.command.response.ErrorResponse;
@@ -105,10 +106,28 @@
//
return HTTPResponse.sendRedirect(location);
}
+ else if (controllerResponse instanceof RedirectionResponse)
+ {
+ // Get the optional signout location
+ String location = ((RedirectionResponse)controllerResponse).getLocation();
+
+ //
+ if (location == null)
+ {
+ PortalObjectContainer portalObjectContainer = controllerContext.getController().getPortalObjectContainer();
+ Portal portal = (Portal)portalObjectContainer.getObject(DEFAULT_PORTAL_PATH);
+ ViewPageCommand renderCmd = new ViewPageCommand(portal.getId());
+ URLContext urlContext = invocation.getServerContext().getURLContext();
+ location = controllerContext.renderURL(renderCmd, urlContext, null);
+ }
+
+ //
+ return HTTPResponse.sendRedirect(location);
+ }
else if (controllerResponse instanceof StreamContentResponse)
{
StreamContentResponse scr = (StreamContentResponse)controllerResponse;
- return HTTPResponse.sendBinary(scr.getContentType(), scr.getInputStream());
+ return HTTPResponse.sendBinary(scr.getContentType(), scr.getLastModified(), scr.getInputStream());
}
else if (controllerResponse instanceof SecurityErrorResponse)
{
Modified: branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java
===================================================================
--- branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java 2008-01-24 21:33:17 UTC (rev 9600)
+++ branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java 2008-01-24 22:28:21 UTC (rev 9601)
@@ -35,11 +35,17 @@
/** . */
private String contentType;
+
+ /**
+ * The time the content was last modified, measured in milliseconds since
+ * the epoch (00:00:00 GMT, January 1, 1970).
+ */
+ private long lastModified;
/** . */
private InputStream inputStream;
- public StreamContentResponse(String contentType, InputStream inputStream)
+ public StreamContentResponse(String contentType, long lastModified, InputStream inputStream)
{
if (contentType == null)
{
@@ -50,6 +56,7 @@
throw new IllegalArgumentException();
}
this.contentType = contentType;
+ this.lastModified = lastModified;
this.inputStream = inputStream;
}
@@ -57,6 +64,11 @@
{
return contentType;
}
+
+ public long getLastModified()
+ {
+ return lastModified;
+ }
public InputStream getInputStream()
{
Modified: branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java
===================================================================
--- branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java 2008-01-24 21:33:17 UTC (rev 9600)
+++ branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java 2008-01-24 22:28:21 UTC (rev 9601)
@@ -54,7 +54,7 @@
};
}
- public static HTTPResponse sendBinary(final String contentType, final InputStream in)
+ public static HTTPResponse sendBinary(final String contentType, final long lastModified, final InputStream in)
{
return new HTTPResponse()
{
@@ -62,6 +62,7 @@
{
HttpServletResponse resp = ctx.getClientResponse();
resp.setContentType(contentType);
+ resp.addDateHeader("Last-Modified", lastModified);
ServletOutputStream sout = null;
try
{
Modified: branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core-cms/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java
===================================================================
--- branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core-cms/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java 2008-01-24 21:33:17 UTC (rev 9600)
+++ branches/JBoss_Portal_2_6_1_JBPORTAL-1872/core-cms/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java 2008-01-24 22:28:21 UTC (rev 9601)
@@ -86,8 +86,18 @@
}
Content content = file.getContent();
String mimeType = content.getMimeType();
+ long lastModified;
+ if(content.getLastModified() != null)
+ {
+ lastModified = content.getLastModified().getTime();
+ }
+ else
+ {
+ // Use current time in none available
+ lastModified = System.currentTimeMillis();
+ }
InputStream inputStream = content.getStream();
- return new StreamContentResponse(mimeType, inputStream);
+ return new StreamContentResponse(mimeType, lastModified, inputStream);
}
catch (Exception e)
{
18 years, 3 months