0001: /*
0002: * The contents of this file are subject to the terms of the Common Development
0003: * and Distribution License (the License). You may not use this file except in
0004: * compliance with the License.
0005: *
0006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
0007: * or http://www.netbeans.org/cddl.txt.
0008: *
0009: * When distributing Covered Code, include this CDDL Header Notice in each file
0010: * and include the License file at http://www.netbeans.org/cddl.txt.
0011: * If applicable, add the following below the CDDL Header, with the fields
0012: * enclosed by brackets [] replaced by your own identifying information:
0013: * "Portions Copyrighted [year] [name of copyright owner]"
0014: *
0015: * The Original Software is NetBeans. The Initial Developer of the Original
0016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
0017: * Microsystems, Inc. All Rights Reserved.
0018: */
0019: package org.netbeans.modules.wsdlextensions.jms.validator;
0020:
0021: import java.net.URI;
0022: import java.net.URL;
0023: import java.text.MessageFormat;
0024: import java.util.ArrayList;
0025: import java.util.Collection;
0026: import java.util.Collections;
0027: import java.util.HashMap;
0028: import java.util.HashSet;
0029: import java.util.Iterator;
0030: import java.util.List;
0031: import java.util.Map;
0032: import java.util.StringTokenizer;
0033: import java.util.ResourceBundle;
0034:
0035: import org.netbeans.modules.xml.wsdl.model.Binding;
0036: import org.netbeans.modules.xml.wsdl.model.BindingInput;
0037: import org.netbeans.modules.xml.wsdl.model.BindingFault;
0038: import org.netbeans.modules.xml.wsdl.model.BindingOperation;
0039: import org.netbeans.modules.xml.wsdl.model.BindingOutput;
0040: import org.netbeans.modules.xml.wsdl.model.Definitions;
0041: import org.netbeans.modules.xml.wsdl.model.Input;
0042: import org.netbeans.modules.xml.wsdl.model.Output;
0043: import org.netbeans.modules.xml.wsdl.model.Operation;
0044: import org.netbeans.modules.xml.wsdl.model.OperationParameter;
0045: import org.netbeans.modules.xml.wsdl.model.Port;
0046: import org.netbeans.modules.xml.wsdl.model.PortType;
0047: import org.netbeans.modules.xml.wsdl.model.Service;
0048: import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
0049: import org.netbeans.modules.xml.wsdl.model.WSDLModel;
0050: import org.netbeans.modules.xml.wsdl.model.Message;
0051: import org.netbeans.modules.xml.wsdl.model.Part;
0052:
0053: import org.netbeans.modules.xml.xam.Component;
0054: import org.netbeans.modules.xml.xam.Model;
0055: import org.netbeans.modules.xml.xam.Model.State;
0056: import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
0057: import org.netbeans.modules.xml.xam.Reference;
0058: import org.netbeans.modules.xml.xam.spi.Validation;
0059: import org.netbeans.modules.xml.xam.spi.Validation.ValidationType;
0060: import org.netbeans.modules.xml.xam.spi.ValidationResult;
0061: import org.netbeans.modules.xml.xam.spi.Validator;
0062: import org.netbeans.modules.xml.xam.spi.Validator.ResultItem;
0063:
0064: import org.netbeans.modules.wsdlextensions.jms.JMSComponent;
0065: import org.netbeans.modules.wsdlextensions.jms.JMSConstants;
0066: import org.netbeans.modules.wsdlextensions.jms.JMSOperation;
0067: import org.netbeans.modules.wsdlextensions.jms.JMSOptions;
0068: import org.netbeans.modules.wsdlextensions.jms.JMSOption;
0069: import org.netbeans.modules.wsdlextensions.jms.JMSMessage;
0070: import org.netbeans.modules.wsdlextensions.jms.JMSBinding;
0071: import org.netbeans.modules.wsdlextensions.jms.JMSAddress;
0072: import org.netbeans.modules.wsdlextensions.jms.JMSMapMessage;
0073: import org.netbeans.modules.wsdlextensions.jms.JMSMapMessagePart;
0074: import org.netbeans.modules.wsdlextensions.jms.JMSProperties;
0075: import org.netbeans.modules.wsdlextensions.jms.JMSProperty;
0076: import org.netbeans.modules.wsdlextensions.jms.JMSJNDIEnv;
0077: import org.netbeans.modules.wsdlextensions.jms.JMSJNDIEnvEntry;
0078:
0079: /**
0080: * JMSComponentValidator
0081: * semantic validation, check WSDL elements & attributes values and
0082: * any relationship between;
0083: *
0084: *
0085: */
0086: public class JMSComponentValidator implements Validator {
0087:
0088: private static final ResourceBundle mMessages = ResourceBundle
0089: .getBundle("org.netbeans.modules.wsdlextensions.jms.validator.Bundle");
0090:
0091: private Validation mValidation;
0092: private ValidationType mValidationType;
0093: private ValidationResult mValidationResult;
0094:
0095: public static final ValidationResult EMPTY_RESULT = new ValidationResult(
0096: Collections.EMPTY_SET, Collections.EMPTY_SET);
0097:
0098: public JMSComponentValidator() {
0099: }
0100:
0101: /**
0102: * Returns name of this validation service.
0103: */
0104: public String getName() {
0105: return getClass().getName();
0106: }
0107:
0108: /**
0109: * Validates given model.
0110: *
0111: * @param model model to validate.
0112: * @param validation reference to the validation context.
0113: * @param validationType the type of validation to perform
0114: * @return ValidationResult.
0115: */
0116: public ValidationResult validate(Model model,
0117: Validation validation, ValidationType validationType) {
0118: mValidation = validation;
0119: mValidationType = validationType;
0120:
0121: HashSet<ResultItem> results = new HashSet<ResultItem>();
0122: HashSet<Model> models = new HashSet<Model>();
0123: models.add(model);
0124: mValidationResult = new ValidationResult(results, models);
0125:
0126: // Traverse the model
0127: if (model instanceof WSDLModel) {
0128: WSDLModel wsdlModel = (WSDLModel) model;
0129:
0130: if (model.getState() == State.NOT_WELL_FORMED) {
0131: return EMPTY_RESULT;
0132: }
0133:
0134: Definitions defs = wsdlModel.getDefinitions();
0135:
0136: Iterator<Service> services = defs.getServices().iterator();
0137: while (services.hasNext()) {
0138: Iterator<Port> ports = services.next().getPorts()
0139: .iterator();
0140: while (ports.hasNext()) {
0141: Port port = ports.next();
0142:
0143: // ensure that jms:jndienv is not child elemnt of port
0144: List<JMSJNDIEnv> jmsJndiEnvList = port
0145: .getExtensibilityElements(JMSJNDIEnv.class);
0146: if (jmsJndiEnvList.size() > 0) {
0147: results
0148: .add(new Validator.ResultItem(
0149: this ,
0150: Validator.ResultType.ERROR,
0151: port,
0152: getMessage(
0153: "JMSBindingValidation.INVALID_USAGE_OF_JMS_JNDIENV_ELEM",
0154: new Object[] {
0155: port.getName(),
0156: new Integer(
0157: jmsJndiEnvList
0158: .size()) })));
0159: }
0160:
0161: if (port.getBinding() != null) {
0162: Binding binding = port.getBinding().get();
0163: if (binding != null) {
0164: int numRelatedJMSBindings = binding
0165: .getExtensibilityElements(
0166: JMSBinding.class).size();
0167: List<JMSAddress> jmsAddressList = port
0168: .getExtensibilityElements(JMSAddress.class);
0169: Iterator<JMSAddress> jmsAddresses = jmsAddressList
0170: .iterator();
0171: if ((numRelatedJMSBindings > 0)
0172: && (jmsAddressList.size() == 0)) {
0173: results
0174: .add(new Validator.ResultItem(
0175: this ,
0176: Validator.ResultType.ERROR,
0177: port,
0178: getMessage(
0179: "JMSAddressValidation.MISSING_JMS_ADDRESS",
0180: new Object[] {
0181: port
0182: .getName(),
0183: new Integer(
0184: numRelatedJMSBindings) })));
0185: }
0186:
0187: if (jmsAddressList.size() > 1) {
0188: results
0189: .add(new Validator.ResultItem(
0190: this ,
0191: Validator.ResultType.ERROR,
0192: port,
0193: getMessage(
0194: "JMSAddressValidation.ONLY_ONE_JMS_ADDRESS_ALLOWED",
0195: new Object[] {
0196: port
0197: .getName(),
0198: new Integer(
0199: jmsAddressList
0200: .size()) })));
0201: }
0202: while (jmsAddresses.hasNext()) {
0203: JMSAddress jmsAddr = jmsAddresses
0204: .next();
0205: validate(jmsAddr);
0206: if (jmsAddr
0207: .getConnectionURL()
0208: .startsWith(
0209: JMSConstants.JMS_GENERIC_JNDI_PROTOCOL)) {
0210: Iterator<BindingOperation> bindingOps = binding
0211: .getBindingOperations()
0212: .iterator();
0213: while (bindingOps.hasNext()) {
0214: BindingOperation bindingOp = bindingOps
0215: .next();
0216: }
0217: }
0218: }
0219: }
0220: }
0221: }
0222: }
0223:
0224: Iterator<Binding> bindings = defs.getBindings().iterator();
0225: while (bindings.hasNext()) {
0226: Binding binding = bindings.next();
0227:
0228: if (binding.getType() == null
0229: || binding.getType().get() == null) {
0230: continue;
0231: }
0232:
0233: int numJMSBindings = binding.getExtensibilityElements(
0234: JMSBinding.class).size();
0235: if (numJMSBindings == 0) {
0236: continue;
0237: }
0238:
0239: if (numJMSBindings > 0 && numJMSBindings != 1) {
0240: results
0241: .add(new Validator.ResultItem(
0242: this ,
0243: Validator.ResultType.ERROR,
0244: binding,
0245: getMessage(
0246: "JMSBindingValidation.ONLY_ONE_JMS_BINDING_ALLOWED",
0247: new Object[] {
0248: binding.getName(),
0249: new Integer(
0250: numJMSBindings) })));
0251: }
0252:
0253: Iterator<BindingOperation> bindingOps = binding
0254: .getBindingOperations().iterator();
0255: boolean foundJMSOp = false;
0256: int msgCnt = 0;
0257: while (bindingOps.hasNext()) {
0258: BindingOperation bindingOp = bindingOps.next();
0259: List<JMSOperation> jmsOpsList = bindingOp
0260: .getExtensibilityElements(JMSOperation.class);
0261: Iterator<JMSOperation> jmsOps = jmsOpsList
0262: .iterator();
0263:
0264: // there should only be one jms:operation for the binding operation
0265: if (jmsOpsList.size() > 1) {
0266: results
0267: .add(new Validator.ResultItem(
0268: this ,
0269: Validator.ResultType.ERROR,
0270: bindingOp,
0271: getMessage(
0272: "JMSBindingValidation.ONLY_ONE_JMS_OPERATION_ALLOWED",
0273: new Object[] {
0274: binding
0275: .getName(),
0276: bindingOp
0277: .getName(),
0278: new Integer(
0279: jmsOpsList
0280: .size()) })));
0281: }
0282:
0283: // validate all anyways if more than one is found
0284: while (jmsOps.hasNext()) {
0285: validate(bindingOp, jmsOps.next());
0286: }
0287:
0288: if (jmsOpsList.size() > 0) {
0289: foundJMSOp = true;
0290: if (!checkSignature(bindingOp)) {
0291: results
0292: .add(new Validator.ResultItem(
0293: this ,
0294: Validator.ResultType.ERROR,
0295: bindingOp,
0296: getMessage(
0297: "JMSBindingValidation.OP_SIG_MISMATCH_BINDING_ABSTRACT",
0298: new Object[] {
0299: binding
0300: .getName(),
0301: bindingOp
0302: .getName() })));
0303: continue;
0304: }
0305: BindingInput bindingInput = bindingOp
0306: .getBindingInput();
0307: if (bindingInput != null) {
0308: msgCnt = 0;
0309: // assumption:
0310: // under <input>, there could be one of the following:
0311: // <jms:message>
0312: // but only one is allowed;
0313: //
0314: Iterator<JMSMessage> jmsMessages = bindingInput
0315: .getExtensibilityElements(
0316: JMSMessage.class)
0317: .iterator();
0318: if (jmsMessages != null) {
0319: while (jmsMessages.hasNext()) {
0320: msgCnt++;
0321: JMSMessage jmsMessage = jmsMessages
0322: .next();
0323: validate(bindingOp, bindingInput
0324: .getInput().get(),
0325: jmsMessage);
0326: }
0327: if (msgCnt > 1) {
0328: results
0329: .add(new Validator.ResultItem(
0330: this ,
0331: Validator.ResultType.ERROR,
0332: bindingInput,
0333: getMessage(
0334: "JMSBindingValidation.ATMOST_ONE_MESSAGE_IN_INPUT",
0335: new Object[] {
0336: bindingOp
0337: .getName(),
0338: new Integer(
0339: msgCnt),
0340: bindingInput
0341: .getName() })));
0342: }
0343: }
0344:
0345: if (msgCnt == 0) {
0346: results
0347: .add(new Validator.ResultItem(
0348: this ,
0349: Validator.ResultType.ERROR,
0350: bindingInput,
0351: getMessage(
0352: "JMSBindingValidation.NO_MESSAGE_FOUND_IN_INPUT",
0353: new Object[] {
0354: bindingOp
0355: .getName(),
0356: bindingInput
0357: .getName() })));
0358: }
0359:
0360: // invalidate if jms:mapmessage and/or jms:properties is found as child elment(s) of input
0361: List<JMSProperties> jmsProperites = bindingInput
0362: .getExtensibilityElements(JMSProperties.class);
0363: if (jmsProperites != null
0364: && jmsProperites.size() > 0) {
0365: results
0366: .add(new Validator.ResultItem(
0367: this ,
0368: Validator.ResultType.ERROR,
0369: bindingInput,
0370: getMessage(
0371: "JMSBindingValidation.INVALID_USAGE_OF_JMS_PROPERITES_ELEM",
0372: new Object[] {
0373: bindingOp
0374: .getName(),
0375: bindingInput
0376: .getName() })));
0377: }
0378: List<JMSMapMessage> jmsMapMessage = bindingInput
0379: .getExtensibilityElements(JMSMapMessage.class);
0380: if (jmsMapMessage != null
0381: && jmsMapMessage.size() > 0) {
0382: results
0383: .add(new Validator.ResultItem(
0384: this ,
0385: Validator.ResultType.ERROR,
0386: bindingInput,
0387: getMessage(
0388: "JMSBindingValidation.INVALID_USAGE_OF_JMS_MAPMESSAGE_ELEM",
0389: new Object[] {
0390: bindingOp
0391: .getName(),
0392: bindingInput
0393: .getName() })));
0394: }
0395: }
0396:
0397: BindingOutput bindingOutput = bindingOp
0398: .getBindingOutput();
0399: if (bindingOutput != null) {
0400: // reset and do output checking
0401: msgCnt = 0;
0402:
0403: Iterator<JMSMessage> jmsMessages = bindingOutput
0404: .getExtensibilityElements(
0405: JMSMessage.class)
0406: .iterator();
0407: if (jmsMessages != null) {
0408: while (jmsMessages.hasNext()) {
0409: msgCnt++;
0410: JMSMessage jmsMessage = jmsMessages
0411: .next();
0412: validate(bindingOp, bindingOutput
0413: .getOutput().get(),
0414: jmsMessage);
0415: }
0416: if (msgCnt > 1) {
0417: results
0418: .add(new Validator.ResultItem(
0419: this ,
0420: Validator.ResultType.ERROR,
0421: bindingOutput,
0422: getMessage(
0423: "JMSBindingValidation.ATMOST_ONE_MESSAGE_IN_OUTPUT",
0424: new Object[] {
0425: bindingOp
0426: .getName(),
0427: new Integer(
0428: msgCnt),
0429: bindingOutput
0430: .getName() })));
0431: }
0432: }
0433:
0434: if (msgCnt == 0) {
0435: results
0436: .add(new Validator.ResultItem(
0437: this ,
0438: Validator.ResultType.ERROR,
0439: bindingOutput,
0440: getMessage(
0441: "JMSBindingValidation.NO_MESSAGE_FOUND_IN_OUTPUT",
0442: new Object[] {
0443: bindingOp
0444: .getName(),
0445: bindingOutput
0446: .getName() })));
0447: }
0448:
0449: // invalidate if jms:mapmessage and/or jms:properties is found as child elment(s) of input
0450: List<JMSProperties> jmsProperites = bindingOutput
0451: .getExtensibilityElements(JMSProperties.class);
0452: if (jmsProperites != null
0453: && jmsProperites.size() > 0) {
0454: results
0455: .add(new Validator.ResultItem(
0456: this ,
0457: Validator.ResultType.ERROR,
0458: bindingOutput,
0459: getMessage(
0460: "JMSBindingValidation.INVALID_USAGE_OF_JMS_PROPERITES_ELEM",
0461: new Object[] {
0462: bindingOp
0463: .getName(),
0464: bindingOutput
0465: .getName() })));
0466: }
0467: List<JMSMapMessage> jmsMapMessage = bindingOutput
0468: .getExtensibilityElements(JMSMapMessage.class);
0469: if (jmsMapMessage != null
0470: && jmsMapMessage.size() > 0) {
0471: results
0472: .add(new Validator.ResultItem(
0473: this ,
0474: Validator.ResultType.ERROR,
0475: bindingOutput,
0476: getMessage(
0477: "JMSBindingValidation.INVALID_USAGE_OF_JMS_MAPMESSAGE_ELEM",
0478: new Object[] {
0479: bindingOp
0480: .getName(),
0481: bindingOutput
0482: .getName() })));
0483: }
0484: }
0485: }
0486:
0487: // check to ensure options are defined at the right level
0488: List<JMSOptions> jmsOptions = bindingOp
0489: .getExtensibilityElements(JMSOptions.class);
0490: if (jmsOptions.size() > 0) {
0491: results
0492: .add(new Validator.ResultItem(
0493: this ,
0494: Validator.ResultType.ERROR,
0495: jmsOptions.get(0),
0496: getMessage(
0497: "JMSBindingValidation.IMPROPER_USAGE_OF_OPTIONS",
0498: new Object[] {
0499: binding
0500: .getName(),
0501: jmsOptions
0502: .size() })));
0503: }
0504:
0505: }
0506: // there is jms:binding but no jms:operation
0507: if (numJMSBindings > 0 && !foundJMSOp) {
0508: results
0509: .add(new Validator.ResultItem(
0510: this ,
0511: Validator.ResultType.ERROR,
0512: binding,
0513: getMessage(
0514: "JMSBindingValidation.MISSING_JMS_OPERATION",
0515: new Object[] { binding
0516: .getName() })));
0517: }
0518: // there is no jms:binding but there are jms:operation
0519: if (numJMSBindings == 0 && foundJMSOp) {
0520: results
0521: .add(new Validator.ResultItem(
0522: this ,
0523: Validator.ResultType.ERROR,
0524: binding,
0525: getMessage(
0526: "JMSBindingValidation.JMS_OPERATION_WO_JMS_BINDING",
0527: new Object[] { binding
0528: .getName() })));
0529: }
0530: }
0531: }
0532: // Clear out our state
0533: mValidation = null;
0534: mValidationType = null;
0535:
0536: return mValidationResult;
0537: }
0538:
0539: private void validate(JMSAddress target) {
0540: // validate connection url
0541: Collection<ResultItem> results = mValidationResult
0542: .getValidationResult();
0543:
0544: final String URL_SEPARATORS = ",";
0545: StringTokenizer urls = new StringTokenizer(target
0546: .getConnectionURL(), URL_SEPARATORS);
0547: while (urls.hasMoreTokens()) {
0548: String aurl = urls.nextToken();
0549: if (!isAToken(aurl, target)) {
0550:
0551: // try generic url parser
0552: UrlParser url = new UrlParser(aurl);
0553:
0554: // cause url to be parsed
0555: String protocol = null;
0556: String host = null;
0557: int UNLIKELY_PORT = -291; // unlikely that user will enter this number
0558: int port = UNLIKELY_PORT;
0559: try {
0560: protocol = url.getProtocol();
0561: host = url.getHost();
0562: port = url.getPort();
0563:
0564: if (protocol == null || protocol.length() == 0) {
0565: results
0566: .add(new Validator.ResultItem(
0567: this ,
0568: Validator.ResultType.ERROR,
0569: target,
0570: getMessage(
0571: "JMSAddress.NO_PROTOCOL_SPECIFIED",
0572: new Object[] { aurl })));
0573: } else {
0574: // now try parsing specific provider urls
0575: if (protocol
0576: .equals(ConnectionUrl.PROTOCOL_JMS_PROVIDER_SUN_JAVA_SYSTEM_MQ)) {
0577: try {
0578: SunOneUrlParser urlParser = new SunOneUrlParser(
0579: aurl);
0580: urlParser.validate();
0581: } catch (ValidationException ex) {
0582: results
0583: .add(new Validator.ResultItem(
0584: this ,
0585: Validator.ResultType.ERROR,
0586: target,
0587: getMessage(
0588: "JMSAddress.INVALID_CONNECTION_URL",
0589: new Object[] {
0590: aurl,
0591: ex })));
0592: }
0593: } else { // for others check if protocol is supported
0594: if (!protocol
0595: .equals(ConnectionUrl.PROTOCOL_JMS_PROVIDER_WEPSHERE_MQ)
0596: && !protocol
0597: .equals(ConnectionUrl.PROTOCOL_JMS_PROVIDER_JBOSS)
0598: && !protocol
0599: .equals(ConnectionUrl.PROTOCOL_JMS_PROVIDER_STCMS)
0600: && !protocol
0601: .equals(ConnectionUrl.PROTOCOL_JMS_PROVIDER_WAVE)
0602: && !protocol
0603: .equals(ConnectionUrl.PROTOCOL_JMS_PROVIDER_WEBLOGIC)
0604: && !protocol
0605: .equals(ConnectionUrl.PROTOCOL_GENERIC_JMS_JNDI)) {
0606: results
0607: .add(new Validator.ResultItem(
0608: this ,
0609: Validator.ResultType.ERROR,
0610: target,
0611: getMessage(
0612: "JMSAddress.PROVIDER_NOT_SUPPORTED",
0613: new Object[] {
0614: aurl,
0615: protocol })));
0616: }
0617: }
0618: }
0619:
0620: if (!protocol
0621: .equals(ConnectionUrl.PROTOCOL_GENERIC_JMS_JNDI)) {
0622: if (host == null || host.length() == 0) {
0623: results
0624: .add(new Validator.ResultItem(
0625: this ,
0626: Validator.ResultType.ERROR,
0627: target,
0628: getMessage(
0629: "JMSAddress.NO_HOST_SPECIFIED",
0630: new Object[] { aurl })));
0631: }
0632:
0633: if (port == UNLIKELY_PORT) {
0634: results
0635: .add(new Validator.ResultItem(
0636: this ,
0637: Validator.ResultType.ERROR,
0638: target,
0639: getMessage(
0640: "JMSAddress.NO_PORT_SPECIFIED",
0641: new Object[] { aurl })));
0642: } else if (port <= 0) {
0643: results
0644: .add(new Validator.ResultItem(
0645: this ,
0646: Validator.ResultType.ERROR,
0647: target,
0648: getMessage(
0649: "JMSAddress.INVALID_PORT_SPECIFIED",
0650: new Object[] {
0651: aurl,
0652: new Integer(
0653: port) })));
0654: }
0655: String username = target.getUsername();
0656:
0657: if (username != null) {
0658: isAToken(username, target);
0659: String password = target.getPassword();
0660: if (password == null) {
0661: results
0662: .add(new Validator.ResultItem(
0663: this ,
0664: Validator.ResultType.ERROR,
0665: target,
0666: getMessage(
0667: "JMSAddress.MISSING_PASSWORD",
0668: new Object[] { username })));
0669: } else {
0670: isAToken(password, target);
0671: }
0672: }
0673:
0674: // warn if any of the JNDI related attributes are used
0675: if (target.getConnectionFactoryName() != null) {
0676: results
0677: .add(new Validator.ResultItem(
0678: this ,
0679: Validator.ResultType.WARNING,
0680: target,
0681: getMessage(
0682: "JMSAddress.JNDI_CF_NAME_IN_JMS_ADDRESS_IGNORED",
0683: new Object[] {
0684: aurl,
0685: target
0686: .getConnectionFactoryName() })));
0687: }
0688:
0689: if (target.getInitialContextFactory() != null) {
0690: results
0691: .add(new Validator.ResultItem(
0692: this ,
0693: Validator.ResultType.WARNING,
0694: target,
0695: getMessage(
0696: "JMSAddress.JNDI_INIT_CTX_FACT_IN_JMS_ADDRESS_IGNORED",
0697: new Object[] {
0698: aurl,
0699: target
0700: .getInitialContextFactory() })));
0701: }
0702:
0703: if (target.getProviderURL() != null) {
0704: results
0705: .add(new Validator.ResultItem(
0706: this ,
0707: Validator.ResultType.WARNING,
0708: target,
0709: getMessage(
0710: "JMSAddress.JNDI_PROVIDER_URL_IN_JMS_ADDRESS_IGNORED",
0711: new Object[] {
0712: aurl,
0713: target
0714: .getProviderURL() })));
0715: }
0716:
0717: if (target.getSecurityPrincial() != null) {
0718: results
0719: .add(new Validator.ResultItem(
0720: this ,
0721: Validator.ResultType.WARNING,
0722: target,
0723: getMessage(
0724: "JMSAddress.JNDI_SEC_PRINCIPAL_IN_JMS_ADDRESS_IGNORED",
0725: new Object[] {
0726: aurl,
0727: target
0728: .getSecurityPrincial() })));
0729: }
0730:
0731: if (target.getSecurityCredentials() != null) {
0732: results
0733: .add(new Validator.ResultItem(
0734: this ,
0735: Validator.ResultType.WARNING,
0736: target,
0737: getMessage(
0738: "JMSAddress.JNDI_SEC_CREDENTIALS_IN_JMS_ADDRESS_IGNORED",
0739: new Object[] {
0740: aurl,
0741: target
0742: .getSecurityCredentials() })));
0743: }
0744:
0745: // warn if jndienv is used
0746: List<JMSJNDIEnv> jndienvs = target
0747: .getExtensibilityElements(JMSJNDIEnv.class);
0748: if (jndienvs.size() > 0) {
0749: results
0750: .add(new Validator.ResultItem(
0751: this ,
0752: Validator.ResultType.WARNING,
0753: target,
0754: getMessage(
0755: "JMSAddress.JNDIENV_ELEM_IN_JMS_ADDRESS_IGNORED",
0756: new Object[] { aurl })));
0757: }
0758: } else {
0759: // check for jndiconnectionfactory name
0760: if (target.getConnectionFactoryName() == null) {
0761: results
0762: .add(new Validator.ResultItem(
0763: this ,
0764: Validator.ResultType.ERROR,
0765: target,
0766: getMessage(
0767: "JMSAddress.JNDI_CONNECTION_FACTORY_NAME_UNDEFINED",
0768: new Object[] { aurl })));
0769:
0770: }
0771:
0772: // if not using local JNDI (i.e, initial context factory is defined),
0773: // ensure that the provider url is also defined.
0774: if (target.getInitialContextFactory() != null
0775: && target.getProviderURL() == null) {
0776: results
0777: .add(new Validator.ResultItem(
0778: this ,
0779: Validator.ResultType.ERROR,
0780: target,
0781: getMessage(
0782: "JMSAddress.JNDI_PROVIDER_URL_UNDEFINED",
0783: new Object[] {
0784: aurl,
0785: target
0786: .getInitialContextFactory() })));
0787: }
0788:
0789: String jndiSecPrincipal = target
0790: .getSecurityPrincial();
0791: if (jndiSecPrincipal != null) {
0792: isAToken(jndiSecPrincipal, target);
0793: String jndiSecCredentials = target
0794: .getSecurityCredentials();
0795: if (jndiSecCredentials == null) {
0796: results
0797: .add(new Validator.ResultItem(
0798: this ,
0799: Validator.ResultType.ERROR,
0800: target,
0801: getMessage(
0802: "JMSAddress.MISSING_JNDI_SECURITY_CREDENTIALS",
0803: new Object[] { jndiSecPrincipal })));
0804: } else {
0805: isAToken(jndiSecCredentials, target);
0806: }
0807: }
0808:
0809: //
0810: // check list of jndienv
0811: List<JMSJNDIEnv> jndienvs = target
0812: .getExtensibilityElements(JMSJNDIEnv.class);
0813: if (jndienvs.size() > 1) {
0814: results
0815: .add(new Validator.ResultItem(
0816: this ,
0817: Validator.ResultType.ERROR,
0818: target,
0819: getMessage(
0820: "JMSAddress.ATMOST_ONE_JNDIENV_ELEM_IN_JMS_ADDRESS",
0821: new Object[] { jndienvs
0822: .size() })));
0823: }
0824:
0825: if (jndienvs.size() == 1) {
0826: // check if no jndienventry(ies) were found
0827: List<JMSJNDIEnvEntry> jndienventries = jndienvs
0828: .get(0).getExtensibilityElements(
0829: JMSJNDIEnvEntry.class);
0830: if (jndienventries.size() == 0) {
0831: results
0832: .add(new Validator.ResultItem(
0833: this ,
0834: Validator.ResultType.ERROR,
0835: jndienvs.get(0),
0836: getMessage(
0837: "JMSAddress.MISSING_JNDIENVENTRY_ELEMS_IN_JMS_JNDIENV",
0838: new Object[] { target
0839: .getConnectionURL() })));
0840: }
0841: }
0842:
0843: // ensure that jndienventry elements are child elements of jndienv element
0844: List<JMSJNDIEnvEntry> jndienventries = target
0845: .getExtensibilityElements(JMSJNDIEnvEntry.class);
0846: if (jndienventries.size() > 0) {
0847: results
0848: .add(new Validator.ResultItem(
0849: this ,
0850: Validator.ResultType.ERROR,
0851: target,
0852: getMessage(
0853: "JMSAddress.IMPROPER_USAGE_OF_JNDIENVENTRY",
0854: new Object[] { jndienventries
0855: .size() })));
0856: }
0857: }
0858: } catch (Throwable t) {
0859: results
0860: .add(new Validator.ResultItem(
0861: this ,
0862: Validator.ResultType.ERROR,
0863: target,
0864: getMessage(
0865: "JMSAddress.INVALID_CONNECTION_URL",
0866: new Object[] {
0867: aurl,
0868: t
0869: .getLocalizedMessage() })));
0870: }
0871: }
0872: }
0873: }
0874:
0875: private void validate(JMSBinding target) {
0876: // for jms binding tag - nothing to validate at this point
0877: }
0878:
0879: private void validate(BindingOperation bindingOp,
0880: JMSOperation target) {
0881: Collection<ResultItem> results = mValidationResult
0882: .getValidationResult();
0883:
0884: // ToDo: validate JMS operation
0885: String mep = "in-only";
0886: boolean hasInput = bindingOp.getBindingInput() != null;
0887: boolean hasOutput = bindingOp.getBindingOutput() != null;
0888:
0889: if (hasInput && hasOutput) {
0890: mep = "in-out";
0891: }
0892:
0893: String destination = target.getDestination();
0894: isAToken(destination, target);
0895:
0896: String destinationType = target.getDestinationType();
0897: if (destination == null && destination.length() == 0) {
0898: results.add(new Validator.ResultItem(this ,
0899: Validator.ResultType.ERROR, target, getMessage(
0900: "JMSOperation.EMPTY_DESTINATION_EMPTY",
0901: new Object[] { bindingOp.getName() })));
0902: }
0903:
0904: String subscriptionDurability = target
0905: .getSubscriptionDurability();
0906: if (subscriptionDurability != null
0907: && subscriptionDurability.equals(JMSConstants.DURABLE)) {
0908: String subscriptionName = target.getSubscriptionName();
0909: if (subscriptionName == null
0910: || subscriptionName.length() == 0) {
0911: results
0912: .add(new Validator.ResultItem(
0913: this ,
0914: Validator.ResultType.ERROR,
0915: target,
0916: getMessage(
0917: "JMSOperation.DURABLE_SUBSCRIBER_BUT_NO_SUBSCRIPTION_NAME",
0918: new Object[] { bindingOp
0919: .getName() })));
0920: }
0921: isAToken(subscriptionName, target);
0922:
0923: if (destinationType.equals(JMSConstants.QUEUE)) {
0924: results
0925: .add(new Validator.ResultItem(
0926: this ,
0927: Validator.ResultType.ERROR,
0928: target,
0929: getMessage(
0930: "JMSOperation.DURABLE_SUBSCRIBER_BUT_DESTINATION_TYPE_IS_QUEUE",
0931: new Object[] { bindingOp
0932: .getName() })));
0933: }
0934:
0935: String clientID = target.getClientID();
0936: if (clientID == null || clientID.length() == 0) {
0937: results
0938: .add(new Validator.ResultItem(
0939: this ,
0940: Validator.ResultType.WARNING,
0941: target,
0942: getMessage(
0943: "JMSOperation.DURABLE_SUBSCRIBER_BUT_NO_CLIENT_ID",
0944: new Object[] { bindingOp
0945: .getName() })));
0946: }
0947: isAToken(clientID, target);
0948: }
0949:
0950: int maxConcurrentConsumers = target.getMaxConcurrentConsumers();
0951: if (maxConcurrentConsumers > 1
0952: && destinationType.equals(JMSConstants.TOPIC)) {
0953: results
0954: .add(new Validator.ResultItem(
0955: this ,
0956: Validator.ResultType.WARNING,
0957: target,
0958: getMessage(
0959: "JMSOperation.MAX_CONCURRENT_CONSUMERS_SUPPORTED_FOR_TOPICS",
0960: new Object[] { bindingOp.getName(),
0961: maxConcurrentConsumers })));
0962: }
0963:
0964: /*
0965: int batchSize = target.getBatchSize();
0966: if (batchSize > 1) {
0967: String transaction = target.getTransaction();
0968: if (transaction != null &&
0969: transaction.equals(JMSConstants.TRANSACTION_XA)) {
0970: results.add(new Validator.ResultItem(this,
0971: Validator.ResultType.ERROR,
0972: target,
0973: getMessage("JMSOperation.XA_NOT_SUPPORTED_FOR_BATCH",
0974: new Object[] {bindingOp.getName(),
0975: batchSize})));
0976: }
0977: }
0978: */
0979:
0980: String redeliveryHandling = target.getRedeliveryHandling();
0981: if (redeliveryHandling != null
0982: && redeliveryHandling.length() > 0) {
0983: if (!isAToken(redeliveryHandling, target)) {
0984: try {
0985: RedeliveryHandlingParser.parse(redeliveryHandling,
0986: "none", JMSConstants.QUEUE);
0987: } catch (Throwable t) {
0988: results
0989: .add(new Validator.ResultItem(
0990: this ,
0991: Validator.ResultType.ERROR,
0992: target,
0993: getMessage(
0994: "JMSOperation.INVALID_REDELIVERY_HANDLING_ACTIONS",
0995: new Object[] {
0996: bindingOp.getName(),
0997: redeliveryHandling,
0998: t
0999: .getLocalizedMessage() })));
1000: }
1001: }
1002: }
1003:
1004: // check list of options
1005: List<JMSOptions> options = target
1006: .getExtensibilityElements(JMSOptions.class);
1007: if (options.size() > 1) {
1008: results
1009: .add(new Validator.ResultItem(
1010: this ,
1011: Validator.ResultType.ERROR,
1012: target,
1013: getMessage(
1014: "JMSOperation.ATMOST_ONE_OPTIONS_ELEM_IN_JMS_OPERATION",
1015: new Object[] { bindingOp.getName(),
1016: options.size() })));
1017: } /*else if (options.size() == 1) {
1018: JMSOptions jmsOptions = options.iterator().next();
1019: // validate each option??
1020: Iterator <JMSOption> optionIter = jmsOptions.getOptions().iterator();
1021: while (optionIter.hasNext()) {
1022: JMSOption jmsOption = optionIter.next();
1023: String name = jmsOption.getName();
1024: String value = jmsOption.getValue();
1025: }
1026: }*/
1027:
1028: // ensure that option elements are child elements of options element
1029: List<JMSOption> option = target
1030: .getExtensibilityElements(JMSOption.class);
1031: if (option.size() > 0) {
1032: results.add(new Validator.ResultItem(this ,
1033: Validator.ResultType.ERROR, option.get(0),
1034: getMessage("JMSOperation.IMPROPER_USAGE_OF_OPTION",
1035: new Object[] { bindingOp.getName(),
1036: option.size() })));
1037: }
1038: }
1039:
1040: private void validate(BindingOperation bindingOp,
1041: OperationParameter opParam, JMSMessage target) {
1042: Collection<ResultItem> results = mValidationResult
1043: .getValidationResult();
1044:
1045: // get JMS message type
1046: String jmsMsgType = target.getMessageType();
1047: if (jmsMsgType.equals(JMSConstants.TEXT_MESSAGE)) {
1048: // Check textPart
1049: String textPart = target.getTextPart();
1050: if (textPart == null || textPart.length() == 0) {
1051: results
1052: .add(new Validator.ResultItem(
1053: this ,
1054: Validator.ResultType.ERROR,
1055: target,
1056: getMessage(
1057: "JMSMessage.TEXT_MESSAGE_TEXTPART_NOT_SPECIFIED",
1058: new Object[] {
1059: bindingOp.getName(),
1060: (opParam instanceof Input) ? "input"
1061: : "output",
1062: opParam.getName() })));
1063: } else {
1064: // make sure textPart references a vald wsdl message part
1065: if (!referencesValidMessagePart(opParam.getMessage(),
1066: textPart)) {
1067: results
1068: .add(new Validator.ResultItem(
1069: this ,
1070: Validator.ResultType.ERROR,
1071: target,
1072: getMessage(
1073: "JMSMessage.TEXT_PART_REFERENCES_NON_EXISTENT_PART",
1074: new Object[] {
1075: bindingOp.getName(),
1076: (opParam instanceof Input) ? "input"
1077: : "output",
1078: opParam.getName(),
1079: textPart,
1080: opParam
1081: .getMessage()
1082: .getQName() })));
1083: }
1084: }
1085:
1086: List<JMSMapMessage> mapmessageList = target
1087: .getExtensibilityElements(JMSMapMessage.class);
1088: if (mapmessageList.size() > 0) {
1089: results
1090: .add(new Validator.ResultItem(
1091: this ,
1092: Validator.ResultType.ERROR,
1093: mapmessageList.iterator().next(),
1094: getMessage(
1095: "JMSMessage.TEXT_MESSAGE_CANNOT_HAVE_MAPMESSAGE_ELEM",
1096: new Object[] {
1097: bindingOp.getName(),
1098: (opParam instanceof Input) ? "input"
1099: : "output",
1100: opParam.getName() })));
1101: }
1102:
1103: // Check use and encoded
1104: String use = target.getUse();
1105: if (use != null && use.length() > 0) {
1106: String encodingStyle = target.getJMSEncodingStyle();
1107: if (use.equals(JMSMessage.ATTR_USE_TYPE_ENCODED)) {
1108: // ensure encodingStyle is defined
1109: if (encodingStyle == null
1110: || encodingStyle.length() == 0) {
1111: results
1112: .add(new Validator.ResultItem(
1113: this ,
1114: Validator.ResultType.ERROR,
1115: target,
1116: getMessage(
1117: "JMSMessage.ENCODING_STYLE_NOT_SPECIFIED",
1118: new Object[] {
1119: bindingOp
1120: .getName(),
1121: (opParam instanceof Input) ? "input"
1122: : "output",
1123: opParam
1124: .getName() })));
1125: } // add rule to validate different styles?
1126: } else { // must be 'literal'
1127: // encodingStyle should not be defined
1128: if (encodingStyle != null
1129: && encodingStyle.length() > 0) {
1130: results
1131: .add(new Validator.ResultItem(
1132: this ,
1133: Validator.ResultType.ERROR,
1134: target,
1135: getMessage(
1136: "JMSMessage.ENCODING_STYLE_INVALID_USE",
1137: new Object[] {
1138: bindingOp
1139: .getName(),
1140: (opParam instanceof Input) ? "input"
1141: : "output",
1142: opParam
1143: .getName(),
1144: encodingStyle })));
1145: }
1146: }
1147: }
1148: } else if (jmsMsgType.equals(JMSConstants.MAP_MESSAGE)) {
1149: // Check textPart
1150: String textPart = target.getTextPart();
1151: if (textPart != null && textPart.length() > 0) {
1152: results
1153: .add(new Validator.ResultItem(
1154: this ,
1155: Validator.ResultType.ERROR,
1156: target,
1157: getMessage(
1158: "JMSMessage.MAP_MESSAGE_CANNOT_HAVE_TEXTPART_ATTR",
1159: new Object[] {
1160: bindingOp.getName(),
1161: (opParam instanceof Input) ? "input"
1162: : "output",
1163: opParam.getName() })));
1164: }
1165:
1166: // Check use
1167: String use = target.getUse();
1168: if (use != null && use.length() > 0) {
1169: results
1170: .add(new Validator.ResultItem(
1171: this ,
1172: Validator.ResultType.WARNING,
1173: target,
1174: getMessage(
1175: "JMSMessage.USE_IGNORED",
1176: new Object[] {
1177: bindingOp.getName(),
1178: (opParam instanceof Input) ? "input"
1179: : "output",
1180: opParam.getName(), use })));
1181: }
1182:
1183: // check for jms:mapmessage definition
1184: List<JMSMapMessage> mapmessageList = target
1185: .getExtensibilityElements(JMSMapMessage.class);
1186: switch (mapmessageList.size()) {
1187: case 0:
1188: results
1189: .add(new Validator.ResultItem(
1190: this ,
1191: Validator.ResultType.ERROR,
1192: target,
1193: getMessage(
1194: "JMSMessage.MISSING_MAPMESSAGE_ELEM_IN_JMS_MESSAGE",
1195: new Object[] {
1196: bindingOp.getName(),
1197: (opParam instanceof Input) ? "input"
1198: : "output",
1199: opParam.getName() })));
1200: break;
1201: case 1:
1202: JMSMapMessage mapmessage = mapmessageList.iterator()
1203: .next();
1204: List<JMSMapMessagePart> mappartList = mapmessage
1205: .getMapMessageParts();
1206: switch (mappartList.size()) {
1207: case 0:
1208: results
1209: .add(new Validator.ResultItem(
1210: this ,
1211: Validator.ResultType.ERROR,
1212: mapmessage,
1213: getMessage(
1214: "JMSMessage.EMPTY_MAPMESSAGE_PARTS",
1215: new Object[] {
1216: bindingOp.getName(),
1217: (opParam instanceof Input) ? "input"
1218: : "output",
1219: opParam.getName() })));
1220: break;
1221: default:
1222: Iterator<JMSMapMessagePart> mappartIter = mappartList
1223: .iterator();
1224: while (mappartIter.hasNext()) {
1225: JMSMapMessagePart mappart = mappartIter.next();
1226: String name = mappart.getName();
1227: String type = mappart.getType();
1228: String part = mappart.getPart();
1229:
1230: if (name == null || name.length() == 0) {
1231: results
1232: .add(new Validator.ResultItem(
1233: this ,
1234: Validator.ResultType.ERROR,
1235: mappart,
1236: getMessage(
1237: "JMSMessage.EMTPY_MAPPART_NAME",
1238: new Object[] {
1239: bindingOp
1240: .getName(),
1241: (opParam instanceof Input) ? "input"
1242: : "output",
1243: opParam
1244: .getName() })));
1245:
1246: }
1247: if (type == null || type.length() == 0) {
1248: results
1249: .add(new Validator.ResultItem(
1250: this ,
1251: Validator.ResultType.ERROR,
1252: mappart,
1253: getMessage(
1254: "JMSMessage.EMTPY_MAPPART_TYPE",
1255: new Object[] {
1256: bindingOp
1257: .getName(),
1258: (opParam instanceof Input) ? "input"
1259: : "output",
1260: opParam
1261: .getName() })));
1262:
1263: }
1264: if (part == null || part.length() == 0) {
1265: results
1266: .add(new Validator.ResultItem(
1267: this ,
1268: Validator.ResultType.ERROR,
1269: mappart,
1270: getMessage(
1271: "JMSMessage.EMTPY_MAPPART_PART",
1272: new Object[] {
1273: bindingOp
1274: .getName(),
1275: (opParam instanceof Input) ? "input"
1276: : "output",
1277: opParam
1278: .getName() })));
1279: } else {
1280: if (!referencesValidMessagePart(opParam
1281: .getMessage(), part)) {
1282: results
1283: .add(new Validator.ResultItem(
1284: this ,
1285: Validator.ResultType.ERROR,
1286: mappart,
1287: getMessage(
1288: "JMSMessage.MAPPART_PART_REFERENCES_NON_EXISTENT_PART",
1289: new Object[] {
1290: bindingOp
1291: .getName(),
1292: (opParam instanceof Input) ? "input"
1293: : "output",
1294: opParam
1295: .getName(),
1296: part,
1297: opParam
1298: .getMessage()
1299: .getQName() })));
1300: }
1301: }
1302: }
1303: }
1304: break;
1305: default:
1306: results
1307: .add(new Validator.ResultItem(
1308: this ,
1309: Validator.ResultType.ERROR,
1310: target,
1311: getMessage(
1312: "JMSMessage.ATMOST_ONE_MAPMESSAGE_ELEM_IN_JMS_MESSAGE",
1313: new Object[] {
1314: bindingOp.getName(),
1315: (opParam instanceof Input) ? "input"
1316: : "output",
1317: opParam.getName(),
1318: mapmessageList.size() })));
1319: }
1320: } else {
1321: results
1322: .add(new Validator.ResultItem(
1323: this ,
1324: Validator.ResultType.ERROR,
1325: target,
1326: getMessage(
1327: "JMSMessage.MESSAGE_TYPE_IS_NOT_SUPPORTED",
1328: new Object[] {
1329: bindingOp.getName(),
1330: (opParam instanceof Input) ? "input"
1331: : "output",
1332: opParam.getName(),
1333: jmsMsgType })));
1334: }
1335:
1336: // check jms:properties
1337: List<JMSProperties> propertiesList = target
1338: .getExtensibilityElements(JMSProperties.class);
1339: switch (propertiesList.size()) {
1340: case 0:
1341: // JMS user properties (jms:properties) are optional
1342: break;
1343: case 1:
1344: JMSProperties properties = propertiesList.iterator().next();
1345: List<JMSProperty> propertyList = properties.getProperties();
1346: switch (propertyList.size()) {
1347: case 0:
1348: results
1349: .add(new Validator.ResultItem(
1350: this ,
1351: Validator.ResultType.ERROR,
1352: properties,
1353: getMessage(
1354: "JMSMessage.EMPTY_PROPERTIES_PARTS",
1355: new Object[] {
1356: bindingOp.getName(),
1357: (opParam instanceof Input) ? "input"
1358: : "output",
1359: opParam.getName() })));
1360: break;
1361: default:
1362: Iterator<JMSProperty> propertyIter = propertyList
1363: .iterator();
1364: while (propertyIter.hasNext()) {
1365: JMSProperty property = propertyIter.next();
1366: String name = property.getName();
1367: String type = property.getType();
1368: String part = property.getPart();
1369:
1370: if (name == null || name.length() == 0) {
1371: results
1372: .add(new Validator.ResultItem(
1373: this ,
1374: Validator.ResultType.ERROR,
1375: property,
1376: getMessage(
1377: "JMSMessage.EMTPY_PROPERTY_NAME",
1378: new Object[] {
1379: bindingOp
1380: .getName(),
1381: (opParam instanceof Input) ? "input"
1382: : "output",
1383: opParam
1384: .getName() })));
1385:
1386: }
1387: if (type == null || type.length() == 0) {
1388: results
1389: .add(new Validator.ResultItem(
1390: this ,
1391: Validator.ResultType.ERROR,
1392: property,
1393: getMessage(
1394: "JMSMessage.EMTPY_PROPERTY_TYPE",
1395: new Object[] {
1396: bindingOp
1397: .getName(),
1398: (opParam instanceof Input) ? "input"
1399: : "output",
1400: opParam
1401: .getName() })));
1402:
1403: }
1404: if (part == null || part.length() == 0) {
1405: results
1406: .add(new Validator.ResultItem(
1407: this ,
1408: Validator.ResultType.ERROR,
1409: property,
1410: getMessage(
1411: "JMSMessage.EMTPY_PROPERTY_PART",
1412: new Object[] {
1413: bindingOp
1414: .getName(),
1415: (opParam instanceof Input) ? "input"
1416: : "output",
1417: opParam
1418: .getName() })));
1419: } else {
1420: if (!referencesValidMessagePart(opParam
1421: .getMessage(), part)) {
1422: results
1423: .add(new Validator.ResultItem(
1424: this ,
1425: Validator.ResultType.ERROR,
1426: property,
1427: getMessage(
1428: "JMSMessage.PROPERTY_PART_REFERENCES_NON_EXISTENT_PART",
1429: new Object[] {
1430: bindingOp
1431: .getName(),
1432: (opParam instanceof Input) ? "input"
1433: : "output",
1434: opParam
1435: .getName(),
1436: part,
1437: opParam
1438: .getMessage()
1439: .getQName() })));
1440: }
1441: }
1442: }
1443: }
1444: break;
1445: default:
1446: results
1447: .add(new Validator.ResultItem(
1448: this ,
1449: Validator.ResultType.ERROR,
1450: target,
1451: getMessage(
1452: "JMSMessage.ATMOST_ONE_PROPERTIES_ELEM_IN_JMS_MESSAGE",
1453: new Object[] {
1454: bindingOp.getName(),
1455: (opParam instanceof Input) ? "input"
1456: : "output",
1457: opParam.getName(),
1458: propertiesList.size() })));
1459: }
1460:
1461: // check JMS standard headers
1462: String correlationIDPart = target.getCorrelationIdPart();
1463: if (correlationIDPart != null) {
1464: if (correlationIDPart.length() == 0) {
1465: results
1466: .add(new Validator.ResultItem(
1467: this ,
1468: Validator.ResultType.ERROR,
1469: target,
1470: getMessage(
1471: "JMSMessage.EMTPY_CORRELATIONID_PART",
1472: new Object[] {
1473: bindingOp.getName(),
1474: (opParam instanceof Input) ? "input"
1475: : "output",
1476: opParam.getName() })));
1477:
1478: } else if (!referencesValidMessagePart(
1479: opParam.getMessage(), correlationIDPart)) {
1480: results
1481: .add(new Validator.ResultItem(
1482: this ,
1483: Validator.ResultType.ERROR,
1484: target,
1485: getMessage(
1486: "JMSMessage.CORRELATIONID_PART_REFERENCES_NON_EXISTENT_PART",
1487: new Object[] {
1488: bindingOp.getName(),
1489: (opParam instanceof Input) ? "input"
1490: : "output",
1491: opParam.getName(),
1492: correlationIDPart,
1493: opParam.getMessage()
1494: .getQName() })));
1495: }
1496: }
1497:
1498: String deliveryModePart = target.getDeliveryModePart();
1499: if (deliveryModePart != null) {
1500: if (deliveryModePart.length() == 0) {
1501: results
1502: .add(new Validator.ResultItem(
1503: this ,
1504: Validator.ResultType.ERROR,
1505: target,
1506: getMessage(
1507: "JMSMessage.EMTPY_DELIVERYMODE_PART",
1508: new Object[] {
1509: bindingOp.getName(),
1510: (opParam instanceof Input) ? "input"
1511: : "output",
1512: opParam.getName() })));
1513:
1514: } else if (!referencesValidMessagePart(
1515: opParam.getMessage(), deliveryModePart)) {
1516: results
1517: .add(new Validator.ResultItem(
1518: this ,
1519: Validator.ResultType.ERROR,
1520: target,
1521: getMessage(
1522: "JMSMessage.DELIVERYMODE_PART_REFERENCES_NON_EXISTENT_PART",
1523: new Object[] {
1524: bindingOp.getName(),
1525: (opParam instanceof Input) ? "input"
1526: : "output",
1527: opParam.getName(),
1528: deliveryModePart,
1529: opParam.getMessage()
1530: .getQName() })));
1531: }
1532: }
1533:
1534: String priorityPart = target.getPriorityPart();
1535: if (priorityPart != null) {
1536: if (priorityPart.length() == 0) {
1537: results
1538: .add(new Validator.ResultItem(
1539: this ,
1540: Validator.ResultType.ERROR,
1541: target,
1542: getMessage(
1543: "JMSMessage.EMTPY_PRIORITY_PART",
1544: new Object[] {
1545: bindingOp.getName(),
1546: (opParam instanceof Input) ? "input"
1547: : "output",
1548: opParam.getName() })));
1549:
1550: } else if (!referencesValidMessagePart(
1551: opParam.getMessage(), priorityPart)) {
1552: results
1553: .add(new Validator.ResultItem(
1554: this ,
1555: Validator.ResultType.ERROR,
1556: target,
1557: getMessage(
1558: "JMSMessage.PRIORITY_PART_REFERENCES_NON_EXISTENT_PART",
1559: new Object[] {
1560: bindingOp.getName(),
1561: (opParam instanceof Input) ? "input"
1562: : "output",
1563: opParam.getName(),
1564: priorityPart,
1565: opParam.getMessage()
1566: .getQName() })));
1567: }
1568: }
1569:
1570: String typePart = target.getTypePart();
1571: if (typePart != null) {
1572: if (typePart.length() == 0) {
1573: results
1574: .add(new Validator.ResultItem(
1575: this ,
1576: Validator.ResultType.ERROR,
1577: target,
1578: getMessage(
1579: "JMSMessage.EMTPY_TYPE_PART",
1580: new Object[] {
1581: bindingOp.getName(),
1582: (opParam instanceof Input) ? "input"
1583: : "output",
1584: opParam.getName() })));
1585:
1586: } else if (!referencesValidMessagePart(
1587: opParam.getMessage(), typePart)) {
1588: results
1589: .add(new Validator.ResultItem(
1590: this ,
1591: Validator.ResultType.ERROR,
1592: target,
1593: getMessage(
1594: "JMSMessage.TYPE_PART_REFERENCES_NON_EXISTENT_PART",
1595: new Object[] {
1596: bindingOp.getName(),
1597: (opParam instanceof Input) ? "input"
1598: : "output",
1599: opParam.getName(),
1600: typePart,
1601: opParam.getMessage()
1602: .getQName() })));
1603: }
1604: }
1605:
1606: String messageIDPart = target.getMessageIDPart();
1607: if (messageIDPart != null) {
1608: if (messageIDPart.length() == 0) {
1609: results
1610: .add(new Validator.ResultItem(
1611: this ,
1612: Validator.ResultType.ERROR,
1613: target,
1614: getMessage(
1615: "JMSMessage.EMTPY_MESSAGEID_PART",
1616: new Object[] {
1617: bindingOp.getName(),
1618: (opParam instanceof Input) ? "input"
1619: : "output",
1620: opParam.getName() })));
1621:
1622: } else if (!referencesValidMessagePart(
1623: opParam.getMessage(), messageIDPart)) {
1624: results
1625: .add(new Validator.ResultItem(
1626: this ,
1627: Validator.ResultType.ERROR,
1628: target,
1629: getMessage(
1630: "JMSMessage.MESSAGEID_PART_REFERENCES_NON_EXISTENT_PART",
1631: new Object[] {
1632: bindingOp.getName(),
1633: (opParam instanceof Input) ? "input"
1634: : "output",
1635: opParam.getName(),
1636: messageIDPart,
1637: opParam.getMessage()
1638: .getQName() })));
1639: }
1640: }
1641:
1642: String redeliveredPart = target.getRedeliveredPart();
1643: if (redeliveredPart != null) {
1644: if (redeliveredPart.length() == 0) {
1645: results
1646: .add(new Validator.ResultItem(
1647: this ,
1648: Validator.ResultType.ERROR,
1649: target,
1650: getMessage(
1651: "JMSMessage.EMTPY_REDELIVERED_PART",
1652: new Object[] {
1653: bindingOp.getName(),
1654: (opParam instanceof Input) ? "input"
1655: : "output",
1656: opParam.getName() })));
1657:
1658: } else if (!referencesValidMessagePart(
1659: opParam.getMessage(), redeliveredPart)) {
1660: results
1661: .add(new Validator.ResultItem(
1662: this ,
1663: Validator.ResultType.ERROR,
1664: target,
1665: getMessage(
1666: "JMSMessage.REDELIVERED_PART_REFERENCES_NON_EXISTENT_PART",
1667: new Object[] {
1668: bindingOp.getName(),
1669: (opParam instanceof Input) ? "input"
1670: : "output",
1671: opParam.getName(),
1672: redeliveredPart,
1673: opParam.getMessage()
1674: .getQName() })));
1675: }
1676: }
1677:
1678: String timestampPart = target.getTimestampPart();
1679: if (timestampPart != null) {
1680: if (timestampPart.length() == 0) {
1681: results
1682: .add(new Validator.ResultItem(
1683: this ,
1684: Validator.ResultType.ERROR,
1685: target,
1686: getMessage(
1687: "JMSMessage.EMTPY_TIMESTAMP_PART",
1688: new Object[] {
1689: bindingOp.getName(),
1690: (opParam instanceof Input) ? "input"
1691: : "output",
1692: opParam.getName() })));
1693:
1694: } else if (!referencesValidMessagePart(
1695: opParam.getMessage(), timestampPart)) {
1696: results
1697: .add(new Validator.ResultItem(
1698: this ,
1699: Validator.ResultType.ERROR,
1700: target,
1701: getMessage(
1702: "JMSMessage.TIMESTAMP_PART_REFERENCES_NON_EXISTENT_PART",
1703: new Object[] {
1704: bindingOp.getName(),
1705: (opParam instanceof Input) ? "input"
1706: : "output",
1707: opParam.getName(),
1708: timestampPart,
1709: opParam.getMessage()
1710: .getQName() })));
1711: }
1712: }
1713:
1714: }
1715:
1716: private boolean checkSignature(BindingOperation bindingOp/*, Object inputChild, Object outputChild*/) {
1717: boolean result = true;
1718: Reference<Operation> opRef = bindingOp.getOperation();
1719: if (opRef == null)
1720: return false;
1721: Operation op = opRef.get();
1722: if (op == null)
1723: return false;
1724: if ((op.getInput() == null && bindingOp.getBindingInput() == null /*&& inputChild == null*/)
1725: || (op.getInput() != null && bindingOp
1726: .getBindingInput() != null /*&& inputChild != null*/)) {
1727:
1728: } else {
1729: result = false;
1730: }
1731:
1732: if ((op.getOutput() == null && bindingOp.getBindingOutput() == null /*&& outputChild == null*/)
1733: || (op.getOutput() != null && bindingOp
1734: .getBindingOutput() != null /*&& outputChild != null*/)) {
1735:
1736: } else {
1737: result = false;
1738: }
1739: return result;
1740: }
1741:
1742: private boolean referencesValidMessagePart(
1743: NamedComponentReference<Message> wsdlMessage,
1744: String partName) {
1745:
1746: // Let wsdl validator catch undefined message for operation input or output
1747: if (wsdlMessage == null || wsdlMessage.get() == null
1748: || wsdlMessage.get().getParts() == null) {
1749: return true;
1750: }
1751:
1752: boolean isValdPartReference = false;
1753: Iterator<Part> partIter = wsdlMessage.get().getParts()
1754: .iterator();
1755: while (partIter.hasNext()) {
1756: Part p = partIter.next();
1757: if (p.getName().equals(partName)) {
1758: isValdPartReference = true;
1759: break;
1760: }
1761: }
1762: return isValdPartReference;
1763: }
1764:
1765: private boolean isAToken(String name, JMSComponent target) {
1766: Collection<ResultItem> results = mValidationResult
1767: .getValidationResult();
1768:
1769: boolean isToken = false;
1770:
1771: if (name != null && name.startsWith("${")) {
1772: isToken = true;
1773: if (!name.endsWith("}")) {
1774: results
1775: .add(new Validator.ResultItem(
1776: this ,
1777: Validator.ResultType.ERROR,
1778: target,
1779: getMessage(
1780: "JMSComponentValidator.INVALID_ENVIRONMENT_TOKEN_NAME",
1781: new Object[] { name })));
1782: }
1783: }
1784:
1785: return isToken;
1786: }
1787:
1788: private String getMessage(String key, String param) {
1789: return getMessage(key, new Object[] { param });
1790: }
1791:
1792: private String getMessage(String key, Object[] params) {
1793: String fmt = mMessages.getString(key);
1794: if (params != null) {
1795: return MessageFormat.format(fmt, params);
1796: } else {
1797: return fmt;
1798: }
1799: }
1800: }
|