Package org.platformlayer.xml

Examples of org.platformlayer.xml.JaxbHelper


  @Override
  public void writeDescriptor() throws OpsException {
    String path = getBackupId() + ".backup.xml";

    JaxbHelper jaxb = JaxbHelper.get(BackupData.class);
    String xml;
    try {
      xml = jaxb.marshal(data, true);
    } catch (JAXBException e) {
      throw new OpsException("Error serializing metadata", e);
    }
    byte[] data = Utf8.getBytes(xml);
View Full Code Here


    return out;
  }

  private Action deserializeAction(String xml) throws OpsException {
    try {
      JaxbHelper jaxbHelper = JaxbHelper.get(Action.class);
      return (Action) jaxbHelper.unmarshal(xml);
    } catch (JAXBException e) {
      throw new OpsException("Error deserializing action", e);
    }
  }
View Full Code Here

    return findItem(key, itemClass);
  }

  public <T> PlatformLayerKey toKey(Class<T> itemClass, String id) throws PlatformLayerClientException {
    JaxbHelper jaxbHelper = PlatformLayerClientBase.toJaxbHelper(itemClass, new Class[0]);
    ManagedItemId itemId = new ManagedItemId(id);

    PlatformLayerKey key = PlatformLayerClientBase.toKey(jaxbHelper, itemId, itemClass,
        platformLayerClient.listServices(true));
    return key;
View Full Code Here

    if (links == null) {
      Node element = XmlHelper.findUniqueChild(root, "links", false);
      if (element == null) {
        links = new Links();
      } else {
        JaxbHelper helper = JaxbHelper.get(Links.class);
        try {
          links = (Links) helper.unmarshal(element);
        } catch (JAXBException e) {
          throw new IllegalStateException("Error parsing tags data", e);
        }
      }
    }
View Full Code Here

  }

  public void setTags(Tags tags) {
    Document document;

    JaxbHelper helper = JaxbHelper.get(Tags.class);
    try {
      document = helper.marshalToDom(tags);
    } catch (JAXBException e) {
      throw new IllegalStateException("Error parsing tags data", e);
    }

    replaceNode("tags", document.getDocumentElement());
View Full Code Here

    ItemBase item = new ItemBase();
    item.links = links;

    Document document;

    JaxbHelper helper = JaxbHelper.get(ItemBase.class);
    try {
      document = helper.marshalToDom(item);
    } catch (JAXBException e) {
      throw new IllegalStateException("Error serializing data", e);
    }

    replaceNode("links", XmlHelper.findUniqueChild(document.getDocumentElement(), "links", false));
View Full Code Here

        httpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        return;
      }
    } else {
      try {
        JaxbHelper jaxb = JaxbHelper.get(response.getClass());
        boolean formatted = false;
        jaxb.marshal(response, formatted, baos);
      } catch (Exception e) {
        log.error("Error serializing value", e);
        httpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        return;
      }
View Full Code Here

      if (c == Void.class) {
        return null;
      } else {
        String xml = result.getBody();

        JaxbHelper jaxb = JaxbHelper.get(c);
        try {
          return (T) jaxb.unmarshal(xml);
        } catch (JAXBException e) {
          throw new OpenstackException("Error deserializing response", e);
        }
      }
    }
View Full Code Here

    }

    public CurlRequest toCurlRequest() {
      CurlRequest request = new CurlRequest(resourceUrl);
      if (body != null) {
        JaxbHelper jaxb = JaxbHelper.get(body.getClass());
        String xml;
        try {
          xml = jaxb.marshal(body, false);
        } catch (JAXBException e) {
          throw new OpenstackException("Error serializing request body", e);
        }
        request.body = xml;
      }
View Full Code Here

    return executions;
  }

  @Override
  public <T extends ItemBase> T putItem(T item) throws OpsException {
    JaxbHelper jaxbHelper = PlatformLayerClientBase.toJaxbHelper(item);

    String xml = PlatformLayerClientBase.serialize(jaxbHelper, item);

    PlatformLayerKey key = PlatformLayerClientBase.toKey(jaxbHelper, item, listServices(true));
View Full Code Here

TOP

Related Classes of org.platformlayer.xml.JaxbHelper

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.