Exemplo n.º 1
0
 private static void writeConnectorServices(XMLExtendedStreamWriter writer, ModelNode node)
     throws XMLStreamException {
   if (!node.isDefined()) {
     return;
   }
   List<Property> properties = node.asPropertyList();
   if (!properties.isEmpty()) {
     writer.writeStartElement(Element.CONNECTOR_SERVICES.getLocalName());
     for (final Property property : node.asPropertyList()) {
       writer.writeStartElement(Element.CONNECTOR_SERVICE.getLocalName());
       writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
       final ModelNode service = property.getValue();
       for (AttributeDefinition attribute : ConnectorServiceDefinition.ATTRIBUTES) {
         attribute.marshallAsElement(property.getValue(), writer);
       }
       // TODO use a custom attribute marshaller
       if (service.hasDefined(CommonAttributes.PARAM)) {
         for (Property param : service.get(CommonAttributes.PARAM).asPropertyList()) {
           writer.writeEmptyElement(Element.PARAM.getLocalName());
           writer.writeAttribute(Attribute.KEY.getLocalName(), param.getName());
           writer.writeAttribute(
               Attribute.VALUE.getLocalName(),
               param.getValue().get(ConnectorServiceParamDefinition.VALUE.getName()).asString());
         }
       }
       writer.writeEndElement();
     }
     writer.writeEndElement();
     writeNewLine(writer);
   }
 }
  @Override
  public void marshallAsElement(ModelNode resourceModel, XMLStreamWriter writer)
      throws XMLStreamException {
    if (resourceModel.hasDefined(getName()) && resourceModel.asInt() > 0) {
      final ModelNode modules = resourceModel.get(getName());
      for (ModelNode module : modules.asList()) {
        writer.writeStartElement(getXmlName());
        writer.writeAttribute(Attribute.CODE.getLocalName(), module.get(CODE).asString());
        if (module.hasDefined(Constants.LOGIN_MODULE_STACK_REF)) {
          writer.writeAttribute(
              Attribute.LOGIN_MODULE_STACK_REF.getLocalName(),
              module.get(Constants.LOGIN_MODULE_STACK_REF).asString());
        }

        if (module.hasDefined(Constants.MODULE_OPTIONS)) {
          for (ModelNode option : module.get(Constants.MODULE_OPTIONS).asList()) {
            writer.writeEmptyElement(Element.MODULE_OPTION.getLocalName());
            writer.writeAttribute(Attribute.NAME.getLocalName(), option.asProperty().getName());
            writer.writeAttribute(
                Attribute.VALUE.getLocalName(), option.asProperty().getValue().asString());
          }
        }
        writer.writeEndElement();
      }
    }
  }
Exemplo n.º 3
0
 private static void writeTransportParam(
     final XMLExtendedStreamWriter writer, final ModelNode param) throws XMLStreamException {
   if (param.isDefined()) {
     for (final Property parameter : param.asPropertyList()) {
       writer.writeStartElement(Element.PARAM.getLocalName());
       writer.writeAttribute(Attribute.KEY.getLocalName(), parameter.getName());
       writer.writeAttribute(
           Attribute.VALUE.getLocalName(),
           parameter.getValue().get(TransportParamDefinition.VALUE.getName()).asString());
       writer.writeEndElement();
     }
   }
 }
Exemplo n.º 4
0
 static ModelNode parseContainerConfig(XMLExtendedStreamReader reader) throws XMLStreamException {
   final ModelNode config = new ModelNode();
   // no attributes
   if (reader.getAttributeCount() > 0) {
     throw unexpectedAttribute(reader, 0);
   }
   // elements
   while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
     final Element element = Element.forName(reader.getLocalName());
     switch (element) {
       case STATIC_RESOURCES:
         {
           final ModelNode resourceServing = parseStaticResources(reader);
           config.get(STATIC_RESOURCES).set(resourceServing);
           break;
         }
       case JSP_CONFIGURATION:
         {
           final ModelNode jspConfiguration = parseJSPConfiguration(reader);
           config.get(JSP_CONFIGURATION).set(jspConfiguration);
           break;
         }
       case MIME_MAPPING:
         {
           final String[] array =
               requireAttributes(
                   reader, Attribute.NAME.getLocalName(), Attribute.VALUE.getLocalName());
           config.get(MIME_MAPPING).get(array[0]).set(array[1]);
           requireNoContent(reader);
           break;
         }
       case WELCOME_FILE:
         {
           final String welcomeFile = reader.getElementText().trim();
           config.get(WELCOME_FILE).add(welcomeFile);
           break;
         }
       default:
         throw unexpectedElement(reader);
     }
   }
   return config;
 }
