Skip to content

Commit

Permalink
[WFLY-13367] Bump mail model and schema version to 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fjuma committed Apr 21, 2020
1 parent 9e16ff3 commit 2615e11
Show file tree
Hide file tree
Showing 11 changed files with 420 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ public void initializeParsers(ExtensionParsingContext context) {
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.MAIL_1_2.getUriString(), MailSubsystemParser::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.MAIL_2_0.getUriString(), MailSubsystemParser2_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.MAIL_3_0.getUriString(), MailSubsystemParser3_0::new);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.MAIL_4_0.getUriString(), MailSubsystemParser4_0::new);
}

static final ModelVersion CURRENT_MODEL_VERSION = ModelVersion.create(3, 0, 0);
static final ModelVersion CURRENT_MODEL_VERSION = ModelVersion.create(4, 0, 0);


@Override
Expand All @@ -72,7 +73,7 @@ public void initialize(ExtensionContext context) {
final ManagementResourceRegistration subsystemRegistration = subsystem.registerSubsystemModel(MailSubsystemResource.INSTANCE);
subsystemRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);

subsystem.registerXMLElementWriter(new MailSubsystemParser3_0());
subsystem.registerXMLElementWriter(new MailSubsystemParser4_0());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
* /
*/

package org.jboss.as.mail.extension;

import static org.jboss.as.controller.PersistentResourceXMLDescription.builder;

import org.jboss.as.controller.PersistentResourceXMLDescription;
import org.jboss.as.controller.PersistentResourceXMLParser;

