JBoss Portal SVN: r7248 - trunk/core/src/main/org/jboss/portal/core/model/portal.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-05-12 18:10:34 -0400 (Sat, 12 May 2007)
New Revision: 7248
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java
Log:
cache toString value of PortalObjectId
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java 2007-05-12 03:53:59 UTC (rev 7247)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java 2007-05-12 22:10:34 UTC (rev 7248)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portal.core.model.portal;
-import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.util.Base64;
@@ -55,6 +54,9 @@
/** The lazy computed hash code. */
private Integer hashCode;
+ /** The lazy computed to string value. */
+ private String toString;
+
public PortalObjectId()
{
this.names = EMPTY_STRINGS;
@@ -71,6 +73,8 @@
public PortalObjectId(PortalObjectId that) throws IllegalArgumentException
{
ParameterValidation.throwIllegalArgExceptionIfNull(that, "PortalObjectId to be copied");
+
+ //
this.names = that.names;
this.hashCode = that.hashCode;
this.from = that.from;
@@ -86,6 +90,8 @@
public PortalObjectId(String[] names) throws IllegalArgumentException
{
ParameterValidation.throwIllegalArgExceptionIfNull(names, "composing names");
+
+ //
this.names = names;
this.from = 0;
this.to = names.length;
@@ -100,20 +106,13 @@
private PortalObjectId(String[] names, int from, int to) throws IllegalArgumentException
{
ParameterValidation.throwIllegalArgExceptionIfNull(names, "composing names");
+
+ //
this.names = names;
this.from = from;
this.to = to;
}
- public PortalObjectId blah() throws IllegalStateException
- {
- if (from == to)
- {
- throw new IllegalStateException();
- }
- return new PortalObjectId(names, from + 1, to);
- }
-
/**
* Build an id by parsing a string representation.
*
@@ -124,6 +123,8 @@
public PortalObjectId(String value, Format format) throws IllegalArgumentException
{
ParameterValidation.throwIllegalArgExceptionIfNull(format, "Format");
+
+ //
this.names = format.parse(value);
this.from = 0;
this.to = names.length;
@@ -232,7 +233,11 @@
/** Returns the canonical representation of the id. */
public String toString()
{
- return CANONICAL_FORMAT.toString(names, from, to);
+ if (toString == null)
+ {
+ toString = CANONICAL_FORMAT.toString(names, from, to);
+ }
+ return toString;
}
/**
@@ -244,6 +249,8 @@
public String toString(Format format)
{
ParameterValidation.throwIllegalArgExceptionIfNull(format, "Format");
+
+ //
return format.toString(names, from, to);
}
@@ -274,6 +281,8 @@
public final String toString(PortalObjectId id) throws IllegalArgumentException
{
ParameterValidation.throwIllegalArgExceptionIfNull(id, "PortalObjectId");
+
+ //
return toString(id.names, id.from, id.to);
}
}
@@ -363,6 +372,8 @@
public String[] parse(String value)
{
ParameterValidation.throwIllegalArgExceptionIfNull(value, "value");
+
+ //
if (value.length() == 0)
{
return EMPTY_STRING_ARRAY;
@@ -396,10 +407,14 @@
public String toString(String[] names, int from, int to)
{
ParameterValidation.throwIllegalArgExceptionIfNull(names, "name string array");
+
+ //
if (from == to)
{
return "";
}
+
+ //
StringBuffer buffer = new StringBuffer((to - from) * 8);
for (int i = from; i < to; i++)
{
18 years, 11 months
JBoss Portal SVN: r7247 - in trunk/wsrp/src/resources/portal-wsrp-war: WEB-INF and 1 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-05-11 23:53:59 -0400 (Fri, 11 May 2007)
New Revision: 7247
Modified:
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/wsrp-object.xml
trunk/wsrp/src/resources/portal-wsrp-war/style.css
Log:
- JBPORTAL-1397: Everything fixed except for labels and Refresh button issue.
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml 2007-05-11 21:01:18 UTC (rev 7246)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml 2007-05-12 03:53:59 UTC (rev 7247)
@@ -5,73 +5,61 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core">
- <h1 class="portlet">Configured WSRP Consumers</h1>
-
- <hr/>
-
- <h:messages errorClass="error" infoClass="info"/>
-
- <h:form>
- Create a consumer named:
- <h:inputText value="#{consumersMgr.selectedId}" id="consumerName"/><h:message styleClass="error"
- for="consumerName"/>
+ <h:form style="padding: 1em 0;">
+ Create a consumer named: <h:inputText value="#{consumersMgr.selectedId}" id="consumerName"/>
+ <h:message styleClass="error" for="consumerName"/>
<h:commandButton action="#{consumersMgr.createConsumer}" value="Create Consumer"
styleClass="portlet-form-button"/>
</h:form>
- <table width="100%" class="portlet-table-body">
+ <hr style="margin: 1em 0 2em;"/>
+
+ <h:messages errorClass="error" infoClass="info"/>
+
+ <table width="100%" class="portlet-table-body" style="margin-bottom: 1em;">
<thead>
<tr class="portlet-table-header">
- <th>Consumer</th>
+ <th>Consumer
+ <div style="font-size: 75%; display:inline; font-weight: normal;">
+ [status: <span class="active">active</span>, <span class="inactive">inactive</span>,
+ <span class="needsRefresh">needs refresh</span>]
+ </div>
+ </th>
<th>Actions</th>
</tr>
- <tr>
- <td colspan="2">Legend:
- <span class="active">active</span>
- <span class="inactive">inactive</span>
- <span class="needsRefresh">needs refresh</span>
- </td>
- </tr>
</thead>
<tbody>
<h:form>
- <c:forEach items="#{consumersMgr.consumers}" var="consumer">
- <tr class="#{consumer.active ? 'active' : 'inactive'} #{consumer.refreshNeeded ? 'needsRefresh' : ''}">
- <td>
- <h:commandLink action="#{consumersMgr.configureConsumer}">
- <f:param name="id" value="#{consumer.producerId}"/>
- <h:outputText
- value="#{consumer.producerId} (#{consumer.active ? 'active' : 'inactive'})
- #{consumer.refreshNeeded ? '(refresh needed)' : ''}"/>
- </h:commandLink>
+ <c:forEach items="#{consumersMgr.consumers}" var="consumer" varStatus="status">
+ <tr>
+ <td
+ class="#{consumer.active ? 'active' : 'inactive'} #{consumer.refreshNeeded ? 'needsRefresh' : ''}">
+ <h:outputText value="#{consumer.producerId} (#{consumer.active ? 'active' : 'inactive'})
+ #{consumer.refreshNeeded ? '(refresh needed)' : ''}"/>
</td>
- <td>
+ <td class="#{status.index % 2 == 0 ? 'portlet-section-body' : 'portlet-section-alternate'}">
<h:commandLink action="#{consumersMgr.configureConsumer}">
<f:param name="id" value="#{consumer.producerId}"/>
<h:outputText value="Configure"/>
- </h:commandLink> |
- <h:commandLink action="#{consumersMgr.refreshConsumer}">
- <f:param name="id" value="#{consumer.producerId}"/>
- <h:outputText value="Refresh"/>
- </h:commandLink> |
- <h:commandLink action="#{consumersMgr.activateConsumer}">
- <f:param name="id" value="#{consumer.producerId}"/>
- <f:param name="activate" value="#{!consumer.active}"/>
- <h:outputText value="#{consumer.active ? 'Deactivate' : 'Activate'}"/>
- </h:commandLink>
+ </h:commandLink> | <h:commandLink action="#{consumersMgr.refreshConsumer}">
+ <f:param name="id" value="#{consumer.producerId}"/>
+ <h:outputText value="Refresh"/>
+ </h:commandLink> | <h:commandLink action="#{consumersMgr.activateConsumer}">
+ <f:param name="id" value="#{consumer.producerId}"/>
+ <f:param name="activate" value="#{!consumer.active}"/>
+ <h:outputText value="#{consumer.active ? 'Deactivate' : 'Activate'}"/>
+ </h:commandLink>
<c:if
test="#{!consumer.refreshNeeded and consumer.active and consumer.producerInfo.registrationRequired}">
- |
- <h:commandLink action="#{consumersMgr.registerConsumer}">
- <f:param name="id" value="#{consumer.producerId}"/>
- <f:param name="register" value="#{!consumer.producerInfo.registered}"/>
- <h:outputText value="#{consumer.producerInfo.registered ? 'Deregister' : 'Register'}"/>
- </h:commandLink>
- </c:if> |
- <h:commandLink action="#{consumersMgr.destroyConsumer}">
+ | <h:commandLink action="#{consumersMgr.registerConsumer}">
<f:param name="id" value="#{consumer.producerId}"/>
- <h:outputText value="Destroy"/>
+ <f:param name="register" value="#{!consumer.producerInfo.registered}"/>
+ <h:outputText value="#{consumer.producerInfo.registered ? 'Deregister' : 'Register'}"/>
</h:commandLink>
+ </c:if> | <h:commandLink action="#{consumersMgr.destroyConsumer}">
+ <f:param name="id" value="#{consumer.producerId}"/>
+ <h:outputText value="Destroy"/>
+ </h:commandLink>
</td>
</tr>
</c:forEach>
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml 2007-05-11 21:01:18 UTC (rev 7246)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml 2007-05-12 03:53:59 UTC (rev 7247)
@@ -148,39 +148,15 @@
</c:choose>
</c:if>
<tr>
- <td>
+ <td colspan="2" style="padding: 1em 1em 1em 0;">
<h:commandButton action="#{consumer.update}" value="Save" styleClass="portlet-form-button"/>
<h:commandLink action="#{consumersMgr.refreshConsumer}" value="Refresh" title="Refresh information from Producer"
styleClass="portlet-form-button">
<f:param name="id" value="#{consumer.id}"/>
</h:commandLink>
+ <h:commandLink action="#{consumersMgr.listConsumers}" value="Cancel" styleClass="portlet-form-button"/>
</td>
- <td style="text-align: right;">
- <h:commandLink action="#{consumersMgr.listConsumers}" value="Return to list" styleClass="portlet-form-button"/>
- </td>
</tr>
-<tr>
- <td>
- <h:commandLink action="#{consumersMgr.activateConsumer}" styleClass="portlet-form-button"
- value="#{consumer.active ? 'Deactivate' : 'Activate'}">
- <f:param name="id" value="#{consumer.id}"/>
- <f:param name="activate" value="#{!consumer.active}"/>
- </h:commandLink>
-
- <h:commandLink action="#{consumersMgr.registerConsumer}" styleClass="portlet-form-button"
- rendered="#{!consumer.refreshNeeded and consumer.active and consumer.registrationRequired}"
- value="#{consumer.registered ? 'Deregister' : 'Register'}">
- <f:param name="id" value="#{consumer.id}"/>
- <f:param name="register" value="#{!consumer.registered}"/>
- </h:commandLink>
-
- </td>
- <td style="text-align: right;">
- <h:commandLink action="#{consumersMgr.destroyConsumer}" value="Destroy" styleClass="portlet-form-button">
- <f:param name="id" value="#{consumer.id}"/>
- </h:commandLink>
- </td>
-</tr>
</table>
</h:form>
</div>
\ No newline at end of file
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/wsrp-object.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/wsrp-object.xml 2007-05-11 21:01:18 UTC (rev 7246)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/wsrp-object.xml 2007-05-12 03:53:59 UTC (rev 7247)
@@ -41,13 +41,7 @@
<instance-ref>WSRPConsumersConfigurationPortletInstance</instance-ref>
<region>center</region>
<height>0</height>
- </window>
- <window>
- <window-name>CatalogPortletWindow</window-name>
- <instance-ref>CatalogPortletInstance</instance-ref>
- <region>left</region>
- <height>0</height>
- </window>
+ </window>
</page>
</deployment>
</deployments>
Modified: trunk/wsrp/src/resources/portal-wsrp-war/style.css
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/style.css 2007-05-11 21:01:18 UTC (rev 7246)
+++ trunk/wsrp/src/resources/portal-wsrp-war/style.css 2007-05-12 03:53:59 UTC (rev 7247)
@@ -18,7 +18,6 @@
.wsrp-consumer-ui th {
text-align: left;
border: 0;
- border-right: 2px solid;
vertical-align: top;
}
@@ -47,10 +46,6 @@
border-collapse: separate;
}
-.wsrp-consumer-ui .registration-prop-table th {
- border: none;
-}
-
.wsrp-consumer-ui .portlet-form-button {
padding: .2em;
margin: .3em;
18 years, 11 months
JBoss Portal SVN: r7246 - in trunk/wsrp/src/main/org/jboss/portal: wsrp/consumer and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-05-11 17:01:18 -0400 (Fri, 11 May 2007)
New Revision: 7246
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RenderHandlerTestCase.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
Log:
- JBPORTAL-1396: ResourceURLRewriter would always decode URLs. Needs more testing!
Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RenderHandlerTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RenderHandlerTestCase.java (rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RenderHandlerTestCase.java 2007-05-11 21:01:18 UTC (rev 7246)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.wsrp.consumer;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.wsrp.consumer.RenderHandler;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class RenderHandlerTestCase extends TestCase
+{
+
+ public void testResourceURLRewriter()
+ {
+ String markup = "<a href=\"/portal/portal/default/Test/EXAMPLE/EXAMPLE?action=1d&windowstate=&mode=" +
+ "&ns=_next%3D%2Fdk%2Fskat%2Fportal%2Ffront%2Fportlets%2Fexample%2Findex.jsp" +
+ "&is=_action%3D%252Fdk%252Fskat%252Fportal%252Ffront%252Fportlets%252Fexample%252FprocessLink" +
+ "%26jbpns_2fdefault_2fTest_2fEXAMPLE_2fEXAMPLEsnpbjname%3DChris\">Press to use default name.</a>";
+ String result = URLTools.replaceURLsBy(markup, new RenderHandler.ResourceURLRewriter());
+ assertEquals(markup, result);
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RenderHandlerTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2007-05-11 18:58:35 UTC (rev 7245)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2007-05-11 21:01:18 UTC (rev 7246)
@@ -233,7 +233,7 @@
}
}
- private static class ResourceURLRewriter extends URLTools.URLReplacementGenerator
+ public static class ResourceURLRewriter extends URLTools.URLReplacementGenerator
{
public String getReplacementFor(int currentIndex, URLTools.URLMatch currentMatch)
{
@@ -251,8 +251,10 @@
// FIX-ME: do something
log.debug("Required re-writing but this is not yet implemented...");
}
+ return URLTools.decodeXWWWFormURL(urlAsString);
}
- return URLTools.decodeXWWWFormURL(urlAsString);
+
+ return urlAsString;
}
}
}
18 years, 12 months
JBoss Portal SVN: r7245 - trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-05-11 14:58:35 -0400 (Fri, 11 May 2007)
New Revision: 7245
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml
Log:
minor
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml 2007-05-11 18:44:03 UTC (rev 7244)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml 2007-05-11 18:58:35 UTC (rev 7245)
@@ -10,11 +10,12 @@
<!-- Sub page addition -->
<div style="padding:1em 0 0 0">
<h:form id="portal_form">
- <div class="portlet-font">Create a portal:
+ <span class="portlet-font">Create a portal:</span>
+ <span style="padding:1em 0 1em 0">
<h:inputText id="name" value="#{portalAction.portalName}" styleClass="portlet-form-input-field" required="true"/>
<h:commandButton action="#{portalAction.addPortal}" value="Add portal" styleClass="portlet-form-button"/>
<h:message for="name" errorClass="portlet-msg-error"/>
- </div>
+ </span>
</h:form>
</div>
18 years, 12 months
JBoss Portal SVN: r7244 - trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-05-11 14:44:03 -0400 (Fri, 11 May 2007)
New Revision: 7244
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml
Log:
Add a portal label beside the field
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml 2007-05-11 04:05:30 UTC (rev 7243)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editContext.xhtml 2007-05-11 18:44:03 UTC (rev 7244)
@@ -9,14 +9,13 @@
<!-- Sub page addition -->
<div style="padding:1em 0 0 0">
- <div class="portlet-font">Create a portal:</div>
- <div style="padding:1em 0 1em 0">
- <h:form id="portal_form">
+ <h:form id="portal_form">
+ <div class="portlet-font">Create a portal:
<h:inputText id="name" value="#{portalAction.portalName}" styleClass="portlet-form-input-field" required="true"/>
<h:commandButton action="#{portalAction.addPortal}" value="Add portal" styleClass="portlet-form-button"/>
<h:message for="name" errorClass="portlet-msg-error"/>
- </h:form>
- </div>
+ </div>
+ </h:form>
</div>
<!-- Separation -->
18 years, 12 months
JBoss Portal SVN: r7243 - in trunk/wsrp: src/main/org/jboss/portal/test/wsrp and 2 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-05-11 00:05:30 -0400 (Fri, 11 May 2007)
New Revision: 7243
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java
Removed:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java
Modified:
trunk/wsrp/build.xml
Log:
- Moved *InfoTestCase to a new consumer package.
- Renamed consumer and producer targets to protocolv1-* to distinguish between class tests and protocol tests.
- Added *consumer* targets.
- Added missing portal-faces-lib.jar (might not be needed if core-admin is deployed).
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2007-05-11 00:46:42 UTC (rev 7242)
+++ trunk/wsrp/build.xml 2007-05-11 04:05:30 UTC (rev 7243)
@@ -235,9 +235,9 @@
<mkdir dir="${build.resources}"/>
<copy todir="${build.resources}">
<filterset>
- <filtersfile file="../build/etc/single.properties"/>
+ <filtersfile file="../build/etc/single.properties"/>
<filter token="portal.datasource.name" value="${portal.datasource.name}"/>
- </filterset>
+ </filterset>
<fileset dir="${source.resources}" includes="**/domain.hbm.xml"/>
<fileset dir="${source.resources}" includes="**/hibernate.cfg.xml"/>
<fileset dir="${source.resources}" includes="**/jboss-service.xml"/>
@@ -289,6 +289,7 @@
</jar>
<copy todir="${build.resources}/portal-wsrp-war/lib">
<!-- For JSF -->
+ <fileset dir="${jboss.portal-faces.root}/lib" includes="portal-faces-lib.jar"/>
<fileset dir="../core-admin/src/etc/sun-jsf" includes="jsf-example.jar"/>
<fileset dir="${facelets.facelets.lib}" includes="jsf-facelets.jar"/>
<fileset dir="${el.el.lib}" includes="el-api.jar,el-ri.jar"/>
@@ -373,7 +374,7 @@
</target>
<target name="deploy-producer-test" description="Deploy services needed to test the WSRP Producer."
- depends="package-producer-test">
+ depends="package-protocolv1-producer-test">
<require file="${jboss.deploy.dir}"/>
<deploy file="${build.lib.test}/test-wsrp-producer.sar" config="default"/>
</target>
@@ -385,7 +386,7 @@
</target>
<target name="deploy-consumer-test" description="Deploy services needed to test the WSRP Consumer."
- depends="package-consumer-test">
+ depends="package-protocolv1-consumer-test">
<require file="${jboss.deploy.dir}"/>
<deploy file="${build.lib.test}/test-wsrp-consumer.sar" config="default"/>
</target>
@@ -421,7 +422,7 @@
</jar>
</target>
- <target name="package-other-test" description="Generates the test artifacts" depends="compile">
+ <target name="package-other-test" description="Generates the other test artifacts" depends="compile">
<jar jarfile="${build.lib.test}/test-other-lib.jar">
<fileset dir="${build.classes}/">
<include name="org/jboss/portal/test/wsrp/framework/**"/>
@@ -429,9 +430,18 @@
<include name="org/jboss/portal/test/wsrp/handler/*.class"/>
</fileset>
</jar>
- </target>
+ </target>
- <target name="package-consumer-test" description="Generates the consumer test artifacts"
+ <target name="package-consumer-test" description="Generates Consumer-specific test artifacts" depends="compile">
+ <jar jarfile="${build.lib.test}/test-consumer-lib.jar">
+ <fileset dir="${build.classes}/">
+ <include name="org/jboss/portal/test/wsrp/framework/**"/>
+ <include name="org/jboss/portal/test/wsrp/consumer/*.class"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="package-protocolv1-consumer-test" description="Generates the consumer test artifacts"
depends="compile">
<jar jarfile="${build.lib.test}/test-wsrp-consumer-client.jar">
<fileset dir="${build.resources.test}/test-wsrp-consumer-client"/>
@@ -498,7 +508,7 @@
</target>
<!-- Producer tests -->
- <target name="package-producer-test" description="Generate the producer test artifacts"
+ <target name="package-protocolv1-producer-test" description="Generate the producer test artifacts"
depends="package-test-portlets">
<jar jarfile="${build.lib.test}/test-wsrp-producer-client.jar">
<fileset dir="${build.resources.test}/test-wsrp-producer-client"/>
@@ -602,8 +612,8 @@
</target>
<!-- Packages all the test related artifacts. Note that compilation should have been already executed -->
- <target name="package-tests" depends="package-consumer-test, package-deployment-test, package-other-test,
- package-producer-test, package-producer-configuration-test"
+ <target name="package-tests" depends="package-protocolv1-consumer-test, package-deployment-test, package-other-test,
+ package-protocolv1-producer-test, package-producer-configuration-test"
description="Packages all the test-related artifacts. Does NOT compile classes so this should be done before
calling this task."/>
@@ -621,10 +631,11 @@
<target name="tests-local" depends="clean, output">
<server:start name="default"/>
<antcall target="agent-deploy"/>
- <antcall target="producer-test"/>
- <antcall target="consumer-test"/>
+ <antcall target="protocolv1-producer-test"/>
+ <antcall target="protocolv1-consumer-test"/>
<antcall target="deployment-test"/>
<antcall target="other-test"/>
+ <antcall target="consumer-test"/>
<antcall target="producer-configuration-test"/>
<antcall target="agent-undeploy"/>
<server:stop name="default"/>
@@ -632,15 +643,16 @@
</target>
<target name="tests" depends="clean-test">
- <antcall target="producer-test"/>
- <antcall target="consumer-test"/>
+ <antcall target="protocolv1-producer-test"/>
+ <antcall target="protocolv1-consumer-test"/>
<antcall target="deployment-test"/>
<antcall target="other-test"/>
+ <antcall target="consumer-test"/>
<antcall target="producer-configuration-test"/>
</target>
- <!-- WSRP Producer tests -->
- <target name="producer-test" depends="deploy-producer-test">
+ <!-- WSRP v1 Protocol Producer tests -->
+ <target name="protocolv1-producer-test" depends="deploy-producer-test">
<execute-tests>
<x-test>
<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.v1.producer.ServiceDescriptionTestRunner"/>
@@ -669,8 +681,8 @@
<antcall target="undeploy-producer-test"/>
</target>
- <!--WSRP Consumer implementation tests-->
- <target name="consumer-test" depends="deploy-consumer-test">
+ <!--WSRP v1 Protocol Consumer implementation tests-->
+ <target name="protocolv1-consumer-test" depends="deploy-consumer-test">
<execute-tests>
<x-test>
<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.v1.consumer.ServiceDescriptionTestRunner"/>
@@ -746,19 +758,47 @@
</execute-tests>
</target>
+ <!-- Consumer-specific tests -->
+ <target name="consumer-test" depends="package-consumer-test">
+ <execute-tests>
+ <x-test>
+ <test todir="${test.reports}"
+ name="org.jboss.portal.test.wsrp.consumer.ProducerSessionInformationTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.consumer.EndpointConfigurationInfoTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.consumer.ProducerInfoTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.consumer.RegistrationInfoTestCase"/>
+ <!--<zest todir="${test.reports}" name="org.jboss.portal.test.wsrp.consumer.ConsumerRegistryTestCase"
+ outfile="TEST-ConsumerRegistryTestCase">
+ <parameter name="ConfigLocation" value="org/jboss/portal/test/wsrp/consumer/transient-jboss-beans.xml"/>
+ </zest>-->
+ </x-test>
+ <x-sysproperty>
+ <!--<jvmarg value="-Xdebug"/>
+ <jvmarg value="-Xnoagent"/>
+ <jvmarg value="-Djava.compiler=NONE"/>
+ <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787"/>-->
+ <sysproperty key="test.root" value="${build.lib}/tests"/>
+ </x-sysproperty>
+ <x-classpath>
+ <fileset dir="${build.lib}" includes="portal-wsrp-lib.jar"/>
+ <fileset dir="${build.lib.test}" includes="test-consumer-lib.jar"/>
+ <path refid="jboss.microcontainer.classpath"/>
+ <path refid="library.classpath"/>
+ <path refid="dependentmodule.classpath"/>
+ <path refid="ws.classpath"/>
+ </x-classpath>
+ </execute-tests>
+ </target>
+
<!-- Other WSRP tests-->
<target name="other-test" depends="package-other-test">
<execute-tests>
<x-test>
- <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.ProducerSessionInformationTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.WSRPPortletURLTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.UserContextConverterTestCase"/>
- <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.EndpointConfigurationInfoTestCase"/>
- <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.ProducerInfoTestCase"/>
- <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.other.RegistrationInfoTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.RegistrationPropertyDescriptionTestCase"/>
- <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.handler.RequestHeaderClientHandlerTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.handler.RequestHeaderClientHandlerTestCase"/>
</x-test>
<x-sysproperty>
<!--<jvmarg value="-Xdebug"/>
Copied: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java (from rev 7227, trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java (rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java 2007-05-11 04:05:30 UTC (rev 7243)
@@ -0,0 +1,127 @@
+/*
+* 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.wsrp.consumer;
+
+import junit.framework.TestCase;
+import org.jboss.portal.test.wsrp.framework.support.BehaviorBackedServiceFactory;
+import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
+import org.jboss.portal.wsrp.services.PerEndpointSOAPInvokerServiceFactory;
+import org.jboss.portal.wsrp.services.RemoteSOAPInvokerServiceFactory;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class EndpointConfigurationInfoTestCase extends TestCase
+{
+ private EndpointConfigurationInfo info;
+ private String url = "http://www.example.com/";
+
+ protected void setUp() throws Exception
+ {
+ info = new EndpointConfigurationInfo();
+ }
+
+ public void testSetURLs()
+ {
+ info.setServiceDescriptionURL(url);
+ assertEquals(url, info.getServiceDescriptionURL());
+ try
+ {
+ info.getServiceFactory();
+ fail("Missing markup URL: service factory should not be initialized");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+
+ info.setMarkupURL(url);
+ assertNotNull(info.getServiceFactory());
+ assertEquals(url, info.getServiceFactory().getServiceDescriptionURL());
+ assertEquals(url, info.getServiceFactory().getMarkupURL());
+ assertTrue(info.getServiceFactory().isAvailable());
+ }
+
+ public void testSetWSDLURL()
+ {
+ info.setServiceDescriptionURL(url);
+ info.setMarkupURL(url);
+ assertTrue(info.getServiceFactory() instanceof PerEndpointSOAPInvokerServiceFactory);
+ assertFalse(info.usesWSDL());
+
+ String bea = "http://wsrp.bea.com:7001/producer/producer?WSDL";
+ info.setWsdlDefinitionURL(bea);
+ assertEquals(bea, info.getWsdlDefinitionURL());
+ assertTrue(info.getServiceFactory() instanceof RemoteSOAPInvokerServiceFactory);
+ assertEquals(bea, ((RemoteSOAPInvokerServiceFactory)info.getServiceFactory()).getWsdlDefinitionURL());
+ assertTrue(info.usesWSDL());
+
+ info.setMarkupURL(url);
+ assertEquals(url, info.getMarkupURL());
+ assertEquals(url, info.getServiceFactory().getMarkupURL());
+ assertTrue(info.usesWSDL());
+ }
+
+ public void testSetNullWSDLURL()
+ {
+ info.setServiceDescriptionURL(url);
+ info.setMarkupURL(url);
+
+ // it should be possible to set the WSDL to null for Hibernate
+ info.setWsdlDefinitionURL(null);
+ }
+
+ public void testRefreshWSDL() throws Exception
+ {
+ assertTrue(info.isRefreshNeeded());
+ assertFalse(info.isAvailable());
+
+ String bea = "http://wsrp.bea.com:7001/producer/producer?WSDL";
+ info.setWsdlDefinitionURL(bea);
+ info.refresh();
+ assertFalse(info.isRefreshNeeded());
+ assertTrue(info.isAvailable());
+ }
+
+ public void testRefresh() throws Exception
+ {
+ assertTrue(info.isRefreshNeeded());
+ assertFalse(info.isAvailable());
+
+ // change the service factory to a fake one to be able to simulate access to endpoint
+ info.setServiceFactory(new BehaviorBackedServiceFactory());
+ info.refresh();
+ assertFalse(info.isRefreshNeeded());
+ assertTrue(info.isAvailable());
+
+ info.setServiceDescriptionURL(url);
+ assertTrue(info.isRefreshNeeded());
+
+ info.getRegistrationService();
+ assertTrue(info.isRefreshNeeded());
+
+ info.getServiceDescriptionService();
+ assertFalse(info.isRefreshNeeded());
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java (from rev 7227, trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java (rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2007-05-11 04:05:30 UTC (rev 7243)
@@ -0,0 +1,160 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.wsrp.consumer;
+
+import junit.framework.TestCase;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.test.wsrp.framework.PortletManagementBehavior;
+import org.jboss.portal.test.wsrp.framework.RegistrationBehavior;
+import org.jboss.portal.test.wsrp.framework.ServiceDescriptionBehavior;
+import org.jboss.portal.test.wsrp.framework.support.BehaviorBackedServiceFactory;
+import org.jboss.portal.test.wsrp.framework.support.MockConsumerRegistry;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
+import org.jboss.portal.wsrp.consumer.ProducerInfo;
+import org.jboss.portal.wsrp.core.AccessDeniedFault;
+import org.jboss.portal.wsrp.core.GetPortletDescription;
+import org.jboss.portal.wsrp.core.InconsistentParametersFault;
+import org.jboss.portal.wsrp.core.InvalidHandleFault;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
+import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
+import org.jboss.portal.wsrp.core.MissingParametersFault;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
+
+import java.rmi.RemoteException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ProducerInfoTestCase extends TestCase
+{
+ private ProducerInfo info;
+ private BehaviorBackedServiceFactory serviceFactory;
+
+ protected void setUp() throws Exception
+ {
+ info = new ProducerInfo();
+ info.setId("test");
+ serviceFactory = new BehaviorBackedServiceFactory();
+ new EndpointConfigurationInfo(info, serviceFactory);
+ info.setRegistry(new MockConsumerRegistry());
+ }
+
+ public void testRefreshAndCache() throws Exception
+ {
+ ServiceDescriptionBehavior behavior = new ServiceDescriptionBehavior();
+ serviceFactory.getRegistry().setServiceDescriptionBehavior(behavior);
+
+ assertNull(info.getExpirationCacheSeconds());
+
+ assertTrue(info.isRefreshNeeded(false));
+ assertFalse(info.isRegistrationChecked());
+ assertTrue(info.refresh(false));
+ assertFalse(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistrationChecked());
+ assertTrue(info.refresh(false));
+ assertFalse(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistrationChecked());
+ assertEquals(2, behavior.getCallCount());
+
+ info.setExpirationCacheSeconds(new Integer(1));
+ assertEquals(new Integer(1), info.getExpirationCacheSeconds());
+ assertTrue(info.refresh(false));
+ assertFalse(info.refresh(false));
+ assertFalse(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistrationChecked());
+ assertEquals(3, behavior.getCallCount());
+
+ // wait for cache expiration
+ Thread.sleep(1500);
+ assertFalse("refresh is not needed if cache is not considered", info.isRefreshNeeded(false));
+ assertTrue("refresh is needed if cache is not considered since it has expired", info.isRefreshNeeded(true));
+ assertTrue(info.refresh(false));
+ assertFalse("Was just refreshed so refresh is not needed even considering cache", info.isRefreshNeeded(true));
+ assertTrue(info.isRegistrationChecked());
+ assertFalse(info.refresh(false));
+ assertTrue(info.refresh(true));
+ assertFalse(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistrationChecked());
+ assertEquals(5, behavior.getCallCount());
+ }
+
+ public void testGetPortlet() throws Exception
+ {
+ ServiceDescriptionBehavior behavior = new ServiceDescriptionBehavior();
+ behavior.addPortletDescription(behavior.createPortletDescription("test", null));
+ serviceFactory.getRegistry().setServiceDescriptionBehavior(behavior);
+
+ PortletContext portletContext = PortletContext.createPortletContext("test");
+ Portlet portlet = info.getPortlet(portletContext);
+ assertNotNull(portlet);
+ assertEquals(portletContext, portlet.getContext());
+
+ // test2 is not in the service description, so it should be looked up via Portlet Management...
+ portletContext = PortletContext.createPortletContext("test2");
+ // add portlet management behavior
+ TestPortletManagementBehavior pmBehavior = new TestPortletManagementBehavior();
+ serviceFactory.getRegistry().setPortletManagementBehavior(pmBehavior);
+ portlet = info.getPortlet(portletContext);
+ assertEquals(1, pmBehavior.getCallCount());
+ assertNotNull(portlet);
+ assertEquals(portletContext, portlet.getContext());
+ }
+
+ public void testRefreshAndRegistration() throws Exception
+ {
+ assertFalse(info.isRegistered());
+ assertNull(info.getRegistrationInfo());
+
+ ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
+ sd.setRequiresRegistration(true);
+ serviceFactory.getRegistry().setServiceDescriptionBehavior(sd);
+ RegistrationBehavior regBehavior = new RegistrationBehavior();
+ serviceFactory.getRegistry().setRegistrationBehavior(regBehavior);
+
+ assertTrue(info.refresh(false));
+ assertEquals(1, regBehavior.getCallCount());
+ assertTrue(info.isRegistered());
+ assertNotNull(info.getRegistrationInfo());
+ assertEquals(RegistrationBehavior.REGISTRATION_HANDLE, info.getRegistrationContext().getRegistrationHandle());
+
+ assertTrue(info.refresh(true));
+ assertEquals(1, regBehavior.getCallCount());
+ }
+
+ private static class TestPortletManagementBehavior extends PortletManagementBehavior
+ {
+ public PortletDescriptionResponse getPortletDescription(GetPortletDescription getPortletDescription)
+ throws AccessDeniedFault, InvalidHandleFault, InvalidUserCategoryFault, InconsistentParametersFault,
+ MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
+ {
+ incrementCallCount();
+ return WSRPTypeFactory.createPortletDescriptionResponse(createPortletDescription("test2", null));
+ }
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java (from rev 7227, trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java (rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java 2007-05-11 04:05:30 UTC (rev 7243)
@@ -0,0 +1,221 @@
+/******************************************************************************
+ * 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.wsrp.consumer;
+
+import junit.framework.TestCase;
+import org.apache.commons.httpclient.Cookie;
+import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com?subject=org.jboss.portal.test.wsrp.consumer.ProducerSessionInformationTestCase">Chris
+ * Laprun</a>
+ * @version $Revision$
+ * @since 2.4
+ */
+public class ProducerSessionInformationTestCase extends TestCase
+{
+ ProducerSessionInformation info;
+
+ protected void setUp() throws Exception
+ {
+ info = new ProducerSessionInformation();
+ }
+
+ public void testUserCookie() throws Exception
+ {
+ assertNull(info.getUserCookie());
+
+ Cookie[] cookies = new Cookie[]{createCookie("name", "value", 1)};
+ info.setUserCookie(cookies);
+
+ assertEquals("name=value", info.getUserCookie());
+
+ // wait for cookie expiration
+ Thread.sleep(1000);
+ assertNull(info.getUserCookie()); // we shouldn't have a cookie now
+
+ cookies = new Cookie[]{createCookie("name1", "value1", 1), createCookie("name2", "value2", 3)};
+ info.setUserCookie(cookies);
+ assertEquals("name1=value1;name2=value2", info.getUserCookie());
+
+ Thread.sleep(1000);
+ assertEquals("name2=value2", info.getUserCookie());
+
+ try
+ {
+ info.setUserCookie(null);
+ fail("Should have thrown an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException e)
+ {
+ //expected
+ }
+ }
+
+ public void testGroupCookies() throws Exception
+ {
+ String groupId = "groupId";
+
+ try
+ {
+ info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name1", "value1", 1), createCookie("name2", "value2", -1)});
+ fail("Cannot add group cookie if not perGroup");
+ }
+ catch (IllegalStateException e)
+ {
+ //expected
+ }
+
+ info.setPerGroupCookies(true);
+ info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name1", "value1", 1),
+ createCookie("name2", "value2", WSRPConstants.SESSION_NEVER_EXPIRES)});
+
+ assertEquals("name1=value1;name2=value2", info.getGroupCookieFor(groupId));
+
+ Thread.sleep(1000);
+ assertEquals("name2=value2", info.getGroupCookieFor(groupId));
+
+ info.clearGroupCookies();
+ assertNull(info.getGroupCookieFor(groupId));
+ }
+
+ public void testSessionForPortlet() throws Exception
+ {
+ String handle = "handle";
+ String handle2 = "handle2";
+ String sid = "id";
+ String sid2 = "id2";
+
+ assertNull(info.getSessionIdForPortlet(handle));
+ assertEquals(0, info.getNumberOfSessions());
+
+ addSession(handle, sid, 1);
+ addSession(handle2, sid2, 3);
+
+ assertNull(info.getSessionIdForPortlet("unknown"));
+
+ assertEquals(sid, info.getSessionIdForPortlet(handle));
+ assertEquals(2, info.getNumberOfSessions());
+
+ Thread.sleep(1000);
+ assertNull(info.getSessionIdForPortlet(handle));
+ assertEquals(sid2, info.getSessionIdForPortlet(handle2));
+ assertEquals(1, info.getNumberOfSessions());
+
+ info.removeSessionForPortlet(handle2);
+ assertEquals(0, info.getNumberOfSessions());
+ }
+
+ public void testReplaceUserCookies() throws Exception
+ {
+ info.setUserCookie(new Cookie[]{createCookie("name", "value", 1)});
+
+ info.replaceUserCookiesWith(null);
+ assertEquals("name=value", info.getUserCookie());
+
+ ProducerSessionInformation other = new ProducerSessionInformation();
+
+ info.replaceUserCookiesWith(other);
+ assertEquals("name=value", info.getUserCookie());
+
+ other.setUserCookie(new Cookie[]{createCookie("name2", "value2", 1)});
+ info.replaceUserCookiesWith(other);
+ assertEquals("name2=value2", info.getUserCookie());
+
+ Thread.sleep(1000);
+ info.replaceUserCookiesWith(other);
+ assertNull(info.getUserCookie());
+ }
+
+ public void testReleaseSessions()
+ {
+ addSession("handle", "id", 1);
+ addSession("handle2", "id2", 1);
+ addSession("handle3", "id3", 1);
+
+ assertEquals(3, info.getNumberOfSessions());
+
+ info.removeSessions();
+
+ assertEquals(0, info.getNumberOfSessions());
+
+ addSession("handle", "id", 1);
+ addSession("handle2", "id2", 2);
+
+ info.removeSession("id2");
+
+ assertEquals(1, info.getNumberOfSessions());
+ assertNull(info.getSessionIdForPortlet("handle2"));
+ assertEquals("id", info.getSessionIdForPortlet("handle"));
+
+ info.removeSessionForPortlet("handle");
+
+ assertEquals(0, info.getNumberOfSessions());
+ assertNull(info.getSessionIdForPortlet("handle"));
+
+ try
+ {
+ info.removeSessionForPortlet("handle");
+ fail("Session for portlet 'handle' should have already been released!");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected
+ }
+ }
+
+ public void testSetParentSessionId()
+ {
+ assertNull(info.getParentSessionId());
+
+ String id = "session";
+ info.setParentSessionId(id);
+ assertEquals(id, info.getParentSessionId());
+
+ // trying to set the same id should work
+ info.setParentSessionId(id);
+
+ try
+ {
+ info.setParentSessionId("other");
+ fail("Cannot modify session id once it has been set");
+ }
+ catch (IllegalStateException expected)
+ {
+ // expected
+ }
+ }
+
+ private Cookie createCookie(String name, String value, int secondsBeforeExpiration)
+ {
+ return new Cookie("domain", name, value, "path", secondsBeforeExpiration, false);
+ }
+
+ private void addSession(String handle, String sid, int expires)
+ {
+ info.addSessionForPortlet(handle, WSRPTypeFactory.createSessionContext(sid, expires));
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java (from rev 7227, trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java (rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java 2007-05-11 04:05:30 UTC (rev 7243)
@@ -0,0 +1,285 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.wsrp.consumer;
+
+import junit.framework.TestCase;
+import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.consumer.RefreshResult;
+import org.jboss.portal.wsrp.consumer.RegistrationInfo;
+import org.jboss.portal.wsrp.consumer.RegistrationProperty;
+import org.jboss.portal.wsrp.core.PropertyDescription;
+import org.jboss.portal.wsrp.core.RegistrationContext;
+import org.jboss.portal.wsrp.core.ServiceDescription;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class RegistrationInfoTestCase extends TestCase
+{
+ private RegistrationInfo info;
+ private static final String producerId = "test";
+
+ protected void setUp() throws Exception
+ {
+ info = new RegistrationInfo();
+ }
+
+ public void testInitialState()
+ {
+ assertTrue(info.getRegistrationProperties().isEmpty());
+ assertTrue(info.getRegistrationPropertyNames().isEmpty());
+ assertNull(info.getRegistrationContext());
+ assertNotNull(info.getRegistrationData());
+ assertNull(info.getRegistrationHandle());
+ assertNull(info.getRegistrationState());
+
+ // before refresh, refresh is needed...
+ assertTrue(info.isRefreshNeeded());
+ // we don't know if the the local info is consistent with the producer expectations...
+ assertNull(info.isConsistentWithProducerExpectations());
+ // we don't know if the registration is required...
+ assertNull(info.isRegistrationRequired());
+ // and we don't know if the registration is valid
+ assertNull(info.isRegistrationValid());
+
+ try
+ {
+ info.isRegistrationDeterminedNotRequired();
+ fail("refresh hasn't been called, isRegistrationDeterminedNotRequired should fail");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+
+ try
+ {
+ info.isRegistrationDeterminedRequired();
+ fail("refresh hasn't been called, isRegistrationDeterminedRequired should fail");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ }
+
+ public void testSetGetRegistrationProperty()
+ {
+ String key = "foo";
+ info.setRegistrationPropertyValue(key, "bar");
+ assertNull(info.isConsistentWithProducerExpectations());
+ Map properties = info.getRegistrationProperties();
+ assertFalse(properties.isEmpty());
+ Set names = info.getRegistrationPropertyNames();
+ assertFalse(names.isEmpty());
+ assertTrue(properties.containsKey(key));
+ assertTrue(names.contains(key));
+ assertNotNull(properties.get(key));
+ assertEquals(properties.get(key), info.getRegistrationProperty(key));
+ assertEquals("bar", info.getRegistrationProperty(key).getValue());
+ }
+
+ public void testRefreshNoRegistration()
+ {
+ // no registration expected
+ ServiceDescription sd = createServiceDescription(false, 0);
+ RefreshResult result = info.refresh(sd, producerId, true, false);
+ assertNotNull(result);
+ assertFalse(result.hasIssues());
+ assertTrue(info.isConsistentWithProducerExpectations().booleanValue());
+ assertFalse(info.isRegistrationRequired().booleanValue());
+ assertTrue(info.isRegistrationDeterminedNotRequired());
+ assertFalse(info.isRegistrationDeterminedRequired());
+ assertTrue(info.isRegistrationValid().booleanValue());
+
+ result = info.refresh(sd, producerId, false, false);
+ assertNotNull(result);
+ assertFalse(result.hasIssues());
+ assertTrue(info.isConsistentWithProducerExpectations().booleanValue());
+ assertFalse(info.isRegistrationRequired().booleanValue());
+ assertTrue(info.isRegistrationDeterminedNotRequired());
+ assertFalse(info.isRegistrationDeterminedRequired());
+ assertTrue(info.isRegistrationValid().booleanValue());
+ }
+
+ public void testRefreshRegistrationDefaultRegistrationNoLocalInfo()
+ {
+ // before refresh registration status is undetermined
+ assertNull(info.isRegistrationRequired());
+ assertNull(info.isRegistrationValid());
+
+ RegistrationInfo.RegistrationRefreshResult result = info.refresh(
+ createServiceDescription(true, 0), producerId, true, false);
+ assertNotNull(result);
+ assertFalse(result.hasIssues());
+ assertTrue(info.isRegistrationRequired().booleanValue());
+ assertTrue(info.isRegistrationDeterminedRequired());
+ assertFalse(info.isRegistrationDeterminedNotRequired());
+ assertFalse(info.isRegistrationValid().booleanValue());
+ }
+
+ public void testRefreshRegistrationDefaultRegistrationExtraLocalInfo()
+ {
+ // set a registration property
+ info.setRegistrationPropertyValue("foo", "bar");
+
+ RegistrationInfo.RegistrationRefreshResult result = info.refresh(
+ createServiceDescription(true, 0), producerId, false, false);
+ assertNotNull(result);
+ assertTrue(result.hasIssues());
+ String status = result.getStatus();
+ assertNotNull(status);
+ assertTrue(status.indexOf("foo") != -1);
+ assertEquals(1, info.getRegistrationProperties().size());
+ assertEquals(1, result.getRegistrationProperties().size());
+
+ Map regProps = result.getRegistrationProperties();
+ assertNotNull(regProps);
+
+ RegistrationProperty prop = (RegistrationProperty)regProps.get("foo");
+ assertNotNull(prop);
+ assertEquals("bar", prop.getValue());
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.INEXISTENT_STATUS, prop.getStatus());
+ }
+
+ public void testRefreshRegistrationRegistrationNoLocalInfo()
+ {
+ // producer requests 2 registration properties
+ ServiceDescription sd = createServiceDescription(true, 2);
+
+ RegistrationInfo.RegistrationRefreshResult result = info.refresh(sd, producerId, false, false);
+ assertNotNull(result);
+ assertTrue(result.hasIssues());
+ String status = result.getStatus();
+ assertNotNull(status);
+ assertTrue(status.indexOf("prop0") != -1 && status.indexOf("prop1") != -1);
+ assertEquals(0, info.getRegistrationProperties().size());
+ assertEquals(2, result.getRegistrationProperties().size());
+
+ Map regProps = result.getRegistrationProperties();
+ assertNotNull(regProps);
+
+ RegistrationProperty prop = (RegistrationProperty)regProps.get("prop0");
+ assertNotNull(prop);
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.MISSING_STATUS, prop.getStatus());
+ }
+
+ public void testRefreshRegistrationRegistrationMergeWithLocalInfo()
+ {
+ info.setRegistrationPropertyValue("foo", "bar");
+
+ RegistrationInfo.RegistrationRefreshResult result = info.refresh(createServiceDescription(true, 2),
+ producerId, true, false);
+ assertNotNull(result);
+ assertTrue(result.hasIssues());
+
+ RegistrationProperty prop = info.getRegistrationProperty("prop0");
+ assertNotNull(prop);
+ assertNull(prop.getValue());
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.MISSING_VALUE_STATUS, prop.getStatus());
+
+ prop = info.getRegistrationProperty("prop1");
+ assertNotNull(prop);
+ assertNull(prop.getValue());
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.MISSING_VALUE_STATUS, prop.getStatus());
+ assertEquals(2, info.getRegistrationProperties().size());
+ assertEquals(2, result.getRegistrationProperties().size());
+
+ assertNull(info.getRegistrationProperty("foo"));
+ }
+
+ public void testForceRefreshRegistration()
+ {
+ //
+ RefreshResult result = info.refresh(createServiceDescription(true, 0), producerId, false, false);
+ assertNotNull(result);
+ assertFalse(result.hasIssues());
+ assertFalse(info.isRegistrationValid().booleanValue());
+
+ // Modifying a property renders the info dirty and hence should be refreshed
+ info.setRegistrationPropertyValue("foo", "bar");
+ result = info.refresh(createServiceDescription(true, 0), producerId, false, false);
+ assertTrue(result.hasIssues());
+ assertFalse(info.isRegistrationValid().booleanValue());
+
+ info.removeRegistrationProperty("foo");
+ result = info.refresh(createServiceDescription(true, 0), producerId, false, false);
+ assertFalse(result.hasIssues());
+ assertFalse(info.isRegistrationValid().booleanValue());
+
+ // producer has changed but we're not forcing refresh so registration should still be invalid
+ result = info.refresh(createServiceDescription(false, 0), producerId, false, false);
+ assertFalse(result.hasIssues());
+ assertFalse(info.isRegistrationValid().booleanValue());
+
+ // force refresh, registration should now be valid
+ result = info.refresh(createServiceDescription(false, 0), producerId, false, true);
+ assertFalse(result.hasIssues());
+ assertTrue(info.isRegistrationValid().booleanValue());
+ }
+
+ public void testSetRegistrationContext()
+ {
+ assertNull(info.isConsistentWithProducerExpectations());
+ assertNull(info.getRegistrationHandle());
+
+ String registrationHandle = "registrationHandle";
+ info.setRegistrationContext(WSRPTypeFactory.createRegistrationContext(registrationHandle));
+ RegistrationContext registrationContext = info.getRegistrationContext();
+ assertNotNull(registrationContext);
+ assertEquals(registrationHandle, registrationContext.getRegistrationHandle());
+ assertNull(registrationContext.getRegistrationState());
+ assertTrue(info.isConsistentWithProducerExpectations().booleanValue());
+ assertTrue(info.isRegistrationValid().booleanValue());
+ assertFalse(info.isRefreshNeeded());
+ assertTrue(info.isRegistrationRequired().booleanValue());
+ assertTrue(info.isRegistrationDeterminedRequired());
+ assertFalse(info.isRegistrationDeterminedNotRequired());
+ }
+
+ private ServiceDescription createServiceDescription(boolean requiresRegistration, int numberOfProperties)
+ {
+ ServiceDescription sd = WSRPTypeFactory.createServiceDescription(requiresRegistration);
+
+ if (requiresRegistration)
+ {
+ PropertyDescription[] descriptions = new PropertyDescription[numberOfProperties];
+ for (int i = 0; i < numberOfProperties; i++)
+ {
+ descriptions[i] = WSRPTypeFactory.createPropertyDescription("prop" + i, WSRPConstants.XSD_STRING);
+ }
+ sd.setRegistrationPropertyDescription(WSRPTypeFactory.createModelDescription(descriptions));
+ }
+
+ return sd;
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java 2007-05-11 00:46:42 UTC (rev 7242)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java 2007-05-11 04:05:30 UTC (rev 7243)
@@ -1,127 +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.test.wsrp.other;
-
-import junit.framework.TestCase;
-import org.jboss.portal.test.wsrp.framework.support.BehaviorBackedServiceFactory;
-import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
-import org.jboss.portal.wsrp.services.PerEndpointSOAPInvokerServiceFactory;
-import org.jboss.portal.wsrp.services.RemoteSOAPInvokerServiceFactory;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class EndpointConfigurationInfoTestCase extends TestCase
-{
- private EndpointConfigurationInfo info;
- private String url = "http://www.example.com/";
-
- protected void setUp() throws Exception
- {
- info = new EndpointConfigurationInfo();
- }
-
- public void testSetURLs()
- {
- info.setServiceDescriptionURL(url);
- assertEquals(url, info.getServiceDescriptionURL());
- try
- {
- info.getServiceFactory();
- fail("Missing markup URL: service factory should not be initialized");
- }
- catch (IllegalStateException expected)
- {
- }
-
- info.setMarkupURL(url);
- assertNotNull(info.getServiceFactory());
- assertEquals(url, info.getServiceFactory().getServiceDescriptionURL());
- assertEquals(url, info.getServiceFactory().getMarkupURL());
- assertTrue(info.getServiceFactory().isAvailable());
- }
-
- public void testSetWSDLURL()
- {
- info.setServiceDescriptionURL(url);
- info.setMarkupURL(url);
- assertTrue(info.getServiceFactory() instanceof PerEndpointSOAPInvokerServiceFactory);
- assertFalse(info.usesWSDL());
-
- String bea = "http://wsrp.bea.com:7001/producer/producer?WSDL";
- info.setWsdlDefinitionURL(bea);
- assertEquals(bea, info.getWsdlDefinitionURL());
- assertTrue(info.getServiceFactory() instanceof RemoteSOAPInvokerServiceFactory);
- assertEquals(bea, ((RemoteSOAPInvokerServiceFactory)info.getServiceFactory()).getWsdlDefinitionURL());
- assertTrue(info.usesWSDL());
-
- info.setMarkupURL(url);
- assertEquals(url, info.getMarkupURL());
- assertEquals(url, info.getServiceFactory().getMarkupURL());
- assertTrue(info.usesWSDL());
- }
-
- public void testSetNullWSDLURL()
- {
- info.setServiceDescriptionURL(url);
- info.setMarkupURL(url);
-
- // it should be possible to set the WSDL to null for Hibernate
- info.setWsdlDefinitionURL(null);
- }
-
- public void testRefreshWSDL() throws Exception
- {
- assertTrue(info.isRefreshNeeded());
- assertFalse(info.isAvailable());
-
- String bea = "http://wsrp.bea.com:7001/producer/producer?WSDL";
- info.setWsdlDefinitionURL(bea);
- info.refresh();
- assertFalse(info.isRefreshNeeded());
- assertTrue(info.isAvailable());
- }
-
- public void testRefresh() throws Exception
- {
- assertTrue(info.isRefreshNeeded());
- assertFalse(info.isAvailable());
-
- // change the service factory to a fake one to be able to simulate access to endpoint
- info.setServiceFactory(new BehaviorBackedServiceFactory());
- info.refresh();
- assertFalse(info.isRefreshNeeded());
- assertTrue(info.isAvailable());
-
- info.setServiceDescriptionURL(url);
- assertTrue(info.isRefreshNeeded());
-
- info.getRegistrationService();
- assertTrue(info.isRefreshNeeded());
-
- info.getServiceDescriptionService();
- assertFalse(info.isRefreshNeeded());
- }
-}
Deleted: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java 2007-05-11 00:46:42 UTC (rev 7242)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java 2007-05-11 04:05:30 UTC (rev 7243)
@@ -1,160 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2007, 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.wsrp.other;
-
-import junit.framework.TestCase;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.test.wsrp.framework.PortletManagementBehavior;
-import org.jboss.portal.test.wsrp.framework.RegistrationBehavior;
-import org.jboss.portal.test.wsrp.framework.ServiceDescriptionBehavior;
-import org.jboss.portal.test.wsrp.framework.support.BehaviorBackedServiceFactory;
-import org.jboss.portal.test.wsrp.framework.support.MockConsumerRegistry;
-import org.jboss.portal.wsrp.WSRPTypeFactory;
-import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
-import org.jboss.portal.wsrp.consumer.ProducerInfo;
-import org.jboss.portal.wsrp.core.AccessDeniedFault;
-import org.jboss.portal.wsrp.core.GetPortletDescription;
-import org.jboss.portal.wsrp.core.InconsistentParametersFault;
-import org.jboss.portal.wsrp.core.InvalidHandleFault;
-import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
-import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
-import org.jboss.portal.wsrp.core.MissingParametersFault;
-import org.jboss.portal.wsrp.core.OperationFailedFault;
-import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
-
-import java.rmi.RemoteException;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class ProducerInfoTestCase extends TestCase
-{
- private ProducerInfo info;
- private BehaviorBackedServiceFactory serviceFactory;
-
- protected void setUp() throws Exception
- {
- info = new ProducerInfo();
- info.setId("test");
- serviceFactory = new BehaviorBackedServiceFactory();
- new EndpointConfigurationInfo(info, serviceFactory);
- info.setRegistry(new MockConsumerRegistry());
- }
-
- public void testRefreshAndCache() throws Exception
- {
- ServiceDescriptionBehavior behavior = new ServiceDescriptionBehavior();
- serviceFactory.getRegistry().setServiceDescriptionBehavior(behavior);
-
- assertNull(info.getExpirationCacheSeconds());
-
- assertTrue(info.isRefreshNeeded(false));
- assertFalse(info.isRegistrationChecked());
- assertTrue(info.refresh(false));
- assertFalse(info.isRefreshNeeded(false));
- assertTrue(info.isRegistrationChecked());
- assertTrue(info.refresh(false));
- assertFalse(info.isRefreshNeeded(false));
- assertTrue(info.isRegistrationChecked());
- assertEquals(2, behavior.getCallCount());
-
- info.setExpirationCacheSeconds(new Integer(1));
- assertEquals(new Integer(1), info.getExpirationCacheSeconds());
- assertTrue(info.refresh(false));
- assertFalse(info.refresh(false));
- assertFalse(info.isRefreshNeeded(false));
- assertTrue(info.isRegistrationChecked());
- assertEquals(3, behavior.getCallCount());
-
- // wait for cache expiration
- Thread.sleep(1500);
- assertFalse("refresh is not needed if cache is not considered", info.isRefreshNeeded(false));
- assertTrue("refresh is needed if cache is not considered since it has expired", info.isRefreshNeeded(true));
- assertTrue(info.refresh(false));
- assertFalse("Was just refreshed so refresh is not needed even considering cache", info.isRefreshNeeded(true));
- assertTrue(info.isRegistrationChecked());
- assertFalse(info.refresh(false));
- assertTrue(info.refresh(true));
- assertFalse(info.isRefreshNeeded(false));
- assertTrue(info.isRegistrationChecked());
- assertEquals(5, behavior.getCallCount());
- }
-
- public void testGetPortlet() throws Exception
- {
- ServiceDescriptionBehavior behavior = new ServiceDescriptionBehavior();
- behavior.addPortletDescription(behavior.createPortletDescription("test", null));
- serviceFactory.getRegistry().setServiceDescriptionBehavior(behavior);
-
- PortletContext portletContext = PortletContext.createPortletContext("test");
- Portlet portlet = info.getPortlet(portletContext);
- assertNotNull(portlet);
- assertEquals(portletContext, portlet.getContext());
-
- // test2 is not in the service description, so it should be looked up via Portlet Management...
- portletContext = PortletContext.createPortletContext("test2");
- // add portlet management behavior
- TestPortletManagementBehavior pmBehavior = new TestPortletManagementBehavior();
- serviceFactory.getRegistry().setPortletManagementBehavior(pmBehavior);
- portlet = info.getPortlet(portletContext);
- assertEquals(1, pmBehavior.getCallCount());
- assertNotNull(portlet);
- assertEquals(portletContext, portlet.getContext());
- }
-
- public void testRefreshAndRegistration() throws Exception
- {
- assertFalse(info.isRegistered());
- assertNull(info.getRegistrationInfo());
-
- ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
- sd.setRequiresRegistration(true);
- serviceFactory.getRegistry().setServiceDescriptionBehavior(sd);
- RegistrationBehavior regBehavior = new RegistrationBehavior();
- serviceFactory.getRegistry().setRegistrationBehavior(regBehavior);
-
- assertTrue(info.refresh(false));
- assertEquals(1, regBehavior.getCallCount());
- assertTrue(info.isRegistered());
- assertNotNull(info.getRegistrationInfo());
- assertEquals(RegistrationBehavior.REGISTRATION_HANDLE, info.getRegistrationContext().getRegistrationHandle());
-
- assertTrue(info.refresh(true));
- assertEquals(1, regBehavior.getCallCount());
- }
-
- private static class TestPortletManagementBehavior extends PortletManagementBehavior
- {
- public PortletDescriptionResponse getPortletDescription(GetPortletDescription getPortletDescription)
- throws AccessDeniedFault, InvalidHandleFault, InvalidUserCategoryFault, InconsistentParametersFault,
- MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
- {
- incrementCallCount();
- return WSRPTypeFactory.createPortletDescriptionResponse(createPortletDescription("test2", null));
- }
- }
-}
Deleted: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java 2007-05-11 00:46:42 UTC (rev 7242)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java 2007-05-11 04:05:30 UTC (rev 7243)
@@ -1,221 +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.test.wsrp.other;
-
-import junit.framework.TestCase;
-import org.apache.commons.httpclient.Cookie;
-import org.jboss.portal.wsrp.WSRPConstants;
-import org.jboss.portal.wsrp.WSRPTypeFactory;
-import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com?subject=org.jboss.portal.test.wsrp.other.ProducerSessionInformationTestCase">Chris
- * Laprun</a>
- * @version $Revision$
- * @since 2.4
- */
-public class ProducerSessionInformationTestCase extends TestCase
-{
- ProducerSessionInformation info;
-
- protected void setUp() throws Exception
- {
- info = new ProducerSessionInformation();
- }
-
- public void testUserCookie() throws Exception
- {
- assertNull(info.getUserCookie());
-
- Cookie[] cookies = new Cookie[]{createCookie("name", "value", 1)};
- info.setUserCookie(cookies);
-
- assertEquals("name=value", info.getUserCookie());
-
- // wait for cookie expiration
- Thread.sleep(1000);
- assertNull(info.getUserCookie()); // we shouldn't have a cookie now
-
- cookies = new Cookie[]{createCookie("name1", "value1", 1), createCookie("name2", "value2", 3)};
- info.setUserCookie(cookies);
- assertEquals("name1=value1;name2=value2", info.getUserCookie());
-
- Thread.sleep(1000);
- assertEquals("name2=value2", info.getUserCookie());
-
- try
- {
- info.setUserCookie(null);
- fail("Should have thrown an IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- //expected
- }
- }
-
- public void testGroupCookies() throws Exception
- {
- String groupId = "groupId";
-
- try
- {
- info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name1", "value1", 1), createCookie("name2", "value2", -1)});
- fail("Cannot add group cookie if not perGroup");
- }
- catch (IllegalStateException e)
- {
- //expected
- }
-
- info.setPerGroupCookies(true);
- info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name1", "value1", 1),
- createCookie("name2", "value2", WSRPConstants.SESSION_NEVER_EXPIRES)});
-
- assertEquals("name1=value1;name2=value2", info.getGroupCookieFor(groupId));
-
- Thread.sleep(1000);
- assertEquals("name2=value2", info.getGroupCookieFor(groupId));
-
- info.clearGroupCookies();
- assertNull(info.getGroupCookieFor(groupId));
- }
-
- public void testSessionForPortlet() throws Exception
- {
- String handle = "handle";
- String handle2 = "handle2";
- String sid = "id";
- String sid2 = "id2";
-
- assertNull(info.getSessionIdForPortlet(handle));
- assertEquals(0, info.getNumberOfSessions());
-
- addSession(handle, sid, 1);
- addSession(handle2, sid2, 3);
-
- assertNull(info.getSessionIdForPortlet("unknown"));
-
- assertEquals(sid, info.getSessionIdForPortlet(handle));
- assertEquals(2, info.getNumberOfSessions());
-
- Thread.sleep(1000);
- assertNull(info.getSessionIdForPortlet(handle));
- assertEquals(sid2, info.getSessionIdForPortlet(handle2));
- assertEquals(1, info.getNumberOfSessions());
-
- info.removeSessionForPortlet(handle2);
- assertEquals(0, info.getNumberOfSessions());
- }
-
- public void testReplaceUserCookies() throws Exception
- {
- info.setUserCookie(new Cookie[]{createCookie("name", "value", 1)});
-
- info.replaceUserCookiesWith(null);
- assertEquals("name=value", info.getUserCookie());
-
- ProducerSessionInformation other = new ProducerSessionInformation();
-
- info.replaceUserCookiesWith(other);
- assertEquals("name=value", info.getUserCookie());
-
- other.setUserCookie(new Cookie[]{createCookie("name2", "value2", 1)});
- info.replaceUserCookiesWith(other);
- assertEquals("name2=value2", info.getUserCookie());
-
- Thread.sleep(1000);
- info.replaceUserCookiesWith(other);
- assertNull(info.getUserCookie());
- }
-
- public void testReleaseSessions()
- {
- addSession("handle", "id", 1);
- addSession("handle2", "id2", 1);
- addSession("handle3", "id3", 1);
-
- assertEquals(3, info.getNumberOfSessions());
-
- info.removeSessions();
-
- assertEquals(0, info.getNumberOfSessions());
-
- addSession("handle", "id", 1);
- addSession("handle2", "id2", 2);
-
- info.removeSession("id2");
-
- assertEquals(1, info.getNumberOfSessions());
- assertNull(info.getSessionIdForPortlet("handle2"));
- assertEquals("id", info.getSessionIdForPortlet("handle"));
-
- info.removeSessionForPortlet("handle");
-
- assertEquals(0, info.getNumberOfSessions());
- assertNull(info.getSessionIdForPortlet("handle"));
-
- try
- {
- info.removeSessionForPortlet("handle");
- fail("Session for portlet 'handle' should have already been released!");
- }
- catch (IllegalArgumentException expected)
- {
- // expected
- }
- }
-
- public void testSetParentSessionId()
- {
- assertNull(info.getParentSessionId());
-
- String id = "session";
- info.setParentSessionId(id);
- assertEquals(id, info.getParentSessionId());
-
- // trying to set the same id should work
- info.setParentSessionId(id);
-
- try
- {
- info.setParentSessionId("other");
- fail("Cannot modify session id once it has been set");
- }
- catch (IllegalStateException expected)
- {
- // expected
- }
- }
-
- private Cookie createCookie(String name, String value, int secondsBeforeExpiration)
- {
- return new Cookie("domain", name, value, "path", secondsBeforeExpiration, false);
- }
-
- private void addSession(String handle, String sid, int expires)
- {
- info.addSessionForPortlet(handle, WSRPTypeFactory.createSessionContext(sid, expires));
- }
-}
Deleted: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java 2007-05-11 00:46:42 UTC (rev 7242)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java 2007-05-11 04:05:30 UTC (rev 7243)
@@ -1,285 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2007, 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.wsrp.other;
-
-import junit.framework.TestCase;
-import org.jboss.portal.wsrp.WSRPConstants;
-import org.jboss.portal.wsrp.WSRPTypeFactory;
-import org.jboss.portal.wsrp.consumer.RefreshResult;
-import org.jboss.portal.wsrp.consumer.RegistrationInfo;
-import org.jboss.portal.wsrp.consumer.RegistrationProperty;
-import org.jboss.portal.wsrp.core.PropertyDescription;
-import org.jboss.portal.wsrp.core.RegistrationContext;
-import org.jboss.portal.wsrp.core.ServiceDescription;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class RegistrationInfoTestCase extends TestCase
-{
- private RegistrationInfo info;
- private static final String producerId = "test";
-
- protected void setUp() throws Exception
- {
- info = new RegistrationInfo();
- }
-
- public void testInitialState()
- {
- assertTrue(info.getRegistrationProperties().isEmpty());
- assertTrue(info.getRegistrationPropertyNames().isEmpty());
- assertNull(info.getRegistrationContext());
- assertNotNull(info.getRegistrationData());
- assertNull(info.getRegistrationHandle());
- assertNull(info.getRegistrationState());
-
- // before refresh, refresh is needed...
- assertTrue(info.isRefreshNeeded());
- // we don't know if the the local info is consistent with the producer expectations...
- assertNull(info.isConsistentWithProducerExpectations());
- // we don't know if the registration is required...
- assertNull(info.isRegistrationRequired());
- // and we don't know if the registration is valid
- assertNull(info.isRegistrationValid());
-
- try
- {
- info.isRegistrationDeterminedNotRequired();
- fail("refresh hasn't been called, isRegistrationDeterminedNotRequired should fail");
- }
- catch (IllegalStateException expected)
- {
- }
-
- try
- {
- info.isRegistrationDeterminedRequired();
- fail("refresh hasn't been called, isRegistrationDeterminedRequired should fail");
- }
- catch (IllegalStateException expected)
- {
- }
- }
-
- public void testSetGetRegistrationProperty()
- {
- String key = "foo";
- info.setRegistrationPropertyValue(key, "bar");
- assertNull(info.isConsistentWithProducerExpectations());
- Map properties = info.getRegistrationProperties();
- assertFalse(properties.isEmpty());
- Set names = info.getRegistrationPropertyNames();
- assertFalse(names.isEmpty());
- assertTrue(properties.containsKey(key));
- assertTrue(names.contains(key));
- assertNotNull(properties.get(key));
- assertEquals(properties.get(key), info.getRegistrationProperty(key));
- assertEquals("bar", info.getRegistrationProperty(key).getValue());
- }
-
- public void testRefreshNoRegistration()
- {
- // no registration expected
- ServiceDescription sd = createServiceDescription(false, 0);
- RefreshResult result = info.refresh(sd, producerId, true, false);
- assertNotNull(result);
- assertFalse(result.hasIssues());
- assertTrue(info.isConsistentWithProducerExpectations().booleanValue());
- assertFalse(info.isRegistrationRequired().booleanValue());
- assertTrue(info.isRegistrationDeterminedNotRequired());
- assertFalse(info.isRegistrationDeterminedRequired());
- assertTrue(info.isRegistrationValid().booleanValue());
-
- result = info.refresh(sd, producerId, false, false);
- assertNotNull(result);
- assertFalse(result.hasIssues());
- assertTrue(info.isConsistentWithProducerExpectations().booleanValue());
- assertFalse(info.isRegistrationRequired().booleanValue());
- assertTrue(info.isRegistrationDeterminedNotRequired());
- assertFalse(info.isRegistrationDeterminedRequired());
- assertTrue(info.isRegistrationValid().booleanValue());
- }
-
- public void testRefreshRegistrationDefaultRegistrationNoLocalInfo()
- {
- // before refresh registration status is undetermined
- assertNull(info.isRegistrationRequired());
- assertNull(info.isRegistrationValid());
-
- RegistrationInfo.RegistrationRefreshResult result = info.refresh(
- createServiceDescription(true, 0), producerId, true, false);
- assertNotNull(result);
- assertFalse(result.hasIssues());
- assertTrue(info.isRegistrationRequired().booleanValue());
- assertTrue(info.isRegistrationDeterminedRequired());
- assertFalse(info.isRegistrationDeterminedNotRequired());
- assertFalse(info.isRegistrationValid().booleanValue());
- }
-
- public void testRefreshRegistrationDefaultRegistrationExtraLocalInfo()
- {
- // set a registration property
- info.setRegistrationPropertyValue("foo", "bar");
-
- RegistrationInfo.RegistrationRefreshResult result = info.refresh(
- createServiceDescription(true, 0), producerId, false, false);
- assertNotNull(result);
- assertTrue(result.hasIssues());
- String status = result.getStatus();
- assertNotNull(status);
- assertTrue(status.indexOf("foo") != -1);
- assertEquals(1, info.getRegistrationProperties().size());
- assertEquals(1, result.getRegistrationProperties().size());
-
- Map regProps = result.getRegistrationProperties();
- assertNotNull(regProps);
-
- RegistrationProperty prop = (RegistrationProperty)regProps.get("foo");
- assertNotNull(prop);
- assertEquals("bar", prop.getValue());
- assertTrue(prop.isInvalid());
- assertEquals(RegistrationProperty.INEXISTENT_STATUS, prop.getStatus());
- }
-
- public void testRefreshRegistrationRegistrationNoLocalInfo()
- {
- // producer requests 2 registration properties
- ServiceDescription sd = createServiceDescription(true, 2);
-
- RegistrationInfo.RegistrationRefreshResult result = info.refresh(sd, producerId, false, false);
- assertNotNull(result);
- assertTrue(result.hasIssues());
- String status = result.getStatus();
- assertNotNull(status);
- assertTrue(status.indexOf("prop0") != -1 && status.indexOf("prop1") != -1);
- assertEquals(0, info.getRegistrationProperties().size());
- assertEquals(2, result.getRegistrationProperties().size());
-
- Map regProps = result.getRegistrationProperties();
- assertNotNull(regProps);
-
- RegistrationProperty prop = (RegistrationProperty)regProps.get("prop0");
- assertNotNull(prop);
- assertTrue(prop.isInvalid());
- assertEquals(RegistrationProperty.MISSING_STATUS, prop.getStatus());
- }
-
- public void testRefreshRegistrationRegistrationMergeWithLocalInfo()
- {
- info.setRegistrationPropertyValue("foo", "bar");
-
- RegistrationInfo.RegistrationRefreshResult result = info.refresh(createServiceDescription(true, 2),
- producerId, true, false);
- assertNotNull(result);
- assertTrue(result.hasIssues());
-
- RegistrationProperty prop = info.getRegistrationProperty("prop0");
- assertNotNull(prop);
- assertNull(prop.getValue());
- assertTrue(prop.isInvalid());
- assertEquals(RegistrationProperty.MISSING_VALUE_STATUS, prop.getStatus());
-
- prop = info.getRegistrationProperty("prop1");
- assertNotNull(prop);
- assertNull(prop.getValue());
- assertTrue(prop.isInvalid());
- assertEquals(RegistrationProperty.MISSING_VALUE_STATUS, prop.getStatus());
- assertEquals(2, info.getRegistrationProperties().size());
- assertEquals(2, result.getRegistrationProperties().size());
-
- assertNull(info.getRegistrationProperty("foo"));
- }
-
- public void testForceRefreshRegistration()
- {
- //
- RefreshResult result = info.refresh(createServiceDescription(true, 0), producerId, false, false);
- assertNotNull(result);
- assertFalse(result.hasIssues());
- assertFalse(info.isRegistrationValid().booleanValue());
-
- // Modifying a property renders the info dirty and hence should be refreshed
- info.setRegistrationPropertyValue("foo", "bar");
- result = info.refresh(createServiceDescription(true, 0), producerId, false, false);
- assertTrue(result.hasIssues());
- assertFalse(info.isRegistrationValid().booleanValue());
-
- info.removeRegistrationProperty("foo");
- result = info.refresh(createServiceDescription(true, 0), producerId, false, false);
- assertFalse(result.hasIssues());
- assertFalse(info.isRegistrationValid().booleanValue());
-
- // producer has changed but we're not forcing refresh so registration should still be invalid
- result = info.refresh(createServiceDescription(false, 0), producerId, false, false);
- assertFalse(result.hasIssues());
- assertFalse(info.isRegistrationValid().booleanValue());
-
- // force refresh, registration should now be valid
- result = info.refresh(createServiceDescription(false, 0), producerId, false, true);
- assertFalse(result.hasIssues());
- assertTrue(info.isRegistrationValid().booleanValue());
- }
-
- public void testSetRegistrationContext()
- {
- assertNull(info.isConsistentWithProducerExpectations());
- assertNull(info.getRegistrationHandle());
-
- String registrationHandle = "registrationHandle";
- info.setRegistrationContext(WSRPTypeFactory.createRegistrationContext(registrationHandle));
- RegistrationContext registrationContext = info.getRegistrationContext();
- assertNotNull(registrationContext);
- assertEquals(registrationHandle, registrationContext.getRegistrationHandle());
- assertNull(registrationContext.getRegistrationState());
- assertTrue(info.isConsistentWithProducerExpectations().booleanValue());
- assertTrue(info.isRegistrationValid().booleanValue());
- assertFalse(info.isRefreshNeeded());
- assertTrue(info.isRegistrationRequired().booleanValue());
- assertTrue(info.isRegistrationDeterminedRequired());
- assertFalse(info.isRegistrationDeterminedNotRequired());
- }
-
- private ServiceDescription createServiceDescription(boolean requiresRegistration, int numberOfProperties)
- {
- ServiceDescription sd = WSRPTypeFactory.createServiceDescription(requiresRegistration);
-
- if (requiresRegistration)
- {
- PropertyDescription[] descriptions = new PropertyDescription[numberOfProperties];
- for (int i = 0; i < numberOfProperties; i++)
- {
- descriptions[i] = WSRPTypeFactory.createPropertyDescription("prop" + i, WSRPConstants.XSD_STRING);
- }
- sd.setRegistrationPropertyDescription(WSRPTypeFactory.createModelDescription(descriptions));
- }
-
- return sd;
- }
-}
18 years, 12 months
JBoss Portal SVN: r7242 - trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-05-10 20:46:42 -0400 (Thu, 10 May 2007)
New Revision: 7242
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java
Log:
- Properly handle remotable status.
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java 2007-05-11 00:35:37 UTC (rev 7241)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java 2007-05-11 00:46:42 UTC (rev 7242)
@@ -62,7 +62,12 @@
this.security = new ContainerSecurityInfo(portletMD);
this.cache = new ContainerCacheInfo(portletMD, jbossPortletMD);
this.session = new ContainerSessionInfo(jbossPortletMD);
- this.remotable = (jbossPortletMD != null && jbossPortletMD.getRemotable() != null) ? jbossPortletMD.getRemotable() : Boolean.FALSE;
+ // if there is no JBoss specific metadata, remotable status should be indetermined (i.e., null)
+ if (jbossPortletMD != null)
+ {
+ this.remotable = jbossPortletMD.getRemotable();
+ }
+
}
public CapabilitiesInfo getCapabilities()
18 years, 12 months
JBoss Portal SVN: r7241 - trunk/core-cms.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-05-10 20:35:37 -0400 (Thu, 10 May 2007)
New Revision: 7241
Modified:
trunk/core-cms/.classpath
Log:
Eclipse update
Modified: trunk/core-cms/.classpath
===================================================================
--- trunk/core-cms/.classpath 2007-05-10 23:27:23 UTC (rev 7240)
+++ trunk/core-cms/.classpath 2007-05-11 00:35:37 UTC (rev 7241)
@@ -23,5 +23,6 @@
<classpathentry kind="lib" path="/thirdparty/jbpm/jaronly/lib/jbpm.jar"/>
<classpathentry kind="lib" path="/thirdparty/apache-myfaces/lib/myfaces-api.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-admin"/>
+ <classpathentry kind="lib" path="/thirdparty/hibernate/lib/hibernate3.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
18 years, 12 months
JBoss Portal SVN: r7240 - trunk/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-05-10 19:27:23 -0400 (Thu, 10 May 2007)
New Revision: 7240
Modified:
trunk/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeploymentFactory.java
Log:
logging with wrong field
Modified: trunk/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeploymentFactory.java
===================================================================
--- trunk/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeploymentFactory.java 2007-05-10 15:28:52 UTC (rev 7239)
+++ trunk/portlet-server/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeploymentFactory.java 2007-05-10 23:27:23 UTC (rev 7240)
@@ -209,7 +209,7 @@
}
catch (Exception e)
{
- log.error("Cannot create portlet PortletAPIFactory=" + portletAPIFactoryClassName + " will use default one instead", e);
+ log.error("Cannot create portlet PortletInfoFactory=" + portletInfoFactoryClassName + " will use default one instead", e);
}
//
18 years, 12 months
JBoss Portal SVN: r7239 - in trunk: core/src/main/org/jboss/portal/core/impl/model/instance and 6 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-05-10 11:28:52 -0400 (Thu, 10 May 2007)
New Revision: 7239
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerContext.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/JBossInstanceContainerContext.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContainerContext.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceCustomization.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceDefinition.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentRoleSecurityBinding.java
Removed:
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceSecurityBinding.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java
Modified:
trunk/core/build.xml
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceCustomization.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceDefinition.java
trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java
trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-core-sar/conf/hibernate/instance/domain.hbm.xml
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/persistent-jboss-beans.xml
trunk/security/src/main/org/jboss/portal/security/RoleSecurityBinding.java
Log:
- better split between instance container logic and persistence
- set persistent classes as package protected so it cannot leak out of the package
Modified: trunk/core/build.xml
===================================================================
--- trunk/core/build.xml 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/build.xml 2007-05-10 15:28:52 UTC (rev 7239)
@@ -593,7 +593,7 @@
<parameter name="CacheNaturalId" value="true"/>
<parameter name="Config" value="persistent-jboss-beans.xml"/>
</zest>
-<!--
+
<zest todir="${test.reports}" name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
outfile="TEST-PersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
<parameter name="PersistLocally" value="true"/>
@@ -601,7 +601,6 @@
<parameter name="CacheNaturalId" value="true"/>
<parameter name="Config" value="transient-jboss-beans.xml"/>
</zest>
--->
<zest todir="${test.reports}" name="org.jboss.portal.test.core.state.ProducerTestCase"
outfile="TEST-ProducerTestCase-WithoutRegistration">
<parameter name="UseRegistration" value="false"/>
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -102,13 +102,6 @@
return portletContext;
}
- public final void setPortletContext(PortletContext portletContext)
- {
- this.portletRef = portletContext.getId();
- this.state = portletContext.getState();
- this.portletContext = portletContext;
- }
-
public final boolean isModifiable()
{
return isMutable();
@@ -120,18 +113,21 @@
protected abstract Logger getLogger();
- protected abstract String getInstanceId();
-
protected abstract AccessMode getAccessMode();
protected abstract void cloned(PortletContext portletContext);
- protected abstract void modified(PortletContext portletContext);
-
protected abstract AbstractInstanceDefinition getOwner();
- protected abstract ContainerContext getContainerContext();
+ protected abstract InstanceContainerContext getContainerContext();
+ protected abstract String getInstanceId();
+
+ protected final void modified(PortletContext portletContext)
+ {
+ getContainerContext().updateInstance(this, portletContext);
+ }
+
public final InstanceDefinition getDefinition()
{
return getOwner();
@@ -146,7 +142,7 @@
public final InstanceContainer getContainer()
{
- return getContainerContext().getContainer();
+ return ((JBossInstanceContainerContext)getContainerContext()).getContainer();
}
public final void setProperties(PropertyChange[] changes) throws PortletInvokerException
@@ -178,11 +174,7 @@
}
// Update the state
- setPortletContext(portletContext);
- setMutable(true);
-
- //
- getContainerContext().updateInstance(this);
+ getContainerContext().updateInstance(this, portletContext, true);
}
//
@@ -195,10 +187,9 @@
{
getLogger().debug("Received updated portlet context " + portletContext + " for instance " + /*instanceId +*/ " after setting properties");
}
- setPortletContext(portletContext);
- //
- getContainerContext().updateInstance(this);
+ // Update state
+ getContainerContext().updateInstance(this, portletContext);
}
public final PropertyMap getProperties() throws PortletInvokerException
@@ -218,7 +209,6 @@
public final PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
{
boolean debug = getLogger().isDebugEnabled();
- InstanceContainerImpl container = getContainerContext().getContainer();
//
AbstractInstance instance = this;
@@ -237,6 +227,7 @@
invocation.setInstanceContext(instanceContext);
// Perform invocation
+ InstanceContainerImpl container = (InstanceContainerImpl)getContainer();
PortletInvocationResponse response = container.invoke(invocation);
// Create user instance if a clone operation occured
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceCustomization.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceCustomization.java 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceCustomization.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -44,12 +44,12 @@
return isPersistent() ? AccessMode.READ_WRITE : AccessMode.CLONE_BEFORE_WRITE;
}
- protected boolean isMutable()
+ protected final boolean isMutable()
{
return false;
}
- protected void setMutable(boolean modifiable)
+ protected final void setMutable(boolean modifiable)
{
throw new IllegalStateException("Modifiable field is immutable");
}
@@ -61,22 +61,16 @@
protected final void cloned(PortletContext portletContext)
{
- setPortletContext(portletContext);
-
- //
+ // Make it persistent
getContainerContext().createInstanceCustomizaton(this);
- }
- protected final void modified(PortletContext portletContext)
- {
- setPortletContext(portletContext);
-
- //
- getContainerContext().updateInstance(this);
+ // Update state
+ getContainerContext().updateInstance(this, portletContext);
}
protected final String getInstanceId()
{
return getOwner().getInstanceId();
}
+
}
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceDefinition.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceDefinition.java 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstanceDefinition.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -27,8 +27,8 @@
import org.jboss.portal.portlet.PortletContext;
import org.apache.log4j.Logger;
-import java.util.Map;
import java.util.Collection;
+import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -40,9 +40,13 @@
/** The logger. */
protected static final Logger log = Logger.getLogger(AbstractInstanceDefinition.class);
+ public abstract Collection getCustomizations();
+
+ public abstract Set getSecurityBindings();
+
// AbstractInstance implementation **********************************************************************************
- protected AccessMode getAccessMode()
+ protected final AccessMode getAccessMode()
{
/*
if (Mode.EDIT_DEFAULTS.equals(ctxabc.getMode()))
@@ -56,27 +60,18 @@
return AccessMode.READ_ONLY;
}
- protected Logger getLogger()
+ protected final Logger getLogger()
{
return log;
}
- protected void cloned(PortletContext portletContext)
+ protected final void cloned(PortletContext portletContext)
{
throw new IllegalStateException();
}
- protected void modified(PortletContext portletContext)
+ protected final AbstractInstanceDefinition getOwner()
{
- getContainerContext().updateInstance(this);
- }
-
- protected AbstractInstanceDefinition getOwner()
- {
return this;
}
-
- protected abstract Collection getCustomizations();
-
- public abstract Map getSecurityBindings();
}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -1,67 +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.core.impl.model.instance;
-
-import org.jboss.portal.core.model.instance.DuplicateInstanceException;
-import org.jboss.portal.portlet.PortletContext;
-
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class ContainerContext
-{
-
- /** . */
- private InstanceContainerImpl container;
-
- public InstanceContainerImpl getContainer()
- {
- return container;
- }
-
- public void setContainer(InstanceContainerImpl container)
- {
- this.container = container;
- }
-
- public abstract Collection getInstanceDefinitions();
-
- public abstract AbstractInstanceDefinition getInstanceDefinition(String id);
-
- public abstract AbstractInstanceDefinition newInstanceDefinition(String id, String portletRef);
-
- public abstract void createInstanceDefinition(AbstractInstanceDefinition instanceDef) throws DuplicateInstanceException;
-
- public abstract void destroyInstanceDefinition(AbstractInstanceDefinition instanceDef);
-
- public abstract AbstractInstanceCustomization getCustomization(AbstractInstanceDefinition instanceDef, String customizationId);
-
- public abstract AbstractInstanceCustomization newInstanceCustomization(AbstractInstanceDefinition def, String id, PortletContext portletContext);
-
- public abstract void createInstanceCustomizaton(AbstractInstanceCustomization customization);
-
- public abstract void updateInstance(AbstractInstance instanceDef);
-}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerContext.java (from rev 7234, trunk/core/src/main/org/jboss/portal/core/impl/model/instance/ContainerContext.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerContext.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerContext.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * 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.core.impl.model.instance;
+
+import org.jboss.portal.core.model.instance.DuplicateInstanceException;
+import org.jboss.portal.portlet.PortletContext;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public interface InstanceContainerContext
+{
+
+ Collection getInstanceDefinitions();
+
+ AbstractInstanceDefinition getInstanceDefinition(String id);
+
+ AbstractInstanceDefinition newInstanceDefinition(String id, String portletRef);
+
+ void createInstanceDefinition(AbstractInstanceDefinition instanceDef) throws DuplicateInstanceException;
+
+ void destroyInstanceDefinition(AbstractInstanceDefinition instanceDef);
+
+ AbstractInstanceCustomization getCustomization(AbstractInstanceDefinition instanceDef, String customizationId);
+
+ AbstractInstanceCustomization newInstanceCustomization(AbstractInstanceDefinition def, String id, PortletContext portletContext);
+
+ void createInstanceCustomizaton(AbstractInstanceCustomization customization);
+
+ void updateInstance(AbstractInstance instance, PortletContext portletContext, boolean mutable);
+
+ void updateInstance(AbstractInstance instance, PortletContext portletContext);
+
+ void updateInstanceDefinition(AbstractInstanceDefinition def, Set securityBindings);
+
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerContext.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerImpl.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -32,7 +32,6 @@
import org.jboss.portal.core.model.instance.InstancePermission;
import org.jboss.portal.core.model.instance.NoSuchInstanceException;
import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.core.impl.model.instance.persistent.InstanceCustomizationImpl;
import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.PortletInvoker;
@@ -55,7 +54,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -109,7 +107,7 @@
protected boolean cloneOnCreate;
/** The container context. */
- protected ContainerContext containerContext;
+ protected JBossInstanceContainerContext containerContext;
public InterceptorStackFactory getStackFactory()
{
@@ -205,12 +203,12 @@
this.cloneOnCreate = cloneOnCreate;
}
- public ContainerContext getContainerContext()
+ public JBossInstanceContainerContext getContainerContext()
{
return containerContext;
}
- public void setContainerContext(ContainerContext containerContext)
+ public void setContainerContext(JBossInstanceContainerContext containerContext)
{
this.containerContext = containerContext;
}
@@ -275,11 +273,7 @@
}
//
- instance.setPortletContext(portletContext);
- instance.setMutable(true);
-
- //
- containerContext.updateInstance(instance);
+ containerContext.updateInstance(instance, portletContext, true);
}
//
@@ -312,7 +306,7 @@
List toDestroy = new ArrayList(customizations.size());
for (Iterator i = customizations.iterator(); i.hasNext();)
{
- InstanceCustomizationImpl customization = (InstanceCustomizationImpl)i.next();
+ AbstractInstanceCustomization customization = (AbstractInstanceCustomization)i.next();
// Get the user portlet context
PortletContext customizationPortletContext = customization.getPortletContext();
@@ -443,20 +437,16 @@
public Set getSecurityBindings(String uri)
{
- Set constraints = null;
AbstractInstanceDefinition instance = containerContext.getInstanceDefinition(uri);
+
+ //
if (instance != null)
{
- constraints = new HashSet();
- Collection onscs = instance.getSecurityBindings().values();
- for (Iterator i = onscs.iterator(); i.hasNext();)
- {
- InstanceSecurityBinding isc = (InstanceSecurityBinding)i.next();
- RoleSecurityBinding sc = new RoleSecurityBinding(isc.getActions(), isc.getRole());
- constraints.add(sc);
- }
+ return instance.getSecurityBindings();
}
- return constraints;
+
+ //
+ return null;
}
public void setSecurityBindings(String uri, Set securityBindings) throws SecurityConfigurationException
@@ -470,10 +460,7 @@
}
//
- instanceDef.getSecurityBindings().clear();
-
- //
- HashMap map = new HashMap();
+ Set tmp = new HashSet(securityBindings.size());
for (Iterator i = securityBindings.iterator(); i.hasNext();)
{
RoleSecurityBinding sc = (RoleSecurityBinding)i.next();
@@ -481,15 +468,12 @@
// Optimize
if (sc.getActions().size() > 0)
{
- InstanceSecurityBinding isc = new InstanceSecurityBinding(sc.getActions(), sc.getRoleName());
- isc.setInstance(instanceDef);
- map.put(sc.getRoleName(), isc);
+ tmp.add(sc);
}
}
- instanceDef.getSecurityBindings().putAll(map);
//
- containerContext.updateInstance(instanceDef);
+ containerContext.updateInstanceDefinition(instanceDef, tmp);
}
public void removeSecurityBindings(String uri) throws SecurityConfigurationException
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceSecurityBinding.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceSecurityBinding.java 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceSecurityBinding.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -1,256 +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.core.impl.model.instance;
-
-import org.jboss.portal.core.model.instance.Instance;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-/**
- * Security Constraint for an instance
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public final class InstanceSecurityBinding implements Serializable
-{
-
- /** The serialVersionUID */
- private static final long serialVersionUID = -2832148715381794267L;
-
- /** The primary key. */
- private Long key;
-
- /** The role of this contraint. */
- private String role;
-
- /** The set of actions of this constraint. */
- private Set actions;
-
- /** The cached toString value. */
- private transient String toString;
-
- /** The cached hash code. */
- private transient int hashCode;
-
- /** The cached actions as a string. */
- private transient String actionsAsString;
-
- private Instance instance;
-
- public InstanceSecurityBinding()
- {
- super();
- }
-
- /**
- * Create a new constraint with the provided actions for the specified role.
- *
- * @param actions a comma separated list of allowed actions
- * @param role the role name
- */
- public InstanceSecurityBinding(String actions, String role)
- {
- if (role == null)
- {
- throw new IllegalArgumentException("Role cannot be null");
- }
- if (actions == null)
- {
- throw new IllegalArgumentException("Actions cannot be null");
- }
-
- //
- StringTokenizer tokens = new StringTokenizer(actions, ",");
- Set set = new HashSet();
- while (tokens.hasMoreTokens())
- {
- set.add(tokens.nextToken().trim());
- }
-
- //
- this.role = role;
- this.actions = Collections.unmodifiableSet(set);
- }
-
- /**
- * Create a new constraint with the provided actions and the specified role.
- *
- * @param actions the set of actions
- * @param role the role name
- */
- public InstanceSecurityBinding(Set actions, String role)
- {
- if (role == null)
- {
- throw new IllegalArgumentException("Role cannot be null");
- }
- if (actions == null)
- {
- throw new IllegalArgumentException("Actions cannot be null");
- }
-
- //
- this.role = role;
- this.actions = Collections.unmodifiableSet(new HashSet(actions));
- }
-
- /** Copy constructor. */
- public InstanceSecurityBinding(InstanceSecurityBinding other)
- {
- if (other == null)
- {
- throw new IllegalArgumentException("The constraint to clone cannot be null");
- }
-
- //
- this.role = other.role;
- this.actions = other.actions;
- }
-
- /**
- * Return a <code>java.util.Set<String></code> of allowed actions.
- *
- * @return the action set
- */
- public Set getActions()
- {
- return actions;
- }
-
- /**
- * Return the role of this constraint
- *
- * @return the role
- */
- public String getRole()
- {
- return role;
- }
-
- /**
- * Return a comma separated list of actions.
- *
- * @return the action string representation
- */
- public String getActionsAsString()
- {
- if (actionsAsString == null)
- {
- StringBuffer tmp = new StringBuffer();
- for (Iterator i = actions.iterator(); i.hasNext();)
- {
- String action = (String)i.next();
- if (i.hasNext())
- {
- tmp.append(", ");
- }
- tmp.append(action);
- }
- actionsAsString = tmp.toString();
- }
- return actionsAsString;
- }
-
- /** @see Object#toString */
- public String toString()
- {
- if (toString == null)
- {
- StringBuffer tmp = new StringBuffer("SecurityConstraint: actions [");
- for (Iterator i = actions.iterator(); i.hasNext();)
- {
- String action = (String)i.next();
- if (i.hasNext())
- {
- tmp.append(", ");
- }
- tmp.append(action);
- }
- tmp.append("] role [").append(role).append("]");
- toString = tmp.toString();
- }
- return toString;
- }
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o instanceof InstanceSecurityBinding)
- {
- InstanceSecurityBinding that = (InstanceSecurityBinding)o;
- return actions.equals(that.actions) && role.equals(that.role);
- }
- return false;
- }
-
- public int hashCode()
- {
- if (hashCode == 0)
- {
- int hashCode;
- hashCode = actions.hashCode();
- hashCode = 29 * hashCode + role.hashCode();
- this.hashCode = hashCode;
- }
- return hashCode;
- }
-
- protected void setKey(Long k)
- {
- key = k;
- }
-
- protected Long getKey()
- {
- return key;
- }
-
- public void setActions(Set actions)
- {
- this.actions = actions;
- }
-
- public void setRole(String role)
- {
- this.role = role;
- }
-
- public Instance getInstance()
- {
- return instance;
- }
-
- public void setInstance(Instance instance)
- {
- this.instance = instance;
- }
-}
Added: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/JBossInstanceContainerContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/JBossInstanceContainerContext.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/JBossInstanceContainerContext.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * 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.core.impl.model.instance;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface JBossInstanceContainerContext extends InstanceContainerContext
+{
+
+ InstanceContainerImpl getContainer();
+
+ void setContainer(InstanceContainerImpl container);
+
+}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -1,130 +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.core.impl.model.instance.persistent;
-
-import org.jboss.portal.core.impl.model.instance.AbstractInstanceCustomization;
-import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
-import org.jboss.portal.core.impl.model.instance.ContainerContext;
-import org.jboss.portal.portlet.PortletContext;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class InstanceCustomizationImpl extends AbstractInstanceCustomization
-{
-
- // Persistent fields
-
- protected Long key;
- protected InstanceDefinitionImpl relatedDefinition;
- protected String customizationId;
-
- // Runtime fields
-
- protected InstanceDefinitionImpl owner;
- protected boolean persistent;
-
- /** Used to build transient instances. */
- public InstanceCustomizationImpl(InstanceDefinitionImpl owner, String customizationId, PortletContext portletContext)
- {
- if (owner == null)
- {
- throw new IllegalArgumentException();
- }
- if (customizationId == null)
- {
- throw new IllegalArgumentException();
- }
- if (portletContext == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- this.owner = owner;
- this.persistent = false;
-
- //
- setCustomizationId(customizationId);
- setPortletContext(portletContext);
- }
-
- /** Used by hibernate. */
- public InstanceCustomizationImpl()
- {
- this.owner = null;
- this.persistent = true;
- }
-
- public Long getKey()
- {
- return key;
- }
-
- public void setKey(Long key)
- {
- this.key = key;
- }
-
- public String getId()
- {
- return customizationId;
- }
-
- public String getCustomizationId()
- {
- return customizationId;
- }
-
- public void setCustomizationId(String customizationId)
- {
- this.customizationId = customizationId;
- }
-
- public AbstractInstanceDefinition getOwner()
- {
- return owner;
- }
-
- public InstanceDefinitionImpl getRelatedDefinition()
- {
- return relatedDefinition;
- }
-
- public void setRelatedDefinition(InstanceDefinitionImpl relatedDefinition)
- {
- this.relatedDefinition = relatedDefinition;
- this.owner = relatedDefinition;
- }
-
- protected boolean isPersistent()
- {
- return persistent;
- }
-
- protected ContainerContext getContainerContext()
- {
- return owner.containerContext;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -1,150 +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.core.impl.model.instance.persistent;
-
-import org.jboss.portal.core.impl.model.instance.ContainerContext;
-import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
-import org.jboss.portal.jems.hibernate.ContextObject;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class InstanceDefinitionImpl extends AbstractInstanceDefinition implements ContextObject
-{
-
- // Persistent fields
-
- protected Long key;
- protected String instanceId;
- protected boolean mutable;
- protected Map securityBindings;
- protected Map customizationMap;
-
- // Runtime fields
-
- /** . */
- protected ContainerContext containerContext;
-
- public InstanceDefinitionImpl()
- {
- this.mutable = false;
- this.portletRef = null;
- this.instanceId = null;
- this.securityBindings = null;
- this.customizationMap = null;
- this.state = null;
- }
-
- public InstanceDefinitionImpl(String id, String portletRef)
- {
- this.mutable = false;
- this.portletRef = portletRef;
- this.instanceId = id;
- this.securityBindings = new HashMap();
- this.customizationMap = new HashMap();
- this.state = null;
- }
-
- // Hibernate ********************************************************************************************************
-
- public Long getKey()
- {
- return key;
- }
-
- public void setKey(Long key)
- {
- this.key = key;
- }
-
- public String getInstanceId()
- {
- return instanceId;
- }
-
- public void setInstanceId(String instanceId)
- {
- this.instanceId = instanceId;
- }
-
- public Map getSecurityBindings()
- {
- return securityBindings;
- }
-
- public void setSecurityBindings(Map securityBindings)
- {
- this.securityBindings = securityBindings;
- }
-
- public Map getCustomizationMap()
- {
- return customizationMap;
- }
-
- public void setCustomizationMap(Map customizationMap)
- {
- this.customizationMap = customizationMap;
- }
-
- public boolean isMutable()
- {
- return mutable;
- }
-
- public void setMutable(boolean mutable)
- {
- this.mutable = mutable;
- }
-
- // Instance implementation ******************************************************************************************
-
- public String getId()
- {
- return instanceId;
- }
-
- // AbstractInstanceDefinition implementation ************************************************************************
-
- protected Collection getCustomizations()
- {
- return customizationMap.values();
- }
-
- // ContextObject implementation *************************************************************************************
-
- public void setContext(Object context)
- {
- this.containerContext = (ContainerContext)context;
- }
-
- protected ContainerContext getContainerContext()
- {
- return containerContext;
- }
-}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContainerContext.java (from rev 7234, trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContainerContext.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContainerContext.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -0,0 +1,346 @@
+/******************************************************************************
+ * 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.core.impl.model.instance.persistent;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.exception.ConstraintViolationException;
+import org.jboss.portal.jems.hibernate.ObjectContextualizer;
+import org.jboss.portal.core.model.instance.DuplicateInstanceException;
+import org.jboss.portal.core.impl.model.instance.AbstractInstance;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceCustomization;
+import org.jboss.portal.core.impl.model.instance.InstanceContainerImpl;
+import org.jboss.portal.core.impl.model.instance.JBossInstanceContainerContext;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.security.RoleSecurityBinding;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+
+import javax.naming.InitialContext;
+import java.util.Iterator;
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PersistentInstanceContainerContext implements JBossInstanceContainerContext
+{
+
+ /** . */
+ private static final String BY_INSTANCE_ID_QUERY = "from " + Tools.getShortNameOf(PersistentInstanceDefinition.class) + " where instanceId=:instanceId";
+
+ /** . */
+ private static final String FROM_INSTANCE_DEFINITION_IMPL = "from " + Tools.getShortNameOf(PersistentInstanceDefinition.class);
+
+ /** . */
+ protected SessionFactory sessionFactory;
+
+ /** . */
+ protected String sessionFactoryJNDIName;
+
+ /** . */
+ protected ObjectContextualizer contextualizer;
+
+ /** . */
+ protected ConcurrentReaderHashMap cache;
+
+ /** . */
+ protected boolean cacheNaturalId;
+
+ /** . */
+ private InstanceContainerImpl container;
+
+ public PersistentInstanceContainerContext()
+ {
+ this.contextualizer = new ObjectContextualizer(this);
+ this.cache = new ConcurrentReaderHashMap();
+ }
+
+ public InstanceContainerImpl getContainer()
+ {
+ return container;
+ }
+
+ public void setContainer(InstanceContainerImpl container)
+ {
+ this.container = container;
+ }
+
+ public void flushNaturalIdCache()
+ {
+ cache.clear();
+ }
+
+ public int getNaturalIdCacheSize()
+ {
+ return cache.size();
+ }
+
+ public boolean getCacheNaturalId()
+ {
+ return cacheNaturalId;
+ }
+
+ public void setCacheNaturalId(boolean cacheNaturalId)
+ {
+ this.cacheNaturalId = cacheNaturalId;
+ }
+
+ public String getSessionFactoryJNDIName()
+ {
+ return sessionFactoryJNDIName;
+ }
+
+ public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+ {
+ this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+ }
+
+ public void start() throws Exception
+ {
+ sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+
+ //
+ contextualizer.attach(sessionFactory);
+ }
+
+ public void stop() throws Exception
+ {
+ sessionFactory = null;
+ }
+
+ public Collection getInstanceDefinitions()
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ //
+ return session.createQuery(FROM_INSTANCE_DEFINITION_IMPL).list();
+ }
+
+ public AbstractInstanceCustomization newInstanceCustomization(AbstractInstanceDefinition def, String id, PortletContext portletContext)
+ {
+ return new PersistentInstanceCustomization((PersistentInstanceDefinition)def, id, portletContext);
+ }
+
+ public AbstractInstanceDefinition newInstanceDefinition(String id, String portletRef)
+ {
+ return new PersistentInstanceDefinition(this, id, portletRef);
+ }
+
+ public AbstractInstanceDefinition getInstanceDefinition(String id)
+ {
+ // Get cached pk from natural id
+ Long pk = cacheNaturalId ? (Long)cache.get(id) : null;
+
+ //
+ PersistentInstanceDefinition instance;
+
+ //
+ Session session = sessionFactory.getCurrentSession();
+
+ //
+ if (pk == null)
+ {
+ // No pk
+ instance = lookupNoCache(session, id);
+ }
+ else
+ {
+ // Try lookup using the cached pk
+ instance = (PersistentInstanceDefinition)session.get(PersistentInstanceDefinition.class, pk);
+
+ // The pk may be invalid if the instance has been recreted under the same path with a different pk
+ if (instance == null)
+ {
+ // In that case we try a no cache
+ instance = lookupNoCache(session, id);
+ }
+ }
+
+ //
+ if (cacheNaturalId)
+ {
+ if (instance != null)
+ {
+ cache.put(id, instance.getKey());
+ }
+ else
+ {
+ cache.remove(id);
+ }
+ }
+
+ //
+ return instance;
+ }
+
+ public AbstractInstanceCustomization getCustomization(AbstractInstanceDefinition instanceDef, String customizationId)
+ {
+ PersistentInstanceDefinition _instanceDef = (PersistentInstanceDefinition)instanceDef;
+ return (PersistentInstanceCustomization)_instanceDef.relatedCustomizations.get(customizationId);
+ }
+
+ private PersistentInstanceDefinition lookupNoCache(Session session, String id)
+ {
+ Query q = session.createQuery(BY_INSTANCE_ID_QUERY);
+ q.setString("instanceId", id);
+ return (PersistentInstanceDefinition)q.uniqueResult();
+ }
+
+ public void createInstanceDefinition(AbstractInstanceDefinition instanceDef) throws DuplicateInstanceException
+ {
+ String id = instanceDef.getId();
+
+ //
+ if (getInstanceDefinition(id) != null)
+ {
+ throw new DuplicateInstanceException("An instance with id " + id + " already exist");
+ }
+
+ //
+ try
+ {
+ Session session = sessionFactory.getCurrentSession();
+ session.persist(instanceDef);
+ }
+ catch (ConstraintViolationException e)
+ {
+ // May raise a constraint violation exception if it is has been inserted between the lookup
+ // and the insert and the isolation level is not serializable
+ throw new DuplicateInstanceException("An instance with id " + id + " already exist");
+ }
+ }
+
+ public void createInstanceCustomizaton(AbstractInstanceCustomization customization)
+ {
+ createInstanceCustomizaton((PersistentInstanceCustomization)customization);
+ }
+
+ private void createInstanceCustomizaton(PersistentInstanceCustomization customization)
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ // Persist in db
+ session.persist(customization);
+
+ // Get owner that will become the related definition
+ PersistentInstanceDefinition relatedDefinition = customization.owner;
+
+ // Create one to many assoication
+ relatedDefinition.relatedCustomizations.put(customization.customizationId, customization);
+ customization.relatedDefinition = relatedDefinition;
+
+ // Update state
+ session.update(customization.relatedDefinition);
+
+ // Mark state as persistent
+ customization.persistent = true;
+ }
+
+ private void updateInstance(AbstractInstance instanceDef)
+ {
+ Session session = sessionFactory.getCurrentSession();
+ session.update(instanceDef);
+ }
+
+ public void updateInstance(AbstractInstance instance, PortletContext portletContext, boolean mutable)
+ {
+ PersistentInstanceDefinition _instance = (PersistentInstanceDefinition)instance;
+
+ //
+ _instance.setPortletRef(portletContext.getId());
+ _instance.setState(portletContext.getState());
+ _instance.setMutable(mutable);
+
+ //
+ updateInstance(_instance);
+ }
+
+
+ public void updateInstance(AbstractInstance instance, PortletContext portletContext)
+ {
+ instance.setPortletRef(portletContext.getId());
+ instance.setState(portletContext.getState());
+
+
+ //
+ updateInstance(instance);
+ }
+
+ public void updateInstanceDefinition(AbstractInstanceDefinition def, Set securityBindings)
+ {
+ PersistentInstanceDefinition _def = (PersistentInstanceDefinition)def;
+
+ //
+ for (Iterator i = _def.getRelatedSecurityBindings().values().iterator();i.hasNext();)
+ {
+ PersistentRoleSecurityBinding isc = (PersistentRoleSecurityBinding)i.next();
+
+ // Break association
+ i.remove();
+ isc.setInstance(null);
+ }
+
+ for (Iterator i = securityBindings.iterator(); i.hasNext();)
+ {
+ RoleSecurityBinding sc = (RoleSecurityBinding)i.next();
+
+ //
+ PersistentRoleSecurityBinding isc = new PersistentRoleSecurityBinding(sc.getActions(), sc.getRoleName());
+
+ // Create association
+ isc.setInstance(_def);
+ _def.getRelatedSecurityBindings().put(sc.getRoleName(), isc);
+ }
+ }
+
+ public void destroyInstanceDefinition(AbstractInstanceDefinition instanceDef)
+ {
+ destroyInstanceDefinition((PersistentInstanceDefinition)instanceDef);
+ }
+
+ private void destroyInstanceDefinition(PersistentInstanceDefinition instanceDef)
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ // Destroy the user instances
+ Collection customizations = instanceDef.getRelatedCustomizations().values();
+ for (Iterator i = customizations.iterator(); i.hasNext();)
+ {
+ PersistentInstanceCustomization userInstance = (PersistentInstanceCustomization)i.next();
+ i.remove();
+ userInstance.relatedDefinition = null;
+ session.delete(userInstance);
+ }
+
+ // Delete instance
+ session.delete(instanceDef);
+
+ //
+ session.flush();
+ }
+}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContext.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -1,274 +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.core.impl.model.instance.persistent;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.Query;
-import org.hibernate.exception.ConstraintViolationException;
-import org.jboss.portal.jems.hibernate.ObjectContextualizer;
-import org.jboss.portal.core.model.instance.DuplicateInstanceException;
-import org.jboss.portal.core.impl.model.instance.ContainerContext;
-import org.jboss.portal.core.impl.model.instance.AbstractInstance;
-import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
-import org.jboss.portal.core.impl.model.instance.AbstractInstanceCustomization;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.portlet.PortletContext;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
-
-import javax.naming.InitialContext;
-import java.util.Iterator;
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PersistentInstanceContext extends ContainerContext
-{
-
- /** . */
- private static final String BY_INSTANCE_ID_QUERY = "from " + Tools.getShortNameOf(InstanceDefinitionImpl.class) + " where instanceId=:instanceId";
-
- /** . */
- protected SessionFactory sessionFactory;
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- /** . */
- protected ObjectContextualizer contextualizer;
-
- /** . */
- protected ConcurrentReaderHashMap cache;
-
- /** . */
- protected boolean cacheNaturalId;
-
- public PersistentInstanceContext()
- {
- this.contextualizer = new ObjectContextualizer(this);
- this.cache = new ConcurrentReaderHashMap();
- }
-
- public void flushNaturalIdCache()
- {
- cache.clear();
- }
-
- public int getNaturalIdCacheSize()
- {
- return cache.size();
- }
-
- public boolean getCacheNaturalId()
- {
- return cacheNaturalId;
- }
-
- public void setCacheNaturalId(boolean cacheNaturalId)
- {
- this.cacheNaturalId = cacheNaturalId;
- }
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
- public void start() throws Exception
- {
- sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
- //
- contextualizer.attach(sessionFactory);
- }
-
- public void stop() throws Exception
- {
- sessionFactory = null;
- }
-
- public Collection getInstanceDefinitions()
- {
- Session session = sessionFactory.getCurrentSession();
- return session.createQuery("from InstanceDefinitionImpl").list();
- }
-
- public AbstractInstanceCustomization newInstanceCustomization(AbstractInstanceDefinition def, String id, PortletContext portletContext)
- {
- return new InstanceCustomizationImpl((InstanceDefinitionImpl)def, id, portletContext);
- }
-
- public AbstractInstanceDefinition newInstanceDefinition(String id, String portletRef)
- {
- return new InstanceDefinitionImpl(id, portletRef);
- }
-
- public AbstractInstanceDefinition getInstanceDefinition(String id)
- {
- // Get cached pk from natural id
- Long pk = cacheNaturalId ? (Long)cache.get(id) : null;
-
- //
- InstanceDefinitionImpl instance;
-
- //
- Session session = sessionFactory.getCurrentSession();
-
- //
- if (pk == null)
- {
- // No pk
- instance = lookupNoCache(session, id);
- }
- else
- {
- // Try lookup using the cached pk
- instance = (InstanceDefinitionImpl)session.get(InstanceDefinitionImpl.class, pk);
-
- // The pk may be invalid if the instance has been recreted under the same path with a different pk
- if (instance == null)
- {
- // In that case we try a no cache
- instance = lookupNoCache(session, id);
- }
- }
-
- //
- if (cacheNaturalId)
- {
- if (instance != null)
- {
- cache.put(id, instance.getKey());
- }
- else
- {
- cache.remove(id);
- }
- }
-
- //
- return instance;
- }
-
- public AbstractInstanceCustomization getCustomization(AbstractInstanceDefinition instanceDef, String customizationId)
- {
- InstanceDefinitionImpl _instanceDef = (InstanceDefinitionImpl)instanceDef;
- return (InstanceCustomizationImpl)_instanceDef.customizationMap.get(customizationId);
- }
-
- private InstanceDefinitionImpl lookupNoCache(Session session, String id)
- {
- Query q = session.createQuery(BY_INSTANCE_ID_QUERY);
- q.setString("instanceId", id);
- return (InstanceDefinitionImpl)q.uniqueResult();
- }
-
- public void createInstanceDefinition(AbstractInstanceDefinition instanceDef) throws DuplicateInstanceException
- {
- String id = instanceDef.getId();
-
- //
- if (getInstanceDefinition(id) != null)
- {
- throw new DuplicateInstanceException("An instance with id " + id + " already exist");
- }
-
- //
- try
- {
- Session session = sessionFactory.getCurrentSession();
- session.persist(instanceDef);
- }
- catch (ConstraintViolationException e)
- {
- // May raise a constraint violation exception if it is has been inserted between the lookup
- // and the insert and the isolation level is not serializable
- throw new DuplicateInstanceException("An instance with id " + id + " already exist");
- }
- }
-
- public void createInstanceCustomizaton(AbstractInstanceCustomization customization)
- {
- createInstanceCustomizaton((InstanceCustomizationImpl)customization);
- }
-
- private void createInstanceCustomizaton(InstanceCustomizationImpl customization)
- {
- Session session = sessionFactory.getCurrentSession();
-
- // Persist in db
- session.persist(customization);
-
- // Get owner that will become the related definition
- InstanceDefinitionImpl relatedDefinition = customization.owner;
-
- // Create one to many assoication
- relatedDefinition.customizationMap.put(customization.customizationId, customization);
- customization.relatedDefinition = relatedDefinition;
-
- // Update state
- session.update(customization.relatedDefinition);
-
- // Mark state as persistent
- customization.persistent = true;
- }
-
- public void updateInstance(AbstractInstance instanceDef)
- {
- Session session = sessionFactory.getCurrentSession();
- session.update(instanceDef);
- }
-
- public void destroyInstanceDefinition(AbstractInstanceDefinition instanceDef)
- {
- destroyInstanceDefinition((InstanceDefinitionImpl)instanceDef);
- }
-
- private void destroyInstanceDefinition(InstanceDefinitionImpl instanceDef)
- {
- Session session = sessionFactory.getCurrentSession();
-
- // Destroy the user instances
- Collection customizations = instanceDef.getCustomizationMap().values();
- for (Iterator i = customizations.iterator(); i.hasNext();)
- {
- InstanceCustomizationImpl userInstance = (InstanceCustomizationImpl)i.next();
- i.remove();
- userInstance.relatedDefinition = null;
- session.delete(userInstance);
- }
-
- // Delete instance
- session.delete(instanceDef);
-
- //
- session.flush();
- }
-}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceCustomization.java (from rev 7234, trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceCustomizationImpl.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceCustomization.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceCustomization.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -0,0 +1,131 @@
+/******************************************************************************
+ * 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.core.impl.model.instance.persistent;
+
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceCustomization;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
+import org.jboss.portal.core.impl.model.instance.InstanceContainerContext;
+import org.jboss.portal.portlet.PortletContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+class PersistentInstanceCustomization extends AbstractInstanceCustomization
+{
+
+ // Persistent fields
+
+ protected Long key;
+ protected PersistentInstanceDefinition relatedDefinition;
+ protected String customizationId;
+
+ // Runtime fields
+
+ protected PersistentInstanceDefinition owner;
+ protected boolean persistent;
+
+ /** Used to build transient instances. */
+ public PersistentInstanceCustomization(PersistentInstanceDefinition owner, String customizationId, PortletContext portletContext)
+ {
+ if (owner == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (customizationId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (portletContext == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.owner = owner;
+ this.persistent = false;
+
+ //
+ this.customizationId = customizationId;
+ this.portletRef = portletContext.getId();
+ this.state = portletContext.getState();
+ }
+
+ /** Used by hibernate. */
+ public PersistentInstanceCustomization()
+ {
+ this.owner = null;
+ this.persistent = true;
+ }
+
+ public Long getKey()
+ {
+ return key;
+ }
+
+ public void setKey(Long key)
+ {
+ this.key = key;
+ }
+
+ public String getId()
+ {
+ return customizationId;
+ }
+
+ public String getCustomizationId()
+ {
+ return customizationId;
+ }
+
+ public void setCustomizationId(String customizationId)
+ {
+ this.customizationId = customizationId;
+ }
+
+ public AbstractInstanceDefinition getOwner()
+ {
+ return owner;
+ }
+
+ public PersistentInstanceDefinition getRelatedDefinition()
+ {
+ return relatedDefinition;
+ }
+
+ public void setRelatedDefinition(PersistentInstanceDefinition relatedDefinition)
+ {
+ this.relatedDefinition = relatedDefinition;
+ this.owner = relatedDefinition;
+ }
+
+ protected boolean isPersistent()
+ {
+ return persistent;
+ }
+
+ protected InstanceContainerContext getContainerContext()
+ {
+ return owner.containerContext;
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceCustomization.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceDefinition.java (from rev 7234, trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/InstanceDefinitionImpl.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceDefinition.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceDefinition.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -0,0 +1,167 @@
+/******************************************************************************
+ * 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.core.impl.model.instance.persistent;
+
+import org.jboss.portal.core.impl.model.instance.InstanceContainerContext;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
+import org.jboss.portal.jems.hibernate.ContextObject;
+import org.jboss.portal.security.RoleSecurityBinding;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Collection;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+class PersistentInstanceDefinition extends AbstractInstanceDefinition implements ContextObject
+{
+
+ // Persistent fields
+
+ protected Long key;
+ protected String instanceId;
+ protected boolean mutable;
+ protected Map relatedSecurityBindings;
+ protected Map relatedCustomizations;
+
+ // Runtime fields
+
+ /** . */
+ protected InstanceContainerContext containerContext;
+
+ public PersistentInstanceDefinition()
+ {
+ this.mutable = false;
+ this.portletRef = null;
+ this.instanceId = null;
+ this.relatedSecurityBindings = null;
+ this.relatedCustomizations = null;
+ this.state = null;
+ }
+
+ public PersistentInstanceDefinition(InstanceContainerContext containerContext, String id, String portletRef)
+ {
+ this.containerContext = containerContext;
+ this.mutable = false;
+ this.portletRef = portletRef;
+ this.instanceId = id;
+ this.relatedSecurityBindings = new HashMap();
+ this.relatedCustomizations = new HashMap();
+ this.state = null;
+ }
+
+ // Hibernate ********************************************************************************************************
+
+ public Long getKey()
+ {
+ return key;
+ }
+
+ public void setKey(Long key)
+ {
+ this.key = key;
+ }
+
+ public String getInstanceId()
+ {
+ return instanceId;
+ }
+
+ public void setInstanceId(String instanceId)
+ {
+ this.instanceId = instanceId;
+ }
+
+ public Map getRelatedSecurityBindings()
+ {
+ return relatedSecurityBindings;
+ }
+
+ public void setRelatedSecurityBindings(Map relatedSecurityBindings)
+ {
+ this.relatedSecurityBindings = relatedSecurityBindings;
+ }
+
+ public Map getRelatedCustomizations()
+ {
+ return relatedCustomizations;
+ }
+
+ public void setRelatedCustomizations(Map relatedCustomizations)
+ {
+ this.relatedCustomizations = relatedCustomizations;
+ }
+
+ public boolean isMutable()
+ {
+ return mutable;
+ }
+
+ public void setMutable(boolean mutable)
+ {
+ this.mutable = mutable;
+ }
+
+ // Instance implementation ******************************************************************************************
+
+ public String getId()
+ {
+ return instanceId;
+ }
+
+ // AbstractInstanceDefinition implementation ************************************************************************
+
+ public Collection getCustomizations()
+ {
+ return relatedCustomizations.values();
+ }
+
+ public Set getSecurityBindings()
+ {
+ Set constraints = new HashSet();
+ for (Iterator i = relatedSecurityBindings.values().iterator(); i.hasNext();)
+ {
+ PersistentRoleSecurityBinding isc = (PersistentRoleSecurityBinding)i.next();
+ RoleSecurityBinding sc = new RoleSecurityBinding(isc.getActions(), isc.getRole());
+ constraints.add(sc);
+ }
+ return constraints;
+ }
+
+ // ContextObject implementation *************************************************************************************
+
+ public void setContext(Object context)
+ {
+ this.containerContext = (InstanceContainerContext)context;
+ }
+
+ protected InstanceContainerContext getContainerContext()
+ {
+ return containerContext;
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceDefinition.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentRoleSecurityBinding.java (from rev 7233, trunk/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceSecurityBinding.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentRoleSecurityBinding.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentRoleSecurityBinding.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -0,0 +1,256 @@
+/******************************************************************************
+ * 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.core.impl.model.instance.persistent;
+
+import org.jboss.portal.core.model.instance.Instance;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Security Constraint for an instance
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+final class PersistentRoleSecurityBinding implements Serializable
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -2832148715381794267L;
+
+ /** The primary key. */
+ private Long key;
+
+ /** The role of this contraint. */
+ private String role;
+
+ /** The set of actions of this constraint. */
+ private Set actions;
+
+ /** The cached toString value. */
+ private transient String toString;
+
+ /** The cached hash code. */
+ private transient int hashCode;
+
+ /** The cached actions as a string. */
+ private transient String actionsAsString;
+
+ private Instance instance;
+
+ public PersistentRoleSecurityBinding()
+ {
+ super();
+ }
+
+ /**
+ * Create a new constraint with the provided actions for the specified role.
+ *
+ * @param actions a comma separated list of allowed actions
+ * @param role the role name
+ */
+ public PersistentRoleSecurityBinding(String actions, String role)
+ {
+ if (role == null)
+ {
+ throw new IllegalArgumentException("Role cannot be null");
+ }
+ if (actions == null)
+ {
+ throw new IllegalArgumentException("Actions cannot be null");
+ }
+
+ //
+ StringTokenizer tokens = new StringTokenizer(actions, ",");
+ Set set = new HashSet();
+ while (tokens.hasMoreTokens())
+ {
+ set.add(tokens.nextToken().trim());
+ }
+
+ //
+ this.role = role;
+ this.actions = Collections.unmodifiableSet(set);
+ }
+
+ /**
+ * Create a new constraint with the provided actions and the specified role.
+ *
+ * @param actions the set of actions
+ * @param role the role name
+ */
+ public PersistentRoleSecurityBinding(Set actions, String role)
+ {
+ if (role == null)
+ {
+ throw new IllegalArgumentException("Role cannot be null");
+ }
+ if (actions == null)
+ {
+ throw new IllegalArgumentException("Actions cannot be null");
+ }
+
+ //
+ this.role = role;
+ this.actions = Collections.unmodifiableSet(new HashSet(actions));
+ }
+
+ /** Copy constructor. */
+ public PersistentRoleSecurityBinding(PersistentRoleSecurityBinding other)
+ {
+ if (other == null)
+ {
+ throw new IllegalArgumentException("The constraint to clone cannot be null");
+ }
+
+ //
+ this.role = other.role;
+ this.actions = other.actions;
+ }
+
+ /**
+ * Return a <code>java.util.Set<String></code> of allowed actions.
+ *
+ * @return the action set
+ */
+ public Set getActions()
+ {
+ return actions;
+ }
+
+ /**
+ * Return the role of this constraint
+ *
+ * @return the role
+ */
+ public String getRole()
+ {
+ return role;
+ }
+
+ /**
+ * Return a comma separated list of actions.
+ *
+ * @return the action string representation
+ */
+ public String getActionsAsString()
+ {
+ if (actionsAsString == null)
+ {
+ StringBuffer tmp = new StringBuffer();
+ for (Iterator i = actions.iterator(); i.hasNext();)
+ {
+ String action = (String)i.next();
+ if (i.hasNext())
+ {
+ tmp.append(", ");
+ }
+ tmp.append(action);
+ }
+ actionsAsString = tmp.toString();
+ }
+ return actionsAsString;
+ }
+
+ /** @see Object#toString */
+ public String toString()
+ {
+ if (toString == null)
+ {
+ StringBuffer tmp = new StringBuffer("SecurityConstraint: actions [");
+ for (Iterator i = actions.iterator(); i.hasNext();)
+ {
+ String action = (String)i.next();
+ if (i.hasNext())
+ {
+ tmp.append(", ");
+ }
+ tmp.append(action);
+ }
+ tmp.append("] role [").append(role).append("]");
+ toString = tmp.toString();
+ }
+ return toString;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o instanceof PersistentRoleSecurityBinding)
+ {
+ PersistentRoleSecurityBinding that = (PersistentRoleSecurityBinding)o;
+ return actions.equals(that.actions) && role.equals(that.role);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ if (hashCode == 0)
+ {
+ int hashCode;
+ hashCode = actions.hashCode();
+ hashCode = 29 * hashCode + role.hashCode();
+ this.hashCode = hashCode;
+ }
+ return hashCode;
+ }
+
+ protected void setKey(Long k)
+ {
+ key = k;
+ }
+
+ protected Long getKey()
+ {
+ return key;
+ }
+
+ public void setActions(Set actions)
+ {
+ this.actions = actions;
+ }
+
+ public void setRole(String role)
+ {
+ this.role = role;
+ }
+
+ public Instance getInstance()
+ {
+ return instance;
+ }
+
+ public void setInstance(Instance instance)
+ {
+ this.instance = instance;
+ }
+}
Property changes on: trunk/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentRoleSecurityBinding.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -46,9 +46,9 @@
import org.jboss.portal.common.test.junit.POJOJUnitTest;
import org.jboss.portal.common.test.junit.JUnitAdapter;
import org.jboss.portal.common.test.TestParametrization;
-import org.jboss.portal.core.impl.model.instance.persistent.InstanceCustomizationImpl;
-import org.jboss.portal.core.impl.model.instance.persistent.InstanceDefinitionImpl;
import org.jboss.portal.core.impl.model.instance.InstanceContainerImpl;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
+import org.jboss.portal.core.impl.model.instance.AbstractInstanceCustomization;
import org.jboss.portal.core.impl.portlet.state.PersistentPortletStatePersistenceManager;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstanceDefinition;
@@ -365,7 +365,7 @@
// InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instances.get(0);
// assertEquals(true, instanceImpl.isModifiable());
assertEquals(1, instanceContainer.getDefinitions().size());
- InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
+ AbstractInstanceDefinition instanceImpl = (AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
assertEquals(true, instanceImpl.isModifiable());
TransactionAssert.commitTransaction();
@@ -389,12 +389,12 @@
//
TransactionAssert.beginTransaction();
// session = instanceHibernateSupport.getCurrentSession();
-// instances = session.createQuery("from InstanceDefinitionImpl").list();
+// instances = session.createQuery("from AbstractInstanceDefinition").list();
// assertEquals(1, instances.size());
-// instanceImpl = (InstanceDefinitionImpl)instances.get(0);
+// instanceImpl = (AbstractInstanceDefinition)instances.get(0);
// assertEquals(true, instanceImpl.isModifiable());
assertEquals(1, instanceContainer.getDefinitions().size());
- instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
+ instanceImpl = (AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
assertEquals(true, instanceImpl.isModifiable());
TransactionAssert.commitTransaction();
@@ -416,9 +416,10 @@
//
TransactionAssert.beginTransaction();
- Session session = instanceHibernateSupport.getCurrentSession();
- assertEquals(0, session.createQuery("from InstanceDefinitionImpl").list().size());
- assertEquals(0, portletHibernateSupport.getCurrentSession().createQuery("from PersistentPortletState").list().size());
+ assertEquals(0, instanceContainer.getDefinitions().size());
+// Session session = instanceHibernateSupport.getCurrentSession();
+// assertEquals(0, session.createQuery("from AbstractInstanceDefinition").list().size());
+// assertEquals(0, portletHibernateSupport.getCurrentSession().createQuery("from PersistentPortletState").list().size());
TransactionAssert.commitTransaction();
}
@@ -533,9 +534,9 @@
// Check state
TransactionAssert.beginTransaction();
- InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
+ AbstractInstanceDefinition instanceImpl = (AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
- Collection userInstances = instanceImpl.getCustomizationMap().values();
+ Collection userInstances = instanceImpl.getCustomizations();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -563,9 +564,9 @@
// Check state
TransactionAssert.beginTransaction();
- InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
+ AbstractInstanceDefinition instanceImpl = (AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
- Collection userInstances = instanceImpl.getCustomizationMap().values();
+ Collection userInstances = instanceImpl.getCustomizations();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -586,12 +587,12 @@
// Check state
TransactionAssert.beginTransaction();
- InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
+ AbstractInstanceDefinition instanceImpl = (AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
- Collection userInstances = instanceImpl.getCustomizationMap().values();
+ Collection userInstances = instanceImpl.getCustomizations();
assertNotNull(userInstances);
assertEquals(1, userInstances.size());
- InstanceCustomizationImpl userInstance = (InstanceCustomizationImpl)userInstances.iterator().next();
+ AbstractInstanceCustomization userInstance = (AbstractInstanceCustomization)userInstances.iterator().next();
PortletContext userPortletContext = userInstance.getPortletContext();
assertNotNull(userPortletContext);
PropertyMap userProps = instanceContainer.getPortletInvoker().getProperties(userPortletContext);
@@ -621,12 +622,12 @@
// Check state
TransactionAssert.beginTransaction();
- InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
+ AbstractInstanceDefinition instanceImpl = (AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
assertNotNull(instanceImpl);
- Collection userInstances = instanceImpl.getCustomizationMap().values();
+ Collection userInstances = instanceImpl.getCustomizations();
assertNotNull(userInstances);
assertEquals(1, userInstances.size());
- InstanceCustomizationImpl userInstance = (InstanceCustomizationImpl)userInstances.iterator().next();
+ AbstractInstanceCustomization userInstance = (AbstractInstanceCustomization)userInstances.iterator().next();
System.out.println("userInstance.getPortletRef() = " + userInstance.getPortletRef());
System.out.println("userInstance.getState() = " + userInstance.getState());
PortletContext userPortletContext = userInstance.getPortletContext();
@@ -658,8 +659,8 @@
// Check state
TransactionAssert.beginTransaction();
- InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
- Collection userInstances = instanceImpl.getCustomizationMap().values();
+ AbstractInstanceDefinition instanceImpl = (AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
+ Collection userInstances = instanceImpl.getCustomizations();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -680,8 +681,8 @@
// Check state
TransactionAssert.beginTransaction();
- InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
- Collection userInstances = instanceImpl.getCustomizationMap().values();
+ AbstractInstanceDefinition instanceImpl = (AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
+ Collection userInstances = instanceImpl.getCustomizations();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -702,8 +703,8 @@
// Check state
TransactionAssert.beginTransaction();
- InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
- Collection userInstances = instanceImpl.getCustomizationMap().values();
+ AbstractInstanceDefinition instanceImpl = (AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
+ Collection userInstances = instanceImpl.getCustomizations();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -724,8 +725,8 @@
// Check state
TransactionAssert.beginTransaction();
- InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
- Collection userInstances = instanceImpl.getCustomizationMap().values();
+ AbstractInstanceDefinition instanceImpl = (AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
+ Collection userInstances = instanceImpl.getCustomizations();
assertNotNull(userInstances);
assertEquals(0, userInstances.size());
TransactionAssert.commitTransaction();
@@ -758,14 +759,14 @@
//
TransactionAssert.beginTransaction();
- InstanceDefinitionImpl instanceImpl = (InstanceDefinitionImpl)instanceContainer.getDefinition("MyInstance");
+ AbstractInstanceDefinition instanceImpl = (AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
PortletContext sharedPortletContext = instanceImpl.getPortletContext();
assertNotNull(producer.getPortlet(sharedPortletContext));
assertNotNull(instance);
- Collection children = instanceImpl.getCustomizationMap().values();
+ Collection children = instanceImpl.getCustomizations();
assertNotNull(children);
assertEquals(1, children.size());
- InstanceCustomizationImpl userInstance = (InstanceCustomizationImpl)children.iterator().next();
+ AbstractInstanceCustomization userInstance = (AbstractInstanceCustomization)children.iterator().next();
PortletContext userPortletContext = userInstance.getPortletContext();
assertNotNull(producer.getPortlet(userPortletContext));
assertNotNull(userInstance);
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-05-10 15:28:52 UTC (rev 7239)
@@ -561,14 +561,28 @@
</mbean>
<!-- The different containers -->
+
<mbean
+ code="org.jboss.portal.core.impl.model.instance.persistent.PersistentInstanceContainerContext"
+ name="portal:service=InstanceContainerContext"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends>portal:service=Hibernate,type=Instance</depends>
+ <attribute name="SessionFactoryJNDIName">java:/portal/InstanceSessionFactory</attribute>
+ <attribute name="CacheNaturalId">true</attribute>
+ </mbean>
+
+ <mbean
code="org.jboss.portal.core.impl.model.instance.InstanceContainerImpl"
name="portal:container=Instance"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
- <depends>portal:service=Hibernate,type=Instance</depends>
<depends
+ optional-attribute-name="ContainerContext"
+ proxy-type="attribute">portal:service=InstanceContainerContext</depends>
+ <depends
optional-attribute-name="StackFactory"
proxy-type="attribute">portal:service=InterceptorStackFactory,type=Instance</depends>
<depends
@@ -580,8 +594,6 @@
<depends
optional-attribute-name="AuthorizationDomainRegistry"
proxy-type="attribute">portal:service=AuthorizationDomainRegistry</depends>
- <attribute name="SessionFactoryJNDIName">java:/portal/InstanceSessionFactory</attribute>
- <attribute name="CacheNaturalId">true</attribute>
</mbean>
<mbean
code="org.jboss.portal.core.impl.model.portal.PersistentPortalObjectContainer"
Modified: trunk/core/src/resources/portal-core-sar/conf/hibernate/instance/domain.hbm.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/hibernate/instance/domain.hbm.xml 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/resources/portal-core-sar/conf/hibernate/instance/domain.hbm.xml 2007-05-10 15:28:52 UTC (rev 7239)
@@ -27,7 +27,7 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
- name="org.jboss.portal.core.impl.model.instance.persistent.InstanceDefinitionImpl"
+ name="org.jboss.portal.core.impl.model.instance.persistent.PersistentInstanceDefinition"
table="JBP_INSTANCE">
<cache usage="@portal.hibernate.cache.usage@"/>
<id
@@ -62,7 +62,7 @@
unique="false"
length="50000000"/>
<map
- name="securityBindings"
+ name="relatedSecurityBindings"
sort="unsorted"
inverse="true"
cascade="all-delete-orphan"
@@ -70,10 +70,10 @@
<cache usage="@portal.hibernate.cache.usage@"/>
<key column="INSTANCE_PK"/>
<index column="ROLE" type="string"/>
- <one-to-many class="org.jboss.portal.core.impl.model.instance.InstanceSecurityBinding"/>
+ <one-to-many class="org.jboss.portal.core.impl.model.instance.persistent.PersistentRoleSecurityBinding"/>
</map>
<map
- name="customizationMap"
+ name="relatedCustomizations"
inverse="true"
cascade="save-update"
fetch="select"
@@ -83,12 +83,12 @@
<map-key
type="string"
column="USER_ID"/>
- <one-to-many class="org.jboss.portal.core.impl.model.instance.persistent.InstanceCustomizationImpl"/>
+ <one-to-many class="org.jboss.portal.core.impl.model.instance.persistent.PersistentInstanceCustomization"/>
</map>
</class>
<class
- name="org.jboss.portal.core.impl.model.instance.persistent.InstanceCustomizationImpl"
+ name="org.jboss.portal.core.impl.model.instance.persistent.PersistentInstanceCustomization"
table="JBP_INSTANCE_PER_USER">
<cache usage="@portal.hibernate.cache.usage@"/>
<id
@@ -102,7 +102,7 @@
<many-to-one
name="relatedDefinition"
column="INSTANCE_PK"
- class="org.jboss.portal.core.impl.model.instance.persistent.InstanceDefinitionImpl"
+ class="org.jboss.portal.core.impl.model.instance.persistent.PersistentInstanceDefinition"
cascade="none"
fetch="select"/>
<property
@@ -128,7 +128,7 @@
</class>
<class
- name="org.jboss.portal.core.impl.model.instance.InstanceSecurityBinding"
+ name="org.jboss.portal.core.impl.model.instance.persistent.PersistentRoleSecurityBinding"
table="JBP_INSTANCE_SECURITY">
<cache usage="@portal.hibernate.cache.usage@"/>
<id
@@ -156,7 +156,7 @@
<many-to-one
name="instance"
column="INSTANCE_PK"
- class="org.jboss.portal.core.impl.model.instance.persistent.InstanceDefinitionImpl"
+ class="org.jboss.portal.core.impl.model.instance.persistent.PersistentInstanceDefinition"
cascade="none"
fetch="select"/>
</class>
Modified: trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/persistent-jboss-beans.xml
===================================================================
--- trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/persistent-jboss-beans.xml 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/model/instance/persistent-jboss-beans.xml 2007-05-10 15:28:52 UTC (rev 7239)
@@ -102,7 +102,7 @@
<bean name="StackFactory" class="org.jboss.portal.common.invocation.EmptyInterceptorStackFactory">
</bean>
- <bean name="ContainerContext" class="org.jboss.portal.core.impl.model.instance.persistent.PersistentInstanceContext">
+ <bean name="ContainerContext" class="org.jboss.portal.core.impl.model.instance.persistent.PersistentInstanceContainerContext">
<property name="sessionFactoryJNDIName">java:/InstanceSessionFactory</property>
<property name="cacheNaturalId"><inject bean="TestCaseConfig" property="cacheNaturalId"/></property>
</bean>
Modified: trunk/security/src/main/org/jboss/portal/security/RoleSecurityBinding.java
===================================================================
--- trunk/security/src/main/org/jboss/portal/security/RoleSecurityBinding.java 2007-05-10 15:04:30 UTC (rev 7238)
+++ trunk/security/src/main/org/jboss/portal/security/RoleSecurityBinding.java 2007-05-10 15:28:52 UTC (rev 7239)
@@ -173,7 +173,7 @@
{
if (toString == null)
{
- StringBuffer tmp = new StringBuffer("SecurityConstraint: actions [");
+ StringBuffer tmp = new StringBuffer("SecurityConstraint[actions=(");
for (Iterator i = actions.iterator();;)
{
String action = (String)i.next();
@@ -187,7 +187,7 @@
break;
}
}
- tmp.append("] role [").append(roleName).append("]");
+ tmp.append("),role=").append(roleName).append("]");
toString = tmp.toString();
}
return toString;
18 years, 12 months