Author: chris.laprun(a)jboss.com
Date: 2011-01-18 12:33:16 -0500 (Tue, 18 Jan 2011)
New Revision: 5780
Added:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationDestructionListener.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/invoker/
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/invoker/RegistrationCheckingPortletInvoker.java
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/invoker/
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/invoker/RegistrationCheckingPortletInvokerTestCase.java
Removed:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPortletContextChangeListener.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPPortletInvoker.java
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPPortletInvokerTestCase.java
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java
components/wsrp/trunk/pom.xml
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/AbstractRegistrationPersistenceManager.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/Registration.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPersistenceManager.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationImpl.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/spi/RegistrationSPI.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/ServiceDescriptionHandler.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/ActionRequestProcessor.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/EventRequestProcessor.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/MimeResponseProcessor.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/RequestProcessor.java
components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationTestCase.java
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPolicy.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java
components/wsrp/trunk/wsrp-producer-war/src/test/producer-sar/META-INF/jboss-beans.xml
Log:
- GTNWSRP-72: Redesigned putting portlet contexts under Registration control. Still need
to change persistence of Registrations in GTN.
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -33,6 +33,7 @@
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.pc.api.PortletStateType;
+import org.gatein.pc.api.PortletStatus;
import org.gatein.pc.api.invocation.PortletInvocation;
import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
import org.gatein.pc.api.spi.UserContext;
@@ -195,6 +196,18 @@
}
}
+ public PortletStatus getStatus(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
+ {
+ if (producerInfo.getPortlet(portletContext) != null)
+ {
+ return PortletStatus.OFFERED;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
public PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
{
return dispatcher.dispatchAndHandle(invocation);
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -28,6 +28,7 @@
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.pc.api.PortletStateType;
+import org.gatein.pc.api.PortletStatus;
import org.gatein.pc.api.invocation.PortletInvocation;
import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
import org.gatein.pc.api.state.DestroyCloneFailure;
@@ -171,6 +172,11 @@
return null;
}
+ public PortletStatus getStatus(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
+ {
+ return null;
+ }
+
public PortletInvocationResponse invoke(PortletInvocation invocation) throws
IllegalArgumentException, PortletInvokerException
{
return null;
Modified: components/wsrp/trunk/pom.xml
===================================================================
--- components/wsrp/trunk/pom.xml 2011-01-18 17:12:33 UTC (rev 5779)
+++ components/wsrp/trunk/pom.xml 2011-01-18 17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
<!--
~ JBoss, a division of Red Hat
- ~ Copyright 2010, Red Hat Middleware, LLC, and individual
+ ~ Copyright 2011, 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.
@@ -47,7 +47,7 @@
</scm>
<properties>
- <version.gatein.pc>2.2.0-GA</version.gatein.pc>
+ <version.gatein.pc>2.3.0-Alpha01</version.gatein.pc>
<version.gatein.common>2.0.3-GA</version.gatein.common>
<version.gatein.wci>2.0.2-GA</version.gatein.wci>
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/AbstractRegistrationPersistenceManager.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/AbstractRegistrationPersistenceManager.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/AbstractRegistrationPersistenceManager.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,24 +1,25 @@
/*
-* JBoss, a division of Red Hat
-* Copyright 2008, 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.
-*/
+ * JBoss, a division of Red Hat
+ * Copyright 2011, 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.gatein.registration;
@@ -62,14 +63,14 @@
public void saveChangesTo(Registration registration)
{
ParameterValidation.throwIllegalArgExceptionIfNull(registration,
"Registration");
-
+
if (registration.getPersistentKey() == null)
{
throw new IllegalArgumentException("Registration " + registration +
" hasn't yet been persisted and thus cannot be updated");
}
internalSaveChangesTo(registration);
}
-
+
public ConsumerGroup createConsumerGroup(String name) throws RegistrationException
{
ConsumerGroup group = getConsumerGroup(name);
@@ -117,7 +118,7 @@
consumer.removeRegistration(registration);
}
- public Registration addRegistrationFor(String consumerId, Map<QName, Object>
registrationProperties) throws RegistrationException
+ public RegistrationSPI addRegistrationFor(String consumerId, Map<QName, Object>
registrationProperties) throws RegistrationException
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerId,
"Consumer identity", null);
ParameterValidation.throwIllegalArgExceptionIfNull(registrationProperties,
"Registration properties");
@@ -176,7 +177,7 @@
protected abstract ConsumerSPI internalCreateConsumer(String consumerId, String
consumerName);
protected abstract ConsumerSPI internalSaveChangesTo(Consumer consumer);
-
+
protected abstract RegistrationSPI internalSaveChangesTo(Registration registration);
protected abstract void internalAddConsumerGroup(ConsumerGroupSPI group);
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/Registration.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/Registration.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/Registration.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -23,10 +23,11 @@
package org.gatein.registration;
+import org.gatein.pc.api.PortletContext;
+
import javax.xml.namespace.QName;
-
-import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
* A class representing an association between a consumer and a producer.
@@ -96,9 +97,6 @@
*/
void setStatus(RegistrationStatus status);
- /** Clears any state (cloned portlet information, session, etc) associated with this
Registration */
- void clearAssociatedState();
-
void updateProperties(Map registrationProperties);
void removeProperty(QName propertyName);
@@ -108,6 +106,10 @@
Object getPropertyValueFor(QName propertyName);
Object getPropertyValueFor(String propertyName);
-
- List<String> getPortletHandles();
+
+ boolean knows(PortletContext portletContext);
+
+ Set<PortletContext> getKnownPortletContexts();
+
+ boolean knows(String portletContextId);
}
Added:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationDestructionListener.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationDestructionListener.java
(rev 0)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationDestructionListener.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2011, 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.gatein.registration;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public interface RegistrationDestructionListener
+{
+ /**
+ * Called before the specified registration is destroyed. Listener has the opportunity
to prevent destruction by
+ * returning <code>false</code>.
+ *
+ * @param registration the Registration about to be destroyed
+ * @return {@link #SUCCESS} if this listener agrees to move forward with the
destruction, or a negative Vote built
+ * using {@link Vote#negativeVote(String)} specifying the reason of the
negative vote.
+ */
+ Vote destructionScheduledFor(Registration registration);
+
+ static class Vote
+ {
+ public final boolean result;
+ public final String reason;
+
+ public static Vote negativeVote(String reason)
+ {
+ return new Vote(reason);
+ }
+
+ Vote(String reason)
+ {
+ this.result = false;
+ this.reason = reason;
+ }
+
+ Vote()
+ {
+ result = true;
+ reason = null;
+ }
+ }
+
+ static final Vote SUCCESS = new Vote();
+}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationManager.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -36,7 +36,7 @@
* @version $Revision: 8966 $
* @since 2.6
*/
-public interface RegistrationManager extends RegistrationPropertyChangeListener,
RegistrationPolicyChangeListener /*, RegistrationPortletContextChangeListener GTNWSRP-72
*/
+public interface RegistrationManager extends RegistrationPropertyChangeListener,
RegistrationPolicyChangeListener
{
RegistrationPolicy getPolicy();
@@ -83,4 +83,8 @@
Collection<? extends Consumer> getConsumers() throws RegistrationException;
void clear() throws RegistrationException;
+
+ void addRegistrationDestructionListener(RegistrationDestructionListener listener);
+
+ void removeRegistrationDestructionListener(RegistrationDestructionListener listener);
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPersistenceManager.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPersistenceManager.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPersistenceManager.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -23,6 +23,8 @@
package org.gatein.registration;
+import org.gatein.registration.spi.RegistrationSPI;
+
import javax.xml.namespace.QName;
import java.util.Collection;
import java.util.Map;
@@ -48,7 +50,7 @@
* @param consumer
*/
void saveChangesTo(Consumer consumer);
-
+
/**
* Saves changes made to the specified registration.
*
@@ -90,7 +92,7 @@
*/
Consumer getConsumerById(String consumerId) throws IllegalArgumentException,
RegistrationException;
- Registration addRegistrationFor(String consumerId, Map<QName, Object>
registrationProperties) throws RegistrationException;
+ RegistrationSPI addRegistrationFor(String consumerId, Map<QName, Object>
registrationProperties) throws RegistrationException;
Collection<? extends ConsumerGroup> getConsumerGroups();
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPolicy.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -23,6 +23,7 @@
package org.gatein.registration;
+import org.gatein.pc.api.PortletContext;
import org.gatein.wsrp.registration.PropertyDescription;
import javax.xml.namespace.QName;
@@ -121,52 +122,5 @@
*/
void validateConsumerGroupName(String groupName, RegistrationManager manager) throws
IllegalArgumentException, RegistrationException;
- /**
- * Checks if a portlet handle belongs to a specific registration.
- * GTNWSRP-72
- *
- * @param registration The registration to check
- * @param portletHandle The portlet handle to use
- * @return True if the registration contains this portlet handle
- */
-// boolean checkPortletHandle(Registration registration, String portletHandle);
-
- /**
- * Adds a Portlet Handle to a Registration
- * GTNWSRP-72
- *
- * @param registration The registration to use
- * @param portletHandle The portletHandle to add
- */
-// void addPortletHandle(Registration registration, String portletHandle);
-
- /**
- * Removes a portlet handle from a specific registration
- * GTNWSRP-72
- *
- * @param registration The registration to use
- * @param portletHandle The portlet handle to remove
- */
-// void removePortletHandle(Registration registration, String portletHandle);
-
- /**
- * Updates the list of currently available portlet handles.
- * GTNWSRP-72
- *
- * Note: this is not registration specific. This method deals with the situation
where
- * the producer has a change in the available portlets. The RegistrationPolicy needs
to either handle
- * the globally available portlets separately or update each registration when this
type of change occurs.
- *
- * @param portlets
- */
-// void updatePortletHandles(List<String> portlets);
-
- /**
- * Adds a PortletContextChangeListener to the RegistrationPolicy. The
PortletContextChangeListener
- * will be called whenever the portlet contexts within a registration changes.
- * GTNWSRP-72
- *
- * @param listener The listener to add
- */
-// void addPortletContextChangeListener(RegistrationPortletContextChangeListener
listener);
+ boolean allowAccessTo(PortletContext portletContext, Registration registration, String
operation);
}
Deleted:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPortletContextChangeListener.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPortletContextChangeListener.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPortletContextChangeListener.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,35 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, 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.gatein.registration;
-
-/**
- * Listeners for when the portlet contexts of a registration change. GTNWSRP-72
- *
- * @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
- * @version $Revision$
- */
-public interface RegistrationPortletContextChangeListener
-{
- void portletContextsHaveChanged(Registration registration);
-}
-
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationImpl.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationImpl.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -24,17 +24,19 @@
package org.gatein.registration.impl;
import org.gatein.common.util.ParameterValidation;
+import org.gatein.pc.api.PortletContext;
import org.gatein.registration.Registration;
+import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationStatus;
import org.gatein.registration.spi.ConsumerSPI;
import org.gatein.registration.spi.RegistrationSPI;
import javax.xml.namespace.QName;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -49,7 +51,8 @@
private RegistrationStatus status;
private Map<QName, Object> properties;
private String registrationHandle;
- private List<String> portletHandles;
+ private Set<PortletContext> portletContexts;
+ private transient RegistrationManager manager;
RegistrationImpl(String key, ConsumerSPI consumer, RegistrationStatus status,
Map<QName, Object> properties)
@@ -58,7 +61,7 @@
this.consumer = consumer;
this.status = status;
this.properties = new HashMap<QName, Object>(properties);
- this.portletHandles = new ArrayList<String>();
+ portletContexts = new HashSet<PortletContext>();
}
public String getPersistentKey()
@@ -81,6 +84,24 @@
return consumer;
}
+ public void addPortletContext(PortletContext portletContext)
+ {
+ portletContexts.add(portletContext);
+ manager.getPersistenceManager().saveChangesTo(this);
+ }
+
+ public void removePortletContext(PortletContext portletContext)
+ {
+ portletContexts.remove(portletContext);
+ manager.getPersistenceManager().saveChangesTo(this);
+ }
+
+ public void setManager(RegistrationManager manager)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(manager,
"RegistrationManager");
+ this.manager = manager;
+ }
+
public Map<QName, Object> getProperties()
{
return Collections.unmodifiableMap(properties);
@@ -183,18 +204,23 @@
this.status = status;
}
- public void clearAssociatedState()
+ public void updateProperties(Map registrationProperties)
{
- //todo: implement
+ properties = new HashMap(registrationProperties);
}
- public void updateProperties(Map registrationProperties)
+ public boolean knows(PortletContext portletContext)
{
- properties = new HashMap(registrationProperties);
+ return portletContexts.contains(portletContext);
}
- public List<String> getPortletHandles()
+ public boolean knows(String portletContextId)
{
- return portletHandles;
+ return knows(PortletContext.createPortletContext(portletContextId));
}
+
+ public Set<PortletContext> getKnownPortletContexts()
+ {
+ return Collections.unmodifiableSet(portletContexts);
+ }
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -29,11 +29,13 @@
import org.gatein.registration.InvalidConsumerDataException;
import org.gatein.registration.NoSuchRegistrationException;
import org.gatein.registration.Registration;
+import org.gatein.registration.RegistrationDestructionListener;
import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationPersistenceManager;
import org.gatein.registration.RegistrationPolicy;
import org.gatein.registration.RegistrationStatus;
+import org.gatein.registration.spi.RegistrationSPI;
import org.gatein.wsrp.registration.PropertyDescription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,6 +46,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -56,6 +61,7 @@
private RegistrationPolicy policy;
private RegistrationPersistenceManager persistenceManager;
+ private
AtomicReference<CopyOnWriteArrayList<RegistrationDestructionListener>>
listeners = new
AtomicReference<CopyOnWriteArrayList<RegistrationDestructionListener>>();
public RegistrationManagerImpl()
{
@@ -81,6 +87,26 @@
this.persistenceManager = persistenceManager;
}
+ public void addRegistrationDestructionListener(RegistrationDestructionListener
listener)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(listener,
"RegistrationDestructionListener");
+
+ listeners.compareAndSet(null, new
CopyOnWriteArrayList<RegistrationDestructionListener>());
+ listeners.get().add(listener);
+ }
+
+ public void removeRegistrationDestructionListener(RegistrationDestructionListener
listener)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(listener,
"RegistrationDestructionListener");
+
+ if (listeners.get() == null)
+ {
+ return;
+ }
+
+ listeners.get().remove(listener);
+ }
+
public Registration addRegistrationTo(String consumerName, Map<QName, Object>
registrationProperties, final Map<QName, ? extends PropertyDescription>
expectations, boolean createConsumerIfNeeded)
throws RegistrationException
{
@@ -93,12 +119,14 @@
Consumer consumer = getOrCreateConsumer(identity, createConsumerIfNeeded,
consumerName);
// create the actual registration
- Registration registration = persistenceManager.addRegistrationFor(identity,
registrationProperties);
+ RegistrationSPI registration = persistenceManager.addRegistrationFor(identity,
registrationProperties);
// let the policy decide what the handle should be
String handle =
policy.createRegistrationHandleFor(registration.getPersistentKey());
registration.setRegistrationHandle(handle);
+ registration.setManager(this);
+
return registration;
}
@@ -252,8 +280,21 @@
ParameterValidation.throwIllegalArgExceptionIfNull(registration,
"Registration");
registration.setStatus(RegistrationStatus.INVALID); // just in case...
-// registration.clearAssociatedState(); // todo: do we need to clear associated
state?
+ AtomicBoolean canRemove = new AtomicBoolean(true);
+ if (listeners.get() != null)
+ {
+ for (RegistrationDestructionListener listener : listeners.get())
+ {
+ RegistrationDestructionListener.Vote vote =
listener.destructionScheduledFor(registration);
+ if (canRemove.compareAndSet(false, vote.result))
+ {
+ throw new RegistrationException("Could not remove Registration
'" + registration.getRegistrationHandle()
+ + "' because listener '" + listener + "'
vetoed removal. Cause: " + vote.reason);
+ }
+ }
+ }
+
persistenceManager.removeRegistration(registration.getPersistentKey());
}
@@ -364,8 +405,6 @@
// make changes persistent
Consumer consumer = reg.getConsumer();
persistenceManager.saveChangesTo(consumer);
-
-// reg.clearAssociatedState(); //todo: do we need to clear the associated state?
If we do, should we wait until current operations are done?
}
}
@@ -377,13 +416,6 @@
*/
public void policyUpdatedTo(RegistrationPolicy policy)
{
-// policy.addPortletContextChangeListener(this); // GTNWSRP-72
setPolicy(policy);
}
-
- // GTNWSRP-72
- public void portletContextsHaveChanged(Registration registration)
- {
- persistenceManager.saveChangesTo(registration);
- }
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/DefaultRegistrationPolicy.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -24,6 +24,7 @@
package org.gatein.registration.policies;
import org.gatein.common.util.ParameterValidation;
+import org.gatein.pc.api.PortletContext;
import org.gatein.registration.Consumer;
import org.gatein.registration.DuplicateRegistrationException;
import org.gatein.registration.InvalidConsumerDataException;
@@ -31,17 +32,14 @@
import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationPolicy;
-import org.gatein.registration.RegistrationPortletContextChangeListener;
import org.gatein.registration.RegistrationStatus;
import org.gatein.wsrp.registration.PropertyDescription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.namespace.QName;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -57,11 +55,6 @@
{
private RegistrationPropertyValidator validator;
private static final Logger log =
LoggerFactory.getLogger(DefaultRegistrationPolicy.class);
-
- //Stores a list of the default portlet handles which should be available to all
registrations (ie not cloned handles)
- List<String> defaultPortletHandleList = new ArrayList<String>();
-
- List<RegistrationPortletContextChangeListener> listeners;
@Override
public boolean equals(Object o)
@@ -205,6 +198,11 @@
// this is already the behavior in the RegistrationPersistenceManager so no need to
do anything
}
+ public boolean allowAccessTo(PortletContext portletContext, Registration registration,
String operation)
+ {
+ return true;
+ }
+
/**
* Instructs this policy to use the specified RegistrationPropertyValidator. There
shouldn't be any need to call this
* method manually, as the validator is configured via the WSRP Producer xml
configuration file.
@@ -225,66 +223,4 @@
{
return validator;
}
-
- public void addPortletHandle(Registration registration, String portletHandle)
- {
- if (registration != null &&
!registration.getPortletHandles().contains(portletHandle))
- {
- registration.getPortletHandles().add(portletHandle);
- updatePortletContextListeners(registration);
- }
- }
-
- public boolean checkPortletHandle(Registration registration, String portletHandle)
- {
- if (defaultPortletHandleList.contains(portletHandle))
- {
- return true;
- }
-
- if (registration != null &&
registration.getPortletHandles().contains(portletHandle))
- {
- return true;
- }
-
- return false;
- }
-
- public void removePortletHandle(Registration registration, String portletHandle)
- {
- if (registration != null)
- {
- registration.getPortletHandles().remove(portletHandle);
- updatePortletContextListeners(registration);
- }
- }
-
- public void updatePortletHandles(List<String> portletHandles)
- {
- this.defaultPortletHandleList = portletHandles;
- }
-
- public void addPortletContextChangeListener(RegistrationPortletContextChangeListener
listener)
- {
- if (listeners == null)
- {
- listeners = new ArrayList<RegistrationPortletContextChangeListener>();
- }
-
- if (!listeners.contains(listener))
- {
- listeners.add(listener);
- }
- }
-
- protected void updatePortletContextListeners(Registration registration)
- {
- if (listeners != null)
- {
- for (RegistrationPortletContextChangeListener listener : listeners)
- {
- listener.portletContextsHaveChanged(registration);
- }
- }
- }
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/policies/RegistrationPolicyWrapper.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -24,7 +24,9 @@
package org.gatein.registration.policies;
import org.gatein.common.util.ParameterValidation;
+import org.gatein.pc.api.PortletContext;
import org.gatein.registration.InvalidConsumerDataException;
+import org.gatein.registration.Registration;
import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationPolicy;
@@ -99,29 +101,8 @@
return consumerName;
}
- /* GTNWSRP-72
- public void addPortletHandle(Registration registration, String portletHandle)
+ public boolean allowAccessTo(PortletContext portletContext, Registration registration,
String operation)
{
- delegate.addPortletHandle(registration, portletHandle);
+ return delegate.allowAccessTo(portletContext, registration, operation);
}
-
- public boolean checkPortletHandle(Registration registration, String portletHandle)
- {
- return delegate.checkPortletHandle(registration, portletHandle);
- }
-
- public void removePortletHandle(Registration registration, String portletHandle)
- {
- delegate.removePortletHandle(registration, portletHandle);
- }
-
- public void updatePortletHandles(List<String> portletHandles)
- {
- delegate.updatePortletHandles(portletHandles);
- }
-
- public void addPortletContextChangeListener(RegistrationPortletContextChangeListener
listener)
- {
- delegate.addPortletContextChangeListener(listener);
- }*/
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/spi/RegistrationSPI.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/spi/RegistrationSPI.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/spi/RegistrationSPI.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,28 +1,31 @@
/*
-* JBoss, a division of Red Hat
-* Copyright 2008, 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.
-*/
+ * JBoss, a division of Red Hat
+ * Copyright 2011, 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.gatein.registration.spi;
+import org.gatein.pc.api.PortletContext;
import org.gatein.registration.Registration;
+import org.gatein.registration.RegistrationManager;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -31,4 +34,10 @@
public interface RegistrationSPI extends Registration
{
ConsumerSPI getConsumer();
+
+ void addPortletContext(PortletContext portletContext);
+
+ void removePortletContext(PortletContext portletContext);
+
+ void setManager(RegistrationManager manager);
}
Deleted:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPPortletInvoker.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPPortletInvoker.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPPortletInvoker.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,224 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, 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.gatein.wsrp.producer;
-
-import org.gatein.pc.portlet.PortletInvokerInterceptor;
-import org.gatein.registration.RegistrationManager;
-
-/**
- * GTNWSRP-72
- *
- * @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
- * @version $Revision$
- */
-public class WSRPPortletInvoker extends PortletInvokerInterceptor
-{
- /** Registration Manager */
- private RegistrationManager registrationManager; //todo: make sure it's
multi-thread safe
-
- public RegistrationManager getRegistrationManager()
- {
- return registrationManager;
- }
-
- public void setRegistrationManager(RegistrationManager registrationManager)
- {
- this.registrationManager = registrationManager;
- }
-
- /*public Portlet getPortlet(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
- {
- checkPortletContext(portletContext);
- Portlet portlet = super.getPortlet(portletContext);
-
- if (!portlet.getContext().getId().equals(portletContext.getId()))
- {
- addPortletContext(portlet.getContext());
- }
-
- return portlet;
- }
-
- public Set<Portlet> getPortlets() throws PortletInvokerException
- {
- *//**
- * Note: due to the way the ProducerPortletInvoker work, when calling super.getPortlets()
it will
- * return the portlets not for the ProducerPortletInvoker from its parent, which should
only return
- * non-cloned Portlets.
- *//*
-
- Registration registration = RegistrationLocal.getRegistration();
- Set<Portlet> portlets = super.getPortlets();
-
- //We first need to let the RegistrationPolicy know that there are potentially new
portlets available
- //from the PortletContainer (Note: this only included actual portlets, not
clones).
- List<String> portletHandleList = new ArrayList<String>();
- for (Portlet portlet : portlets)
- {
- String portletHandle =
WSRPUtils.convertToWSRPPortletContext(portlet.getContext()).getPortletHandle();
- portletHandleList.add(portletHandle);
- }
- this.registrationManager.getPolicy().updatePortletHandles(portletHandleList);
-
- //Now that the RegistrationPolicy knows about the new Portlets, we need to make
- //sure that we only return portlets that the current registration has access to.
- Set<Portlet> acceptedPortlets = new LinkedHashSet<Portlet>();
- for (Portlet portlet : portlets)
- {
- String portletHandle =
WSRPUtils.convertToWSRPPortletContext(portlet.getContext()).getPortletHandle();
- if (this.registrationManager.getPolicy().checkPortletHandle(registration,
portletHandle))
- {
- acceptedPortlets.add(portlet);
- }
- }
-
- return acceptedPortlets;
- }
-
-
- public PortletInvocationResponse invoke(PortletInvocation invocation) throws
IllegalArgumentException,
- PortletInvokerException
- {
- checkPortletContext(invocation.getTarget());
-
- PortletInvocationResponse response = super.invoke(invocation);
-
- if (invocation.getInstanceContext() instanceof WSRPInstanceContext)
- {
- WSRPInstanceContext wsrpIC =
(WSRPInstanceContext)invocation.getInstanceContext();
- if (wsrpIC.wasModified() &&
!wsrpIC.getPortletContext().getId().equals(invocation.getTarget().getId()))
- {
- addPortletContext(wsrpIC.getPortletContext());
- }
- }
-
- return response;
- }
-
- public PortletContext createClone(PortletStateType stateType, PortletContext
portletContext)
- throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
- {
- checkPortletContext(portletContext);
-
- PortletContext clonedPortletContext = super.createClone(stateType,
portletContext);
-
- if (!portletContext.getId().equals(clonedPortletContext.getId()))
- {
- addPortletContext(clonedPortletContext);
- }
-
- return clonedPortletContext;
- }
-
- public List<DestroyCloneFailure> destroyClones(List<PortletContext>
portletContexts)
- throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
- {
- //TODO: fix this, we shouldn't remove the pc from the registration policy
unless its actually removed from the invoker cleanly
- for (PortletContext portletContext : portletContexts)
- {
- removePortletContext(portletContext);
- }
-
- return super.destroyClones(portletContexts);
- }
-
- public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException,
- PortletInvokerException, UnsupportedOperationException
- {
- checkPortletContext(portletContext);
- return super.getProperties(portletContext);
- }
-
- public PropertyMap getProperties(PortletContext portletContext, Set<String>
keys) throws IllegalArgumentException,
- PortletInvokerException, UnsupportedOperationException
- {
- checkPortletContext(portletContext);
- return super.getProperties(portletContext, keys);
- }
-
- public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes)
- throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
- {
- checkPortletContext(portletContext);
- PortletContext updatedPortletContext = super.setProperties(portletContext,
changes);
-
- if (!portletContext.getId().equals(updatedPortletContext.getId()))
- {
- addPortletContext(updatedPortletContext);
- }
-
- return updatedPortletContext;
- }
-
- public PortletContext importPortlet(PortletStateType stateType, PortletContext
originalPortletContext)
- throws PortletInvokerException, IllegalArgumentException
- {
- //The original portletcontext is the non cloned version and should be one the PC
available from the getPortlets operation
- checkPortletContext(originalPortletContext);
- PortletContext newPortletContext = super.importPortlet(stateType,
originalPortletContext);
-
- if (!newPortletContext.getId().equals(originalPortletContext.getId()))
- {
- addPortletContext(newPortletContext);
- }
-
- return newPortletContext;
- }
-
- public PortletContext exportPortlet(PortletStateType stateType, PortletContext
portletContext)
- throws PortletInvokerException, IllegalArgumentException
- {
- checkPortletContext(portletContext);
- return super.exportPortlet(stateType, portletContext);
- }
-
- protected boolean checkPortletContext(PortletContext portletContext) throws
PortletInvokerException
- {
- Registration registration = RegistrationLocal.getRegistration();
- String portletHandle =
WSRPUtils.convertToWSRPPortletContext(portletContext).getPortletHandle();
- if (this.getRegistrationManager().getPolicy().checkPortletHandle(registration,
portletHandle))
- {
- return true;
- }
- else
- {
- throw new NoSuchPortletException("The PortletContext " +
portletContext.getId() + " does not exist or the application is lacking permission to
access it.", portletContext.getId());
- }
- }
-
- protected void addPortletContext(PortletContext portletContext)
- {
- Registration registration = RegistrationLocal.getRegistration();
- String portletHandle =
WSRPUtils.convertToWSRPPortletContext(portletContext).getPortletHandle();
- this.getRegistrationManager().getPolicy().addPortletHandle(registration,
portletHandle);
- }
-
- protected void removePortletContext(PortletContext portletContext)
- {
- Registration registration = RegistrationLocal.getRegistration();
- String portletHandle =
WSRPUtils.convertToWSRPPortletContext(portletContext).getPortletHandle();
- this.getRegistrationManager().getPolicy().removePortletHandle(registration,
portletHandle);
- }*/
-}
-
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -402,9 +402,6 @@
registrationManager.setPolicy(registrationRequirements.getPolicy());
- // GTNWSRP-72
-//
registrationManager.getPolicy().addPortletContextChangeListener(registrationManager);
-
started = true;
}
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -165,41 +165,49 @@
PortletContext portletContext = getPortletPropertyDescription.getPortletContext();
WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(portletContext,
PORTLET_CONTEXT, GET_PORTLET_PROPERTY_DESCRIPTION);
- Registration registration =
producer.getRegistrationOrFailIfInvalid(getPortletPropertyDescription.getRegistrationContext());
+ try
+ {
+ Registration registration =
producer.getRegistrationOrFailIfInvalid(getPortletPropertyDescription.getRegistrationContext());
+ RegistrationLocal.setRegistration(registration);
- UserContext userContext = getPortletPropertyDescription.getUserContext();
- checkUserAuthorization(userContext);
+ UserContext userContext = getPortletPropertyDescription.getUserContext();
+ checkUserAuthorization(userContext);
- List<String> desiredLocales =
getPortletPropertyDescription.getDesiredLocales();
- Portlet portlet = getPortletFrom(portletContext, registration);
- PortletInfo info = portlet.getInfo();
- PreferencesInfo prefsInfo = info.getPreferences();
+ List<String> desiredLocales =
getPortletPropertyDescription.getDesiredLocales();
+ Portlet portlet = getPortletFrom(portletContext, registration);
+ PortletInfo info = portlet.getInfo();
+ PreferencesInfo prefsInfo = info.getPreferences();
- List<PropertyDescription> descs = Collections.emptyList();
- if (prefsInfo != null)
- {
- Set keySet = prefsInfo.getKeys();
- descs = new ArrayList<PropertyDescription>(keySet.size());
- for (Object key : keySet)
+ List<PropertyDescription> descs = Collections.emptyList();
+ if (prefsInfo != null)
{
- PreferenceInfo prefInfo = prefsInfo.getPreference((String)key);
+ Set keySet = prefsInfo.getKeys();
+ descs = new ArrayList<PropertyDescription>(keySet.size());
+ for (Object key : keySet)
+ {
+ PreferenceInfo prefInfo = prefsInfo.getPreference((String)key);
- // WSRP Spec 8.7: return only the portion of the Portlet's persistent
state the user is allowed to modify
- // if read only status is not determined, we consider it as being read-only
to be safe
- Boolean readOnly = prefInfo.isReadOnly();
- if (readOnly != null && !readOnly)
- {
- //todo: check what we should use key
- //todo: right now we only support String properties
- PropertyDescription desc =
WSRPTypeFactory.createPropertyDescription(prefInfo.getKey(), WSRPConstants.XSD_STRING);
-
desc.setLabel(Utils.convertToWSRPLocalizedString(prefInfo.getDisplayName(),
desiredLocales));
- desc.setHint(Utils.convertToWSRPLocalizedString(prefInfo.getDescription(),
desiredLocales));
- descs.add(desc);
+ // WSRP Spec 8.7: return only the portion of the Portlet's persistent
state the user is allowed to modify
+ // if read only status is not determined, we consider it as being
read-only to be safe
+ Boolean readOnly = prefInfo.isReadOnly();
+ if (readOnly != null && !readOnly)
+ {
+ //todo: check what we should use key
+ //todo: right now we only support String properties
+ PropertyDescription desc =
WSRPTypeFactory.createPropertyDescription(prefInfo.getKey(), WSRPConstants.XSD_STRING);
+
desc.setLabel(Utils.convertToWSRPLocalizedString(prefInfo.getDisplayName(),
desiredLocales));
+
desc.setHint(Utils.convertToWSRPLocalizedString(prefInfo.getDescription(),
desiredLocales));
+ descs.add(desc);
+ }
}
}
+
+ return WSRPTypeFactory.createPortletPropertyDescriptionResponse(descs);
}
-
- return WSRPTypeFactory.createPortletPropertyDescriptionResponse(descs);
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
public PortletContext clonePortlet(ClonePortlet clonePortlet)
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/ServiceDescriptionHandler.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/ServiceDescriptionHandler.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/ServiceDescriptionHandler.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -46,6 +46,7 @@
import org.gatein.pc.portlet.container.managed.ManagedObjectRegistryEventListener;
import org.gatein.pc.portlet.container.managed.ManagedPortletContainer;
import org.gatein.registration.Registration;
+import org.gatein.registration.RegistrationLocal;
import org.gatein.wsrp.WSRPTypeFactory;
import org.gatein.wsrp.WSRPUtils;
import org.gatein.wsrp.producer.ServiceDescriptionInterface;
@@ -103,42 +104,49 @@
{
WSRP2ExceptionFactory.throwOperationFailedIfValueIsMissing(gs,
"GetServiceDescription");
- RegistrationContext registrationContext = gs.getRegistrationContext();
-
- // if a RegistrationContext is provided, we need to validate the registration
information
- Registration registration = null;
- if (registrationContext != null)
+ try
{
- registration = producer.getRegistrationOrFailIfInvalid(registrationContext);
- }
+ // if a RegistrationContext is provided, we need to validate the registration
information
+ RegistrationContext registrationContext = gs.getRegistrationContext();
+ Registration registration = null;
+ if (registrationContext != null)
+ {
+ registration = producer.getRegistrationOrFailIfInvalid(registrationContext);
+ RegistrationLocal.setRegistration(registration);
+ }
- ProducerRegistrationRequirements requirements =
producer.getProducerRegistrationRequirements();
+ ProducerRegistrationRequirements requirements =
producer.getProducerRegistrationRequirements();
- //update the registration properties with the registration requirements
- serviceDescription.updateRegistrationProperties(requirements);
+ //update the registration properties with the registration requirements
+ serviceDescription.updateRegistrationProperties(requirements);
- // if we don't have registration information but a registration is required,
send registration props information
- boolean needsRegistrationProperties = registration == null &&
requirements.isRegistrationRequired();
+ // if we don't have registration information but a registration is required,
send registration props information
+ boolean needsRegistrationProperties = registration == null &&
requirements.isRegistrationRequired();
- // if we allow sending portlet descriptions even when not registered
- boolean needsPortletDescriptions = !(registration == null &&
requirements.isRegistrationRequired()
- && requirements.isRegistrationRequiredForFullDescription());
- if (needsPortletDescriptions)
- {
- Set<Portlet> portlets;
- try
+ // if we allow sending portlet descriptions even when not registered
+ boolean needsPortletDescriptions = !(registration == null &&
requirements.isRegistrationRequired()
+ && requirements.isRegistrationRequiredForFullDescription());
+ if (needsPortletDescriptions)
{
- portlets = producer.getRemotablePortlets();
+ Set<Portlet> portlets;
+ try
+ {
+ portlets = producer.getRemotablePortlets();
+ }
+ catch (PortletInvokerException e)
+ {
+ log.warn("Could not retrieve portlets. Reason:\n\t" +
e.getLocalizedMessage());
+ portlets = Collections.emptySet();
+ }
+ serviceDescription.updatePortletDescriptions(portlets,
gs.getDesiredLocales(), registration);
}
- catch (PortletInvokerException e)
- {
- log.warn("Could not retrieve portlets. Reason:\n\t" +
e.getLocalizedMessage());
- portlets = Collections.emptySet();
- }
- serviceDescription.updatePortletDescriptions(portlets, gs.getDesiredLocales(),
registration);
+
+ return serviceDescription.getServiceDescription(needsRegistrationProperties,
needsPortletDescriptions, gs.getPortletHandles());
}
-
- return serviceDescription.getServiceDescription(needsRegistrationProperties,
needsPortletDescriptions, gs.getPortletHandles());
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
public PortletDescription getPortletDescription(PortletContext portletContext,
List<String> desiredLocales, Registration registration) throws InvalidHandle,
OperationFailed
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/ActionRequestProcessor.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/ActionRequestProcessor.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/ActionRequestProcessor.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -126,7 +126,7 @@
return invocation;
}
- public BlockingInteractionResponse processResponse(PortletInvocationResponse
response)
+ protected BlockingInteractionResponse
internalProcessResponse(PortletInvocationResponse response)
{
if (response instanceof UpdateNavigationalStateResponse)
{
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/EventRequestProcessor.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/EventRequestProcessor.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/EventRequestProcessor.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -156,7 +156,7 @@
}
@Override
- public HandleEventsResponse processResponse(PortletInvocationResponse response)
+ protected HandleEventsResponse internalProcessResponse(PortletInvocationResponse
response)
{
if (response instanceof UpdateNavigationalStateResponse)
{
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/MimeResponseProcessor.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/MimeResponseProcessor.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/MimeResponseProcessor.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -69,7 +69,7 @@
return renderString;
}
- public Response processResponse(PortletInvocationResponse response)
+ protected Response internalProcessResponse(PortletInvocationResponse response)
{
ContentResponse content = (ContentResponse)response;
String itemString = null;
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/RequestProcessor.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/RequestProcessor.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/processors/RequestProcessor.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -40,6 +40,7 @@
import org.gatein.pc.api.state.AccessMode;
import org.gatein.pc.portlet.impl.jsr168.PortletUtils;
import org.gatein.registration.Registration;
+import org.gatein.registration.RegistrationLocal;
import org.gatein.wsrp.UserContextConverter;
import org.gatein.wsrp.WSRPConstants;
import org.gatein.wsrp.WSRPUtils;
@@ -197,9 +198,21 @@
abstract PortletInvocation initInvocation(WSRPPortletInvocationContext context);
- public abstract Response processResponse(PortletInvocationResponse response);
+ public Response processResponse(PortletInvocationResponse response)
+ {
+ try
+ {
+ return internalProcessResponse(response);
+ }
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
+ }
+ protected abstract Response internalProcessResponse(PortletInvocationResponse
response);
+
/**
* Returns the most appropriate information to base markup generation on based on a
Portlet's specified markup types
* and a markup request parameters.
Added:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/invoker/RegistrationCheckingPortletInvoker.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/invoker/RegistrationCheckingPortletInvoker.java
(rev 0)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/invoker/RegistrationCheckingPortletInvoker.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -0,0 +1,320 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2011, 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.gatein.wsrp.producer.invoker;
+
+import org.gatein.pc.api.NoSuchPortletException;
+import org.gatein.pc.api.Portlet;
+import org.gatein.pc.api.PortletContext;
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.api.PortletStateType;
+import org.gatein.pc.api.PortletStatus;
+import org.gatein.pc.api.invocation.PortletInvocation;
+import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
+import org.gatein.pc.api.spi.InstanceContext;
+import org.gatein.pc.api.state.DestroyCloneFailure;
+import org.gatein.pc.api.state.PropertyChange;
+import org.gatein.pc.api.state.PropertyMap;
+import org.gatein.pc.portlet.PortletInvokerInterceptor;
+import org.gatein.registration.Registration;
+import org.gatein.registration.RegistrationDestructionListener;
+import org.gatein.registration.RegistrationLocal;
+import org.gatein.registration.RegistrationManager;
+import org.gatein.registration.RegistrationPolicy;
+import org.gatein.registration.spi.RegistrationSPI;
+import org.gatein.wsrp.producer.handlers.processors.WSRPInstanceContext;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class RegistrationCheckingPortletInvoker extends PortletInvokerInterceptor
implements RegistrationDestructionListener
+{
+ /** Registration Manager */
+ private RegistrationManager registrationManager;
+
+ public void setRegistrationManager(RegistrationManager registrationManager)
+ {
+ this.registrationManager = registrationManager;
+ registrationManager.addRegistrationDestructionListener(this);
+ }
+
+ private RegistrationPolicy getPolicy()
+ {
+ return registrationManager.getPolicy();
+ }
+
+ public Portlet getPortlet(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
+ {
+ Registration registration = RegistrationLocal.getRegistration();
+ if (registration != null)
+ {
+ if (registration.knows(portletContext) || PortletStatus.OFFERED ==
super.getStatus(portletContext))
+ {
+ return super.getPortlet(portletContext);
+ }
+ else
+ {
+ String id = portletContext.getId();
+ throw new NoSuchPortletException("Registration '" +
registration.getRegistrationHandle()
+ + "' does not know the '"
+ + id + "' portlet", id);
+ }
+ }
+ else
+ {
+ return super.getPortlet(portletContext);
+ }
+ }
+
+ public Set<Portlet> getPortlets() throws PortletInvokerException
+ {
+ Set<Portlet> portlets = new HashSet<Portlet>(super.getPortlets());
+ Registration registration = RegistrationLocal.getRegistration();
+
+ if (registration != null)
+ {
+ Set<PortletContext> contexts = registration.getKnownPortletContexts();
+ for (PortletContext context : contexts)
+ {
+ portlets.add(super.getPortlet(context));
+ }
+ }
+
+ return portlets;
+ }
+
+ private RegistrationSPI getRegistrationAsSPI() throws PortletInvokerException
+ {
+ Registration registration = RegistrationLocal.getRegistration();
+
+ if (registration == null)
+ {
+ return null;
+ }
+
+ if (registration instanceof RegistrationSPI)
+ {
+ return (RegistrationSPI)registration;
+ }
+ else
+ {
+ throw new PortletInvokerException("Cannot deal with non-RegistrationSPI
Registrations.");
+ }
+ }
+
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws
IllegalArgumentException, PortletInvokerException
+ {
+ PortletContext portletContext = invocation.getTarget();
+
+ RegistrationSPI registration = getRegistrationAsSPI();
+
+ if (registration != null)
+ {
+ checkOperationIsAllowed(portletContext, registration, "invoke");
+
+ PortletInvocationResponse response = super.invoke(invocation);
+
+ InstanceContext instanceContext = invocation.getInstanceContext();
+ if (instanceContext instanceof WSRPInstanceContext)
+ {
+ WSRPInstanceContext wsrpIC = (WSRPInstanceContext)instanceContext;
+ PortletContext responseContext = wsrpIC.getPortletContext();
+ if (wsrpIC.wasModified() &&
!responseContext.getId().equals(portletContext.getId()))
+ {
+ registration.addPortletContext(responseContext);
+ }
+ }
+
+ return response;
+ }
+ else
+ {
+ return super.invoke(invocation);
+ }
+
+ }
+
+ private void checkOperationIsAllowed(PortletContext portletContext, Registration
registration, String operation) throws NoSuchPortletException
+ {
+ if (!getPolicy().allowAccessTo(portletContext, registration, operation))
+ {
+ String id = portletContext.getId();
+ throw new NoSuchPortletException("The PortletContext '" + id
+ + "' does not exist or the application is lacking permission to
access it for operation '"
+ + operation + "'", id);
+ }
+ }
+
+ public PortletContext createClone(PortletStateType stateType, PortletContext
portletContext)
+ throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ RegistrationSPI registration = getRegistrationAsSPI();
+
+ if (registration != null)
+ {
+ checkOperationIsAllowed(portletContext, registration, "createClone");
+
+ PortletContext clonedPortletContext = super.createClone(stateType,
portletContext);
+ registration.addPortletContext(clonedPortletContext);
+
+ return clonedPortletContext;
+ }
+ else
+ {
+ return super.createClone(stateType, portletContext);
+ }
+ }
+
+ public List<DestroyCloneFailure> destroyClones(List<PortletContext>
portletContexts)
+ throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ RegistrationSPI registration = getRegistrationAsSPI();
+
+ if (registration != null)
+ {
+ for (PortletContext portletContext : portletContexts)
+ {
+ checkOperationIsAllowed(portletContext, registration,
"destroyClones");
+ }
+ }
+
+ List<DestroyCloneFailure> cloneFailures =
super.destroyClones(portletContexts);
+ boolean noFailures = cloneFailures.isEmpty();
+
+ if (registration != null)
+ {
+ for (PortletContext portletContext : portletContexts)
+ {
+ // only remove the portlet context if there are no failures or it's not
part of the failed clones
+ if (noFailures || !cloneFailures.contains(new
DestroyCloneFailure(portletContext.getId())))
+ {
+ registration.removePortletContext(portletContext);
+ }
+ }
+ }
+
+ return cloneFailures;
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException,
+ PortletInvokerException, UnsupportedOperationException
+ {
+ checkOperationIsAllowed(portletContext, RegistrationLocal.getRegistration(),
"getProperties");
+ return super.getProperties(portletContext);
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext, Set<String>
keys) throws IllegalArgumentException,
+ PortletInvokerException, UnsupportedOperationException
+ {
+ checkOperationIsAllowed(portletContext, RegistrationLocal.getRegistration(),
"getProperties");
+ return super.getProperties(portletContext, keys);
+ }
+
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes)
+ throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ RegistrationSPI registration = getRegistrationAsSPI();
+
+ if (registration != null)
+ {
+ checkOperationIsAllowed(portletContext, registration,
"setProperties");
+ PortletContext updatedPortletContext = super.setProperties(portletContext,
changes);
+
+ if (!portletContext.getId().equals(updatedPortletContext.getId()))
+ {
+ registration.addPortletContext(updatedPortletContext);
+ }
+
+ return updatedPortletContext;
+ }
+ else
+ {
+ return super.setProperties(portletContext, changes);
+ }
+ }
+
+ public PortletContext importPortlet(PortletStateType stateType, PortletContext
originalPortletContext)
+ throws PortletInvokerException, IllegalArgumentException
+ {
+ // The original portletcontext is the non cloned version and should be one the PC
available from the getPortlets operation
+ RegistrationSPI registration = getRegistrationAsSPI();
+
+ if (registration != null)
+ {
+ checkOperationIsAllowed(originalPortletContext, registration,
"importPortlet");
+
+ PortletContext newPortletContext = super.importPortlet(stateType,
originalPortletContext);
+
+ if (!newPortletContext.getId().equals(originalPortletContext.getId()))
+ {
+ registration.addPortletContext(newPortletContext);
+ }
+
+ return newPortletContext;
+ }
+ else
+ {
+ return super.importPortlet(stateType, originalPortletContext);
+ }
+ }
+
+ public PortletContext exportPortlet(PortletStateType stateType, PortletContext
portletContext)
+ throws PortletInvokerException, IllegalArgumentException
+ {
+ checkOperationIsAllowed(portletContext, RegistrationLocal.getRegistration(),
"exportPortlet");
+ return super.exportPortlet(stateType, portletContext);
+ }
+
+ /**
+ * Destroy the clones scoped by this Registration.
+ *
+ * @param registration the Registration about to be destroyed
+ * @return
+ */
+ public Vote destructionScheduledFor(Registration registration)
+ {
+ if (registration != null)
+ {
+ List<PortletContext> portletContexts = new
ArrayList<PortletContext>(registration.getKnownPortletContexts());
+ List<DestroyCloneFailure> failures = Collections.emptyList();
+ try
+ {
+ failures = super.destroyClones(portletContexts);
+ }
+ catch (PortletInvokerException e)
+ {
+ return Vote.negativeVote("Couldn't destroy clones: " +
failures);
+ }
+ }
+
+ return RegistrationDestructionListener.SUCCESS;
+ }
+}
Modified:
components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationTestCase.java
===================================================================
---
components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationTestCase.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationTestCase.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -24,9 +24,11 @@
package org.gatein.registration;
import junit.framework.TestCase;
+import org.gatein.pc.api.PortletContext;
import org.gatein.registration.impl.RegistrationManagerImpl;
import org.gatein.registration.impl.RegistrationPersistenceManagerImpl;
import org.gatein.registration.policies.DefaultRegistrationPolicy;
+import org.gatein.registration.spi.RegistrationSPI;
import org.gatein.wsrp.WSRPConstants;
import org.gatein.wsrp.registration.PropertyDescription;
import org.gatein.wsrp.registration.RegistrationPropertyDescription;
@@ -34,6 +36,7 @@
import javax.xml.namespace.QName;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
@@ -42,7 +45,7 @@
*/
public class RegistrationTestCase extends TestCase
{
- private Registration registration;
+ private RegistrationSPI registration;
private Map<QName, Object> registrationProperties;
protected void setUp() throws Exception
@@ -68,7 +71,7 @@
expectations.put(prop1Name, new RegistrationPropertyDescription(prop1Name,
WSRPConstants.XSD_STRING));
expectations.put(prop2Name, new RegistrationPropertyDescription(prop2Name,
WSRPConstants.XSD_STRING));
- registration = manager.addRegistrationTo("name", registrationProperties,
expectations, true);
+ registration = (RegistrationSPI)manager.addRegistrationTo("name",
registrationProperties, expectations, true);
}
public void testGetPropertiesIsUnmodifiable()
@@ -155,9 +158,21 @@
assertTrue(!registration.hasEqualProperties(registrationProperties));
}
- public void testClearAssociatedState()
+ public void testPortletContextOperations()
{
- //todo: implement
+ PortletContext foo = PortletContext.createPortletContext("foo");
+
+ registration.addPortletContext(foo);
+ assertTrue(registration.knows(foo));
+ assertTrue(registration.knows("foo"));
+ Set<PortletContext> knownPortletContexts =
registration.getKnownPortletContexts();
+ assertEquals(1, knownPortletContexts.size());
+ assertTrue(knownPortletContexts.contains(foo));
+
+ registration.removePortletContext(foo);
+ assertFalse(registration.knows(foo));
+ assertFalse(registration.knows("foo"));
+ knownPortletContexts = registration.getKnownPortletContexts();
+ assertTrue(knownPortletContexts.isEmpty());
}
-
}
Deleted:
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPPortletInvokerTestCase.java
===================================================================
---
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPPortletInvokerTestCase.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPPortletInvokerTestCase.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,58 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, 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.gatein.wsrp.producer;
-
-import junit.framework.TestCase;
-import org.gatein.pc.api.Portlet;
-import org.gatein.pc.api.PortletContext;
-import org.gatein.pc.api.PortletInvoker;
-import org.gatein.pc.api.PortletInvokerException;
-import org.gatein.registration.impl.RegistrationManagerImpl;
-import org.gatein.registration.policies.DefaultRegistrationPolicy;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class WSRPPortletInvokerTestCase extends TestCase
-{
- public void testGetPortletShouldWorkDirectly() throws PortletInvokerException
- {
- WSRPPortletInvoker invoker = new WSRPPortletInvoker();
- RegistrationManagerImpl registrationManager = new RegistrationManagerImpl();
- registrationManager.setPolicy(new DefaultRegistrationPolicy());
- invoker.setRegistrationManager(registrationManager);
-
- PortletInvoker next = mock(PortletInvoker.class);
- PortletContext portletContext =
PortletContext.createPortletContext("foo");
- Portlet portlet = mock(Portlet.class);
- when(next.getPortlet(portletContext)).thenReturn(portlet);
-
- invoker.setNext(next);
- assertEquals(portlet, invoker.getPortlet(portletContext));
- }
-}
Modified:
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPolicy.java
===================================================================
---
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPolicy.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/config/TestRegistrationPolicy.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -23,17 +23,15 @@
package org.gatein.wsrp.producer.config;
+import org.gatein.pc.api.PortletContext;
import org.gatein.registration.InvalidConsumerDataException;
import org.gatein.registration.Registration;
import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationPolicy;
-import org.gatein.registration.RegistrationPortletContextChangeListener;
import org.gatein.wsrp.registration.PropertyDescription;
import javax.xml.namespace.QName;
-
-import java.util.List;
import java.util.Map;
/**
@@ -70,25 +68,8 @@
{
}
- public void addPortletHandle(Registration registration, String portletHandle)
+ public boolean allowAccessTo(PortletContext portletContext, Registration registration,
String operation)
{
- }
-
- public boolean checkPortletHandle(Registration registration, String portletHandle)
- {
return true;
}
-
- public void removePortletHandle(Registration registration, String portletHandle)
- {
- }
-
- public void updatePortletHandles(List<String> portletHandles)
- {
- }
-
- public void addPortletContextChangeListener(RegistrationPortletContextChangeListener
listener)
- {
- }
-
}
Copied:
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/invoker/RegistrationCheckingPortletInvokerTestCase.java
(from rev 5750,
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPPortletInvokerTestCase.java)
===================================================================
---
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/invoker/RegistrationCheckingPortletInvokerTestCase.java
(rev 0)
+++
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/invoker/RegistrationCheckingPortletInvokerTestCase.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2011, 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.gatein.wsrp.producer.invoker;
+
+import junit.framework.TestCase;
+import org.gatein.pc.api.Portlet;
+import org.gatein.pc.api.PortletContext;
+import org.gatein.pc.api.PortletInvoker;
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.registration.impl.RegistrationManagerImpl;
+import org.gatein.registration.policies.DefaultRegistrationPolicy;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class RegistrationCheckingPortletInvokerTestCase extends TestCase
+{
+ public void testGetPortletShouldWorkDirectly() throws PortletInvokerException
+ {
+ RegistrationCheckingPortletInvoker invoker = new
RegistrationCheckingPortletInvoker();
+ RegistrationManagerImpl registrationManager = new RegistrationManagerImpl();
+ registrationManager.setPolicy(new DefaultRegistrationPolicy());
+ invoker.setRegistrationManager(registrationManager);
+
+ PortletInvoker next = mock(PortletInvoker.class);
+ PortletContext portletContext =
PortletContext.createPortletContext("foo");
+ Portlet portlet = mock(Portlet.class);
+ when(next.getPortlet(portletContext)).thenReturn(portlet);
+
+ invoker.setNext(next);
+ assertEquals(portlet, invoker.getPortlet(portletContext));
+ }
+}
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -62,6 +62,7 @@
import org.oasis.wsrp.v2.ImportPortlets;
import org.oasis.wsrp.v2.ImportPortletsResponse;
import org.oasis.wsrp.v2.ImportedPortlet;
+import org.oasis.wsrp.v2.InvalidHandle;
import org.oasis.wsrp.v2.InvalidRegistration;
import org.oasis.wsrp.v2.Lifetime;
import org.oasis.wsrp.v2.MarkupContext;
@@ -1100,8 +1101,6 @@
//Check that the proper registration context can access it
checkDefaultMarkup(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle(),
toRegistrationContext);
- /*
- GTNWSRP-72
//Check that the null registration cannot access it
try
{
@@ -1111,7 +1110,7 @@
catch (InvalidHandle e)
{
//expected
- }*/
+ }
}
catch (Exception e)
{
@@ -1148,18 +1147,16 @@
//Check that the proper registration context can access it
checkDefaultMarkup(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle(),
fromRegistrationContext);
- /*
- GTNWSRP-72
//Check that the null registration cannot access it
try
{
checkDefaultMarkup(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle(),
null);
- ExtendedAssert.fail("The null registration context should not be able to
access this portlet");
+ fail("The null registration context should not be able to access this
portlet");
}
catch (InvalidHandle e)
{
//expected
- }*/
+ }
}
/** Check that we can copy one portlet from one registration context to another */
@@ -1185,15 +1182,14 @@
checkSimpleCopyPortletsResponse(response, createStringList(handle),
createStringList());
//Check that the proper registration context can access it
-
checkDefaultMarkup(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle(),
toRegistrationContext);
+ String portletHandle =
response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle();
+ checkDefaultMarkup(portletHandle, toRegistrationContext);
- /*
- GTNWSRP-72
//Check that the original registration cannot access it
try
{
-
checkDefaultMarkup(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle(),
fromRegistrationContext);
- ExtendedAssert.fail("The original registration context should not be able
to access this portlet");
+ checkDefaultMarkup(portletHandle, fromRegistrationContext);
+ fail("The original registration context should not be able to access this
portlet");
}
catch (InvalidHandle e)
{
@@ -1202,13 +1198,13 @@
//Check that the null registration cannot access it
try
{
-
checkDefaultMarkup(response.getCopiedPortlets().get(0).getNewPortletContext().getPortletHandle(),
null);
- ExtendedAssert.fail("The null registration context should not be able to
access this portlet");
+ checkDefaultMarkup(portletHandle, null);
+ fail("The null registration context should not be able to access this
portlet");
}
catch (InvalidHandle e)
{
//expected
- }*/
+ }
}
@Test
@@ -1334,9 +1330,10 @@
CopyPortletsResponse response = producer.copyPortlets(copyPortlets);
assertEquals(1, response.getFailedPortlets().size());
-
assertTrue(response.getFailedPortlets().get(0).getPortletHandles().contains(fakePortletContext1));
-
assertTrue(response.getFailedPortlets().get(0).getPortletHandles().contains(fakePortletContext2));
-
assertTrue(response.getFailedPortlets().get(0).getErrorCode().getLocalPart().contains("InvalidHandle"));
+ FailedPortlets failedPortlets = response.getFailedPortlets().get(0);
+ assertTrue(failedPortlets.getPortletHandles().contains(fakePortletContext1));
+ assertTrue(failedPortlets.getPortletHandles().contains(fakePortletContext2));
+
assertTrue(failedPortlets.getErrorCode().getLocalPart().contains("InvalidHandle"));
assertEquals(1, response.getCopiedPortlets().size());
assertEquals(getDefaultHandle(),
response.getCopiedPortlets().get(0).getFromPortletHandle());
@@ -1426,7 +1423,6 @@
public void checkClonePortletAvailability(RegistrationContext registrationContextA,
RegistrationContext registrationContextB) throws Exception
{
- String handle = getDefaultHandle();
PortletContext portletContext =
WSRPTypeFactory.createPortletContext(getDefaultHandle());
ClonePortlet clonePortlet =
WSRPTypeFactory.createClonePortlet(registrationContextA, portletContext, null);
PortletContext clonedPortletContext = producer.clonePortlet(clonePortlet);
@@ -1437,8 +1433,6 @@
getMarkupA.setRegistrationContext(registrationContextA);
producer.getMarkup(getMarkupA);
- /*
- GTNWSRP-72
try
{
GetMarkup getMarkupB =
createDefaultGetMarkup(clonedPortletContext.getPortletHandle());
@@ -1449,7 +1443,7 @@
catch (InvalidHandle e)
{
//expected
- }*/
+ }
}
@Test
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/producer-sar/META-INF/jboss-beans.xml
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/producer-sar/META-INF/jboss-beans.xml 2011-01-18
17:12:33 UTC (rev 5779)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/producer-sar/META-INF/jboss-beans.xml 2011-01-18
17:33:16 UTC (rev 5780)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, a division of Red Hat
- ~ Copyright 2010, Red Hat Middleware, LLC, and individual
+ ~ Copyright 2011, 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.
@@ -67,13 +67,13 @@
</property>
</bean>
- <bean name="WSRPPortletInvoker"
class="org.gatein.wsrp.producer.WSRPPortletInvoker">
- <property name="next">
- <inject bean="PortletInvoker"/>
- </property>
- <property name="registrationManager">
- <inject bean="RegistrationManagerService"/>
- </property>
+ <bean name="WSRPPortletInvoker"
class="org.gatein.wsrp.producer.invoker.RegistrationCheckingPortletInvoker">
+ <property name="next">
+ <inject bean="PortletInvoker"/>
+ </property>
+ <property name="registrationManager">
+ <inject bean="RegistrationManagerService"/>
+ </property>
</bean>
<!-- TODO: may need to write a new class for this -->