Beispiel #1
0
  /**
   * Set the <code>SourceResolver</code>, the <code>Map</code> with the object model, the source and
   * sitemap <code>Parameters</code> used to process the request.
   */
  public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
      throws SAXException, ProcessingException, IOException {

    if (src == null && defaultSrc != null) {
      if (getLogger().isDebugEnabled()) {
        getLogger().debug("src is null, using default source " + defaultSrc);
      }
      src = defaultSrc;
    }

    if (src == null) {
      throw new ProcessingException("Stylesheet URI can't be null");
    }

    this.par = par;
    this.objectModel = objectModel;
    this.resolver = resolver;
    try {
      this.inputSource = resolver.resolveURI(src);
    } catch (SourceException se) {
      throw SourceUtil.handle("Unable to resolve " + src, se);
    }
    _useParameters = par.getParameterAsBoolean("use-request-parameters", this.useParameters);
    _useCookies = par.getParameterAsBoolean("use-cookies", this.useCookies);
    _useSessionInfo = par.getParameterAsBoolean("use-session-info", this.useSessionInfo);
    final boolean _checkIncludes = par.getParameterAsBoolean("check-includes", this.checkIncludes);

    if (getLogger().isDebugEnabled()) {
      getLogger().debug("Using stylesheet: '" + this.inputSource.getURI() + "' in " + this);
      getLogger().debug("Use parameters is " + this._useParameters);
      getLogger().debug("Use cookies is " + this._useCookies);
      getLogger().debug("Use session info is " + this._useSessionInfo);
      getLogger().debug("Check for included stylesheets is " + _checkIncludes);
    }

    // Get a Transformer Handler if we check for includes
    // If we don't check the handler is get during setConsumer()
    try {
      if (_checkIncludes) {
        XSLTProcessor.TransformerHandlerAndValidity handlerAndValidity =
            this.xsltProcessor.getTransformerHandlerAndValidity(this.inputSource, null);
        this.transformerHandler = handlerAndValidity.getTransfomerHandler();
        this.transformerValidity = handlerAndValidity.getTransfomerValidity();
      } else {
        this.transformerValidity = this.inputSource.getValidity();
      }
    } catch (XSLTProcessorException se) {
      throw new ProcessingException(
          "Unable to get transformer handler for " + this.inputSource.getURI(), se);
    }
  }
  public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters)
      throws ProcessingException, SAXException, IOException {
    super.setup(resolver, objectModel, src, parameters);

    this.exception = parameters.getParameter("exception", super.source);
    this.code = Integer.parseInt(parameters.getParameter("code", "0"));

    // Throw exception in the setup phase?
    if (parameters.getParameterAsBoolean("setup", false)) {
      ExceptionAction.exception(this.exception, this.code);
    }
  }
Beispiel #3
0
 /**
  * Provide component with parameters.
  *
  * @param parameters the parameters
  * @throws ParameterException if parameters are invalid
  */
 public void parameterize(Parameters parameters) throws ParameterException {
   this.localizable = parameters.getParameterAsBoolean("localizable", false);
 }