Exemplo n.º 5
0
 private void writeContainerConfig(XMLExtendedStreamWriter writer, ModelNode config)
     throws XMLStreamException {
   boolean containerConfigStartWritten = false;
   if (config.hasDefined(STATIC_RESOURCES)) {
     containerConfigStartWritten = writeStaticResources(writer, config.get(STATIC_RESOURCES));
   }
   if (config.hasDefined(JSP_CONFIGURATION)) {
     containerConfigStartWritten =
         writeJSPConfiguration(writer, config.get(JSP_CONFIGURATION), containerConfigStartWritten)
             || containerConfigStartWritten;
   }
   ModelNode container = config;
   if (config.hasDefined(CONTAINER)) {
     // this has been added to get the stuff manageable
     container = config.get(CONTAINER);
   }
   if (container.hasDefined(MIME_MAPPING)) {
     if (!containerConfigStartWritten) {
       writer.writeStartElement(Element.CONTAINER_CONFIG.getLocalName());
       containerConfigStartWritten = true;
     }
     for (final Property entry : container.get(MIME_MAPPING).asPropertyList()) {
       writer.writeEmptyElement(Element.MIME_MAPPING.getLocalName());
       writer.writeAttribute(Attribute.NAME.getLocalName(), entry.getName());
       writer.writeAttribute(Attribute.VALUE.getLocalName(), entry.getValue().asString());
     }
   }
   if (container.hasDefined(WELCOME_FILE)) {
     if (!containerConfigStartWritten) {
       writer.writeStartElement(Element.CONTAINER_CONFIG.getLocalName());
       containerConfigStartWritten = true;
     }
     for (final ModelNode file : container.get(WELCOME_FILE).asList()) {
       writer.writeStartElement(Element.WELCOME_FILE.getLocalName());
       writer.writeCharacters(file.asString());
       writer.writeEndElement();
     }
   }
   if (containerConfigStartWritten) {
     writer.writeEndElement();
   }
 }
Exemplo n.º 6
0
 /**
  * Write element content. The start element is already written.
  *
  * @param writer
  * @throws XMLStreamException
  */
 public void writeContent(XMLStreamWriter writer) throws XMLStreamException {
   for (int i = 0; i < moduleEntries.size(); i++) {
     IdentityTrustModuleEntry entry = moduleEntries.get(i);
     writer.writeStartElement(Element.TRUST_MODULE.getLocalName());
     writer.writeAttribute(Attribute.CODE.getLocalName(), entry.getName());
     writer.writeAttribute(
         Attribute.FLAG.getLocalName(),
         entry.getControlFlag().toString().toLowerCase(Locale.ENGLISH));
     Map<String, ?> options = entry.getOptions();
     if (options != null && options.size() > 0) {
       for (Entry<String, ?> option : options.entrySet()) {
         writer.writeStartElement(Element.MODULE_OPTION.getLocalName());
         writer.writeAttribute(Attribute.NAME.getLocalName(), option.getKey());
         writer.writeAttribute(Attribute.VALUE.getLocalName(), option.getValue().toString());
         writer.writeEndElement();
       }
     }
     writer.writeEndElement();
   }
   writer.writeEndElement();
 }
 private void writeConnectionCreationOptions(
     final XMLExtendedStreamWriter writer, final ModelNode model) throws XMLStreamException {
   // <connection-creation-options>
   writer.writeStartElement(Element.CONNECTION_CREATION_OPTIONS.getLocalName());
   final List<Property> connectionCreationOptions =
       model.get(CONNECTION_CREATION_OPTIONS).asPropertyList();
   for (final Property connectionCreationOption : connectionCreationOptions) {
     // <option>
     writer.writeStartElement(Element.OPTION.getLocalName());
     // write the name attribute
     final String optionName = connectionCreationOption.getName();
     writer.writeAttribute(Attribute.NAME.getLocalName(), optionName);
     // write the value attribute
     final String optionValue = connectionCreationOption.getValue().asString();
     writer.writeAttribute(Attribute.VALUE.getLocalName(), optionValue);
     // </option>
     writer.writeEndElement();
   }
   // </connection-creation-options>
   writer.writeEndElement();
 }