Esempio n. 1
0
  public void output(PrintWriter writer) throws OperationException {
    try {
      Map reqArgs = registry.getConfiguration().getRequestArguments();

      if (!truncation && reqArgs != null) reqArgs.put(Constants.PROP_TRUNCLENGTH, "-1");

      LOG.debug("Running OutputMode " + mode.getClass());
      mode.output(this, writer, entries);
    } finally {
      writer.flush();
    }
  }
Esempio n. 2
0
  private void loadOutputMode(String modeName, Registry registry) throws OperationException {
    Configuration conf = registry.getConfiguration();

    LOG.debug("Trying to load OutputMode: " + modeName);

    modeName = modeName.trim();

    String propName = "output." + modeName + ".class";
    String typeName = "output." + modeName + ".ctype";
    String modeClass = conf.getProperty(propName);
    if (modeClass == null || "".equals(modeClass))
      throw new IllegalArgumentException("No property found for " + propName);

    try {

      mode = (OutputMode) Class.forName(modeClass).newInstance();
      mode.setContentType(conf.getProperty(typeName));

      LOG.debug(
          "Loaded OutputMode "
              + mode
              + " with class "
              + modeClass
              + " and set Content-Type to "
              + conf.getProperty(typeName));

      mode.setRegistry(registry);

    } catch (ClassCastException ex) {
      throw new OperationException(
          "Class " + modeClass + " doesn't implement " + OutputMode.class, ex);
    } catch (Exception ex) {
      throw new OperationException(ex);
    }

    if (mode == null) throw new InvalidOutputModeException(modeName);
  }
Esempio n. 3
0
 public String getContentType() {
   return mode != null ? mode.getContentType(entries) : null;
 }