Package de.danet.an.workflow.spis.aii

Examples of de.danet.an.workflow.spis.aii.CannotExecuteException


                        = new StringTokenizer(httpHeaders, "\n");
                    st.hasMoreElements();) {
                    String hdr = st.nextToken();
                    int sep = hdr.indexOf(':');
                    if (sep < 0) {
                        throw new CannotExecuteException
                            ("Invalid header (missing ':'): " + hdr);
                    }
                    mimeHeaders.addHeader
                        (hdr.substring(0, sep),
                         hdr.substring(sep + 1).trim());
                }
            }

            // Add header content, if any
            if (headerContent != null) {
                SOAPHeader hdr = env.getHeader();
                appendNodes (env, hdr, headerContent);
            }

            // Add body content
            SOAPBody body = env.getBody();
            appendNodes (env, body, bodyContent);
           
            // Now invoke with the created message
            SOAPMessage response = null;
            try {
                response = connection.call(message, new URL(endpoint));
            } catch (SOAPException e) {
                if (e.getMessage().indexOf("ConnectException") >= 0) {
                    // Axis way of reporting this
                    if (logger.isDebugEnabled()) {
                        logger.debug
          ("Cannot invoke (signalled ConnectException): "
           + e.getMessage (), e);
                    }
                    throw new CannotExecuteException
                        ("Assuming connection failure: " + e.getMessage(),
                         new ConnectException (e.getMessage(), e));
                } else if (e.getCause() != null
                           && e.getCause().getCause() != null
                           && (e.getCause().getCause()
                               instanceof java.net.ConnectException)) {
                    // JBossWS way of reporting this
                    throw new CannotExecuteException
                        ("Assuming connection failure: " + e.getMessage(),
                         new ConnectException (e.getMessage(), e));
                }
                throw e;
            } finally {
                connection.close ();
            }
            SOAPPart respPart = response.getSOAPPart ();
           
            Map resData = new HashMap ();
            for (int i = 0; i < formPars.length; i++) {
                if (formPars[i].mode() == FormalParameter.Mode.IN) {
                    continue;
                }
                XPath path = (XPath)returnParamInfo.get(formPars[i].id());
                if (path == null) {
                    resData.put(formPars[i].id(),
        convertToSax(respPart.getDocumentElement()));
                } else {
                    if (formPars[i].type().equals (String.class)) {
                        resData.put(formPars[i].id(),
            path.stringValueOf(respPart));
                    } else if ((formPars[i].type() instanceof Class)
             && Number.class.isAssignableFrom
             ((Class)formPars[i].type())) {
                        Number n = path.numberValueOf(respPart);
                        if (formPars[i].type().equals (Long.class)
          && !(n instanceof Long)) {
                            n = new Long (n.longValue());
                        }
                        resData.put(formPars[i].id(), n);
                    } else {
                        resData.put(formPars[i].id(),
            convertToSax(path.selectNodes(respPart)));
                    }
                }
            }     
            result.set (resData);
        } catch (CannotExecuteException e) {
            throw e;
        } catch (MalformedURLException e) {
            throw new CannotExecuteException (e.getMessage(), e);
        } catch (SOAPException e) {
            throw new CannotExecuteException (e.getMessage(), e);
        } catch (SAXException e) {
            throw new CannotExecuteException (e.getMessage(), e);
        } catch (JaxenException e) {
            throw new CannotExecuteException (e.getMessage(), e);
        } catch (TransformerException e) {
            throw new CannotExecuteException (e.getMessage(), e);
        }
    }
View Full Code Here


  try {
      if (fps[0].mode() == FormalParameter.Mode.IN
    || fps[0].type() != Long.class
    || fps[1].mode() == FormalParameter.Mode.OUT
    || fps[1].type() != Date.class) {
    throw new CannotExecuteException
        ("First parameter must be OUT or INOUT (is "
         + fps[0].mode() + ") and of type INTEGER (is "
         + fps[0].type() + ", "
         + "second parameter must be IN or INOUT (is "
         + fps[1].mode() + ") and of type STRING (is "
         + fps[1].type() + ")");
      }
      Date waitUntil = (Date)map.get(fps[1].id());
      if (logger.isDebugEnabled ()) {
    logger.debug ("Creating timer for " + waitUntil);
      }
      long applId = applicationDirectory().registerInstance
    (WaitTool.class.getName(), activity, null, false);
      if (logger.isDebugEnabled()) {
    logger.debug ("Application " + applId
            + " created for " + activity);
      }
      Object timer = timerHandler().createTimer (applId, waitUntil);
      applicationDirectory().updateState
    (applId, new Object[] { timer, null });
      applicationDirectory().updateInvokingActivity (applId, null);
      Map res = new HashMap ();
      res.put (fps[0].id(), new Long (applId));
      result.set (res);
  } catch (InvalidKeyException e) {
      String msg = "Cannot use newly created key?!: " + e.getMessage ();
      logger.error (msg);
      throw new CannotExecuteException (msg);
  }
    }
