Example #1
0
    public MisoPrintService mapRow(ResultSet rs, int rowNum) throws SQLException {
      try {
        MisoPrintService printService = new DefaultPrintService();
        printService.setServiceId(rs.getLong("serviceId"));
        printService.setName(rs.getString("serviceName"));
        printService.setEnabled(rs.getBoolean("enabled"));
        printService.setPrintServiceFor(
            Class.forName(rs.getString("printServiceFor")).asSubclass(Barcodable.class));

        PrintContext pc = printManager.getPrintContext(rs.getString("contextName"));
        JSONObject contextFields = JSONObject.fromObject(rs.getString("contextFields"));
        PrintServiceUtils.mapJSONToContextFields(contextFields, pc);

        pc.getLabelFactory().setSecurityManager(securityManager);
        pc.getLabelFactory().setFilesManager(misoFilesManager);

        printService.setPrintContext(pc);

        return printService;
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      } catch (JSONException e) {
        e.printStackTrace();
      }
      return null;
    }
Example #2
0
  /** Accepts submission from the configuration page. */
  @RequirePOST
  public synchronized void doConfigSubmit(StaplerRequest req, StaplerResponse rsp)
      throws IOException, ServletException, FormException {
    checkPermission(CONFIGURE);

    description = req.getParameter("description");

    keepDependencies = req.getParameter("keepDependencies") != null;

    try {
      JSONObject json = req.getSubmittedForm();

      setDisplayName(json.optString("displayNameOrNull"));

      if (req.getParameter("logrotate") != null)
        logRotator = LogRotator.DESCRIPTOR.newInstance(req, json.getJSONObject("logrotate"));
      else logRotator = null;

      DescribableList<JobProperty<?>, JobPropertyDescriptor> t =
          new DescribableList<JobProperty<?>, JobPropertyDescriptor>(NOOP, getAllProperties());
      t.rebuild(
          req,
          json.optJSONObject("properties"),
          JobPropertyDescriptor.getPropertyDescriptors(Job.this.getClass()));
      properties.clear();
      for (JobProperty p : t) {
        p.setOwner(this);
        properties.add(p);
      }

      submit(req, rsp);

      save();
      ItemListener.fireOnUpdated(this);

      String newName = req.getParameter("name");
      final ProjectNamingStrategy namingStrategy = Jenkins.getInstance().getProjectNamingStrategy();
      if (newName != null && !newName.equals(name)) {
        // check this error early to avoid HTTP response splitting.
        Jenkins.checkGoodName(newName);
        namingStrategy.checkName(newName);
        rsp.sendRedirect("rename?newName=" + URLEncoder.encode(newName, "UTF-8"));
      } else {
        if (namingStrategy.isForceExistingJobs()) {
          namingStrategy.checkName(name);
        }
        FormApply.success(".").generateResponse(req, rsp, null);
      }
    } catch (JSONException e) {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      pw.println("Failed to parse form data. Please report this problem as a bug");
      pw.println("JSON=" + req.getSubmittedForm());
      pw.println();
      e.printStackTrace(pw);

      rsp.setStatus(SC_BAD_REQUEST);
      sendError(sw.toString(), req, rsp, true);
    }
  }
