use of com.enonic.xp.portal.impl.PortalRequestAdapter in project xp by enonic.
the class IdProviderControllerServiceImpl method execute.
@Override
public PortalResponse execute(final IdProviderControllerExecutionParams params) throws IOException {
final IdProviderKey idProviderKey = retrieveIdProviderKey(params);
final IdProvider idProvider = retrieveIdProvider(idProviderKey);
final IdProviderDescriptor idProviderDescriptor = retrieveIdProviderDescriptor(idProvider);
if (idProviderDescriptor != null) {
final IdProviderControllerScript idProviderControllerScript = idProviderControllerScriptFactory.fromScript(idProviderDescriptor.getResourceKey());
final String functionName = params.getFunctionName();
if (idProviderControllerScript.hasMethod(functionName)) {
PortalRequest portalRequest = params.getPortalRequest();
if (portalRequest == null) {
portalRequest = new PortalRequestAdapter().adapt(params.getServletRequest());
}
portalRequest.setApplicationKey(idProviderDescriptor.getKey());
portalRequest.setIdProvider(idProvider);
final PortalResponse portalResponse = idProviderControllerScript.execute(functionName, portalRequest);
if (portalResponse != null) {
final HttpServletResponse response = params.getResponse();
if (response != null) {
responseSerializationService.serialize(portalRequest, portalResponse, response);
}
}
return portalResponse;
}
}
return null;
}
Aggregations