View Full Code Here

    /* Comment copied from interface. */
    public void invoke(Activity activity, FormalParameter[] fps, Map map)
        throws RemoteException, CannotExecuteException {
        if (objectName == null) {
            throw new CannotExecuteException ("Must specify objectName");
        }
        ObjectName on = null;
        try {
            on = new ObjectName(objectName);
        } catch (MalformedObjectNameException e) {
            throw new CannotExecuteException (e.getMessage ());
        }
        if (operation == null) {
            throw new CannotExecuteException ("Must specify operation");
        }
        if (server == null) {
            List serverList = MBeanServerFactory.findMBeanServer(null);
            for (Iterator i = serverList.iterator(); i.hasNext();) {
                MBeanServer s = (MBeanServer)i.next();
                if (s.isRegistered(on)) {
                    server = s;
                    break;
                }
            }
            if (server == null) {
                throw new CannotExecuteException
                    ("MBean with object name " + objectName
                     + " not registered with any server.");
            }
        }
       
        Object[] params = new Object[fps.length - 1];
        String[] sig = new String[fps.length - 1];
        boolean haveOut = fps.length > 0
      && fps[0].mode() == FormalParameter.Mode.OUT;
        for (int i = haveOut ? 1 : 0, pi = 0; i < fps.length; i++, pi++) {
            if (i > 0 && fps[i].mode() == FormalParameter.Mode.OUT) {
                throw new CannotExecuteException
                    ("Only first parameter may have mode OUT");
            }
            params[pi] = map.get(fps[i].id());
            if (XPDLUtil.isXMLType(fps[i].type())) {
                if (params[pi] instanceof SAXEventBuffer) {
                    sig[i - 1] = SAXEventBuffer.class.getName();
                } else if (params[pi] instanceof org.w3c.dom.DocumentFragment) {
                    sig[i - 1] = org.w3c.dom.DocumentFragment.class.getName();
                } else if (params[pi] instanceof org.jdom.Element) {
                    sig[i - 1] = org.jdom.Element.class.getName();
                } else {
                    String msg = "Got argument of XML type, but cannot"
                      + " recognize value's class: " + params[pi].getClass();
                    logger.error(msg);
                    throw new CannotExecuteException (msg);
                }
            } else {
                sig[i - 1] = ((Class)fps[i].type()).getName();
            }
        }
        if (logger.isDebugEnabled()) {
            StringBuffer args = new StringBuffer();
            for (int i = 0; i < params.length; i++) {
                if (i > 0) {
                    args.append(", ");
                }
                args.append(sig[i].toString());
                args.append(" ");
                args.append(params[i].toString());
            }
            logger.debug("Invoking " + operation + "(" + args.toString() + ")");
        }
        Object res = null;
        try {
            res = server.invoke(on, operation, params, sig);
        } catch (ReflectionException e) {
            throw new CannotExecuteException
                ("No matching operation (or signature): " + e.getMessage());
        } catch (InstanceNotFoundException e) {
            throw new CannotExecuteException
                ("Cannot find MBean with object name " + objectName
                 + ": " + e.getMessage());
        } catch (MBeanException e) {
            throw new CannotExecuteException
                ("Problem invoking operation: " + e.getMessage());
        }
        if (res instanceof Throwable) {
            throw (CannotExecuteException)
                (new CannotExecuteException (((Throwable)res).getMessage())
                 .initCause((Throwable)res));
        }
  if (fps.length > 0 && fps[0].mode() != FormalParameter.Mode.IN) {
      Map resMap = new HashMap ();
      resMap.put(fps[0].id(), res);
View Full Code Here

      if (logger.isDebugEnabled()) {
    logger.debug ("Invoked for " + auk + ", script:");
    logger.debug (script);
      }
      if (script == null) {
    throw new CannotExecuteException ("No script.");
      }
      Context cx = Context.enter();
      Scriptable scope = prepareScope (cx, activity, formPars, map);
      Reader sr = new StringReader (script);
      cx.evaluateReader (scope, sr, "<script>", 1, null);
      result.set(convertResult(cx, scope, formPars));
  } catch (AbandonedException e) {
      // thrown when the activity was deliberatly abandoned.
      result.set (new ExceptionResult (e.getMessage ()));
  } catch (RemoteException e) {
      throw e;
  } catch (IOException e) {
      logger.error (e.getMessage(), e);
      throw new CannotExecuteException (e.getMessage());
        } catch (SAXException e) {
            logger.error (e.getMessage(), e);
            throw new CannotExecuteException (e.getMessage());
  } catch (JavaScriptException e) {
      logger.error (e.getMessage(), e);
      throw new CannotExecuteException (e.getMessage());
  } finally {
      Context.exit();
      if (logger.isDebugEnabled()) {
    logger.debug ("Finished invocation of " + auk);
      }
View Full Code Here

        }

        // Verify that we have an assignee (else this won't show up)
        Collection actAssgnmts = activity.assignments();
        if (actAssgnmts == null || actAssgnmts.size() == 0) {
            throw new CannotExecuteException
                (activity.toString () + " has no assignee.");
        }

        Object[] data = new Object[] {
                context.applicationId(), form,
View Full Code Here

    logger.debug (auk + " sent data to "
            + map.get(formalParameter[0].id()));
      }
  } catch (ResourceNotAvailableException e) {
      logger.error (e.getMessage(), e);
      throw new CannotExecuteException (e.getMessage());
  } catch (InvalidDataException e) {
      logger.error (e.getMessage(), e);
      throw new CannotExecuteException (e.getMessage());
  }
    }
