use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class WebMigrateOperation method migrateWelcomeFiles.
private void migrateWelcomeFiles(Map<PathAddress, ModelNode> newAddOperations, ModelNode newAddOp) {
ModelNode welcome = newAddOp.get("welcome-file");
if (welcome.isDefined()) {
for (ModelNode w : welcome.asList()) {
PathAddress wa = pathAddress(pathAddress(UndertowExtension.SUBSYSTEM_PATH, pathElement(Constants.SERVLET_CONTAINER, "default"), pathElement(Constants.WELCOME_FILE, w.asString())));
ModelNode add = createAddOperation(wa);
newAddOperations.put(wa, add);
}
}
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class WebSubsystemParser method parseHostRewrite.
static void parseHostRewrite(XMLExtendedStreamReader reader, final PathAddress parent, List<ModelNode> list, int rewriteCount) throws XMLStreamException {
final ModelNode rewrite = Util.createAddOperation();
final int count = reader.getAttributeCount();
String name = RULE_PREFIX + rewriteCount;
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch(attribute) {
case PATTERN:
WebReWriteDefinition.PATTERN.parseAndSetParameter(value, rewrite, reader);
break;
case SUBSTITUTION:
WebReWriteDefinition.SUBSTITUTION.parseAndSetParameter(value, rewrite, reader);
break;
case FLAGS:
WebReWriteDefinition.FLAGS.parseAndSetParameter(value, rewrite, reader);
break;
case NAME:
name = value;
break;
default:
throw unexpectedAttribute(reader, i);
}
}
final PathAddress address = PathAddress.pathAddress(parent, PathElement.pathElement(REWRITE, name));
rewrite.get(OP_ADDR).set(address.toModelNode());
list.add(rewrite);
int conditionCount = 0;
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
switch(Namespace.forUri(reader.getNamespaceURI())) {
case WEB_1_0:
case WEB_1_1:
case WEB_1_2:
case WEB_1_3:
case WEB_1_4:
case WEB_1_5:
case WEB_2_0:
case WEB_2_1:
case WEB_2_2:
{
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case CONDITION:
final ModelNode condition = Util.createAddOperation();
String condName = CONDITION_PREFIX + conditionCount;
final int count2 = reader.getAttributeCount();
for (int i = 0; i < count2; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch(attribute) {
case NAME:
condName = value;
break;
case TEST:
WebReWriteConditionDefinition.TEST.parseAndSetParameter(value, condition, reader);
break;
case PATTERN:
WebReWriteConditionDefinition.PATTERN.parseAndSetParameter(value, condition, reader);
break;
case FLAGS:
WebReWriteConditionDefinition.FLAGS.parseAndSetParameter(value, condition, reader);
break;
default:
throw unexpectedAttribute(reader, i);
}
}
PathAddress condAddress = address.append(PathElement.pathElement(CONDITION, condName));
condition.get(OP_ADDR).set(condAddress.toModelNode());
requireNoContent(reader);
list.add(condition);
conditionCount++;
break;
default:
throw unexpectedElement(reader);
}
break;
}
default:
throw unexpectedElement(reader);
}
}
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class WebSubsystemParser method parseContainerConfig.
static void parseContainerConfig(XMLExtendedStreamReader reader, PathAddress parent, List<ModelNode> list) throws XMLStreamException {
PathAddress address = PathAddress.pathAddress(parent, WebExtension.CONTAINER_PATH);
final ModelNode config = new ModelNode();
config.get(OP).set(ADD);
config.get(OP_ADDR).set(address.toModelNode());
// no attributes
list.add(config);
if (reader.getAttributeCount() > 0) {
throw unexpectedAttribute(reader, 0);
}
// elements
boolean staticResourcesConfigured = false;
boolean jspConfigured = false;
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case STATIC_RESOURCES:
{
parseStaticResources(reader, parent, list);
staticResourcesConfigured = true;
break;
}
case JSP_CONFIGURATION:
{
parseJSPConfiguration(reader, parent, list);
jspConfigured = true;
break;
}
case MIME_MAPPING:
{
final String[] array = requireAttributes(reader, Attribute.NAME.getLocalName(), Attribute.VALUE.getLocalName());
WebContainerDefinition.MIME_MAPPINGS.parseAndAddParameterElement(array[0], array[1], config, reader);
requireNoContent(reader);
break;
}
case WELCOME_FILE:
{
final String welcomeFile = reader.getElementText().trim();
WebContainerDefinition.WELCOME_FILES.parseAndAddParameterElement(welcomeFile, config, reader);
break;
}
default:
throw unexpectedElement(reader);
}
}
if (!staticResourcesConfigured) {
addDefaultStaticConfiguration(parent, list);
}
if (!jspConfigured) {
addDefaultJSPConfiguration(parent, list);
}
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class WebSubsystemParser method addDefaultStaticConfiguration.
private static void addDefaultStaticConfiguration(final PathAddress parent, List<ModelNode> list) {
PathAddress address = PathAddress.pathAddress(parent, WebExtension.STATIC_RESOURCES_PATH);
final ModelNode resources = new ModelNode();
resources.get(OP).set(ADD);
resources.get(OP_ADDR).set(address.toModelNode());
list.add(resources);
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class WebSubsystemParser method parseHostAccessLog.
static void parseHostAccessLog(XMLExtendedStreamReader reader, final PathAddress parent, List<ModelNode> list) throws XMLStreamException {
PathAddress address = PathAddress.pathAddress(parent, ACCESS_LOG_PATH);
final ModelNode log = new ModelNode();
log.get(OP).set(ADD);
log.get(OP_ADDR).set(address.toModelNode());
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch(attribute) {
case PATTERN:
WebAccessLogDefinition.PATTERN.parseAndSetParameter(value, log, reader);
break;
case RESOLVE_HOSTS:
WebAccessLogDefinition.RESOLVE_HOSTS.parseAndSetParameter(value, log, reader);
break;
case EXTENDED:
WebAccessLogDefinition.EXTENDED.parseAndSetParameter(value, log, reader);
break;
case PREFIX:
WebAccessLogDefinition.PREFIX.parseAndSetParameter(value, log, reader);
break;
case ROTATE:
WebAccessLogDefinition.ROTATE.parseAndSetParameter(value, log, reader);
break;
default:
throw unexpectedAttribute(reader, i);
}
}
list.add(log);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
switch(Namespace.forUri(reader.getNamespaceURI())) {
case WEB_1_0:
case WEB_1_1:
case WEB_1_2:
case WEB_1_3:
case WEB_1_4:
case WEB_1_5:
case WEB_2_0:
case WEB_2_1:
case WEB_2_2:
{
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case DIRECTORY:
parseDirOrFile(reader, address, list, WebExtension.DIRECTORY_PATH);
break;
default:
throw unexpectedElement(reader);
}
break;
}
default:
throw unexpectedElement(reader);
}
}
}
Aggregations