Examples of ProcessException


Examples of org.apache.slide.projector.ProcessException

    static ParameterDescriptor getParameterDescriptor(Map parameter, Context context) throws ProcessException {
        URI actionUri = (URIValue)parameter.get(ACTION);
        Processor action = ProcessorManager.getInstance().getProcessor(actionUri);
        String parameterName = parameter.get(PARAMETER).toString();
        ParameterDescriptor parameterDescriptor = ProcessorHelper.getParameterDescriptor(action, parameterName);
        if ( parameterDescriptor == null ) throw new ProcessException(new ErrorMessage("control/actionParameterNotFound", new Object[] { parameterName, actionUri }));
        return parameterDescriptor;
    }
View Full Code Here

Examples of org.apache.slide.projector.ProcessException

    Value uri = (Value)parameter.get(PROCESSOR);
        if ( uri == null || uri == NullValue.NULL ) {
          uri = (URI)context.getStore(Store.SESSION).get(PROCESSOR);
        }
        if ( uri == null ) {
          throw new ProcessException(new ErrorMessage("test/noProcessorSpecified"));
        }
        context.setProcess((URI)uri);
      context.getStore(Store.SESSION).put(PROCESSOR, uri);
      Value stepResource = (Value)context.getStore(Store.FORM).get(Process.STEP);
      String step;
View Full Code Here

Examples of org.apache.slide.projector.ProcessException

        return name;
    }

    protected void storeValue(Value value, Store stepStore, Result result, ResultEntryDescriptor[] resultEntryDescriptors, Context context) throws ProcessException {
      if ( value == null ) {
        throw new ProcessException(new ErrorMessage("valueToStoreNotFound"));
      }
      if (presentable ) {
            if ( value instanceof StreamableValue ) {
                if ( context instanceof HttpContext ) {
                    ((HttpContext)context).setPresentableResource((StreamableValue)value);
                } else {
                    logger.log(Level.FINE, "Result can only be shown in http-context!");
                }
            } else {
            throw new ProcessException(new ErrorMessage("unpresentableValue"));
            }
        }
        Store resultStore = stepStore;
        if ( store == Store.OUTPUT ) {
          // check if result is defined
          boolean resultDefined = false;
          for ( int i = 0; i < resultEntryDescriptors.length; i++ ) {
            if ( resultEntryDescriptors[i].getName().equals(key) ) {
              // check if result matches description
              if ( ContentType.matches(resultEntryDescriptors[i].getContentType(), value.getContentType()) ) {
                result.addResultEntry(key, value);
                resultDefined = true;
                break;
              } else {
                    throw new ProcessException(new ErrorMessage("contentTypeMismatch", new String[] { key, value.getContentType(), resultEntryDescriptors[i].getContentType()}));
              }
            }
          }
          if ( !resultDefined ) {
            throw new ProcessException(new ErrorMessage("undefinedResultKey", new String[] { key }));
          }
        } else {
            if ( store != Store.NONE ) {
              resultStore = context.getStore(store);
            }
            if ( resultStore == null ) {
            throw new ProcessException(new ErrorMessage("storeNotAvailable", new String[] { key, Store.stores[store] }));
            } else {
                try {
                    String evaluatedKey = Process.evaluateKey(key, context);
                    if ( evaluatedKey != null ) {
                      if ( domain != null ) {
                        Map map;
                        MapValue mapResource = (MapValue)resultStore.get(domain);
                      if ( mapResource == null ) {
                        map = new HashMap();
                        mapResource = new MapValue(map);
                      } else {
                        map = mapResource.getMap();
                      }
                      map.put(evaluatedKey, value);
                      evaluatedKey = domain;
                      value = mapResource;
                      }
                      if ( timeout != -1 ) {
                        resultStore.put(evaluatedKey, value, timeout);
                      } else {
                        resultStore.put(evaluatedKey, value);
                      }
                    }
                } catch ( IOException e ) {
                throw new ProcessException(new ErrorMessage("storingResultFailed"), e);
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.slide.projector.ProcessException

    context.setInputParameters(parameter);
    do {
      logger.log(Level.FINE, "Processing "+processorUri+", step=" + nextStep);
      context.setStep(nextStep);          // Remember current step in context
      step = (Step)steps.get(nextStep);
      if (step == null) throw new ProcessException(new ErrorMessage("stepNotFound", new String[]{nextStep}));
      Processor processor = ProcessorManager.getInstance().getProcessor(step.getProcessorURI());
      try {
        Map processorParameters = loadParameters(step, processor, context);
        if ( processor instanceof EnvironmentConsumer ) {
          checkRequirements((EnvironmentConsumer)processor, context);
        }
        checkRoutings(step, processor);
        try {
          stepResult = ProcessorManager.process(processor, processorParameters, context);
          try {
            saveResults(step, stepResult, stepStore, result, getResultDescriptor().getResultEntryDescriptors(), context);
          } catch ( ProcessException e ) {
            throw new ProcessException(new ErrorMessage("saveFailed", new Object[] { step.getProcessorURI(), nextStep }), e );
          }
          nextStep = routeState(step, stepResult.getState());
        } catch (Exception e) {
          nextStep = routeException(step, e);
        }
View Full Code Here

Examples of org.apache.slide.projector.ProcessException

          if (validStates[j].getState().equals(returnState)) {
            return returnState;
          }
        }
        logger.log(Level.SEVERE, "State '" + returnState + "' not defined!");
        throw new ProcessException(new ErrorMessage("stateNotDefined", new String[]{returnState}));
      }
    }
    return OK;
  }
View Full Code Here

Examples of org.apache.slide.projector.ProcessException

  public Processor getProcessor(URI uri) throws ProcessException {
        if ( processorMap.containsKey(uri) ) {
            return (Processor)processorMap.get(uri);
        }
        logger.log(Level.SEVERE, "Requested processor with URI=" + uri+ " not found!");
        throw new ProcessException(new ErrorMessage("processorNotFound", new Object[] {uri.toString()}));
    }
View Full Code Here

Examples of org.apache.slide.projector.ProcessException

            if ( entry.getValue() == processor ) {
                return ((URI)entry.getKey());
            }
        }
        logger.log(Level.SEVERE, "Requested URI for processor=" + processor + " not found!");
        throw new ProcessException(new ErrorMessage("processorNotFound", new Object[] {processor.toString()}));
    }
