Permalink
Browse files

[AS7-6252] mail subsystem cannot be created from scratch with the CLI

  • Loading branch information...
1 parent ca57e1c commit 2771e1355a7cd498643ff4be9c84d14dc0804097 @tfonteyn tfonteyn committed Dec 28, 2012
Showing with 27 additions and 26 deletions.
  1. +27 −26 mail/src/main/java/org/jboss/as/mail/extension/MailSubsystemParser.java
@@ -81,39 +81,40 @@ public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingCon
context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
ModelNode model = context.getModelNode();
- List<Property> sessions = model.get(MAIL_SESSION).asPropertyList();
+ if (model.hasDefined(MAIL_SESSION)) {
+ List<Property> sessions = model.get(MAIL_SESSION).asPropertyList();
- for (Property mailSession : sessions) {
- ModelNode sessionData = mailSession.getValue();
- writer.writeStartElement(Element.MAIL_SESSION.getLocalName());
+ for (Property mailSession : sessions) {
+ ModelNode sessionData = mailSession.getValue();
+ writer.writeStartElement(Element.MAIL_SESSION.getLocalName());
- JNDI_NAME.marshallAsAttribute(sessionData, writer);
- DEBUG.marshallAsAttribute(sessionData, false, writer);
- FROM.marshallAsAttribute(sessionData, false, writer);
+ JNDI_NAME.marshallAsAttribute(sessionData, writer);
+ DEBUG.marshallAsAttribute(sessionData, false, writer);
+ FROM.marshallAsAttribute(sessionData, false, writer);
- if (sessionData.hasDefined(SERVER_TYPE)) {
- for (Property property : sessionData.get(SERVER_TYPE).asPropertyList()) {
- String name = property.getName();
- if (name.equals(SMTP)) {
- writeServerModel(writer, property.getValue(), SMTP_SERVER, null);
- } else if (name.equals(POP3)) {
- writeServerModel(writer, property.getValue(), POP3_SERVER, null);
- } else if (name.equals(IMAP)) {
- writeServerModel(writer, property.getValue(), IMAP_SERVER, null);
- } else {
- throw new XMLStreamException("unknown model element " + name);
+ if (sessionData.hasDefined(SERVER_TYPE)) {
+ for (Property property : sessionData.get(SERVER_TYPE).asPropertyList()) {
+ String name = property.getName();
+ if (name.equals(SMTP)) {
+ writeServerModel(writer, property.getValue(), SMTP_SERVER, null);
+ } else if (name.equals(POP3)) {
+ writeServerModel(writer, property.getValue(), POP3_SERVER, null);
+ } else if (name.equals(IMAP)) {
+ writeServerModel(writer, property.getValue(), IMAP_SERVER, null);
+ } else {
+ throw new XMLStreamException("unknown model element " + name);
+ }
}
}
- }
- if (sessionData.hasDefined(CUSTOM)) {
- for (Property property : sessionData.get(CUSTOM).asPropertyList()) {
- String name = property.getName();
- writeServerModel(writer, property.getValue(), CUSTOM_SERVER, name);
+ if (sessionData.hasDefined(CUSTOM)) {
+ for (Property property : sessionData.get(CUSTOM).asPropertyList()) {
+ String name = property.getName();
+ writeServerModel(writer, property.getValue(), CUSTOM_SERVER, name);
+ }
}
- }
-
- writer.writeEndElement();
+ writer.writeEndElement();
+ }
}
writer.writeEndElement();
}

0 comments on commit 2771e13

Please sign in to comment.