Author: chris.laprun(a)jboss.com
Date: 2011-03-29 10:05:46 -0400 (Tue, 29 Mar 2011)
New Revision: 6134
Added:
components/wsrp/trunk/admin-gui/src/test/java/org/gatein/wsrp/admin/ui/BeanContextTestCase.java
components/wsrp/trunk/admin-gui/src/test/resources/
components/wsrp/trunk/admin-gui/src/test/resources/Resource.properties
Modified:
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java
components/wsrp/trunk/admin-gui/src/main/webapp/WEB-INF/classes/Resource.properties
components/wsrp/trunk/admin-gui/src/main/webapp/WEB-INF/classes/Resource_fr.properties
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/JCRRegistrationPersistenceManager.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/AbstractRegistrationPersistenceManager.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPersistenceManager.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/impl/RegistrationPersistenceManagerImpl.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/handlers/PortletManagementHandler.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/RegistrationHandler.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/invoker/RegistrationCheckingPortletInvoker.java
components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationTestCase.java
Log:
- GTNWSRP-214: Do not swallow exceptions in the registration persistence code.
- Fixed error reporting and improper messages (do NOT forget to properly escape
single-quotes in properties files >_<).
Modified:
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java
===================================================================
---
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java 2011-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -642,11 +642,23 @@
}
}
- beanContext.createLocalizedMessage(BeanContext.STATUS, IMPORT_SUCCESS,
beanContext.getInfoSeverity(), importCount);
+ // only display success message if we have imported at least one portlet
successfully
+ if (importCount > 0)
+ {
+ beanContext.createLocalizedMessage(BeanContext.STATUS, IMPORT_SUCCESS,
beanContext.getInfoSeverity(), importCount);
+ }
+
SortedMap<QName, List<String>>
errorCodesToFailedPortletHandlesMapping =
info.getErrorCodesToFailedPortletHandlesMapping();
if (!errorCodesToFailedPortletHandlesMapping.isEmpty())
{
- beanContext.createErrorMessage(FAILED_PORTLETS,
errorCodesToFailedPortletHandlesMapping);
+ for (Map.Entry<QName, List<String>> entry :
errorCodesToFailedPortletHandlesMapping.entrySet())
+ {
+ QName errorCode = entry.getKey();
+ for (String handle : entry.getValue())
+ {
+ beanContext.createErrorMessage(FAILED_PORTLETS, handle + " (cause:
" + errorCode + ")");
+ }
+ }
}
return ConsumerManagerBean.CONSUMERS;
@@ -656,7 +668,6 @@
beanContext.createErrorMessageFrom(e);
return null;
}
-
}
public String deleteExport()
@@ -704,12 +715,12 @@
{
return consumer.getMigrationService().isAvailableExportInfosEmpty();
}
-
+
public boolean isWssEnabled()
{
return consumer.getProducerInfo().getEndpointConfigurationInfo().getWSSEnabled();
}
-
+
public void setWssEnabled(boolean enable)
{
consumer.getProducerInfo().getEndpointConfigurationInfo().setWSSEnabled(enable);
Modified:
components/wsrp/trunk/admin-gui/src/main/webapp/WEB-INF/classes/Resource.properties
===================================================================
---
components/wsrp/trunk/admin-gui/src/main/webapp/WEB-INF/classes/Resource.properties 2011-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/admin-gui/src/main/webapp/WEB-INF/classes/Resource.properties 2011-03-29
14:05:46 UTC (rev 6134)
@@ -189,7 +189,7 @@
bean_consumer_malformed_url = ''{0}'' is not a valid URL: {1}
bean_consumer_update_success = Successfully updated consumer!
bean_consumer_import_success = {0} portlets were successfully imported!
-bean_consumer_import_failed_portlets = The following portlets couldn't be imported:
{0}
+bean_consumer_import_failed_portlets = The following portlet couldn''t be
imported: {0}
# ConsumerManagerBean
bean_consumermanager_invalid_new_consumer_name = Need a non-null, non-empty name for the
new consumer!
Modified:
components/wsrp/trunk/admin-gui/src/main/webapp/WEB-INF/classes/Resource_fr.properties
===================================================================
---
components/wsrp/trunk/admin-gui/src/main/webapp/WEB-INF/classes/Resource_fr.properties 2011-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/admin-gui/src/main/webapp/WEB-INF/classes/Resource_fr.properties 2011-03-29
14:05:46 UTC (rev 6134)
@@ -175,7 +175,7 @@
import_import=Importer
import_use=Importer?
bean_consumer_import_success=''{0}'' portlets ont �t� correctement
import�es!
-bean_consumer_import_failed_portlets=Les portlets suivantes n'ont pas pu �tre
import�es: {0}
+bean_consumer_import_failed_portlets=La portlet suivante n''a pas pu �tre
import�e: {0}
edit_consumer_export=Exporter portlets
edit_consumer_export_title=Portlets en export
edit_consumer_import=Importer portlets
Added:
components/wsrp/trunk/admin-gui/src/test/java/org/gatein/wsrp/admin/ui/BeanContextTestCase.java
===================================================================
---
components/wsrp/trunk/admin-gui/src/test/java/org/gatein/wsrp/admin/ui/BeanContextTestCase.java
(rev 0)
+++
components/wsrp/trunk/admin-gui/src/test/java/org/gatein/wsrp/admin/ui/BeanContextTestCase.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -0,0 +1,119 @@
+/*
+* 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.
+*/
+
+package org.gatein.wsrp.admin.ui;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class BeanContextTestCase extends TestCase
+{
+ public void testMessageFormatting()
+ {
+ assertEquals("foo value",
BeanContext.getLocalizedMessage("foo", Locale.getDefault()));
+ assertEquals("foo value",
BeanContext.getLocalizedMessage("foo", Locale.getDefault(),
"Resource", "blah"));
+ assertEquals("param value: foo",
BeanContext.getLocalizedMessage("1param", Locale.getDefault(),
"Resource", "foo"));
+ assertEquals("param1 value: foo param2 value: bar",
BeanContext.getLocalizedMessage("2params", Locale.getDefault(),
"Resource", "foo", "bar"));
+ }
+
+ public void testErrorMessage()
+ {
+ TestBeanContext context = new TestBeanContext();
+ context.createErrorMessage("1param", "error");
+ assertEquals("param value: error", context.getMessage());
+ assertEquals(TestBeanContext.ERROR, context.getSeverity());
+ }
+
+ private static class TestBeanContext extends BeanContext
+ {
+ private static final String ERROR = "ERROR";
+ private static final String INFO = "INFO";
+ private String message;
+ private Object severity;
+ private Object[] params;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ public Object getSeverity()
+ {
+ return severity;
+ }
+
+ public Object[] getParams()
+ {
+ return params;
+ }
+
+ @Override
+ public String getParameter(String key)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected void createMessage(String target, String message, Object severity,
Object... additionalParams)
+ {
+ this.message = message;
+ this.severity = severity;
+ this.params = additionalParams;
+ }
+
+ @Override
+ protected Object getErrorSeverity()
+ {
+ return ERROR;
+ }
+
+ @Override
+ protected Object getInfoSeverity()
+ {
+ return INFO;
+ }
+
+ @Override
+ protected Locale getLocale()
+ {
+ return Locale.getDefault();
+ }
+
+ @Override
+ public String getServerAddress()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Map<String, Object> getSessionMap()
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
Added: components/wsrp/trunk/admin-gui/src/test/resources/Resource.properties
===================================================================
--- components/wsrp/trunk/admin-gui/src/test/resources/Resource.properties
(rev 0)
+++ components/wsrp/trunk/admin-gui/src/test/resources/Resource.properties 2011-03-29
14:05:46 UTC (rev 6134)
@@ -0,0 +1,3 @@
+foo=foo value
+1param=param value: {0}
+2params=param1 value: {0} param2 value: {1}
\ No newline at end of file
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/JCRRegistrationPersistenceManager.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/JCRRegistrationPersistenceManager.java 2011-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/JCRRegistrationPersistenceManager.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -98,7 +98,7 @@
}
@Override
- protected RegistrationSPI internalRemoveRegistration(String registrationId)
+ protected RegistrationSPI internalRemoveRegistration(String registrationId) throws
RegistrationException
{
Registration registration = getRegistration(registrationId);
remove(registration.getPersistentKey(), RegistrationMapping.class);
@@ -107,7 +107,7 @@
}
@Override
- protected RegistrationSPI internalCreateRegistration(ConsumerSPI consumer, Map
registrationProperties)
+ protected RegistrationSPI internalCreateRegistration(ConsumerSPI consumer, Map
registrationProperties) throws RegistrationException
{
ChromatticSession session = persister.getSession();
RegistrationSPI registration = null;
@@ -121,15 +121,15 @@
}
catch (Exception e)
{
- e.printStackTrace(); // todo fix me
persister.closeSession(false);
+ throw new RegistrationException(e);
}
return registration;
}
@Override
- protected ConsumerSPI internalRemoveConsumer(String consumerId)
+ protected ConsumerSPI internalRemoveConsumer(String consumerId) throws
RegistrationException
{
remove(consumerId, ConsumerMapping.class);
@@ -144,7 +144,7 @@
}
@Override
- protected ConsumerSPI internalCreateConsumer(String consumerId, String consumerName)
+ protected ConsumerSPI internalCreateConsumer(String consumerId, String consumerName)
throws RegistrationException
{
ConsumerSPI consumer = super.internalCreateConsumer(consumerId, consumerName);
@@ -160,15 +160,15 @@
}
catch (Exception e)
{
- e.printStackTrace(); // todo: fix me
persister.closeSession(false);
+ throw new RegistrationException(e);
}
return consumer;
}
@Override
- protected ConsumerSPI internalSaveChangesTo(Consumer consumer)
+ protected ConsumerSPI internalSaveChangesTo(Consumer consumer) throws
RegistrationException
{
ConsumerSPI consumerSPI = super.internalSaveChangesTo(consumer);
@@ -181,14 +181,14 @@
}
catch (Exception e)
{
- e.printStackTrace(); // todo: fix me
persister.closeSession(false);
+ throw new RegistrationException(e);
}
return consumerSPI;
}
- protected RegistrationSPI internalSaveChangesTo(Registration registration)
+ protected RegistrationSPI internalSaveChangesTo(Registration registration) throws
RegistrationException
{
RegistrationSPI registrationSPI = super.internalSaveChangesTo(registration);
@@ -201,15 +201,15 @@
}
catch (Exception e)
{
- e.printStackTrace(); //todo: fix me
persister.closeSession(false);
+ throw new RegistrationException(e);
}
return registrationSPI;
}
@Override
- protected ConsumerGroupSPI internalRemoveConsumerGroup(String name)
+ protected ConsumerGroupSPI internalRemoveConsumerGroup(String name) throws
RegistrationException
{
try
{
@@ -225,7 +225,7 @@
}
@Override
- protected ConsumerGroupSPI internalCreateConsumerGroup(String name)
+ protected ConsumerGroupSPI internalCreateConsumerGroup(String name) throws
RegistrationException
{
ConsumerGroupSPI group = super.internalCreateConsumerGroup(name);
@@ -240,8 +240,8 @@
}
catch (Exception e)
{
- e.printStackTrace(); // todo: fix me
persister.closeSession(false);
+ throw new RegistrationException(e);
}
return group;
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-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/AbstractRegistrationPersistenceManager.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -48,7 +48,7 @@
return consumer;
}
- public void saveChangesTo(Consumer consumer)
+ public void saveChangesTo(Consumer consumer) throws RegistrationException
{
ParameterValidation.throwIllegalArgExceptionIfNull(consumer,
"Consumer");
@@ -60,7 +60,7 @@
internalSaveChangesTo(consumer);
}
- public void saveChangesTo(Registration registration)
+ public void saveChangesTo(Registration registration) throws RegistrationException
{
ParameterValidation.throwIllegalArgExceptionIfNull(registration,
"Registration");
@@ -164,27 +164,27 @@
// internal methods: extension points for subclasses
- protected abstract void internalAddRegistration(RegistrationSPI registration);
+ protected abstract void internalAddRegistration(RegistrationSPI registration) throws
RegistrationException;
- protected abstract RegistrationSPI internalRemoveRegistration(String registrationId);
+ protected abstract RegistrationSPI internalRemoveRegistration(String registrationId)
throws RegistrationException;
- protected abstract RegistrationSPI internalCreateRegistration(ConsumerSPI consumer,
Map<QName, Object> registrationProperties);
+ protected abstract RegistrationSPI internalCreateRegistration(ConsumerSPI consumer,
Map<QName, Object> registrationProperties) throws RegistrationException;
- protected abstract void internalAddConsumer(ConsumerSPI consumer);
+ protected abstract void internalAddConsumer(ConsumerSPI consumer) throws
RegistrationException;
- protected abstract ConsumerSPI internalRemoveConsumer(String consumerId);
+ protected abstract ConsumerSPI internalRemoveConsumer(String consumerId) throws
RegistrationException;
- protected abstract ConsumerSPI internalCreateConsumer(String consumerId, String
consumerName);
+ protected abstract ConsumerSPI internalCreateConsumer(String consumerId, String
consumerName) throws RegistrationException;
- protected abstract ConsumerSPI internalSaveChangesTo(Consumer consumer);
+ protected abstract ConsumerSPI internalSaveChangesTo(Consumer consumer) throws
RegistrationException;
- protected abstract RegistrationSPI internalSaveChangesTo(Registration registration);
+ protected abstract RegistrationSPI internalSaveChangesTo(Registration registration)
throws RegistrationException;
- protected abstract void internalAddConsumerGroup(ConsumerGroupSPI group);
+ protected abstract void internalAddConsumerGroup(ConsumerGroupSPI group) throws
RegistrationException;
- protected abstract ConsumerGroupSPI internalRemoveConsumerGroup(String name);
+ protected abstract ConsumerGroupSPI internalRemoveConsumerGroup(String name) throws
RegistrationException;
- protected abstract ConsumerGroupSPI internalCreateConsumerGroup(String name);
+ protected abstract ConsumerGroupSPI internalCreateConsumerGroup(String name) throws
RegistrationException;
protected abstract ConsumerSPI getConsumerSPIById(String consumerId) throws
RegistrationException;
}
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-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/RegistrationPersistenceManager.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -49,14 +49,14 @@
*
* @param consumer
*/
- void saveChangesTo(Consumer consumer);
+ void saveChangesTo(Consumer consumer) throws RegistrationException;
/**
* Saves changes made to the specified registration.
*
* @param registration
*/
- void saveChangesTo(Registration registration);
+ void saveChangesTo(Registration registration) throws RegistrationException;
/**
* Retrieves the ConsumerGroup identified by the specified name.
@@ -94,13 +94,13 @@
RegistrationSPI addRegistrationFor(String consumerId, Map<QName, Object>
registrationProperties) throws RegistrationException;
- Collection<? extends ConsumerGroup> getConsumerGroups();
+ Collection<? extends ConsumerGroup> getConsumerGroups() throws
RegistrationException;
- Registration getRegistration(String registrationId);
+ Registration getRegistration(String registrationId) throws RegistrationException;
Consumer addConsumerToGroupNamed(String consumerId, String groupName) throws
RegistrationException;
- Collection<? extends Consumer> getConsumers();
+ Collection<? extends Consumer> getConsumers() throws RegistrationException;
- Collection<? extends Registration> getRegistrations();
+ Collection<? extends Registration> getRegistrations() throws
RegistrationException;
}
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-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationImpl.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -26,6 +26,7 @@
import org.gatein.common.util.ParameterValidation;
import org.gatein.pc.api.PortletContext;
import org.gatein.registration.Registration;
+import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationStatus;
import org.gatein.registration.spi.ConsumerSPI;
@@ -84,13 +85,13 @@
return consumer;
}
- public void addPortletContext(PortletContext portletContext)
+ public void addPortletContext(PortletContext portletContext) throws
RegistrationException
{
portletContexts.add(portletContext);
manager.getPersistenceManager().saveChangesTo(this);
}
- public void removePortletContext(PortletContext portletContext)
+ public void removePortletContext(PortletContext portletContext) throws
RegistrationException
{
portletContexts.remove(portletContext);
manager.getPersistenceManager().saveChangesTo(this);
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-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -322,7 +322,7 @@
return consumer;
}
- private Object getConsumerOrRegistration(String registrationHandle, boolean
getConsumer)
+ private Object getConsumerOrRegistration(String registrationHandle, boolean
getConsumer) throws RegistrationException
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(registrationHandle,
"registration handle", null);
@@ -337,7 +337,7 @@
}
}
- public Collection<? extends ConsumerGroup> getConsumerGroups()
+ public Collection<? extends ConsumerGroup> getConsumerGroups() throws
RegistrationException
{
return persistenceManager.getConsumerGroups();
}
@@ -360,7 +360,7 @@
removeConsumerGroup(getConsumerGroup(name));
}
- public Collection<? extends Consumer> getConsumers()
+ public Collection<? extends Consumer> getConsumers() throws
RegistrationException
{
return persistenceManager.getConsumers();
}
@@ -394,18 +394,39 @@
log.debug("Registration properties have changed, existing registrations
will be invalidated...");
}
- Collection registrations = persistenceManager.getRegistrations();
- for (Object registration : registrations)
+ try
{
- Registration reg = (Registration)registration;
+ Collection registrations = persistenceManager.getRegistrations();
+ for (Object registration : registrations)
+ {
+ Registration reg = (Registration)registration;
- // pending instead of invalid as technically, the registration is not yet
invalid
- reg.setStatus(RegistrationStatus.PENDING);
+ // pending instead of invalid as technically, the registration is not yet
invalid
+ reg.setStatus(RegistrationStatus.PENDING);
- // make changes persistent
- Consumer consumer = reg.getConsumer();
- persistenceManager.saveChangesTo(consumer);
+ // make changes persistent
+ Consumer consumer = reg.getConsumer();
+ try
+ {
+ persistenceManager.saveChangesTo(consumer);
+ }
+ catch (RegistrationException e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Couldn't persist changes to Consumer '" +
consumer.getId() + "'", e);
+ }
+ }
+ }
}
+ catch (RegistrationException e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Couldn't retrieve registrations...", e);
+ }
+ }
+
}
/**
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java 2011-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -52,22 +52,22 @@
private Map<String, ConsumerGroupSPI> groups = new HashMap<String,
ConsumerGroupSPI>();
private Map<String, RegistrationSPI> registrations = new HashMap<String,
RegistrationSPI>();
- public Collection<ConsumerSPI> getConsumers()
+ public Collection<ConsumerSPI> getConsumers() throws RegistrationException
{
return Collections.unmodifiableCollection(consumers.values());
}
- public Collection<RegistrationSPI> getRegistrations()
+ public Collection<RegistrationSPI> getRegistrations() throws
RegistrationException
{
return Collections.unmodifiableCollection(registrations.values());
}
- public Collection<ConsumerGroupSPI> getConsumerGroups()
+ public Collection<ConsumerGroupSPI> getConsumerGroups() throws
RegistrationException
{
return Collections.unmodifiableCollection(groups.values());
}
- public Registration getRegistration(String registrationId)
+ public Registration getRegistration(String registrationId) throws
RegistrationException
{
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(registrationId,
"Registration id", null);
@@ -89,19 +89,19 @@
}
@Override
- protected void internalAddRegistration(RegistrationSPI registration)
+ protected void internalAddRegistration(RegistrationSPI registration) throws
RegistrationException
{
registrations.put(registration.getPersistentKey(), registration);
}
@Override
- protected RegistrationSPI internalRemoveRegistration(String registrationId)
+ protected RegistrationSPI internalRemoveRegistration(String registrationId) throws
RegistrationException
{
return registrations.remove(registrationId);
}
@Override
- protected RegistrationSPI internalCreateRegistration(ConsumerSPI consumer,
Map<QName, Object> registrationProperties)
+ protected RegistrationSPI internalCreateRegistration(ConsumerSPI consumer,
Map<QName, Object> registrationProperties) throws RegistrationException
{
return newRegistrationSPI(consumer, registrationProperties, "" +
lastRegistrationId++);
}
@@ -112,19 +112,19 @@
}
@Override
- protected void internalAddConsumer(ConsumerSPI consumer)
+ protected void internalAddConsumer(ConsumerSPI consumer) throws RegistrationException
{
consumers.put(consumer.getId(), consumer);
}
@Override
- protected ConsumerSPI internalRemoveConsumer(String consumerId)
+ protected ConsumerSPI internalRemoveConsumer(String consumerId) throws
RegistrationException
{
return consumers.remove(consumerId);
}
@Override
- protected ConsumerSPI internalCreateConsumer(String consumerId, String consumerName)
+ protected ConsumerSPI internalCreateConsumer(String consumerId, String consumerName)
throws RegistrationException
{
ConsumerSPI consumerSPI = newConsumerSPI(consumerId, consumerName);
consumerSPI.setPersistentKey(consumerId);
@@ -137,19 +137,19 @@
}
@Override
- protected void internalAddConsumerGroup(ConsumerGroupSPI group)
+ protected void internalAddConsumerGroup(ConsumerGroupSPI group) throws
RegistrationException
{
groups.put(group.getName(), group);
}
@Override
- protected ConsumerGroupSPI internalRemoveConsumerGroup(String name)
+ protected ConsumerGroupSPI internalRemoveConsumerGroup(String name) throws
RegistrationException
{
return groups.remove(name);
}
@Override
- protected ConsumerGroupSPI internalCreateConsumerGroup(String name)
+ protected ConsumerGroupSPI internalCreateConsumerGroup(String name) throws
RegistrationException
{
ConsumerGroupSPI groupSPI = newConsumerGroupSPI(name);
groupSPI.setPersistentKey(name);
@@ -168,13 +168,13 @@
}
@Override
- protected ConsumerSPI internalSaveChangesTo(Consumer consumer)
+ protected ConsumerSPI internalSaveChangesTo(Consumer consumer) throws
RegistrationException
{
return (ConsumerSPI)consumer; // nothing to do here, left up to subclasses to
implement update in persistent store
}
-
+
@Override
- protected RegistrationSPI internalSaveChangesTo(Registration registration)
+ protected RegistrationSPI internalSaveChangesTo(Registration registration) throws
RegistrationException
{
return (RegistrationSPI)registration; // nothing to do here, left up to subclasses
to implement update in persistent store
}
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-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/spi/RegistrationSPI.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -25,6 +25,7 @@
import org.gatein.pc.api.PortletContext;
import org.gatein.registration.Registration;
+import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationManager;
/**
@@ -35,9 +36,9 @@
{
ConsumerSPI getConsumer();
- void addPortletContext(PortletContext portletContext);
+ void addPortletContext(PortletContext portletContext) throws RegistrationException;
- void removePortletContext(PortletContext portletContext);
+ void removePortletContext(PortletContext portletContext) throws
RegistrationException;
void setManager(RegistrationManager manager);
}
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-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -862,7 +862,7 @@
else // default error message.
{
errorCode = ErrorCodes.Codes.OPERATIONFAILED;
- reason = "Error preparing portlet for export";
+ reason = "Error importing portlet.";
}
if (!failedPortletsMap.containsKey(errorCode.name()))
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/RegistrationHandler.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/RegistrationHandler.java 2011-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/RegistrationHandler.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -111,7 +111,7 @@
return registrationContext;
}
- private void updateRegistrationInformation(Registration registration, RegistrationData
registrationData)
+ private void updateRegistrationInformation(Registration registration, RegistrationData
registrationData) throws RegistrationException
{
registration.setStatus(RegistrationStatus.VALID);
Consumer consumer = registration.getConsumer();
Modified:
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 2011-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/invoker/RegistrationCheckingPortletInvoker.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -38,6 +38,7 @@
import org.gatein.pc.portlet.PortletInvokerInterceptor;
import org.gatein.registration.Registration;
import org.gatein.registration.RegistrationDestructionListener;
+import org.gatein.registration.RegistrationException;
import org.gatein.registration.RegistrationLocal;
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationPolicy;
@@ -149,7 +150,14 @@
PortletContext responseContext = wsrpIC.getPortletContext();
if (wsrpIC.wasModified() &&
!responseContext.getId().equals(portletContext.getId()))
{
- registration.addPortletContext(responseContext);
+ try
+ {
+ registration.addPortletContext(responseContext);
+ }
+ catch (RegistrationException e)
+ {
+ throw new PortletInvokerException("Couldn't add portlet
context '" + responseContext + "' to registration '" +
registration.getRegistrationHandle() + "'", e);
+ }
}
}
@@ -183,7 +191,14 @@
checkOperationIsAllowed(portletContext, registration, "createClone");
PortletContext clonedPortletContext = super.createClone(stateType,
portletContext);
- registration.addPortletContext(clonedPortletContext);
+ try
+ {
+ registration.addPortletContext(clonedPortletContext);
+ }
+ catch (RegistrationException e)
+ {
+ throw new PortletInvokerException("Couldn't add portlet context
'" + clonedPortletContext + "' to registration '" +
registration.getRegistrationHandle() + "'", e);
+ }
return clonedPortletContext;
}
@@ -216,7 +231,14 @@
// 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);
+ try
+ {
+ registration.removePortletContext(portletContext);
+ }
+ catch (RegistrationException e)
+ {
+ throw new PortletInvokerException("Couldn't remove portlet
context '" + portletContext + "' to registration '" +
registration.getRegistrationHandle() + "'", e);
+ }
}
}
}
@@ -250,7 +272,14 @@
if (!portletContext.getId().equals(updatedPortletContext.getId()))
{
- registration.addPortletContext(updatedPortletContext);
+ try
+ {
+ registration.addPortletContext(updatedPortletContext);
+ }
+ catch (RegistrationException e)
+ {
+ throw new PortletInvokerException("Couldn't add portlet context
'" + updatedPortletContext + "' to registration '" +
registration.getRegistrationHandle() + "'", e);
+ }
}
return updatedPortletContext;
@@ -275,7 +304,14 @@
if (!newPortletContext.getId().equals(originalPortletContext.getId()))
{
- registration.addPortletContext(newPortletContext);
+ try
+ {
+ registration.addPortletContext(newPortletContext);
+ }
+ catch (RegistrationException e)
+ {
+ throw new PortletInvokerException("Couldn't add portlet context
'" + newPortletContext + "' to registration '" +
registration.getRegistrationHandle() + "'", e);
+ }
}
return newPortletContext;
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-03-29
12:56:29 UTC (rev 6133)
+++
components/wsrp/trunk/producer/src/test/java/org/gatein/registration/RegistrationTestCase.java 2011-03-29
14:05:46 UTC (rev 6134)
@@ -158,7 +158,7 @@
assertTrue(!registration.hasEqualProperties(registrationProperties));
}
- public void testPortletContextOperations()
+ public void testPortletContextOperations() throws RegistrationException
{
PortletContext foo = PortletContext.createPortletContext("foo");