Ejemplo n.º 1
0
  private String registerPrefix(final XMLStreamWriter xmlWriter, final String namespace)
      throws XMLStreamException {
    String prefix = xmlWriter.getPrefix(namespace);

    if (prefix == null) {
      prefix = SessionFiles.generatePrefix(namespace);
      while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) {
        prefix = BeanUtil.getUniquePrefix();
      }

      xmlWriter.writeNamespace(prefix, namespace);
      xmlWriter.setPrefix(prefix, namespace);
    }

    return prefix;
  }
Ejemplo n.º 2
0
  @Override
  public void serialize(
      final QName parentQName,
      final OMFactory factory,
      final MTOMAwareXMLStreamWriter xmlWriter,
      final boolean serializeType)
      throws XMLStreamException, ADBException {
    String prefix = parentQName.getPrefix();
    String namespace = parentQName.getNamespaceURI();

    if ((namespace != null) && (namespace.trim().length() > 0)) {
      final String writerPrefix = xmlWriter.getPrefix(namespace);
      if (writerPrefix != null) {
        xmlWriter.writeStartElement(namespace, parentQName.getLocalPart());
      } else {
        if (prefix == null) {
          prefix = SessionFiles.generatePrefix(namespace);
        }

        xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace);
        xmlWriter.writeNamespace(prefix, namespace);
        xmlWriter.setPrefix(prefix, namespace);
      }
    } else {
      xmlWriter.writeStartElement(parentQName.getLocalPart());
    }

    final String namespacePrefix =
        this.registerPrefix(
            xmlWriter, "http://remotelabs.eng.uts.edu.au/schedserver/localrigprovider");
    if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) {
      this.writeAttribute(
          "xsi",
          "http://www.w3.org/2001/XMLSchema-instance",
          "type",
          namespacePrefix + ":SessionFiles",
          xmlWriter);
    } else {
      this.writeAttribute(
          "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "SessionFiles", xmlWriter);
    }

    xmlWriter.writeStartElement("name");
    if (this.name == null) {
      throw new ADBException("name cannot be null!!");
    } else {
      xmlWriter.writeCharacters(this.name);
    }

    xmlWriter.writeEndElement();
    if (this.files != null) {
      for (final SessionFile localFile : this.files) {
        if (localFile != null) {
          localFile.serialize(new QName("", "files"), factory, xmlWriter);
        } else {
          throw new ADBException("files cannot be null!!");
        }
      }
    } else {
      throw new ADBException("files cannot be null!!");
    }

    xmlWriter.writeStartElement("user");
    if (this.user == null) {
      throw new ADBException("user cannot be null!!");
    } else {
      xmlWriter.writeCharacters(this.user);
    }
    xmlWriter.writeEndElement();

    xmlWriter.writeEndElement();
  }