/**
* @author Tomaz Cerar (c) 2017 Red Hat Inc.
*/
class MailSubsystemParser4_0 extends PersistentResourceXMLParser {

@Override
public PersistentResourceXMLDescription getParserDescription() {
return builder(MailSubsystemResource.INSTANCE.getPathElement(), Namespace.MAIL_4_0.getUriString())
.addChild(
builder(MailSessionDefinition.INSTANCE.getPathElement())
.addAttributes(MailSessionDefinition.DEBUG, MailSessionDefinition.JNDI_NAME, MailSessionDefinition.FROM)
.addChild(
builder(MailServerDefinition.INSTANCE_SMTP.getPathElement())
.addAttributes(MailServerDefinition.OUTBOUND_SOCKET_BINDING_REF, MailServerDefinition.SSL, MailServerDefinition.TLS, MailServerDefinition.USERNAME, MailServerDefinition.PASSWORD, MailServerDefinition.CREDENTIAL_REFERENCE)
.setXmlElementName(MailSubsystemModel.SMTP_SERVER)

)
.addChild(
builder(MailServerDefinition.INSTANCE_POP3.getPathElement())
.addAttributes(MailServerDefinition.OUTBOUND_SOCKET_BINDING_REF, MailServerDefinition.SSL, MailServerDefinition.TLS, MailServerDefinition.USERNAME, MailServerDefinition.PASSWORD, MailServerDefinition.CREDENTIAL_REFERENCE)
.setXmlElementName(MailSubsystemModel.POP3_SERVER)
)
.addChild(
builder(MailServerDefinition.INSTANCE_IMAP.getPathElement())
.addAttributes(MailServerDefinition.OUTBOUND_SOCKET_BINDING_REF, MailServerDefinition.SSL, MailServerDefinition.TLS, MailServerDefinition.USERNAME, MailServerDefinition.PASSWORD, MailServerDefinition.CREDENTIAL_REFERENCE)
.setXmlElementName(MailSubsystemModel.IMAP_SERVER)
)
.addChild(
builder(MailServerDefinition.INSTANCE_CUSTOM.getPathElement())
.addAttributes(MailServerDefinition.OUTBOUND_SOCKET_BINDING_REF_OPTIONAL, MailServerDefinition.SSL, MailServerDefinition.TLS, MailServerDefinition.USERNAME, MailServerDefinition.PASSWORD, MailServerDefinition.CREDENTIAL_REFERENCE, MailServerDefinition.PROPERTIES)
.setXmlElementName(MailSubsystemModel.CUSTOM_SERVER)
)
)
.build();
}
}
5 changes: 3 additions & 2 deletions mail/src/main/java/org/jboss/as/mail/extension/Namespace.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ enum Namespace {
MAIL_1_1("urn:jboss:domain:mail:1.1"),
MAIL_1_2("urn:jboss:domain:mail:1.2"),
MAIL_2_0("urn:jboss:domain:mail:2.0"),
MAIL_3_0("urn:jboss:domain:mail:3.0");
MAIL_3_0("urn:jboss:domain:mail:3.0"),
MAIL_4_0("urn:jboss:domain:mail:4.0");

/**
* The current namespace version.
*/
public static final Namespace CURRENT = MAIL_3_0;
public static final Namespace CURRENT = MAIL_4_0;

private final String name;

Expand Down
173 changes: 173 additions & 0 deletions mail/src/main/resources/schema/wildfly-mail_4_0.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ /*
~ * JBoss, Home of Professional Open Source.
~ * Copyright 2013, Red Hat, Inc., and individual contributors
~ * as indicated by the @author tags. See the copyright.txt file in the
~ * distribution for a full listing of individual contributors.
~ *
~ * This is free software; you can redistribute it and/or modify it
~ * under the terms of the GNU Lesser General Public License as
~ * published by the Free Software Foundation; either version 2.1 of
~ * the License, or (at your option) any later version.
~ *
~ * This software is distributed in the hope that it will be useful,
~ * but WITHOUT ANY WARRANTY; without even the implied warranty of
~ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ * Lesser General Public License for more details.
~ *
~ * You should have received a copy of the GNU Lesser General Public
~ * License along with this software; if not, write to the Free
~ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
~ */
-->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="urn:jboss:domain:mail:4.0"
xmlns:credential-reference="urn:wildfly:credential-reference:1.0"
targetNamespace="urn:jboss:domain:mail:4.0"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.0">

<xs:import namespace="urn:wildfly:credential-reference:1.0" schemaLocation="wildfly-credential-reference_1_0.xsd"/>

<!-- The mail subsystem root element -->
<xs:element name="subsystem" type="mail-subsystemType"/>
<xs:complexType name="mail-subsystemType">
<xs:annotation>
<xs:documentation>
<![CDATA[
The configuration of the mail subsystem.
]]>
</xs:documentation>
</xs:annotation>
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element name="mail-session" type="mail-sessionType"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="mail-sessionType">
<xs:sequence>
<xs:element name="smtp-server" type="server-type" maxOccurs="1" minOccurs="0"/>
<xs:element name="pop3-server" type="server-type" maxOccurs="1" minOccurs="0"/>
<xs:element name="imap-server" type="server-type" maxOccurs="1" minOccurs="0"/>
<xs:element name="custom-server" type="custom-server-type" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="jndi-name" use="required" type="xs:string"/>
<xs:attribute name="debug" use="optional" type="xs:boolean">
<xs:annotation>
<xs:documentation>
<![CDATA[
enables debuging of mail session
]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="from" use="optional" type="xs:string">
<xs:annotation>
<xs:documentation>
<![CDATA[
sets mail.from attribute
]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>


<xs:complexType name="server-type" mixed="true">
<xs:sequence>
<xs:element name="credential-reference" type="credential-reference:credentialReferenceType" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Credential to be used by the configuration.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="outbound-socket-binding-ref" use="required" type="xs:string">
<xs:annotation>
<xs:documentation>
<![CDATA[
Reference to the outbound-socket-binding element in the socket-binding-group that should
be used for configuring the client socket used to communicate with the mail server.
]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ssl" use="optional" type="xs:boolean">
<xs:annotation>
<xs:documentation>
<![CDATA[
enables use of ssl for this server configuration
]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="tls" use="optional" type="xs:boolean">
<xs:annotation>
<xs:documentation>
<![CDATA[
enables use of tls for this server configuration
]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="username" type="xs:string" use="optional"/>
<xs:attribute name="password" type="xs:string" use="optional"/>
</xs:complexType>

<xs:complexType name="property-type">
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="value" type="xs:string"/>
</xs:complexType>


<xs:complexType name="custom-server-type" mixed="true">
<xs:sequence>
<xs:element name="credential-reference" type="credential-reference:credentialReferenceType" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>
Credential to be used by the configuration.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="property" type="property-type" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="outbound-socket-binding-ref" use="optional" type="xs:string">
<xs:annotation>
<xs:documentation>
<![CDATA[
Reference to the outbound-socket-binding element in the socket-binding-group that should
be used for configuring the client socket used to communicate with the mail server.
]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ssl" use="optional" type="xs:boolean">
<xs:annotation>
<xs:documentation>
<![CDATA[
enables use of ssl for this server configuration
]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="tls" use="optional" type="xs:boolean">
<xs:annotation>
<xs:documentation>
<![CDATA[
enables use of tls for this server configuration
]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="username" type="xs:string" use="optional"/>
<xs:attribute name="password" type="xs:string" use="optional"/>
</xs:complexType>

</xs:schema>
2 changes: 1 addition & 1 deletion mail/src/main/resources/subsystem-templates/mail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- See src/resources/configuration/ReadMe.txt for how the configuration assembly works -->
<config>
<extension-module>org.jboss.as.mail</extension-module>
<subsystem xmlns="urn:jboss:domain:mail:3.0">
<subsystem xmlns="urn:jboss:domain:mail:4.0">
<mail-session name="default" jndi-name="java:jboss/mail/Default">
<smtp-server outbound-socket-binding-ref="mail-smtp"/>
</mail-session>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,8 @@ protected String getSubsystemXml() throws IOException {
}

@Override
protected String getSubsystemXsdPath() throws Exception {
return "schema/wildfly-mail_3_0.xsd";
}

@Override
protected String[] getSubsystemTemplatePaths() throws IOException {
return new String[]{
"/subsystem-templates/mail.xml"
};
}

@Test
@Override
public void testSchemaOfSubsystemTemplates() throws Exception {
super.testSchemaOfSubsystemTemplates();
protected KernelServices standardSubsystemTest(String configId, boolean compareXml) throws Exception {
return super.standardSubsystemTest(configId, false);
}

@Test
Expand Down
Loading

0 comments on commit 2615e11

Please sign in to comment.