Examples of TaskException


Examples of center.task.TaskException

      SAMsg in = new SAMsg();
      SAMsg result = new SAMsg();
        int enq = is.read();
        System.out.print("<-- " + toHexString(enq));
        if (enq != SAMsg.ENQ)
          throw new TaskException(State.DONE_ERR, "Incorrect the first signal from host");
        q.sendTo(s.getOutputStream());
        System.out.print("\n-->");
        q.printTo(System.out);

        System.out.println();
        String v;
        for (String n : prmi.getFieldNames()) {
          v = prmi.getField(n);
          System.out.println(n + " = " + v);
        }

        int ch;
        PrmInterface inpi = in.getPrmInterface();
        CloseableOutputStream osc = in.getOutputStream();
        System.out.print("\n<--");
        boolean end = false;
        while (!end && (ch = is.read()) != -1) {
          System.out.print(" ");
          System.out.print(toHexString(ch));
          osc.write(ch);
          if (osc.isClosed()) {
            switch(Integer.parseInt(inpi.getField("type"))) {
            case  SAMsg.STX:
              System.out.println();
              PrmInterface rpi = result.getPrmInterface();
              for (String n : inpi.getFieldNames()) {
                v = inpi.getField(n);
                rpi.setField(n, v);
                System.out.println(n + " = " + v);
              }
              end = true;
              break;
            case  SAMsg.ACK:
              System.out.print("\n<--");
              break;
            case  SAMsg.ENQ:
              System.out.print("\n<--");
              break;
            default:
              System.out.print("\n<--");
              throw new TaskException(State.DONE_ERR, "Incorrect response from host");
            }
            in.reset();
            osc = in.getOutputStream();
          }
        }
       
        os.write(SAMsg.ACK);
        System.out.print("\n--> " + toHexString(SAMsg.ACK));
        os.write(SAMsg.EOT);
        System.out.println("\n--> " + toHexString(SAMsg.EOT));

      PrmInterface rpi = result.getPrmInterface();
      StringList flds = rpi.getFieldNames();
      for (String fld : flds) {
        cntx.setPrmByFullName(msg_grp_out + "/" + fld, rpi.getField(fld), false);
      }
    } catch (UnknownHostException e) {
      throw new TaskException(State.DONE_ERR, e);
    } catch (IOException e) {
      throw new TaskException(State.DONE_ERR, e);
    } finally {
      ru.vassaev.core.util.Sockets.close(s);
    }
    return State.DONE_OK;
  }
View Full Code Here

Examples of center.task.TaskException

                .println("javax.net.ssl.keyStore is not defined");
          else
            System.out.println("javax.net.ssl.keyStore = "
                + keyStore1);
        } catch (NoSuchProviderException e) {
          throw new TaskException(State.DONE_ERR, e);
        } catch (NoSuchAlgorithmException e) {
          throw new TaskException(State.DONE_ERR, e);
        } catch (KeyManagementException e) {
          throw new TaskException(State.DONE_ERR, e);
        } catch (CertificateException e) {
          throw new TaskException(State.DONE_ERR, e);
        } catch (UnrecoverableKeyException e) {
          throw new TaskException(State.DONE_ERR, e);
        } catch (KeyStoreException e) {
          throw new TaskException(State.DONE_ERR, e);
        }
      else
        server = HttpServer.create(new InetSocketAddress(port), 0);
      server.createContext(path, new XMLHttpHandler(cntx));
      server.setExecutor(executor);
      server.start();

      Process prc = Process.currentProcess();
      while (true) {
        try {
          if (prc.isWillBreak())
            return State.BROKEN;
          State st = cntx.ta.getState(cntx.id_task);
          if (st.getType().equals(TypeOfState.LAST))
            return st;
          if (st.equals(State.BREAKING))
            return State.BROKEN;
        } catch (SysException ex) {
          ex.printStackTrace();
        }
        Thread.sleep(2000);// !!!
      }
    } catch (IOException e) {
      throw new TaskException(State.DONE_ERR, e);
    } catch (InterruptedException e) {
      throw new TaskException(State.DONE_ERR, e);
    } finally {
      if (server != null)
        server.stop(0);
    }
  }
View Full Code Here

Examples of com.adito.tasks.TaskException

                }
                if(onFinish.startsWith(".")) {
                    throw new Exception("Forward returned to go to when task is complete is a tile (" + onFinish + "), this is not allowed. The forward must point an absolute or relative URL.");
                }
            } catch(Exception e) {
                throw new TaskException(TaskException.INTERNAL_ERROR, e);
            }
        }
