Package org.gatein.pc.api.invocation.response

Examples of org.gatein.pc.api.invocation.response.ErrorResponse


                     log.trace("Obtained matching event class " + dstPayloadClass.getName() + " in application " + applicationId + " for event " + eventName);
                  }
               }
               catch (ClassNotFoundException e)
               {
                  return new ErrorResponse("The application " + applicationId + " does not have access to the event payload class"
                     + srcPayloadClassName, e);
               }
               catch (NoClassDefFoundError e)
               {
                  return new ErrorResponse("The application " + applicationId + " does not have access to the event payload class"
                     + srcPayloadClassName, e);
               }
            }

            // We need maybe to perform some serialization to the classloader
            if (dstPayloadClass != srcPayload.getClass())
            {
               if (trace)
               {
                  log.trace("Need to convert event payload from class " + srcPayloadClassName + " to " + dstPayloadClass.getName());
               }
               try
               {
                  dstPayload = IOTools.clone(srcPayload, applicationClassLoader);
               }
               catch (ClassNotFoundException e)
               {
                  return new ErrorResponse("Could not convert the event payload from class " + srcPayloadClassName + " to class " + dstPayloadClass.getName(), e);
               }
               catch (IOException e)
               {
                  // The cause is likely a non compatible changes in class version
                  return new ErrorResponse("Could not convert the event payload from class " + srcPayloadClassName + " to class " + dstPayloadClass.getName(), e);
               }
            }
            else
            {
               dstPayload = srcPayload;
View Full Code Here


         return resp.getResponse();
      }
      catch (NoClassDefFoundError e)
      {
         //
         return new ErrorResponse(e);
      }
      catch (Exception e)
      {
         log.error("The portlet threw an exception", e);

         //
         if (e instanceof PortletSecurityException)
         {
            return new SecurityErrorResponse(e);
         }
         else if (e instanceof UnavailableException)
         {
            UnavailableException ue = (UnavailableException)e;
            if (ue.isPermanent())
            {
               return new UnavailableResponse();
            }
            else
            {
               return new UnavailableResponse(ue.getUnavailableSeconds());
            }
         }
         else
         {
            // The exception is either a PortletException, an IOException or a RuntimeException
            return new ErrorResponse(e);
         }
      }
      finally
      {
         dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
View Full Code Here

        } else {

            PortletContainerException pcException;

            if (pir instanceof ErrorResponse) {
                ErrorResponse errorResponse = (ErrorResponse) pir;
                pcException = new PortletContainerException(errorResponse.getMessage(), errorResponse.getCause());
            } else {
                pcException = new PortletContainerException("Unknown invocation response type [" + pir.getClass()
                        + "]. Expected a FragmentResponse or an ErrorResponse");
            }
View Full Code Here

        } else {

            PortletContainerException pcException;

            if (pir instanceof ErrorResponse) {
                ErrorResponse errorResponse = (ErrorResponse) pir;
                pcException = new PortletContainerException(errorResponse.getMessage(), errorResponse.getCause());
            } else {
                pcException = new PortletContainerException("Unknown invocation response type [" + pir.getClass()
                        + "]. Expected a FragmentResponse or an ErrorResponse");
            }
View Full Code Here

            }

            // todo: handle the error response better than this.
            if (!(piResponse instanceof UpdateNavigationalStateResponse)) {
                if (piResponse instanceof ErrorResponse) {
                    ErrorResponse errorResponse = (ErrorResponse) piResponse;
                    throw (Exception) errorResponse.getCause();
                } else {
                    throw new Exception("Unexpected response type [" + piResponse
                            + "]. Expected a UpdateNavigationResponse or an ErrorResponse.");
                }
            }
