Package com.jamesmurty.utils

Examples of com.jamesmurty.utils.XMLBuilder.asString()


         cpuItem.e("rasd:ResourceType").t(ResourceType.MEMORY.value());
         cpuItem.e("rasd:VirtualQuantity").t(memoryInMB.toString());
         cpuItem.e("rasd:Weight").t("0");
         Properties outputProperties = new Properties();
         outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
         request = super.bindToRequest(request, cpuItem.asString(outputProperties));
      } catch (Exception e) {
         Throwables.propagate(e);
      }
      return request;
   }
View Full Code Here


      if (options.getDescription() != null)
         rootBuilder.e("Description").text(options.getDescription());
      rootBuilder.e("Source").a("href", vApp).a("type", VCloudMediaType.VAPP_XML);
      Properties outputProperties = new Properties();
      outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
      return rootBuilder.asString(outputProperties);
   }

   protected XMLBuilder buildRoot(String name) throws ParserConfigurationException, FactoryConfigurationError {
      XMLBuilder rootBuilder = XMLBuilder.create("CaptureVAppParams").a("name", name).a("xmlns", ns)
            .a("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema);
View Full Code Here

      for (Entry<String, Object> entry : postParams.entrySet())
         rootBuilder.a(entry.getKey(), (String) entry.getValue());
      rootBuilder.a("xmlns", ns);
      Properties outputProperties = new Properties();
      outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
      return rootBuilder.asString(outputProperties);
   }

   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
      throw new IllegalArgumentException("incorrect usage");
View Full Code Here

         cpuItem.e("rasd:ResourceType").t(ResourceType.PROCESSOR.value());
         cpuItem.e("rasd:VirtualQuantity").t(cpuCount.toString());
         cpuItem.e("rasd:Weight").t("0");
         Properties outputProperties = new Properties();
         outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
         request = super.bindToRequest(request, cpuItem.asString(outputProperties));
      } catch (Exception e) {
         Throwables.propagate(e);
      }
      return request;
   }
View Full Code Here

            guestCustomizationSection.e("Link").a("rel", "edit").a("type", guest.getType()).a("href",
                     guest.getHref().toASCIIString());

         Properties outputProperties = new Properties();
         outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
         request =  super.bindToRequest(request, guestCustomizationSection.asString(outputProperties));
         request.getPayload().getContentMetadata().setContentType(guest.getType());
      } catch (Exception e) {
         Throwables.propagate(e);
      }
      return request;
View Full Code Here

      if (options.getDescription() != null)
         rootBuilder.e("Description").text(options.getDescription());
      rootBuilder.e("VApp").a("xmlns", ns).a("href", vApp).a("type", TerremarkVCloudMediaType.VAPP_XML);
      Properties outputProperties = new Properties();
      outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
      return rootBuilder.asString(outputProperties);
   }

   protected CloneVAppOptions findOptionsInArgsOrNull(GeneratedHttpRequest gRequest) {
      for (Object arg : gRequest.getInvocation().getArgs()) {
         if (arg instanceof CloneVAppOptions) {
View Full Code Here

      rootBuilder.e("Enabled").t(checkNotNull(postParams.get("enabled"), "enabled").toString());
      if (postParams.containsKey("description") && postParams.get("description") != null)
         rootBuilder.e("Description").t((String) postParams.get("description"));
      Properties outputProperties = new Properties();
      outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
      return rootBuilder.asString(outputProperties);
   }

   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
      try {
View Full Code Here

      String suffix = String.format(nodeNamingConvention, tag, Integer.toHexString(new SecureRandom().nextInt(4095)));
      builder.xpathFind("//volume/name").t(suffix);
      builder.xpathFind("//volume/key").t(suffix);
      builder.xpathFind("//volume/target/path").t(suffix);

      return builder.asString(outputProperties);
   }

   private static String generateClonedDomainXML(String fromXML, StorageVol clonedVol)
            throws ParserConfigurationException, SAXException, IOException, XPathExpressionException,
            TransformerException, LibvirtException {
View Full Code Here

      // generate valid MAC address
      String fromMACaddress = builder.xpathFind("//domain/devices/interface/mac").getElement().getAttribute("address");
      String lastMACoctet = Integer.toHexString(new SecureRandom().nextInt(255));
      builder.xpathFind("//domain/devices/interface/mac").a("address",
               fromMACaddress.substring(0, fromMACaddress.lastIndexOf(":") + 1) + lastMACoctet);
      return builder.asString(outputProperties);
   }

   private static Properties generateOutputXMLProperties() {
      Properties outputProperties = new Properties();
      // Explicitly identify the output as an XML document
View Full Code Here

         cpuItem.e("rasd:ResourceType").t(ResourceType.MEMORY.value());
         cpuItem.e("rasd:VirtualQuantity").t(memoryInMB.toString());
         cpuItem.e("rasd:Weight").t("0");
         Properties outputProperties = new Properties();
         outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
         request = super.bindToRequest(request, cpuItem.asString(outputProperties));
      } catch (Exception e) {
         Throwables.propagate(e);
      }
      return request;
   }
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.