use of org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute in project wildfly by wildfly.
the class AppClientXml method parseSocketBindingGroup.
private void parseSocketBindingGroup(final XMLExtendedStreamReader reader, final Set<String> interfaces, final ModelNode address, final Namespace expectedNs, final List<ModelNode> updates) throws XMLStreamException {
// unique names for both socket-binding and outbound-socket-binding(s)
final Set<String> uniqueBindingNames = new HashSet<String>();
ModelNode op = Util.getEmptyOperation(ADD, null);
// Handle attributes
String socketBindingGroupName = null;
final EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.DEFAULT_INTERFACE);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
if (!isNoNamespaceAttribute(reader, i)) {
throw unexpectedAttribute(reader, i);
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch(attribute) {
case NAME:
{
socketBindingGroupName = value;
required.remove(attribute);
break;
}
case DEFAULT_INTERFACE:
{
SocketBindingGroupResourceDefinition.DEFAULT_INTERFACE.parseAndSetParameter(value, op, reader);
required.remove(attribute);
break;
}
case PORT_OFFSET:
{
SocketBindingGroupResourceDefinition.PORT_OFFSET.parseAndSetParameter(value, op, reader);
break;
}
default:
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
if (!required.isEmpty()) {
throw missingRequired(reader, required);
}
ModelNode groupAddress = address.clone().add(SOCKET_BINDING_GROUP, socketBindingGroupName);
op.get(OP_ADDR).set(groupAddress);
updates.add(op);
// Handle elements
while (reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, expectedNs);
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case SOCKET_BINDING:
{
// FIXME JBAS-8825
final String bindingName = parseSocketBinding(reader, interfaces, groupAddress, updates);
if (!uniqueBindingNames.add(bindingName)) {
throw ControllerLogger.ROOT_LOGGER.alreadyDeclared(Element.SOCKET_BINDING.getLocalName(), Element.OUTBOUND_SOCKET_BINDING.getLocalName(), bindingName, Element.SOCKET_BINDING_GROUP.getLocalName(), socketBindingGroupName, reader.getLocation());
}
break;
}
case OUTBOUND_SOCKET_BINDING:
{
final String bindingName = parseOutboundSocketBinding(reader, interfaces, groupAddress, updates);
if (!uniqueBindingNames.add(bindingName)) {
throw ControllerLogger.ROOT_LOGGER.alreadyDeclared(Element.SOCKET_BINDING.getLocalName(), Element.OUTBOUND_SOCKET_BINDING.getLocalName(), bindingName, Element.SOCKET_BINDING_GROUP.getLocalName(), socketBindingGroupName, reader.getLocation());
}
break;
}
default:
throw unexpectedElement(reader);
}
}
}
use of org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute in project wildfly by wildfly.
the class MessagingSubsystemParser method processConnectors.
void processConnectors(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> updates) throws XMLStreamException {
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
String name = null;
String socketBinding = null;
String serverId = null;
int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String attrValue = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch(attribute) {
case NAME:
{
name = attrValue;
break;
}
case SOCKET_BINDING:
{
socketBinding = attrValue;
break;
}
case SERVER_ID:
{
serverId = attrValue;
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
if (name == null) {
throw missingRequired(reader, Collections.singleton(Attribute.NAME));
}
final ModelNode connectorAddress = address.clone();
final ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
boolean generic = false;
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case CONNECTOR:
{
operation.get(OP_ADDR).set(connectorAddress.add(CONNECTOR, name));
if (socketBinding != null) {
operation.get(RemoteTransportDefinition.SOCKET_BINDING.getName()).set(socketBinding);
}
generic = true;
break;
}
case NETTY_CONNECTOR:
{
operation.get(OP_ADDR).set(connectorAddress.add(REMOTE_CONNECTOR, name));
if (socketBinding == null) {
throw missingRequired(reader, Collections.singleton(Attribute.SOCKET_BINDING));
}
operation.get(RemoteTransportDefinition.SOCKET_BINDING.getName()).set(socketBinding);
break;
}
case IN_VM_CONNECTOR:
{
operation.get(OP_ADDR).set(connectorAddress.add(IN_VM_CONNECTOR, name));
if (serverId != null) {
InVMTransportDefinition.SERVER_ID.parseAndSetParameter(serverId, operation, reader);
}
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
updates.add(operation);
parseTransportConfiguration(reader, operation, generic, updates);
}
}
use of org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute in project wildfly by wildfly.
the class MessagingSubsystemParser method processJmsConnectors.
static ModelNode processJmsConnectors(final XMLExtendedStreamReader reader) throws XMLStreamException {
final ModelNode connectors = new ModelNode();
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
String name = null;
int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch(attribute) {
case CONNECTOR_NAME:
{
name = value.trim();
break;
}
case BACKUP_CONNECTOR_NAME:
{
MessagingLogger.ROOT_LOGGER.deprecatedXMLAttribute(attribute.toString());
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
if (name == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.CONNECTOR_NAME));
}
final Element element = Element.forName(reader.getLocalName());
if (element != Element.CONNECTOR_REF) {
throw ParseUtils.unexpectedElement(reader);
}
ParseUtils.requireNoContent(reader);
// create the connector node
connectors.get(name);
}
return connectors;
}
use of org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute in project wildfly by wildfly.
the class MessagingSubsystemParser method processAcceptors.
void processAcceptors(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> updates) throws XMLStreamException {
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
String name = null;
String socketBinding = null;
String serverId = null;
int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String attrValue = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch(attribute) {
case NAME:
{
name = attrValue;
break;
}
case SOCKET_BINDING:
{
socketBinding = attrValue;
break;
}
case SERVER_ID:
{
serverId = attrValue;
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
if (name == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.NAME));
}
final ModelNode acceptorAddress = address.clone();
final ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
boolean generic = false;
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case ACCEPTOR:
{
operation.get(OP_ADDR).set(acceptorAddress.add(ACCEPTOR, name));
if (socketBinding != null) {
operation.get(RemoteTransportDefinition.SOCKET_BINDING.getName()).set(socketBinding);
}
generic = true;
break;
}
case NETTY_ACCEPTOR:
{
operation.get(OP_ADDR).set(acceptorAddress.add(REMOTE_ACCEPTOR, name));
if (socketBinding == null) {
throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.SOCKET_BINDING));
}
operation.get(RemoteTransportDefinition.SOCKET_BINDING.getName()).set(socketBinding);
break;
}
case IN_VM_ACCEPTOR:
{
operation.get(OP_ADDR).set(acceptorAddress.add(IN_VM_ACCEPTOR, name));
if (serverId != null) {
InVMTransportDefinition.SERVER_ID.parseAndSetParameter(serverId, operation, reader);
}
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
updates.add(operation);
parseTransportConfiguration(reader, operation, generic, updates);
}
}
use of org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute in project wildfly by wildfly.
the class MessagingSubsystemParser method parseSecurityRoles.
private void parseSecurityRoles(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> operations) throws XMLStreamException {
final Map<String, Set<AttributeDefinition>> permsByRole = new HashMap<String, Set<AttributeDefinition>>();
String localName = null;
do {
reader.nextTag();
localName = reader.getLocalName();
final Element element = Element.forName(localName);
if (element != Element.PERMISSION_ELEMENT_NAME) {
break;
}
final Set<Attribute> required = EnumSet.of(Attribute.ROLES_ATTR_NAME, Attribute.TYPE_ATTR_NAME);
List<String> roles = null;
AttributeDefinition perm = null;
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
required.remove(attribute);
switch(attribute) {
case ROLES_ATTR_NAME:
roles = parseRolesAttribute(reader, i);
break;
case TYPE_ATTR_NAME:
perm = SecurityRoleDefinition.ROLE_ATTRIBUTES_BY_XML_NAME.get(reader.getAttributeValue(i));
if (perm == null) {
throw ControllerLogger.ROOT_LOGGER.invalidAttributeValue(reader.getAttributeValue(i), reader.getAttributeName(i), SecurityRoleDefinition.ROLE_ATTRIBUTES_BY_XML_NAME.keySet(), reader.getLocation());
}
break;
default:
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
if (!required.isEmpty()) {
throw missingRequired(reader, required);
}
for (String role : roles) {
role = role.trim();
Set<AttributeDefinition> perms = permsByRole.get(role);
if (perms == null) {
perms = new HashSet<AttributeDefinition>();
permsByRole.put(role, perms);
}
perms.add(perm);
}
// Scan to element end
reader.discardRemainder();
} while (reader.hasNext());
for (Map.Entry<String, Set<AttributeDefinition>> entry : permsByRole.entrySet()) {
final String role = entry.getKey();
final Set<AttributeDefinition> perms = entry.getValue();
final ModelNode addr = address.clone();
addr.add(ROLE, role);
final ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
operation.get(OP_ADDR).set(addr);
for (AttributeDefinition perm : SecurityRoleDefinition.ATTRIBUTES) {
operation.get(perm.getName()).set(perms.contains(perm));
}
operations.add(operation);
}
}
Aggregations