コード例 #1
0
  public Result execute(Result previousResult, int nr, Repository rep, Job parentJob) {
    LogWriter log = LogWriter.getInstance();
    Result result = previousResult;
    result.setResult(false);

    if (filename != null) {
      String realFilename = getRealFilename();
      try {
        FileObject file = KettleVFS.getFileObject(realFilename);
        if (file.exists() && file.isReadable()) {
          log.logDetailed(
              toString(),
              Messages.getString("JobEntryFileExists.File_Exists", realFilename)); // $NON-NLS-1$
          result.setResult(true);
        } else {
          log.logDetailed(
              toString(),
              Messages.getString(
                  "JobEntryFileExists.File_Does_Not_Exist", realFilename)); // $NON-NLS-1$
        }
      } catch (IOException e) {
        result.setNrErrors(1);
        log.logError(
            toString(),
            Messages.getString(
                "JobEntryFileExists.ERROR_0004_IO_Exception", e.toString())); // $NON-NLS-1$
      }
    } else {
      result.setNrErrors(1);
      log.logError(
          toString(),
          Messages.getString("JobEntryFileExists.ERROR_0005_No_Filename_Defined")); // $NON-NLS-1$
    }

    return result;
  }
コード例 #2
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    if (!request.getRequestURI().equals(CONTEXT_PATH + "/")) return;

    if (log.isDebug()) log.logDebug(toString(), "Slave Server registration requested");

    PrintWriter out = response.getWriter();
    BufferedReader in = request.getReader();
    if (log.isDetailed())
      log.logDetailed(toString(), "Encoding: " + request.getCharacterEncoding());

    // We always use XML to reply here...
    //
    response.setContentType("text/xml");
    out.print(XMLHandler.getXMLHeader());
    response.setStatus(HttpServletResponse.SC_OK);

    try {
      // First read the slave server information in memory from the request
      //
      StringBuilder xml = new StringBuilder(request.getContentLength());
      int c;
      while ((c = in.read()) != -1) {
        xml.append((char) c);
      }

      // Parse the XML, create a transformation configuration
      //
      Document document = XMLHandler.loadXMLString(xml.toString());
      Node node = XMLHandler.getSubNode(document, SlaveServerDetection.XML_TAG);
      SlaveServerDetection slaveServerDetection = new SlaveServerDetection(node);

      // See if this slave server is already in our list...
      //
      String message;
      int index = detections.indexOf(slaveServerDetection);
      if (index < 0) {
        detections.add(slaveServerDetection);
        message =
            "Slave server detection '"
                + slaveServerDetection.getSlaveServer().getName()
                + "' was replaced in the list.";
      } else {
        // replace the data in the old one...
        //
        SlaveServerDetection old = detections.get(index);
        old.setSlaveServer(slaveServerDetection.getSlaveServer());
        old.setActive(slaveServerDetection.isActive());

        // Note: in case it's not the slave server itself doing the sending, it might be possible
        // for it to be inactive...
        //
        if (old.isActive()) {
          old.setLastActiveDate(slaveServerDetection.getLastActiveDate());
        } else {
          old.setLastInactiveDate(slaveServerDetection.getLastInactiveDate());
        }
        message =
            "Slave server detection '"
                + slaveServerDetection.getSlaveServer().getName()
                + "' was added to the list.";
      }

      out.println(new WebResult(WebResult.STRING_OK, message));
    } catch (Exception ex) {
      out.println(new WebResult(WebResult.STRING_ERROR, Const.getStackTracker(ex)));
    }
  }