Package de.danet.an.workflow.omgcore

Examples of de.danet.an.workflow.omgcore.InvalidDataException


                logger.warn("Call to setResult() ignored because " + toString()
                        + " has already been abandoned (probably called "
                        + "by tool that could not be terminated).");
                return;
            }
      throw new InvalidDataException
    ("Cannot set result for " + this + ": state is "
     + state() + " (not open).");
  }
  if (curExec == 0 || curExec == Integer.MAX_VALUE) {
      throw new InvalidDataException
    ("Cannot set result for " + this + ": no tool running.");
  }
  ((ExtImplementationLocal)getPaActImpl()[Math.abs(curExec) - 1])
      .mergeResult (toActivityLocal(), result);
  if (getPaPreliminarilyChosen ()) {
View Full Code Here


    if (fp.mode() == FormalParameter.Mode.IN) {
        continue;
    }
    Object actParam = actualParameters()[i];
    if (!result.containsKey(fp.id())) {
        throw new InvalidDataException
      ("Result does not include out parameter \""
       + fp.id() + "\".");
    }
    pd.put (actParam, result.get(fp.id()));
    items.remove (fp.id());
      }
      if (items.size() > 0) {
    Iterator itr = items.iterator();
    throw new InvalidDataException
        ("Result includes excessive parameter \""
         + (String)itr.next() + "\".");
      }
      process.setProcessContext (pd);
  } catch (UpdateNotAllowedException e) {
      // This is a bit curious, but the only possible
      // mapping. And the OMG considers it "legal": "...or when
      // an invalid attempt is made to update the results of an
      // activity; lack of access rights might be one of those
      // reasons."
      throw new InvalidDataException ("Caused by: " + e.getMessage());
  }
    }
