Package com.sos.scheduler.model.answers

Examples of com.sos.scheduler.model.answers.Answer


      SchedulerObjectFactory objJSFactory = new SchedulerObjectFactory();
      objJSFactory.initMarshaller(ShowHistory.class);
      JSCmdShowHistory objShowHistory = objJSFactory.createShowHistory();
      objShowHistory.setJob(strJobName);
      objShowHistory.setPrev(BigInteger.valueOf(1));
      Answer objAnswer = null;
     
      if(flgRunAsSchedulerAPIJob) {
        logger.debug("... runs as Job Scheduler API job");
        String strShowHistoryXML = objShowHistory.toXMLString();
        String answerXML = objJSCommands.executeXML(strShowHistoryXML);
        objAnswer = objShowHistory.getAnswer(answerXML);
      }
      else {
        logger.debug("... runs as command line job");
        objJSFactory.Options().ServerName.Value(Options().SchedulerHostName.Value());
        objJSFactory.Options().PortNumber.value(Options().SchedulerPort.value());
        objShowHistory.run();
        objAnswer = objShowHistory.getAnswer();
      }
     
      if(objAnswer != null) {
        ERROR objError = objAnswer.getERROR();
        if(objError != null) {
          throw new JSCommandErrorException(objError.getText());
        }
        List<HistoryEntry> objHistoryEntries = objAnswer.getHistory().getHistoryEntry();
        if(objHistoryEntries.size() == 0) {
          logger.error(String.format("no history entry found for %1$s", strJobName));
          throw new JobSchedulerException(String.format("no history entry found for %1$s", strJobName));
        }
        else {
View Full Code Here


   * @param pobjJSCmd
   * @return
   */
  public Answer run(JSCmdBase pobjJSCmd) {
    final String conMethodName = conClassName + "::run";
    Answer objAnswer = null;
    String strT = pobjJSCmd.toXMLString();
    String strA = "";
    try {
      logger.debug(String.format("%1$s: Request: %n%2$s", conMethodName, strT));
      if (objOptions.TransferMethod.isTcp()) {
        this.getSocket().sendRequest(strT);
        strA = getSocket().getResponse();
        objAnswer = getAnswer(strA);
      }
      else
        if (objOptions.TransferMethod.isUdp()) {
          DatagramSocket udpSocket = null;
          int intPortNumber = 0;
          try {
            udpSocket = new DatagramSocket();
            intPortNumber = objOptions.PortNumber.value();
            InetAddress objInetAddress = objOptions.ServerName.getInetAddress();
            udpSocket.connect(objInetAddress, intPortNumber);
            if (strT.indexOf("<?xml") == -1) {
              strT = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" + strT;
            }
            byte[] btyBuffer = strT.getBytes();
            udpSocket.send(new DatagramPacket(btyBuffer, btyBuffer.length, objInetAddress, intPortNumber));
          }
          catch (Exception e) {
            e.printStackTrace();
            throw e;
          }
          finally {
            if (udpSocket != null) {
              logger.debug(String.format("Command sent using UDP to host '%1$s' at port '%2$d'", objOptions.ServerName.toString(), intPortNumber)  );
              udpSocket.disconnect();
              udpSocket = null;
            }
          }
        }
        else {
          throw new JobSchedulerException(String.format("TransferMethod '%1$s' not supported (yet)", objOptions.TransferMethod.Value()));
        }
    }
    catch (Exception e) {
      throw new JobSchedulerException(String.format("%1$s: %2$s", conMethodName, e.getMessage()), e);
    }
    if (objAnswer != null) {
      // TODO in Answer den original-response des js als string ablegen.
      // TODO eigenst�ndige BasisKlasse JSAnswerBase bauen. ableiten von JSCmdBase.
      if (objAnswer.getERROR() != null) {
        throw new JobSchedulerException("Job Scheduler responds an error due to an invalid or wrong command\n" + strT);
      }
    }
    return objAnswer;
  } // private Object run
View Full Code Here

   * @return
   */
  public Answer getAnswer(String pXMLStr) {
    final String conMethodName = conClassName + "::getAnswer";
    logger.debug(String.format("%1$s: Response: %n%2$s", conMethodName, pXMLStr));
    Answer objAnswer = null;
    com.sos.scheduler.model.answers.Spooler objSpooler = null;
    try {
      /**
       * den speziellen Context f�r die Answer brauchen wir, solange die Answer nicht in der scheduler.xsd enthalten ist.
       * dadurch ist das dann ein anderer Namespace und das passt nicht zusammen.
View Full Code Here

TOP

Related Classes of com.sos.scheduler.model.answers.Answer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.