コード例 #1
0
ファイル: DialogExport.java プロジェクト: fpapai/basex
  @Override
  public void close() {
    try {
      gui.set(MainOptions.EXPORTER, options(SerialMethod.valueOf(method.getSelectedItem())));
    } catch (final BaseXException ex) {
      throw Util.notExpected(ex);
    }
    if (!ok) return;

    super.close();
    path.store();
  }
コード例 #2
0
ファイル: HTTPContext.java プロジェクト: phspaelti/basex
  /**
   * Sets a status and sends an info message.
   *
   * @param code status code
   * @param message info message
   * @param error treat as error (use web server standard output)
   * @throws IOException I/O exception
   */
  public void status(final int code, final String message, final boolean error) throws IOException {
    try {
      log(message, code);
      res.resetBuffer();
      if (code == SC_UNAUTHORIZED) res.setHeader(WWW_AUTHENTICATE, BASIC);

      if (error && code >= SC_BAD_REQUEST) {
        res.sendError(code, message);
      } else {
        res.setStatus(code);
        if (message != null) res.getOutputStream().write(token(message));
      }
    } catch (final IllegalStateException ex) {
      log(Util.message(ex), SC_INTERNAL_SERVER_ERROR);
    }
  }
コード例 #3
0
ファイル: HTTPContext.java プロジェクト: phspaelti/basex
  /**
   * Initializes the database context, based on the initial servlet context. Parses all context
   * parameters and passes them on to the database context.
   *
   * @param sc servlet context
   * @throws IOException I/O exception
   */
  public static synchronized void init(final ServletContext sc) throws IOException {
    // check if HTTP context has already been initialized
    if (init) return;
    init = true;

    // set web application path as home directory and HTTPPATH
    final String webapp = sc.getRealPath("/");
    Options.setSystem(Prop.PATH, webapp);
    Options.setSystem(GlobalOptions.WEBPATH, webapp);

    // bind all parameters that start with "org.basex." to system properties
    final Enumeration<String> en = sc.getInitParameterNames();
    while (en.hasMoreElements()) {
      final String key = en.nextElement();
      if (!key.startsWith(Prop.DBPREFIX)) continue;

      String val = sc.getInitParameter(key);
      if (key.endsWith("path") && !new File(val).isAbsolute()) {
        // prefix relative path with absolute servlet path
        Util.debug(key.toUpperCase(Locale.ENGLISH) + ": " + val);
        val = new IOFile(webapp, val).path();
      }
      Options.setSystem(key, val);
    }

    // create context, update options
    if (context == null) {
      context = new Context(false);
    } else {
      context.globalopts.setSystem();
      context.options.setSystem();
    }

    // start server instance
    if (!context.globalopts.get(GlobalOptions.HTTPLOCAL)) new BaseXServer(context);
  }
コード例 #4
0
ファイル: DBAdd.java プロジェクト: LeoWoerteler/basex
 @Override
 public String toString() {
   return Util.className(this) + '[' + newDocs.inputs + ']';
 }