View Full Code Here

Examples of org.apache.slide.projector.ProcessException

    public Value process(Value input, Context context) throws Exception {
        Value output;
        if ( context instanceof HttpContext ) {
            output = new StringValue(((HttpContext)context).getContextPath() + "/" + ((StringValue)input).toString());
        } else {
            throw new ProcessException(new ErrorMessage("httpContextRequired"));
        }
        return output;
    }
View Full Code Here

Examples of org.apache.slide.projector.ProcessException

    public Value process(URI simpleProcessorUri, Object input, String resultKey, Context context) throws Exception {
        Processor  processor = getProcessor(simpleProcessorUri);
        ParameterDescriptor[] parameterDescriptors = processor.getParameterDescriptors();
        if ( parameterDescriptors.length > 1 && countRequiredParameters(parameterDescriptors) > 1 ) {
            throw new ProcessException(new ErrorMessage("valueProcessorNeedsTooManyParametersException"));
        }
        if ( resultKey  == null ) {
            ResultDescriptor resultDescriptor = processor.getResultDescriptor();
            if ( resultDescriptor.getResultEntryDescriptors().length == 0 ) {
                throw new ProcessException(new ErrorMessage("parameterProcessingException", new String[] { simpleProcessorUri.toString() }));
            } else {
                resultKey = resultDescriptor.getResultEntryDescriptors()[0].getName();
            }
        }
        if ( input == null && parameterDescriptors.length == 1 && parameterDescriptors[0].isRequired()) {
            throw new ProcessException(new ErrorMessage("requiredParameterMissing", new String[]{parameterDescriptors[0].getName()}));
        } else if ( input == null && parameterDescriptors.length > 1 ) {
            ParameterDescriptor requiredParameter = getRequiredParameter(parameterDescriptors);
            if ( requiredParameter != null ) throw new ProcessException(new ErrorMessage("requiredParameterMissing", new String[]{ requiredParameter.getName()}));
        } else {
            try {
                // check for SimpleProcessor to avoid HashMap creation
                if ( processor instanceof EnvironmentConsumer ) {
                    Process.checkRequirements((EnvironmentConsumer)processor, context);
                }
                if ( processor instanceof SimpleProcessor ) {
                    Value preparedValue = prepareValue(parameterDescriptors[0], input, context);
                    input = ((SimpleProcessor)processor).process(preparedValue, context);
                } else {
                    Map parameters = new HashMap();
                    if ( parameterDescriptors.length == 1 ) {
                        parameters.put(parameterDescriptors[0].getName(), prepareValue(parameterDescriptors[0], input, context));
                    } else {
                      for ( int i = 0; i < parameterDescriptors.length; i++ ) {
                            if ( parameterDescriptors[i].isRequired() ) {
                                parameters.put(parameterDescriptors[i].getName(), prepareValue(parameterDescriptors[i], input, context));
                            } else {
                                parameters.put(parameterDescriptors[i].getName(), parameterDescriptors[i].getDefaultValue());
                            }
                        }
                     
                    }
                    Result processorResult = processor.process(parameters, context);
                    input = processorResult.getResultEntries().get(resultKey);
                }
            } catch ( Exception exception ) {
                throw new ProcessException(new ErrorMessage("parameterProcessingException", new String[] { simpleProcessorUri.toString(), exception.getMessage() }), exception);
            }
        }
        return (Value)input;
    }
View Full Code Here

Examples of org.apache.slide.projector.ProcessException

            linkBuffer.append(entry.getKey());
            linkBuffer.append('=');
            linkBuffer.append(entry.getValue());
            }
    } else {
            throw new ProcessException(new ErrorMessage("httpContextRequired"));
        }
        return new Result(StateDescriptor.OK, SimpleProcessor.OUTPUT, new StringValue(linkBuffer.toString()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.