Package br.net.woodstock.rockframework.core.xml.dom

Examples of br.net.woodstock.rockframework.core.xml.dom.XmlDocument


  }

  @Override
  public void read(final InputStream inputStream, final String password) throws IOException {
    try {
      XmlDocument document = XmlDocument.read(inputStream);
      XmlElement root = document.getRoot();

      String encoding = root.getAttribute(XMLStore.ENCODING_ATTRIBUTE);

      XmlElement certificates = root.getElement(XMLStore.CERTIFICATES_ELEMENT);
      XmlElement privateKeys = root.getElement(XMLStore.PRIVATE_KEYS_ELEMENT);
View Full Code Here


  }

  @Override
  public void write(final OutputStream outputStream, final String password) throws IOException {
    try {
      XmlDocument document = new XmlDocument(XMLStore.STORE_ELEMENT);

      XmlElement root = document.getRoot();
      root.setAttribute(XMLStore.ENCODING_ATTRIBUTE, XMLStore.ENCODING);

      XmlElement certificates = root.addElement(XMLStore.CERTIFICATES_ELEMENT);
      XmlElement privateKeys = root.addElement(XMLStore.PRIVATE_KEYS_ELEMENT);
      XmlElement publicKeys = root.addElement(XMLStore.PUBLIC_KEYS_ELEMENT);
      XmlElement secretKeys = root.addElement(XMLStore.SECRET_KEYS_ELEMENT);
      for (Entry<String, Certificate> entry : this.getCertificateMap().entrySet()) {
        String alias = entry.getKey();
        Certificate certificate = entry.getValue();
        this.addCertificateElement(certificates, alias, certificate);
      }
      for (Entry<String, Identity> entry : this.getPrivateKeyMap().entrySet()) {
        String alias = entry.getKey();
        Identity identity = entry.getValue();
        this.addPrivateKeyElement(privateKeys, alias, identity);
      }
      for (Entry<String, PublicKey> entry : this.getPublicKeyMap().entrySet()) {
        String alias = entry.getKey();
        PublicKey publicKey = entry.getValue();
        this.addPublicKeyElement(publicKeys, alias, publicKey);
      }
      for (Entry<String, SecretKey> entry : this.getSecretKeyMap().entrySet()) {
        String alias = entry.getKey();
        SecretKey secretKey = entry.getValue();
        this.addSecretKeyElement(secretKeys, alias, secretKey);
      }
      document.write(outputStream);
    } catch (GeneralSecurityException e) {
      throw new StoreException(e);
    }
  }
View Full Code Here

    return this.toXML(bytes);
  }

  private String toXML(final byte[] bytes) throws IOException {
    try {
      XmlDocument document = XmlDocument.read(new ByteArrayInputStream(bytes));
      String xml = document.toString();
      return xml;
    } catch (SAXException e) {
      throw new WebException(e);
    }
  }
View Full Code Here

      RockFrameworkLogger.getLogger().info("Class " + clazz.getCanonicalName() + " is not not a child of " + JspTag.class.getCanonicalName());
    }

    Tag tag = clazz.getAnnotation(Tag.class);

    XmlDocument document = new XmlDocument("tag");
    XmlElement root = document.getRoot();

    if (Conditions.isNotEmpty(tag.description())) {
      root.addElement("description").setData(tag.description());
    }

    root.addElement("name").setData(tag.name());
    root.addElement("tag-class").setData(clazz.getCanonicalName());
    root.addElement("body-content").setData(tag.content());

    if (tag.dynamicAttributes()) {
      root.addElement("dynamic-attributes").setData(Boolean.valueOf(tag.dynamicAttributes()));
    }

    BeanDescriptor beanDescriptor = new BeanDescriptorBuilder(clazz).getBeanDescriptor();

    for (PropertyDescriptor propertyDescriptor : beanDescriptor.getProperties()) {
      if (!propertyDescriptor.isAnnotationPresent(Attribute.class)) {
        continue;
      }

      Attribute tldAttribute = propertyDescriptor.getAnnotation(Attribute.class);
      XmlElement e = root.addElement("attribute");

      if (Conditions.isNotEmpty(tldAttribute.description())) {
        e.addElement("description").setData(tldAttribute.description());
      }

      e.addElement("name").setData(propertyDescriptor.getName());
      e.addElement("required").setData(Boolean.valueOf(tldAttribute.required()));
      e.addElement("rtexprvalue").setData(Boolean.valueOf(tldAttribute.rtexprvalue()));
      if ((!tldAttribute.rtexprvalue()) && (tldAttribute.type() != String.class)) {
        e.addElement("type").setData(tldAttribute.type().getCanonicalName());
      }
    }

    return document.toString();
  }
View Full Code Here

  }

  public XmlDocument toXML(final String baseName) {
    Assert.notEmpty(baseName, "baseName");
    ClassFinder classFinder = new ClassFinderImpl(baseName, new AnnotationClassFilter(Entity.class));
    XmlDocument document = new XmlDocument(AnnotationToXML.XML_NAMESPACE, AnnotationToXML.XML_LOCATION, AnnotationToXML.XML_ROOT);
    XmlElement entityMappings = document.getRoot();

    for (Class<?> clazz : classFinder.getClasses()) {
      XmlElement entity = entityMappings.addElement("entity");
      entity.setAttribute("class", clazz.getCanonicalName());
      entity.setAttribute("access", "PROPERTY");
View Full Code Here

TOP

Related Classes of br.net.woodstock.rockframework.core.xml.dom.XmlDocument

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.