{
throw new IllegalArgumentException("GetResource needs a valid resource id.");
}
// Create ResourceParams
ResourceParams resourceParams = WSRPTypeFactory.createResourceParams(params.isSecureClientCommunication(),
params.getLocales(), params.getMimeTypes(), params.getMode(), params.getWindowState(), resourceId,
WSRPUtils.getStateChangeFromAccessMode(accessMode));
resourceParams.setNavigationalContext(params.getNavigationalContext());
resourceParams.setClientData(params.getClientData());
resourceParams.setResourceCacheability(WSRPUtils.getResourceCacheabilityFromCacheLevel(invocation.getCacheLevel()));
resourceParams.getExtensions().addAll(ExtensionAccess.getConsumerExtensionAccessor().getRequestExtensionsFor(ResourceParams.class));
for (Map.Entry<String, String[]> entry : invocation.getForm().entrySet())
{
String name = entry.getKey();
for (String value : entry.getValue())
{
resourceParams.getFormParameters().add(WSRPTypeFactory.createNamedString(name, value));
}
}
StateString resourceState = invocation.getResourceState();
if (resourceState != null)
{
String state = resourceState.getStringValue();
if (!StateString.JBPNS_PREFIX.equals(state)) // fix-me: see JBPORTAL-900
{
resourceParams.setResourceState(state);
}
}
MultiPartResult multiPartResult = MultiPartUtil.getMultiPartContent(invocation.getRequestContext());
if (multiPartResult != null)
{
resourceParams.getFormParameters().addAll(multiPartResult.getFormParameters());
resourceParams.getUploadContexts().addAll(multiPartResult.getUploadContexts());
}
return WSRPTypeFactory.createGetResource(requestPrecursor.getRegistrationContext(), portletContext,
requestPrecursor.getRuntimeContext(), requestPrecursor.getUserContext(), resourceParams);
}