View Full Code Here

Examples of q_impress.pmi.lib.tasks.TaskException

    return true;
  }

  @Override
  public Map<String, AbstractResource> execute() throws TaskException {
    if (canExecute() == false) throw new TaskException(this, "Task parameters are not valid.");
   
    // check the validity of prism resources
    checkPrismResources();
   
    ByteArrayOutputStream prismModelStream = new ByteArrayOutputStream();
    ByteArrayOutputStream prismPropsStream = new ByteArrayOutputStream();
    try {
      AtopTranslator translator = new AtopTranslator(umlResource.getResourceSet(), umlResource.loadResource(),
          sourceActivityName, modelType, prismModelStream, prismPropsStream);
     
      translator.translate();
     
      writeToResources(prismModelStream, prismPropsStream);
    } catch (ResourceException e) {
      throw new TaskException(this, "Unable to execute translation", e);
    } catch (TranslationException e) {
      throw new TaskException(this, "Unable to execute translation", e);
    } finally {
      try {
        prismModelStream.close();
        prismPropsStream.close();
      } catch (IOException e) {
View Full Code Here

Examples of q_impress.pmi.lib.tasks.TaskException

 
  private void checkPrismResources() throws TaskException {
    try {
      prismModelResource.getFile();
    } catch (ResourceException e) {
      throw new TaskException(this, "Invalid location for PRISM model", e);
    }
   
    try {
      prismPropertiesResource.getFile();
    } catch (ResourceException e) {
      throw new TaskException(this, "Invalid location for PRISM properties", e);
    }
  }
View Full Code Here

Examples of q_impress.pmi.lib.tasks.TaskException

    try {
      IFile tempFile = prismModelResource.getFile();
      if (!tempFile.exists()) tempFile.create(inStream, false, null);
      else tempFile.setContents(inStream, IFile.NONE, null);
    } catch (ResourceException e) {
      throw new TaskException(this, "Invalid location for PRISM model", e);
    } catch (CoreException e) {
      throw new TaskException(this, "Unable to save PRISM model", e);
    } finally {
      try {
        inStream.close();
      } catch (IOException e) {
        assert false;
      }
    }
   
    inStream = new ByteArrayInputStream(propsStream.toByteArray());
    try {
      IFile tempFile = prismPropertiesResource.getFile();
      if (!tempFile.exists()) tempFile.create(inStream, false, null);
      else tempFile.setContents(inStream, IFile.NONE, null);
    } catch (ResourceException e) {
      throw new TaskException(this, "Invalid location for PRISM properties", e);
    } catch (CoreException e) {
      throw new TaskException(this, "Unable to save PRISM properties", e);
    } finally {
      try {
        inStream.close();
      } catch (IOException e) {
        assert false;
View Full Code Here

Examples of q_impress.pmi.lib.tasks.TaskException

    return true;
  }

  @Override
  public Map<String, AbstractResource> execute() throws TaskException {
    if (canExecute() == false) throw new TaskException(this, "Task parameters are not valid.");

    // check the validity of jmt resources
    checkJmtResources();
   
    ByteArrayOutputStream jmtStream = new ByteArrayOutputStream();
    try {
      JmtTranslator translator = new JmtTranslator(umlResource.getResourceSet(), umlResource.loadResource(),
          activityNames, jmtStream);
     
      translator.translate();
     
      writeToResources(jmtStream);
    } catch (ResourceException e) {
      throw new TaskException(this, "Unable to execute translation", e);
    } catch (TranslationException e) {
      throw new TaskException(this, "Unable to execute translation", e);
    } finally {
      try {
        jmtStream.close();
      } catch (IOException e) {
        assert false;
View Full Code Here

Examples of q_impress.pmi.lib.tasks.TaskException

 
  private void checkJmtResources() throws TaskException {
    try {
      jmtResource.getFile();
    } catch (ResourceException e) {
      throw new TaskException(this, "Invalid location for PRISM model", e);
    }
  }
View Full Code Here

Examples of q_impress.pmi.lib.tasks.TaskException

    try {
      IFile tempFile = jmtResource.getFile();
      if (!tempFile.exists()) tempFile.create(inStream, false, null);
      else tempFile.setContents(inStream, IFile.NONE, null);
    } catch (ResourceException e) {
      throw new TaskException(this, "Invalid location for PRISM model", e);
    } catch (CoreException e) {
      throw new TaskException(this, "Unable to save PRISM model", e);
    } finally {
      try {
        inStream.close();
      } catch (IOException e) {
        assert false;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.