Пример #1
0
  /** Construct error handler with everything needed to handle an error. */
  public SitemapErrorHandler(
      ErrorHandlerHelper handler, Environment environment, InvokeContext context) {
    this.handler = handler;
    this.environment = environment;
    this.context = context;

    this.envPrefix = environment.getURIPrefix();
    this.envURI = environment.getURI();
    this.envContext = environment.getContext();
  }
Пример #2
0
  public final boolean invoke(Environment env, InvokeContext context) throws Exception {

    // Check view
    if (this.views != null) {

      // inform the pipeline that we have a branch point
      context.getProcessingPipeline().informBranchPoint();

      String cocoonView = env.getView();
      if (cocoonView != null) {

        // Get view node
        ProcessingNode viewNode = (ProcessingNode) this.views.get(cocoonView);

        if (viewNode != null) {
          if (getLogger().isInfoEnabled()) {
            getLogger()
                .info(
                    "Jumping to view " + cocoonView + " from serializer at " + this.getLocation());
          }
          return viewNode.invoke(env, context);
        }
      }
    }

    Map objectModel = env.getObjectModel();
    ProcessingPipeline pipeline = context.getProcessingPipeline();

    // Perform link translation if requested
    if (objectModel.containsKey(Constants.LINK_OBJECT)) {
      pipeline.addTransformer(
          "<translator>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
    }

    if (objectModel.containsKey(Constants.LINK_COLLECTION_OBJECT) && env.isExternal()) {
      pipeline.addTransformer(
          "<gatherer>", null, Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
    }

    pipeline.setSerializer(
        this.serializerName,
        source.resolve(context, objectModel),
        VariableResolver.buildParameters(this.parameters, context, objectModel),
        this.pipelineHints == null
            ? Parameters.EMPTY_PARAMETERS
            : VariableResolver.buildParameters(this.pipelineHints, context, objectModel),
        this.mimeType.resolve(context, env.getObjectModel()));

    // Set status code if there is one
    if (this.statusCode >= 0) {
      env.setStatus(this.statusCode);
    }

    if (!context.isBuildingPipelineOnly()) {
      // Process pipeline
      return pipeline.process(env);

    } else {
      // Return true : pipeline is finished.
      return true;
    }
  }