Author: chris.laprun(a)jboss.com
Date: 2008-06-25 11:41:53 -0400 (Wed, 25 Jun 2008)
New Revision: 11147
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
Log:
- Fix PortletManagement tests.
- More generification.
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2008-06-25
15:38:35 UTC (rev 11146)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2008-06-25
15:41:53 UTC (rev 11147)
@@ -25,8 +25,6 @@
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.value.StringValue;
-import org.jboss.portal.common.value.Value;
import org.jboss.portal.portlet.InvalidPortletIdException;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.Portlet;
@@ -96,8 +94,8 @@
}
public PortletDescriptionResponse getPortletDescription(GetPortletDescription
getPortletDescription)
- throws AccessDeniedFault, InvalidHandleFault, InvalidUserCategoryFault,
InconsistentParametersFault,
- MissingParametersFault, InvalidRegistrationFault, OperationFailedFault,
RemoteException
+ throws AccessDeniedFault, InvalidHandleFault, InvalidUserCategoryFault,
InconsistentParametersFault,
+ MissingParametersFault, InvalidRegistrationFault, OperationFailedFault,
RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(getPortletDescription,
GET_PORTLET_DESCRIPTION);
Registration registration =
producer.getRegistrationOrFailIfInvalid(getPortletDescription.getRegistrationContext());
@@ -114,8 +112,8 @@
}
public PortletPropertyDescriptionResponse
getPortletPropertyDescription(GetPortletPropertyDescription
getPortletPropertyDescription)
- throws MissingParametersFault, InconsistentParametersFault,
InvalidUserCategoryFault, InvalidRegistrationFault,
- AccessDeniedFault, InvalidHandleFault, OperationFailedFault, RemoteException
+ throws MissingParametersFault, InconsistentParametersFault,
InvalidUserCategoryFault, InvalidRegistrationFault,
+ AccessDeniedFault, InvalidHandleFault, OperationFailedFault, RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(getPortletPropertyDescription,
GET_PORTLET_PROPERTY_DESCRIPTION);
@@ -161,8 +159,8 @@
}
public PortletContext clonePortlet(ClonePortlet clonePortlet) throws
InvalidUserCategoryFault, AccessDeniedFault,
- OperationFailedFault, InvalidHandleFault, InvalidRegistrationFault,
InconsistentParametersFault,
- MissingParametersFault, RemoteException
+ OperationFailedFault, InvalidHandleFault, InvalidRegistrationFault,
InconsistentParametersFault,
+ MissingParametersFault, RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(clonePortlet,
"ClonePortlet");
@@ -184,17 +182,17 @@
catch (NoSuchPortletException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
- "Failed to create clone for portlet '" +
portletContext.getPortletHandle(), e);
+ "Failed to create clone for portlet '" +
portletContext.getPortletHandle(), e);
}
catch (InvalidPortletIdException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INCONSISTENT_PARAMETERS,
- "Failed to create clone for portlet '" +
portletContext.getPortletHandle(), e);
+ "Failed to create clone for portlet '" +
portletContext.getPortletHandle(), e);
}
catch (PortletInvokerException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
- "Failed to create clone for portlet '" +
portletContext.getPortletHandle(), e);
+ "Failed to create clone for portlet '" +
portletContext.getPortletHandle(), e);
}
finally
{
@@ -203,7 +201,7 @@
}
public DestroyPortletsResponse destroyPortlets(DestroyPortlets destroyPortlets) throws
InconsistentParametersFault,
- MissingParametersFault, InvalidRegistrationFault, OperationFailedFault,
RemoteException
+ MissingParametersFault, InvalidRegistrationFault, OperationFailedFault,
RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(destroyPortlets,
"DestroyPortlets");
@@ -244,7 +242,7 @@
catch (PortletInvokerException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
- "Failed to destroy clones", e);
+ "Failed to destroy clones", e);
}
finally
{
@@ -253,8 +251,8 @@
}
public PortletContext setPortletProperties(SetPortletProperties setPortletProperties)
throws OperationFailedFault,
- InvalidHandleFault, MissingParametersFault, InconsistentParametersFault,
InvalidUserCategoryFault,
- AccessDeniedFault, InvalidRegistrationFault, RemoteException
+ InvalidHandleFault, MissingParametersFault, InconsistentParametersFault,
InvalidUserCategoryFault,
+ AccessDeniedFault, InvalidRegistrationFault, RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(setPortletProperties,
"SetPortletProperties");
@@ -312,24 +310,24 @@
{
RegistrationLocal.setRegistration(registration);
org.jboss.portal.portlet.PortletContext resultContext =
-
producer.getInvoker().setProperties(WSRPUtils.convertToPortalPortletContext(portletContext),
- (PropertyChange[])changes.toArray(new PropertyChange[0]));
+
producer.getInvoker().setProperties(WSRPUtils.convertToPortalPortletContext(portletContext),
+ (PropertyChange[])changes.toArray(new PropertyChange[0]));
return WSRPUtils.convertToWSRPPortletContext(resultContext);
}
catch (NoSuchPortletException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
- "Failed to set properties for portlet '" +
portletContext.getPortletHandle() + "'", e);
+ "Failed to set properties for portlet '" +
portletContext.getPortletHandle() + "'", e);
}
catch (InvalidPortletIdException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INCONSISTENT_PARAMETERS,
- "Failed to set properties for portlet '" +
portletContext.getPortletHandle() + "'", e);
+ "Failed to set properties for portlet '" +
portletContext.getPortletHandle() + "'", e);
}
catch (PortletInvokerException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
- "Failed to set properties for portlet '" +
portletContext.getPortletHandle() + "'", e);
+ "Failed to set properties for portlet '" +
portletContext.getPortletHandle() + "'", e);
}
finally
{
@@ -341,8 +339,8 @@
}
public PropertyList getPortletProperties(GetPortletProperties getPortletProperties)
throws InvalidHandleFault,
- MissingParametersFault, InvalidRegistrationFault, AccessDeniedFault,
OperationFailedFault,
- InconsistentParametersFault, InvalidUserCategoryFault, RemoteException
+ MissingParametersFault, InvalidRegistrationFault, AccessDeniedFault,
OperationFailedFault,
+ InconsistentParametersFault, InvalidUserCategoryFault, RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(getPortletProperties,
GET_PORTLET_PROPERTIES);
@@ -355,7 +353,7 @@
checkUserAuthorization(userContext);
String[] names = getPortletProperties.getNames();
- Set keys = getKeysFromNames(names);
+ Set<String> keys = getKeysFromNames(names);
try
{
@@ -385,18 +383,24 @@
int i = 0;
PreferenceInfo prefInfo;
String key;
- Value value;
+ List<String> values;
LocalizedString displayName;
for (Iterator entries = properties.entrySet().iterator(); entries.hasNext();
i++)
{
Map.Entry entry = (Map.Entry)entries.next();
key = (String)entry.getKey();
- value = (Value)entry.getValue();
+ values = (List<String>)entry.getValue();
prefInfo = info.getPreferences().getPreference(key);
displayName = prefInfo.getDisplayName();
String lang = WSRPUtils.toString(displayName.getDefaultLocale());
- resProperties[i] = WSRPTypeFactory.createProperty(key, lang,
value.asString()); //todo: check what we should use key
+
+ // todo: support multi-valued properties
+ if(values.size() != 1)
+ {
+ throw new UnsupportedOperationException("Currently doesn't
support multi-valued properties!");
+ }
+ resProperties[i] = WSRPTypeFactory.createProperty(key, lang,
values.get(0)); //todo: check what we should use key
}
result.setProperties(resProperties);
@@ -407,7 +411,7 @@
catch (PortletInvokerException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
- "Could not retrieve properties for portlet '" + portletContext
+ "'", e);
+ "Could not retrieve properties for portlet '" +
portletContext + "'", e);
}
finally
{
@@ -424,14 +428,14 @@
}
}
- private Set getKeysFromNames(String[] names)
+ private Set<String> getKeysFromNames(String[] names)
{
- Set keys = null;
+ Set<String> keys = null;
if (names != null)
{
if (names.length == 0)
{
- keys = Collections.EMPTY_SET;
+ keys = Collections.emptySet();
}
else
{
@@ -466,7 +470,7 @@
catch (PortletInvokerException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
- "Could not retrieve portlet '" +
portletContext.getPortletHandle() + "'", e);
+ "Could not retrieve portlet '" +
portletContext.getPortletHandle() + "'", e);
}
finally
{