View Full Code Here

  ProcessDataInfo sig = getPaProcessDef().contextSignature ();
  for (Iterator i = newValues.keySet().iterator(); i.hasNext();) {
      String name = (String)i.next();
      Object type = sig.get (name);
      if (type == null) {
    throw new InvalidDataException ("No such data field: " + name);
      }
      Object v = newValues.get(name);
      if (v == null) {
    continue;
      }
            if ((type instanceof ExternalReference)
                && XPDLUtil.isJavaType((ExternalReference)type)) {
                Class vc = null;
                try {
                    vc = XPDLUtil.getJavaType((ExternalReference)type);
                } catch (ClassNotFoundException e) {
                    throw (InvalidDataException)
                        (new InvalidDataException
                         ("Required Java class no longer available: "
                          + e.getMessage())).initCause(e);
                }
                if (vc.isAssignableFrom(v.getClass())) {
                    continue;
                } else {
                    throw new InvalidDataException
                        ("Context entry " + name + " is "
                         + v.getClass().getName() + " must be instance of "
                         + vc.getName());
                }
            }
      if ((type instanceof SAXEventBuffer)
    || (type instanceof ExternalReference)
    || type.equals(org.w3c.dom.Element.class)) {
    boolean elemList = false;
    if (v instanceof List) {
        if (((List)v).size() == 0) {
      elemList = true;
        } else {
      Iterator ti = ((List)v).iterator ();
      if (ti.next() instanceof Element) {
          elemList = true;
      }
        }
    }
    if (! ((v instanceof Element)
           || (v instanceof Document)
           || elemList
           || (v instanceof org.w3c.dom.Element)
           || (v instanceof org.w3c.dom.DocumentFragment)
           || (v instanceof org.w3c.dom.Document)
           || (v instanceof SAXEventBuffer))) {
        throw new InvalidDataException
      ("Not a usable XML representation: " + name);
    }
    continue;
      }
      if (type instanceof Class) {
    Class vc = v.getClass();
    if (v instanceof Float) {
        vc = Double.class;
    } else if (v instanceof Integer) {
        vc = Long.class;
    }
    if (type == Participant.class) {
        type = String.class;
    }
    if (! ((Class)type).isAssignableFrom (vc)) {
        throw new InvalidDataException
      ("Values for data field \"" + name
       + "\" must be of type " + ((Class)type).getName ()
       + " (is " + v.getClass().getName () + ")");
    }
    continue;
      }
      throw new InvalidDataException
    ("Invalid type for data field \"" + name
     + "\": " + ((Class)type).getName ());
  }
  // now do changes
  DOMBuilder builder = null;
  ProcessData oldValues = new DefaultProcessData();
  for (Iterator i = (new ArrayList (newValues.keySet())).iterator();
       i.hasNext();) {
      String name = (String)i.next();
      oldValues.put(name, getPaProcessData().get(name));
      Object v = newValues.get(name);
            if (logger.isDebugEnabled ()) {
                logger.debug ("Setting context data item " + name + " = " + v);
            }
            Object type = sig.get (name);
            if ((type instanceof ExternalReference)
                && XPDLUtil.isJavaType((ExternalReference)type)) {
                // accept literally
            } else if (v instanceof Float) {
    v = new Double (((Float)v).doubleValue ());
    newValues.put (name, v);
      } else if (v instanceof Integer) {
    v = new Long (((Integer)v).longValue ());
    newValues.put (name, v);
      } else if ((v instanceof Element)
           || (v instanceof Document)
           || (v instanceof List)) {
    try {
        if (logger.isDebugEnabled ()) {
      logger.debug
          ("Convering item " + name + " from JDOM to SAX");
        }
        SAXOutputter outputter = new SAXOutputter();
        SAXEventBufferImpl b = new SAXEventBufferImpl ();
        outputter.setContentHandler(b);
        outputter.setLexicalHandler(b);
        if (v instanceof Document) {
      outputter.output ((Document)v);
        } else {
      List l;
      if (v instanceof List) {
          l = (List)v;
      } else {
          l = new ArrayList ();
          l.add (v);
      }
      outputter.output (l);
        }
        b.pack();
        v = b;
        newValues.put (name, v);
    } catch (JDOMException e) {
        logger.error (e.getMessage (), e);
        throw new InvalidDataException (e.getMessage ());
    }
      } else if ((v instanceof org.w3c.dom.Element)
           || (v instanceof org.w3c.dom.DocumentFragment)
           || (v instanceof org.w3c.dom.Document)) {
    try {
        if (logger.isDebugEnabled ()) {
      logger.debug
          ("Convering item " + name + " from W3C DOM to SAX");
        }
        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer t = tf.newTransformer ();
        SAXEventBufferImpl b = new SAXEventBufferImpl ();
        // There seems to be a bug in Xalan that causes it to
        // fire two endDocument events when transforming a
        // DocumentFragment, filter it out.
        t.transform (new DOMSource ((org.w3c.dom.Node)v),
         new SAXResult(new DupEndFilter(b)));
        b.pack();
        v = b;
        newValues.put (name, v);
    } catch (TransformerConfigurationException e) {
        String s = "Error converting DOM to SAX: "+e.getMessage ();
        logger.error (s, e);
        throw new IllegalStateException (s);
    } catch (TransformerException e) {
        String s = "Error converting DOM to SAX: "+e.getMessage ();
        logger.error (s, e);
        throw new InvalidDataException (s);
    }
      }
      getPaProcessData().put(name, v);
  }
View Full Code Here

     * match formal parameter names or excessive entries exist.
     */
    public void mergeResult (ActivityLocal act, Map result)
  throws InvalidDataException {
  if (!(result instanceof ProcessDataWithParams)) {
      throw new InvalidDataException ("Need ProcDataWithParams");
  }
  ProcessLocal process = (ProcessLocal)act.containerLocal();
  FormalParameter[] fps
      = ((ProcessDataWithParams)result).formalParameters();
  mergeResult (process, fps, result);
View Full Code Here

TOP

Related Classes of de.danet.an.workflow.omgcore.InvalidDataException

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.