View Full Code Here

  ExtProcess proc = (ExtProcess)act.container();
  if (originatorIndex.intValue() > 0) {
      for (int i = originatorIndex.intValue(); i > 0; i--) {
    proc = (ExtProcess)proc.requestingProcess();
    if (proc == null) {
        throw new CannotExecuteException
      (act + " does not have " + originatorIndex
       + " requesting anchestors");
    }
      }
  } else {
      List procs = new ArrayList ();
      while (true) {
    procs.add (0, proc);
    proc = (ExtProcess)proc.requestingProcess();
    if (proc == null) {
        break;
    }
      }
      try {
    proc = (ExtProcess)procs.get (-originatorIndex.intValue());
      } catch (IndexOutOfBoundsException e) {
    throw new CannotExecuteException
        ("Subflow depth from root of " + act
         + " is less than " + -originatorIndex.intValue());
      }
  }
  return proc;
View Full Code Here

      activity.complete ();
  } catch (CannotCompleteException e) {
      logger.error
    (activity + " receiving from channel "
     + "but cannot be completed?!: " + e.getMessage (), e);
      throw new CannotExecuteException
    ("Receiving activity cannot be completed");
  } catch (InvalidDataException e) {
      logger.warn
    (activity + " received invalid data from channel "
     + channel + ": " + e.getMessage (), e);
      throw new CannotExecuteException (e.getMessage ());
  }
    }
View Full Code Here

  ExtProcess proc = (ExtProcess)act.container();
  if (listenerIndex.intValue() > 0) {
      for (int i = listenerIndex.intValue(); i > 0; i--) {
    proc = (ExtProcess)proc.requestingProcess();
    if (proc == null) {
        throw new CannotExecuteException
      (act + " does not have " + listenerIndex
       + " requesting anchestors");
    }
      }
  } else {
      List procs = new ArrayList ();
      while (true) {
    procs.add (0, proc);
    proc = (ExtProcess)proc.requestingProcess();
    if (proc == null) {
        break;
    }
      }
      try {
    proc = (ExtProcess)procs.get (-listenerIndex.intValue());
      } catch (IndexOutOfBoundsException e) {
    throw new CannotExecuteException
        ("Subflow depth from root of " + act
         + " is less than " + -listenerIndex.intValue());
      }
  }
  return proc;
View Full Code Here

        if (!mappings.isEmpty()) {
            Element mappingElement;
            try {
                mappingElement = createMappings();
            } catch (ParserConfigurationException e) {
                throw new CannotExecuteException(e.getMessage(), e);
            }
            getXSLTTool().setMappings(mappingElement);
        }

        super.invokeTool(formPars, map);
View Full Code Here

TOP

Related Classes of de.danet.an.workflow.spis.aii.CannotExecuteException

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.