Search in sources :

Example 1 with PortalRequestAdapter

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;
}
Also used : PortalResponse(com.enonic.xp.portal.PortalResponse) PortalRequestAdapter(com.enonic.xp.portal.impl.PortalRequestAdapter) IdProvider(com.enonic.xp.security.IdProvider) IdProviderDescriptor(com.enonic.xp.idprovider.IdProviderDescriptor) IdProviderKey(com.enonic.xp.security.IdProviderKey) HttpServletResponse(javax.servlet.http.HttpServletResponse) PortalRequest(com.enonic.xp.portal.PortalRequest)

Aggregations

IdProviderDescriptor (com.enonic.xp.idprovider.IdProviderDescriptor)1 PortalRequest (com.enonic.xp.portal.PortalRequest)1 PortalResponse (com.enonic.xp.portal.PortalResponse)1 PortalRequestAdapter (com.enonic.xp.portal.impl.PortalRequestAdapter)1 IdProvider (com.enonic.xp.security.IdProvider)1 IdProviderKey (com.enonic.xp.security.IdProviderKey)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1