View Full Code Here

                String contentType;
                String charset;
                Object content;
                if (!(portletResponse instanceof ContentResponse)) {
                    if (portletResponse instanceof ErrorResponse) {
                        ErrorResponse errorResponse = (ErrorResponse) portletResponse;
                        Throwable cause = errorResponse.getCause();
                        if (cause != null) {
                            log.trace("Got error response from portlet", cause);
                        } else if (errorResponse.getMessage() != null) {
                            log.trace("Got error response from portlet:" + errorResponse.getMessage());
                        } else {
                            log.trace("Got error response from portlet");
                        }
                    } else {
                        log.trace("Unexpected response type [" + portletResponse
View Full Code Here

   private void checkForError(PortletInvocationResponse response) throws UnsupportedMode, OperationFailed, UnsupportedWindowState
   {
      if (response instanceof ErrorResponse)
      {
         // if we have an ErrorResponse, try to interpret it as a WSRP exception
         ErrorResponse errorResult = (ErrorResponse)response;
         Throwable cause = errorResult.getCause();
         if (cause instanceof PortletModeException)
         {
            throw WSRP2ExceptionFactory.throwWSException(UnsupportedMode.class, "Unsupported mode: " + ((PortletModeException)cause).getMode(), null);
         }
         if (cause instanceof WindowStateException)
         {
            throw WSRP2ExceptionFactory.throwWSException(UnsupportedWindowState.class, "Unsupported window state: " + ((WindowStateException)cause).getState(), null);
         }
         // todo: deal with other exceptions

         // we're not sure what happened so throw an OperationFailedFault
         throw WSRP2ExceptionFactory.throwWSException(OperationFailed.class, errorResult.getMessage(), cause);

      }
      else if (!(response instanceof HTTPRedirectionResponse || response instanceof FragmentResponse || response instanceof UpdateNavigationalStateResponse || response instanceof ContentResponse))
      {
         throw WSRP2ExceptionFactory.throwWSException(OperationFailed.class, "Unsupported result type: " + response.getClass().getName(), null);
View Full Code Here

         }
         else
         {
            if (consumer.isUsingWSRP2())
            {
               return new ErrorResponse("Did not get a resource URL or a resource ID, cannot fetch resource.");
            }
            else //using WSRP1
            {
               return new ErrorResponse("Did not get a resource URL, cannot fetch resource.");
            }
         }
      }
      else if (invocation instanceof EventInvocation)
      {
         final ProducerInfo producerInfo = consumer.getProducerInfo();
         if (producerInfo.getSupportedOptions().contains(WSRP2Constants.OPTIONS_EVENTS))
         {
            handler = eventHandler;
         }
         else
         {
            // do something better here?
            return new ErrorResponse("Producer " + producerInfo.getId() + " doesn't support event processing.");
         }
      }
      else
      {
         throw new InvocationException("Unknown invocation type: " + invocation);
View Full Code Here

   protected PortletInvocationResponse processResponse(HandleEventsResponse response, EventInvocation invocation, RequestPrecursor<EventInvocation> requestPrecursor) throws PortletInvokerException
   {
      List<HandleEventsFailed> failed = response.getFailedEvents();
      if (ParameterValidation.existsAndIsNotEmpty(failed))
      {
         return new ErrorResponse("Couldn't process events: " + failed);
      }

      return processUpdateResponse(invocation, requestPrecursor, response.getUpdateResponse());
   }
View Full Code Here

   {
      String markup = mimeResponse.getItemString();
      byte[] binary = mimeResponse.getItemBinary();
      if (markup != null && binary != null)
      {
         return new ErrorResponse(new IllegalArgumentException("Markup response cannot contain both string and binary " +
            "markup. Per Section 6.1.10 of the WSRP 1.0 specification, this is a Producer error."));
      }

      if (markup == null && binary == null)
      {
         if (mimeResponse.isUseCachedItem() != null && mimeResponse.isUseCachedItem())
         {
            //todo: deal with cache GTNWSRP-40
            log.debug("Consumer " + consumer.getProducerId() + " requested cached data. Not implemented yet!");
         }
         else
         {
            return new ErrorResponse(new IllegalArgumentException("Markup response must contain at least string or binary" +
               " markup. Per Section 6.1.10 of the WSRP 1.0 specification, this is a Producer error."));
         }
      }

      String mimeType = mimeResponse.getMimeType();
      if (ParameterValidation.isNullOrEmpty(mimeType))
      {
         return new ErrorResponse(new IllegalArgumentException("No MIME type was provided for portlet content."));
      }

      if (Boolean.TRUE.equals(mimeResponse.isRequiresRewriting()))
      {
         if (!ParameterValidation.isNullOrEmpty(markup))
View Full Code Here

TOP

Related Classes of org.gatein.pc.api.invocation.response.ErrorResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.