Example #3
0
  public String processTxn() {
    String resultHtml = null;
    session = ActionContext.getContext().getSession();
    mockLogin();

    String unique = new String();
    String application_name = (String) session.get("APPLICATION_NAME");
    String transcode = "CNUCNF"; // will be coming form command

    // creating a unique id.
    // unique id = transaction code.
    unique += (String) session.get("NET_ID");
    unique += "_" + System.currentTimeMillis();

    String xml = "<?xml version=\"1.0\"?>";
    xml += "<IDCT>";
    xml += "<TRANS_CODE>" + transcode + "</TRANS_CODE>";
    xml += "<IDCT_ID>" + application_name + "_" + unique + "</IDCT_ID>";
    xml += "<DATETIME>" + new Date().toString() + "</DATETIME>";
    xml += "<NET_ID>" + (String) session.get("NET_ID") + "</NET_ID>";
    xml += "<MESSAGE_VER_NO>1.0</MESSAGE_VER_NO>";
    xml += "<CHANNEL_ID>WEB</CHANNEL_ID>";
    xml += "<MESSAGE_DIGEST>NO_DATA</MESSAGE_DIGEST>";
    xml += "<IDCT_STATUS>NO_DATA</IDCT_STATUS>";
    xml += "<IDCT_ERR_CODE>NO_DATA</IDCT_ERR_CODE>";
    xml += "<IDCT_MESSAGE_TYPE>01</IDCT_MESSAGE_TYPE>";

    try {
      JSONObject jobj1 = JSONObject.fromObject(submitdatatxncode);

      JSONObject txnrec = jobj1.getJSONObject("txnrec");
      JSONObject single = txnrec.getJSONObject("single");
      JSONArray multiple = txnrec.getJSONArray("multiple");

      final JAXBContext jc = JAXBContext.newInstance(Root.class);
      final Root root =
          (Root)
              jc.createUnmarshaller()
                  .unmarshal(
                      new File(
                          "C:/Eclipse/workspace1/FEtranslator1/src/repo/txnmap/nrow_txnmap.xml"));

      for (Txn txn : root.getTxn()) {
        if (txn.getId().equals(transcode)) {
          String strReqSingle = txn.getReq().getSingle();
          if (strReqSingle != null) {
            String[] arSingle = strReqSingle.split(",");
          }
          String strReqMultiple = txn.getReq().getSingle();
          if (strReqMultiple != null) {
            String[] arMultiple = strReqMultiple.split(",");
          }
        }
      }

    } catch (JSONException e) {
      logger.debug("submitdata parsing error", e);
      e.printStackTrace();
    } catch (JAXBException e) {
      logger.debug("submitdata parsing error", e);
      e.printStackTrace();
    }

    inputStream = new StringBufferInputStream(resultHtml);
    return "saveajax";
  }
  public void handlRequest(HttpServletRequest request, HttpServletResponse response) {

    printRequest(request);

    String method = request.getParameter(ServiceConstant.METHOD);
    CommonService obj = null;

    try {
      obj = CommonService.createServiceObjectByMethod(method);
    } catch (InstantiationException e1) {
      log.severe(
          "<handlRequest> but exception while create service object for method("
              + method
              + "), exception="
              + e1.toString());
      e1.printStackTrace();
    } catch (IllegalAccessException e1) {
      log.severe(
          "<handlRequest> but exception while create service object for method("
              + method
              + "), exception="
              + e1.toString());
      e1.printStackTrace();
    }

    try {

      if (obj == null) {
        sendResponseByErrorCode(response, ErrorCode.ERROR_PARA_METHOD_NOT_FOUND);
        return;
      }

      obj.setCassandraClient(cassandraClient);
      obj.setMongoClient(mongoClient);
      obj.setRequest(request);

      if (!obj.validateSecurity(request)) {
        sendResponseByErrorCode(response, ErrorCode.ERROR_INVALID_SECURITY);
        return;
      }

      // parse request parameters
      if (!obj.setDataFromRequest(request)) {
        sendResponseByErrorCode(response, obj.resultCode);
        return;
      }

      // print parameters
      obj.printData();

      // handle request
      obj.handleData();
    } catch (HectorException e) {
      obj.resultCode = ErrorCode.ERROR_CASSANDRA;
      log.severe("catch DB exception=" + e.toString());
      e.printStackTrace();
    } catch (JSONException e) {
      obj.resultCode = ErrorCode.ERROR_JSON;
      log.severe("catch JSON exception=" + e.toString());
      e.printStackTrace();
    } catch (Exception e) {
      obj.resultCode = ErrorCode.ERROR_SYSTEM;
      log.severe("catch general exception=" + e.toString());
      e.printStackTrace();
    } finally {
    }

    String responseData = obj.getResponseString();

    // send back response
    sendResponse(response, responseData);
  }