private IncludeDirective buildIncludeDirective(Element element, boolean flag)
     throws DecodingException {
   final String tag = element.getTagName();
   final Properties properties = buildProperties(element);
   if (INCLUDE_ELEMENT_NAME.equals(tag)) {
     Category category = buildCategory(element, flag);
     if (element.hasAttribute("key")) {
       final String value = ElementHelper.getAttribute(element, "key", null);
       return new IncludeDirective(IncludeDirective.KEY, category, value, properties);
     } else if (element.hasAttribute("ref")) {
       final String value = ElementHelper.getAttribute(element, "ref", null);
       return new IncludeDirective(IncludeDirective.REF, category, value, properties);
     } else if (element.hasAttribute("uri")) {
       final String value = ElementHelper.getAttribute(element, "uri", null);
       return new IncludeDirective(IncludeDirective.URI, category, value, properties);
     } else {
       final String error =
           "Include directive does not declare a 'uri', 'key' or 'ref' attribute.\n"
               + element.toString();
       throw new IllegalArgumentException(error);
     }
   } else {
     final String error = "Invalid include element name [" + tag + "].";
     throw new DecodingException(error, null, element);
   }
 }
 private ImportDirective buildImportDirective(Element element) throws DecodingException {
   final String tag = element.getTagName();
   final Properties properties = buildProperties(element);
   if (IMPORT_ELEMENT_NAME.equals(tag)) {
     try {
       if (element.hasAttribute("file")) {
         final String value = ElementHelper.getAttribute(element, "file", null);
         return new ImportDirective(ImportDirective.FILE, value, properties);
       } else if (element.hasAttribute("uri")) {
         final String value = ElementHelper.getAttribute(element, "uri", null);
         return new ImportDirective(ImportDirective.URI, value, properties);
       } else {
         final String error =
             "Import element does not declare a 'file' or 'uri' attribute.\n" + element.toString();
         throw new IllegalArgumentException(error);
       }
     } catch (Throwable e) {
       final String error = "Internal error while attempting to resolve an import directive.";
       throw new DecodingException(error, e, element);
     }
   } else {
     final String error = "Invalid include element name [" + tag + "].";
     throw new IllegalArgumentException(error);
   }
 }
 /**
  * This returns the label text for the adapted class.
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public String getText(Object object) {
   Element labelValue = ((Query) object).getDocumentationElement();
   String label = labelValue == null ? null : labelValue.toString();
   return label == null || label.length() == 0
       ? getString("_UI_Query_type")
       : //$NON-NLS-1$
       getString("_UI_Query_type") + " " + label; // $NON-NLS-1$ //$NON-NLS-2$
 }
示例#4
0
 private void getNames(NodeList nl) {
   for (int i = 0; i < nl.getLength(); i++) {
     Node n = nl.item(i);
     if (n instanceof Element) {
       Element el = (Element) n;
       if (ModelDSN.debug >= 2) {
         System.out.println(
             "!!!Element: (" + el.getChildNodes().getLength() + ") " + el.toString());
       }
       if (el.getNodeName().equals("NAME")) {
         tc.setName(el.getTextContent());
       } else if (el.getNodeName().equals("TEXT")) {
         tc.addText(el);
       } else if (el.getNodeName().equals("WIRE")) {
         tc.addWire(el);
       } else if (el.getNodeName().equals("BUS")) {
         tc.addBus(el);
       } else if (el.getNodeName().equals("ELLIPSE")) {
         tc.addEllipse(el);
       } else if (el.getNodeName().equals("FONT")) {
         tc.addFont(el);
       } else if (el.getNodeName().equals("STYLE")) {
         tc.addStyle(el);
       } else if (el.getNodeName().equals("SYMBOLDEF")) {
         tc.addSymboldef(el);
       } else if (el.getNodeName().equals("SYMBOL")) {
         tc.addSymbol(el);
       } else if (el.getNodeName().equals("JUNCTION")) {
         tc.addJunction(el);
       } else if (el.getNodeName().equals("POWER")) {
         tc.addPower(el);
       } else if (el.getNodeName().equals("LABEL")) {
         tc.addLabel(el);
       } else if (el.getNodeName().equals("POLYGON")) {
         tc.addPolygon(el);
       } else if (el.getNodeName().equals("BUSSLASH")) {
         tc.addBusSlash(el);
       } else if (el.getNodeName().equals("DETAILS")) {
         tc.setDetails(el.getChildNodes());
       } else if (el.getNodeName().equals("OPTIONS")) {
         tc.setOptions(el.getChildNodes());
       }
     }
   }
 }
示例#5
0
  @SuppressWarnings("unchecked")
  private CorrelationKey computeCorrelationKey(
      OScope.CorrelationSet cset, OMessageVarType messagetype, Element msg) {
    CorrelationKey key = null;

    String[] values = new String[cset.properties.size()];

    int jIdx = 0;
    for (Iterator j = cset.properties.iterator(); j.hasNext(); ++jIdx) {
      OProcess.OProperty property = (OProcess.OProperty) j.next();
      OProcess.OPropertyAlias alias = property.getAlias(messagetype);

      if (alias == null) {
        // TODO: Throw a real exception! And catch this at compile
        // time.
        throw new IllegalArgumentException(
            "No alias matching property '"
                + property.name
                + "' with message type '"
                + messagetype
                + "'");
      }

      String value;
      try {
        value = _process.extractProperty(msg, alias, msg.toString());
      } catch (FaultException fe) {
        String emsg =
            __msgs.msgPropertyAliasDerefFailedOnMessage(alias.getDescription(), fe.getMessage());
        __log.error(emsg, fe);
        throw new InvalidMessageException(emsg, fe);
      }
      values[jIdx] = value;
    }

    if (cset.hasJoinUseCases) {
      key = new OptionalCorrelationKey(cset.name, values);
    } else {
      key = new CorrelationKey(cset.name, values);
    }

    return key;
  }
示例#6
0
  private void doCreate() throws Exception {
    try {
      String type = getItemType();
      String name = getItemName();

      ManagedObjectReference taskMoRef = null;

      ManagedObjectReference folderMoRef =
          cb.getServiceUtil().getDecendentMoRef(null, "Folder", getParentName());

      if (folderMoRef == null) {
        System.out.println("Parent folder '" + getParentName() + "' not found");
      } else {
        if (type.equals("Folder")) {
          cb.getConnection().getService().createFolder(folderMoRef, name);
          System.out.println("Sucessfully created::" + name);
        } else if (type.equals("Datacenter")) {
          cb.getConnection().getService().createDatacenter(folderMoRef, name);
          System.out.println("Sucessfully created::" + name);
        } else if (type.equals("Cluster")) {
          ClusterConfigSpec clusterSpec = new ClusterConfigSpec();
          cb.getConnection().getService().createCluster(folderMoRef, name, clusterSpec);
          System.out.println("Sucessfully created::" + name);
        } else if (type.equals("Host-Standalone")) {
          HostConnectSpec hostSpec = new HostConnectSpec();
          hostSpec.setHostName(name);
          hostSpec.setUserName(getUserName());
          hostSpec.setPassword(getPassword());
          hostSpec.setPort(getPort());
          if (type.equals("Host-Standalone")) {
            taskMoRef =
                cb.getConnection().getService().addStandaloneHost_Task(folderMoRef, hostSpec, true);

            if (taskMoRef != null) {
              String status = cb.getServiceUtil().waitForTask(taskMoRef);
              if (status.equalsIgnoreCase("sucess")) {
                System.out.println("Sucessfully created::" + name);
              } else {
                System.out.println("Host'" + name + " not created::");
              }
            }
          }
        } else {
          System.out.println("Unknown Type. Allowed types are:");
          System.out.println(" Host-Standalone");
          System.out.println(" Cluster");
          System.out.println(" Datacenter");
          System.out.println(" Folder");
        }
      }
    } catch (Exception e) {
      if (e instanceof org.apache.axis.AxisFault) {
        org.apache.axis.AxisFault fault = (org.apache.axis.AxisFault) e;
        org.w3c.dom.Element[] errors = fault.getFaultDetails();
        for (Element error : errors) {
          if (error.toString().indexOf("DuplicateName") != -1) {
            System.out.println("Managed Entity with the name already exists");
          } else if (error.toString().indexOf("InvalidArgument") != -1) {
            System.out.println("Specification is invalid");
          } else if (error.toString().indexOf("InvalidName") != -1) {
            System.out.println("Managed Entity Name is empty or too long");
          } else if (error.toString().indexOf("RuntimeFault") != -1) {
            System.out.println(
                error.toString() + " " + "Either parent name or item name is invalid");
          } else if (error.toString().indexOf("NotSupportedFault: null") != -1) {
            System.out.println(
                error.toString() + " " + "The Operation is not supported on this object");
          } else {
            System.out.println(
                error.toString() + " " + "The Operation is not supported on this object");
          }
        }
      } else {
        throw e;
      }
    }
  }