Source Code Cross Referenced for FTPComponentValidator.java in  » IDE-Netbeans » wsdlextensions.file » org » netbeans » modules » wsdlextensions » ftp » validator » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » wsdlextensions.file » org.netbeans.modules.wsdlextensions.ftp.validator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.ftp.validator;
0020:
0021:        import org.netbeans.modules.wsdlextensions.ftp.FTPComponentEncodable;
0022:        import org.netbeans.modules.wsdlextensions.ftp.FTPMessage; //import org.netbeans.modules.wsdlextensions.ftp.FTPMessageActivePassive;
0023:        import java.net.URI;
0024:        import java.net.URL;
0025:        import java.text.MessageFormat;
0026:        import java.util.Collection;
0027:        import java.util.Collections;
0028:        import java.util.HashSet;
0029:        import java.util.Iterator;
0030:        import java.util.List;
0031:        import java.util.StringTokenizer;
0032:        import java.util.ResourceBundle;
0033:
0034:        import org.netbeans.modules.xml.wsdl.model.Binding;
0035:        import org.netbeans.modules.xml.wsdl.model.BindingInput;
0036:        import org.netbeans.modules.xml.wsdl.model.BindingFault;
0037:        import org.netbeans.modules.xml.wsdl.model.BindingOperation;
0038:        import org.netbeans.modules.xml.wsdl.model.BindingOutput;
0039:        import org.netbeans.modules.xml.wsdl.model.Definitions;
0040:        import org.netbeans.modules.xml.wsdl.model.Input;
0041:        import org.netbeans.modules.xml.wsdl.model.Operation;
0042:        import org.netbeans.modules.xml.wsdl.model.Output;
0043:        import org.netbeans.modules.xml.wsdl.model.Part;
0044:        import org.netbeans.modules.xml.wsdl.model.Port;
0045:        import org.netbeans.modules.xml.wsdl.model.Service;
0046:        import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
0047:        import org.netbeans.modules.xml.wsdl.model.WSDLModel;
0048:
0049:        import org.netbeans.modules.xml.xam.Component;
0050:        import org.netbeans.modules.xml.xam.Model;
0051:        import org.netbeans.modules.xml.xam.Model.State;
0052:        import org.netbeans.modules.xml.xam.Reference;
0053:        import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
0054:        import org.netbeans.modules.xml.wsdl.model.Message;
0055:        import org.netbeans.modules.xml.xam.spi.Validation;
0056:        import org.netbeans.modules.xml.xam.spi.Validation.ValidationType;
0057:        import org.netbeans.modules.xml.xam.spi.ValidationResult;
0058:        import org.netbeans.modules.xml.xam.spi.Validator;
0059:        import org.netbeans.modules.xml.xam.spi.Validator.ResultItem;
0060:
0061:        import org.netbeans.modules.wsdlextensions.ftp.FTPComponent;
0062:        import org.netbeans.modules.wsdlextensions.ftp.FTPOperation;
0063:        import org.netbeans.modules.wsdlextensions.ftp.FTPTransfer;
0064:        import org.netbeans.modules.wsdlextensions.ftp.FTPBinding;
0065:        import org.netbeans.modules.wsdlextensions.ftp.FTPAddress;
0066:
0067:        /**
0068:         * semantic validation, check WSDL elements & attributes values and 
0069:         * any relationship between;
0070:         *
0071:         * @author jfu
0072:         */
0073:        public class FTPComponentValidator implements  Validator,
0074:                FTPComponent.Visitor {
0075:
0076:            private static final String FTP_URL_PREFIX = "ftp://";
0077:            private static final String FTP_URL_LOGIN_HOST_DELIM = "@";
0078:            private static final String FTP_URL_COLON_DELIM = ":";
0079:            private static final String FTP_URL_PATH_DELIM = "/";
0080:
0081:            private Validation mValidation;
0082:            private ValidationType mValidationType;
0083:            private ValidationResult mValidationResult;
0084:
0085:            public static final ValidationResult EMPTY_RESULT = new ValidationResult(
0086:                    Collections.EMPTY_SET, Collections.EMPTY_SET);
0087:
0088:            public FTPComponentValidator() {
0089:            }
0090:
0091:            /**
0092:             * Returns name of this validation service.
0093:             */
0094:            public String getName() {
0095:                return getClass().getName();
0096:            }
0097:
0098:            /**
0099:             * Validates given model.
0100:             *
0101:             * @param model model to validate.
0102:             * @param validation reference to the validation context.
0103:             * @param validationType the type of validation to perform
0104:             * @return ValidationResult.
0105:             */
0106:            public ValidationResult validate(Model model,
0107:                    Validation validation, ValidationType validationType) {
0108:                mValidation = validation;
0109:                mValidationType = validationType;
0110:
0111:                HashSet<ResultItem> results = new HashSet<ResultItem>();
0112:                HashSet<Model> models = new HashSet<Model>();
0113:                models.add(model);
0114:                mValidationResult = new ValidationResult(results, models);
0115:
0116:                // Traverse the model
0117:                if (model instanceof  WSDLModel) {
0118:                    WSDLModel wsdlModel = (WSDLModel) model;
0119:
0120:                    if (model.getState() == State.NOT_WELL_FORMED) {
0121:                        return EMPTY_RESULT;
0122:                    }
0123:
0124:                    Definitions defs = wsdlModel.getDefinitions();
0125:                    Iterator<Binding> bindings = defs.getBindings().iterator();
0126:
0127:                    while (bindings.hasNext()) {
0128:                        Binding binding = bindings.next();
0129:                        // bindings port type will be validated - generically by WSDL editor
0130:                        // so don't need to bother about it.
0131:
0132:                        // but need to check the parameters for an operation:
0133:                        // e.g.: 
0134:                        // if op1 requires input and output, then op1 binding 
0135:                        // should have input and output too, etc.
0136:                        int numFTPBindings = binding.getExtensibilityElements(
0137:                                FTPBinding.class).size();
0138:                        if (numFTPBindings > 0 && numFTPBindings != 1) {
0139:                            results
0140:                                    .add(new Validator.ResultItem(
0141:                                            this ,
0142:                                            Validator.ResultType.ERROR,
0143:                                            binding,
0144:                                            Util
0145:                                                    .getMessage("FTPBindingValidation.ONLY_ONE_FTP_BINDING_ALLOWED")));
0146:                        }
0147:
0148:                        if (numFTPBindings == 0)
0149:                            continue;
0150:
0151:                        if (binding.getType() == null
0152:                                || binding.getType().get() == null)
0153:                            continue;
0154:
0155:                        Iterator<BindingOperation> bindingOps = binding
0156:                                .getBindingOperations().iterator();
0157:                        boolean foundFTPOp = false;
0158:                        int transCntInput = 0;
0159:                        int msgCntInput = 0;
0160:                        //int msgModeCntInput = 0;
0161:                        int transCntOutput = 0;
0162:                        int msgCntOutput = 0;
0163:                        //int msgModeCntOutput = 0;
0164:                        Object inputChild = null, outputChild = null;
0165:                        while (bindingOps.hasNext()) {
0166:                            BindingOperation bindingOp = bindingOps.next();
0167:                            List ftpOpsList = bindingOp
0168:                                    .getExtensibilityElements(FTPOperation.class);
0169:                            inputChild = outputChild = null;
0170:                            if (ftpOpsList.size() == 1) {
0171:                                Iterator<FTPOperation> ftpOps = ftpOpsList
0172:                                        .iterator();
0173:
0174:                                while (ftpOps.hasNext()) {
0175:                                    ftpOps.next().accept(this );
0176:                                }
0177:
0178:                                foundFTPOp = true;
0179:                                BindingInput bindingInput = bindingOp
0180:                                        .getBindingInput();
0181:                                if (bindingInput != null) {
0182:                                    transCntInput = 0;
0183:                                    msgCntInput = 0;
0184:                                    //msgModeCntInput = 0;
0185:                                    // now with the introduction of more extensibility elements
0186:                                    // that could be under <input> as child, need to do
0187:                                    // more validation
0188:
0189:                                    // assumption:
0190:                                    // under <input>, there could be one of the following:
0191:                                    // <ftp:message> or <ftp:transfer> or <ftp:messageActivePassive>
0192:                                    // but only one is allowed;
0193:                                    // 
0194:                                    Iterator<FTPTransfer> ftpTransfers = bindingInput
0195:                                            .getExtensibilityElements(
0196:                                                    FTPTransfer.class)
0197:                                            .iterator();
0198:                                    if (ftpTransfers != null) {
0199:                                        while (ftpTransfers.hasNext()) {
0200:                                            transCntInput++;
0201:                                            FTPTransfer ftpTransfer = ftpTransfers
0202:                                                    .next();
0203:                                            ftpTransfer.accept(this );
0204:                                            inputChild = ftpTransfer;
0205:                                        }
0206:                                        if (transCntInput > 1) {
0207:                                            results
0208:                                                    .add(new Validator.ResultItem(
0209:                                                            this ,
0210:                                                            Validator.ResultType.ERROR,
0211:                                                            binding,
0212:                                                            Util
0213:                                                                    .getMessage(
0214:                                                                            "FTPBindingValidation.ATMOST_ONE_TRANSFER_IN_INPUT",
0215:                                                                            new Object[] { transCntInput })));
0216:                                        }
0217:                                    }
0218:
0219:                                    Iterator<FTPMessage> ftpMessages = bindingInput
0220:                                            .getExtensibilityElements(
0221:                                                    FTPMessage.class)
0222:                                            .iterator();
0223:                                    if (ftpMessages != null) {
0224:                                        while (ftpMessages.hasNext()) {
0225:                                            msgCntInput++;
0226:                                            FTPMessage ftpMessage = ftpMessages
0227:                                                    .next();
0228:                                            ftpMessage.accept(this );
0229:                                            inputChild = ftpMessage;
0230:                                        }
0231:                                        if (msgCntInput > 1) {
0232:                                            results
0233:                                                    .add(new Validator.ResultItem(
0234:                                                            this ,
0235:                                                            Validator.ResultType.ERROR,
0236:                                                            binding,
0237:                                                            Util
0238:                                                                    .getMessage(
0239:                                                                            "FTPBindingValidation.ATMOST_ONE_TRANSFER_IN_INPUT",
0240:                                                                            new Object[] { msgCntInput })));
0241:                                        }
0242:                                    }
0243:
0244:                                    //                            Iterator<FTPMessageActivePassive> ftpMessagesMode =
0245:                                    //                                    bindingInput.getExtensibilityElements(FTPMessageActivePassive.class).iterator();
0246:                                    //                            if ( ftpMessagesMode != null ) {                                    
0247:                                    //                                while (ftpMessagesMode.hasNext()) {
0248:                                    //                                    msgModeCntInput++;
0249:                                    //                                    FTPMessageActivePassive ftpMessageMode = ftpMessagesMode.next();
0250:                                    //                                    ftpMessageMode.accept(this);
0251:                                    //                                    inputChild = ftpMessageMode;
0252:                                    //                                }
0253:                                    //                                if ( msgModeCntInput > 1 ) {
0254:                                    //                                    results.add(
0255:                                    //                                            new Validator.ResultItem(this,
0256:                                    //                                            Validator.ResultType.ERROR,
0257:                                    //                                            binding,
0258:                                    //                                            Util.getMessage("FTPBindingValidation.ATMOST_ONE_TRANSFER_IN_INPUT", new Object[] {msgModeCntInput})));
0259:                                    //                                }
0260:                                    //                            }
0261:                                }
0262:
0263:                                if (transCntInput + msgCntInput /*+ msgModeCntInput*/> 1) {
0264:                                    results
0265:                                            .add(new Validator.ResultItem(
0266:                                                    this ,
0267:                                                    Validator.ResultType.ERROR,
0268:                                                    binding,
0269:                                                    Util
0270:                                                            .getMessage(
0271:                                                                    "FTPBindingValidation.ATMOST_ONE_TRANSFER_IN_INPUT",
0272:                                                                    new Object[] { transCntInput
0273:                                                                            + msgCntInput /*+ msgModeCntInput*/})));
0274:                                }
0275:
0276:                                if (bindingInput != null
0277:                                        && transCntInput + msgCntInput /*+ msgModeCntInput*/== 0) {
0278:                                    results
0279:                                            .add(new Validator.ResultItem(
0280:                                                    this ,
0281:                                                    Validator.ResultType.ERROR,
0282:                                                    binding,
0283:                                                    Util
0284:                                                            .getMessage("FTPBindingValidation.NO_EXTENSIBILITY_ELEMENT_FOUND_IN_INPUT")));
0285:                                }
0286:                                BindingOutput bindingOutput = bindingOp
0287:                                        .getBindingOutput();
0288:                                if (bindingOutput != null) {
0289:                                    // reset and do output checking
0290:                                    transCntOutput = 0;
0291:                                    msgCntOutput = 0;
0292:                                    //msgModeCntOutput = 0;
0293:                                    Iterator<FTPTransfer> ftpTransfers = bindingOutput
0294:                                            .getExtensibilityElements(
0295:                                                    FTPTransfer.class)
0296:                                            .iterator();
0297:                                    if (ftpTransfers != null) {
0298:                                        while (ftpTransfers.hasNext()) {
0299:                                            transCntOutput++;
0300:                                            FTPTransfer ftpTransfer = ftpTransfers
0301:                                                    .next();
0302:                                            ftpTransfer.accept(this );
0303:                                            outputChild = ftpTransfer;
0304:                                        }
0305:                                        if (transCntOutput > 1) {
0306:                                            results
0307:                                                    .add(new Validator.ResultItem(
0308:                                                            this ,
0309:                                                            Validator.ResultType.ERROR,
0310:                                                            binding,
0311:                                                            Util
0312:                                                                    .getMessage(
0313:                                                                            "FTPBindingValidation.ATMOST_ONE_TRANSFER_IN_OUTPUT",
0314:                                                                            new Object[] { transCntOutput })));
0315:                                        }
0316:                                    }
0317:
0318:                                    Iterator<FTPMessage> ftpMessages = bindingOutput
0319:                                            .getExtensibilityElements(
0320:                                                    FTPMessage.class)
0321:                                            .iterator();
0322:                                    if (ftpMessages != null) {
0323:                                        while (ftpMessages.hasNext()) {
0324:                                            msgCntOutput++;
0325:                                            FTPMessage ftpMessage = ftpMessages
0326:                                                    .next();
0327:                                            ftpMessage.accept(this );
0328:                                            outputChild = ftpMessage;
0329:                                        }
0330:                                        if (msgCntOutput > 1) {
0331:                                            results
0332:                                                    .add(new Validator.ResultItem(
0333:                                                            this ,
0334:                                                            Validator.ResultType.ERROR,
0335:                                                            binding,
0336:                                                            Util
0337:                                                                    .getMessage(
0338:                                                                            "FTPBindingValidation.ATMOST_ONE_TRANSFER_IN_OUTPUT",
0339:                                                                            new Object[] { msgCntOutput })));
0340:                                        }
0341:                                    }
0342:
0343:                                    //                            Iterator<FTPMessageActivePassive> ftpMessagesMode =
0344:                                    //                                    bindingOutput.getExtensibilityElements(FTPMessageActivePassive.class).iterator();
0345:                                    //                            if ( ftpMessagesMode != null ) {
0346:                                    //                                while (ftpMessagesMode.hasNext()) {
0347:                                    //                                    msgModeCntOutput++;
0348:                                    //                                    FTPMessageActivePassive ftpMessageMode = ftpMessagesMode.next();
0349:                                    //                                    ftpMessageMode.accept(this);
0350:                                    //                                    outputChild = ftpMessageMode;
0351:                                    //                                }
0352:                                    //                                if ( msgModeCntOutput > 1 ) {
0353:                                    //                                    results.add(
0354:                                    //                                            new Validator.ResultItem(this,
0355:                                    //                                            Validator.ResultType.ERROR,
0356:                                    //                                            binding,
0357:                                    //                                            Util.getMessage("FTPBindingValidation.ATMOST_ONE_TRANSFER_IN_OUTPUT", new Object[] {msgModeCntOutput})));
0358:                                    //                                }
0359:                                    //                            }
0360:
0361:                                    if (transCntOutput + msgCntOutput /*+ msgModeCntOutput*/> 1) {
0362:                                        results
0363:                                                .add(new Validator.ResultItem(
0364:                                                        this ,
0365:                                                        Validator.ResultType.ERROR,
0366:                                                        binding,
0367:                                                        Util
0368:                                                                .getMessage(
0369:                                                                        "FTPBindingValidation.ATMOST_ONE_TRANSFER_IN_OUTPUT",
0370:                                                                        new Object[] { transCntOutput
0371:                                                                                + msgCntOutput /*+ msgModeCntOutput*/})));
0372:                                    }
0373:
0374:                                    if (transCntOutput + msgCntOutput /*+ msgModeCntOutput*/== 0) {
0375:                                        results
0376:                                                .add(new Validator.ResultItem(
0377:                                                        this ,
0378:                                                        Validator.ResultType.ERROR,
0379:                                                        binding,
0380:                                                        Util
0381:                                                                .getMessage("FTPBindingValidation.NO_EXTENSIBILITY_ELEMENT_FOUND_IN_OUTPUT")));
0382:                                    }
0383:                                }
0384:
0385:                                //Reference<Operation> opRef = bindingOp.getOperation();
0386:                                //boolean noAbstractOp = false;
0387:                                //if ( opRef == null ) {
0388:                                //    noAbstractOp = true;
0389:                                //    results.add(
0390:                                //            new Validator.ResultItem(this,
0391:                                //            Validator.ResultType.ERROR,
0392:                                //            binding,
0393:                                //            Util.getMessage("FTPBindingValidation.OP_ABSTRACT_NOT_FOUND", new Object[] {bindingOp.getName()})));
0394:                                //}
0395:                                //else {
0396:                                //    Operation op = opRef.get();
0397:                                //    if ( op == null ) {
0398:                                //        noAbstractOp = true;
0399:                                //        results.add(
0400:                                //                new Validator.ResultItem(this,
0401:                                //                Validator.ResultType.ERROR,
0402:                                //                binding,
0403:                                //                Util.getMessage("FTPBindingValidation.OP_ABSTRACT_NOT_FOUND", new Object[] {bindingOp.getName()})));
0404:                                //    }
0405:                                //}
0406:
0407:                                // taken care of by generic wsdl model validation
0408:                                //if ( !noAbstractOp ) {
0409:                                //    if ( !checkSignature(bindingOp/*, inputChild, outputChild*/) ) {
0410:                                //        results.add(
0411:                                //                new Validator.ResultItem(this,
0412:                                //                Validator.ResultType.ERROR,
0413:                                //                binding,
0414:                                //                Util.getMessage("FTPBindingValidation.OP_SIG_MISMATCH_BINDING_ABSTRACT", new Object[] {bindingOp.getName()})));
0415:                                //    }
0416:                                //}
0417:
0418:                                // inputChild and outputChild should be same type
0419:                                // if input & output both present, they should have same type 
0420:                                // of FTP BC ext elements as child
0421:                                if (inputChild != null && outputChild != null) {
0422:                                    if (inputChild.getClass().isAssignableFrom(
0423:                                            outputChild.getClass())
0424:                                            && outputChild
0425:                                                    .getClass()
0426:                                                    .isAssignableFrom(
0427:                                                            inputChild
0428:                                                                    .getClass())) {
0429:                                        // fine
0430:                                    } else {
0431:                                        // otherwise
0432:                                        results
0433:                                                .add(new Validator.ResultItem(
0434:                                                        this ,
0435:                                                        Validator.ResultType.ERROR,
0436:                                                        binding,
0437:                                                        Util
0438:                                                                .getMessage(
0439:                                                                        "FTPBindingValidation.INPUT_OUTPUT_REQUIRE_SAME_TYPE_FTPBC_EXT",
0440:                                                                        new Object[] {
0441:                                                                                ((FTPComponent) inputChild)
0442:                                                                                        .getQName()
0443:                                                                                        .toString(),
0444:                                                                                ((FTPComponent) outputChild)
0445:                                                                                        .getQName()
0446:                                                                                        .toString() })));
0447:                                    }
0448:
0449:                                }
0450:                            } else if (ftpOpsList.size() > 1) {
0451:                                // at most one
0452:                                foundFTPOp = true;
0453:                                results
0454:                                        .add(new Validator.ResultItem(
0455:                                                this ,
0456:                                                Validator.ResultType.ERROR,
0457:                                                binding,
0458:                                                Util
0459:                                                        .getMessage("FTPBindingValidation.AT_MOST_ONE_FTP_OPERATION")));
0460:                            }
0461:                        }
0462:                        // there is ftp:binding but no ftp:operation
0463:                        if (numFTPBindings > 0 && !foundFTPOp) {
0464:                            results
0465:                                    .add(new Validator.ResultItem(
0466:                                            this ,
0467:                                            Validator.ResultType.ERROR,
0468:                                            binding,
0469:                                            Util
0470:                                                    .getMessage("FTPBindingValidation.MISSING_FTP_OPERATION")));
0471:                        }
0472:                        // there is no ftp:binding but there are ftp:operation
0473:                        if (numFTPBindings == 0 && foundFTPOp) {
0474:                            results
0475:                                    .add(new Validator.ResultItem(
0476:                                            this ,
0477:                                            Validator.ResultType.ERROR,
0478:                                            binding,
0479:                                            Util
0480:                                                    .getMessage("FTPBindingValidation.FTP_OPERATION_WO_FTP_BINDING")));
0481:                        }
0482:                    }
0483:
0484:                    Iterator<Service> services = defs.getServices().iterator();
0485:                    while (services.hasNext()) {
0486:                        Iterator<Port> ports = services.next().getPorts()
0487:                                .iterator();
0488:                        while (ports.hasNext()) {
0489:                            Port port = ports.next();
0490:                            if (port.getBinding() != null) {
0491:                                Binding binding = port.getBinding().get();
0492:                                if (binding != null) {
0493:                                    int numRelatedFTPBindings = binding
0494:                                            .getExtensibilityElements(
0495:                                                    FTPBinding.class).size();
0496:                                    Iterator<FTPAddress> ftpAddresses = port
0497:                                            .getExtensibilityElements(
0498:                                                    FTPAddress.class)
0499:                                            .iterator();
0500:                                    if ((numRelatedFTPBindings > 0)
0501:                                            && (!ftpAddresses.hasNext())) {
0502:                                        results
0503:                                                .add(new Validator.ResultItem(
0504:                                                        this ,
0505:                                                        Validator.ResultType.ERROR,
0506:                                                        port,
0507:                                                        Util
0508:                                                                .getMessage("FTPExtValidation.MISSING_FTP_ADDRESS")));
0509:                                    }
0510:
0511:                                    if (port.getExtensibilityElements(
0512:                                            FTPAddress.class).size() > 1) {
0513:                                        results
0514:                                                .add(new Validator.ResultItem(
0515:                                                        this ,
0516:                                                        Validator.ResultType.ERROR,
0517:                                                        port,
0518:                                                        Util
0519:                                                                .getMessage("FTPExtValidation.ONLY_ONE_FTPADDRESS_ALLOWED")));
0520:                                    }
0521:                                    while (ftpAddresses.hasNext()) {
0522:                                        ftpAddresses.next().accept(this );
0523:                                    }
0524:                                }
0525:                            }
0526:                        }
0527:                    }
0528:                }
0529:                // Clear out our state
0530:                mValidation = null;
0531:                mValidationType = null;
0532:
0533:                return mValidationResult;
0534:            }
0535:
0536:            private boolean checkSignature(BindingOperation bindingOp/*, Object inputChild, Object outputChild*/) {
0537:                boolean result = true;
0538:                Reference<Operation> opRef = bindingOp.getOperation();
0539:                if (opRef == null)
0540:                    return false;
0541:                Operation op = opRef.get();
0542:                if (op == null)
0543:                    return false;
0544:                if ((op.getInput() == null && bindingOp.getBindingInput() == null /*&& inputChild == null*/)
0545:                        || (op.getInput() != null && bindingOp
0546:                                .getBindingInput() != null /*&& inputChild != null*/)) {
0547:
0548:                } else {
0549:                    result = false;
0550:                }
0551:
0552:                if ((op.getOutput() == null && bindingOp.getBindingOutput() == null /*&& outputChild == null*/)
0553:                        || (op.getOutput() != null && bindingOp
0554:                                .getBindingOutput() != null /*&& outputChild != null*/)) {
0555:
0556:                } else {
0557:                    result = false;
0558:                }
0559:                return result;
0560:            }
0561:
0562:            public void visit(FTPAddress target) {
0563:                // validate the following:
0564:                // (1) attribute 'url' has the right syntax: i.e. ftp://[ftp_user]:[ftp_password]@[ftp_host]:[ftp_port]
0565:                // (2) if attribute 'useProxy' is true, also validate attribute 'proxy'
0566:                // has the right syntax: [proxy protocol]://[proxy_user]:[proxy_password]@[proxy_host]:[proxy_port]
0567:                Collection<ResultItem> results = mValidationResult
0568:                        .getValidationResult();
0569:                FTPAddressURL url = new FTPAddressURL(target.getFTPURL());
0570:
0571:                url.parse(results, this , target);
0572:
0573:                if (target.getUseUserDefinedHeuristics()) {
0574:                    String udn = target.getUserDefDirListStyle();
0575:                    String udloc = target.getUserDefDirListHeuristics();
0576:                    if (udn == null || udn.trim().length() == 0) {
0577:                        results
0578:                                .add(new Validator.ResultItem(
0579:                                        this ,
0580:                                        Validator.ResultType.ERROR,
0581:                                        target,
0582:                                        Util
0583:                                                .getMessage("FTPAddress.MISSING_UD_DIRLSTSTYLE_NAME")));
0584:                    }
0585:                    if (udloc == null || udloc.trim().length() == 0) {
0586:                        results
0587:                                .add(new Validator.ResultItem(
0588:                                        this ,
0589:                                        Validator.ResultType.ERROR,
0590:                                        target,
0591:                                        Util
0592:                                                .getMessage("FTPAddress.MISSING_UD_HEURISTICS_CFG_LOC")));
0593:                    }
0594:                }
0595:
0596:                validateFTPChannelTimeout(target.getCmdChannelTimeout(),
0597:                        results, target);
0598:                validateFTPChannelTimeout(target.getDataChannelTimeout(),
0599:                        results, target);
0600:            }
0601:
0602:            public void visit(FTPBinding target) {
0603:                // for ftp binding tag - nothing to validate at this point
0604:            }
0605:
0606:            public void visit(FTPOperation target) {
0607:                // for ftp operation tag - nothing to validate at this point
0608:            }
0609:
0610:            public void visit(FTPTransfer target) {
0611:                // check the values and relations of/between all the attributes
0612:                Collection<ResultItem> results = mValidationResult
0613:                        .getValidationResult();
0614:
0615:                if (!doStructuralChecking(results, target))
0616:                    return;
0617:
0618:                String sendTo = null;
0619:                String receiveFrom = null;
0620:
0621:                // sendTo and receiveFrom can not be both NULL or blank
0622:                // if sendTo is specified, then further validate its pre/post
0623:                // if receiveFrom is specified, then further validate its pre/post
0624:
0625:                sendTo = target.getSendTo();
0626:                receiveFrom = target.getReceiveFrom();
0627:
0628:                if ((sendTo == null || sendTo.trim().length() == 0)
0629:                        && (receiveFrom == null || receiveFrom.trim().length() == 0)) {
0630:                    results
0631:                            .add(new Validator.ResultItem(
0632:                                    this ,
0633:                                    Validator.ResultType.ERROR,
0634:                                    target,
0635:                                    Util
0636:                                            .getMessage("FTPTransfer.BOTH_SENDTO_AND_RECEIVEFROM_ARE_NOT_SPECIFIED")));
0637:                }
0638:
0639:                if (sendTo != null && sendTo.trim().length() > 0) {
0640:                    if (!Util.hasMigrationEnvVar(sendTo)) {
0641:                        if (sendTo.endsWith("/")) {
0642:                            results
0643:                                    .add(new Validator.ResultItem(
0644:                                            this ,
0645:                                            Validator.ResultType.ERROR,
0646:                                            target,
0647:                                            Util
0648:                                                    .getMessage(
0649:                                                            "FTPTransfer.A_PATH_POINTING_TO_FILE_REQUIRED",
0650:                                                            new Object[] {
0651:                                                                    "sendTo",
0652:                                                                    sendTo })));
0653:                        }
0654:                    }
0655:                    // validate sendTo related stuff
0656:                    if (target.getPreSendCommand() != null
0657:                            && (target.getPreSendCommand().equals("RENAME") || target
0658:                                    .getPreSendCommand().equals("COPY"))) {
0659:                        if (target.getPreSendLocation() == null
0660:                                || target.getPreSendLocation().trim().length() == 0) {
0661:                            results
0662:                                    .add(new Validator.ResultItem(
0663:                                            this ,
0664:                                            Validator.ResultType.ERROR,
0665:                                            target,
0666:                                            Util
0667:                                                    .getMessage("FTPTransfer.PRE_POST_OPERATION_WO_LOCATION")));
0668:                        }
0669:                        if (!Util.hasMigrationEnvVar(target
0670:                                .getPreSendLocation())) {
0671:                            if (target.getPreSendLocation() != null
0672:                                    && target.getPreSendLocation()
0673:                                            .endsWith("/")) {
0674:                                results
0675:                                        .add(new Validator.ResultItem(
0676:                                                this ,
0677:                                                Validator.ResultType.ERROR,
0678:                                                target,
0679:                                                Util
0680:                                                        .getMessage(
0681:                                                                "FTPTransfer.A_PATH_POINTING_TO_FILE_REQUIRED",
0682:                                                                new Object[] {
0683:                                                                        "preSendLocation",
0684:                                                                        target
0685:                                                                                .getPreSendLocation() })));
0686:                            }
0687:                        }
0688:                    }
0689:
0690:                    if (target.getPostSendCommand() != null
0691:                            && (target.getPostSendCommand().equals("RENAME") || target
0692:                                    .getPostSendCommand().equals("COPY"))) {
0693:                        if (target.getPostSendLocation() == null
0694:                                || target.getPostSendLocation().trim().length() == 0) {
0695:                            results
0696:                                    .add(new Validator.ResultItem(
0697:                                            this ,
0698:                                            Validator.ResultType.ERROR,
0699:                                            target,
0700:                                            Util
0701:                                                    .getMessage("FTPTransfer.PRE_POST_OPERATION_WO_LOCATION")));
0702:                        }
0703:                        if (!Util.hasMigrationEnvVar(target
0704:                                .getPostSendLocation())) {
0705:                            if (target.getPostSendLocation() != null
0706:                                    && target.getPostSendLocation().endsWith(
0707:                                            "/")) {
0708:                                results
0709:                                        .add(new Validator.ResultItem(
0710:                                                this ,
0711:                                                Validator.ResultType.ERROR,
0712:                                                target,
0713:                                                Util
0714:                                                        .getMessage(
0715:                                                                "FTPTransfer.A_PATH_POINTING_TO_FILE_REQUIRED",
0716:                                                                new Object[] {
0717:                                                                        "postSendLocation",
0718:                                                                        target
0719:                                                                                .getPostSendLocation() })));
0720:                            }
0721:                        }
0722:                    }
0723:                }
0724:
0725:                if (receiveFrom != null && receiveFrom.trim().length() > 0) {
0726:                    if (!Util.hasMigrationEnvVar(receiveFrom)) {
0727:                        if (receiveFrom.endsWith("/")) {
0728:                            results
0729:                                    .add(new Validator.ResultItem(
0730:                                            this ,
0731:                                            Validator.ResultType.ERROR,
0732:                                            target,
0733:                                            Util
0734:                                                    .getMessage(
0735:                                                            "FTPTransfer.A_PATH_POINTING_TO_FILE_REQUIRED",
0736:                                                            new Object[] {
0737:                                                                    "receiveFrom",
0738:                                                                    receiveFrom })));
0739:                        }
0740:                    }
0741:                    // validate receiveFrom related stuff
0742:                    if (target.getPreReceiveCommand() != null
0743:                            && (target.getPreReceiveCommand().equals("RENAME") || target
0744:                                    .getPreReceiveCommand().equals("COPY"))) {
0745:                        if (target.getPreReceiveLocation() == null
0746:                                || target.getPreReceiveLocation().trim()
0747:                                        .length() == 0) {
0748:                            results
0749:                                    .add(new Validator.ResultItem(
0750:                                            this ,
0751:                                            Validator.ResultType.ERROR,
0752:                                            target,
0753:                                            Util
0754:                                                    .getMessage("FTPTransfer.PRE_POST_OPERATION_WO_LOCATION")));
0755:                        }
0756:                        if (!Util.hasMigrationEnvVar(target
0757:                                .getPreReceiveLocation())) {
0758:                            if (target.getPreReceiveLocation() != null
0759:                                    && target.getPreReceiveLocation().endsWith(
0760:                                            "/")) {
0761:                                results
0762:                                        .add(new Validator.ResultItem(
0763:                                                this ,
0764:                                                Validator.ResultType.ERROR,
0765:                                                target,
0766:                                                Util
0767:                                                        .getMessage(
0768:                                                                "FTPTransfer.A_PATH_POINTING_TO_FILE_REQUIRED",
0769:                                                                new Object[] {
0770:                                                                        "preReceiveLocation",
0771:                                                                        target
0772:                                                                                .getPreReceiveLocation() })));
0773:                            }
0774:                        }
0775:                    }
0776:                    if (target.getPostReceiveCommand() != null
0777:                            && (target.getPostReceiveCommand().equals("RENAME") || target
0778:                                    .getPostReceiveCommand().equals("COPY"))) {
0779:                        if (target.getPostReceiveLocation() == null
0780:                                || target.getPostReceiveLocation().trim()
0781:                                        .length() == 0) {
0782:                            results
0783:                                    .add(new Validator.ResultItem(
0784:                                            this ,
0785:                                            Validator.ResultType.ERROR,
0786:                                            target,
0787:                                            Util
0788:                                                    .getMessage("FTPTransfer.PRE_POST_OPERATION_WO_LOCATION")));
0789:                        }
0790:                        if (!Util.hasMigrationEnvVar(target
0791:                                .getPostReceiveLocation())) {
0792:                            if (target.getPostReceiveLocation() != null
0793:                                    && target.getPostReceiveLocation()
0794:                                            .endsWith("/")) {
0795:                                results
0796:                                        .add(new Validator.ResultItem(
0797:                                                this ,
0798:                                                Validator.ResultType.ERROR,
0799:                                                target,
0800:                                                Util
0801:                                                        .getMessage(
0802:                                                                "FTPTransfer.A_PATH_POINTING_TO_FILE_REQUIRED",
0803:                                                                new Object[] {
0804:                                                                        "postReceiveLocation",
0805:                                                                        target
0806:                                                                                .getPostReceiveLocation() })));
0807:                            }
0808:                        }
0809:                    }
0810:                }
0811:
0812:                // validate use: if use="encoded", encodingStyle must be specified
0813:                if (!Util.hasMigrationEnvVar(target.getUse())) {
0814:                    if (target.getUse() != null
0815:                            && target.getUse().equals("encoded")) {
0816:                        if (target.getEncodingStyle() == null
0817:                                || target.getEncodingStyle().trim().length() == 0) {
0818:                            results
0819:                                    .add(new Validator.ResultItem(
0820:                                            this ,
0821:                                            Validator.ResultType.ERROR,
0822:                                            target,
0823:                                            Util
0824:                                                    .getMessage("FTPTransfer.MISSING_STYLE_WHEN_USE_ENCODED")));
0825:                        }
0826:                    }
0827:                }
0828:
0829:                // check polling interval
0830:                validatePollInterval(target.getPollInterval(), results, target);
0831:            }
0832:
0833:            public void visit(FTPMessage target) {
0834:                String t = null;
0835:                Collection<ResultItem> results = mValidationResult
0836:                        .getValidationResult();
0837:                if (!doStructuralChecking(results, target))
0838:                    return;
0839:                // validate that a messageRepository is specified
0840:                if (target.getMessageRepository() == null
0841:                        || target.getMessageRepository().trim().length() == 0) {
0842:                    results
0843:                            .add(new Validator.ResultItem(
0844:                                    this ,
0845:                                    Validator.ResultType.ERROR,
0846:                                    target,
0847:                                    Util
0848:                                            .getMessage(
0849:                                                    "FTPMessage.A_PATH_POINTING_TO_MESSAGE_EXCHANGE_AREA_REQUIRED",
0850:                                                    "")));
0851:                }
0852:                // validate use: if use="encoded", encodingStyle must be specified
0853:                if (!Util.hasMigrationEnvVar(target.getUse())) {
0854:                    if (target.getUse() != null
0855:                            && target.getUse().equals("encoded")) {
0856:                        if (target.getEncodingStyle() == null
0857:                                || target.getEncodingStyle().trim().length() == 0) {
0858:                            results
0859:                                    .add(new Validator.ResultItem(
0860:                                            this ,
0861:                                            Validator.ResultType.ERROR,
0862:                                            target,
0863:                                            Util
0864:                                                    .getMessage("FTPMessage.MISSING_STYLE_WHEN_USE_ENCODED")));
0865:                        }
0866:                    }
0867:                }
0868:                // if messageName specified, and does not contain pattern chars (% escaped symbols)
0869:                // give warning (message name usually contains patterns, especially %u)
0870:                t = target.getMessageName();
0871:                if (t != null && t.trim().length() > 0) {
0872:                    if (!Util.hasMigrationEnvVar(t)) {
0873:                        if (t.indexOf("%") < 0) {
0874:                            results
0875:                                    .add(new Validator.ResultItem(
0876:                                            this ,
0877:                                            Validator.ResultType.WARNING,
0878:                                            target,
0879:                                            Util
0880:                                                    .getMessage("FTPMessage.MSG_NAME_SPEC_DOES_NOT_INCLUDE_PATTERN")));
0881:                        }
0882:                    }
0883:                }
0884:
0885:                // if messageNamePrefixIB or messageNamePrefixOB specified, and contains pattern chars (% escaped symbols)
0886:                // give warning (prefix must be a literal string)
0887:                t = target.getMessageNamePrefixIB();
0888:                if (t != null && t.trim().length() > 0) {
0889:                    if (t.indexOf("%") >= 0) {
0890:                        // this is not an accurate check, but just do not allow % in the prefix,
0891:                        // period!
0892:                        results
0893:                                .add(new Validator.ResultItem(
0894:                                        this ,
0895:                                        Validator.ResultType.ERROR,
0896:                                        target,
0897:                                        Util
0898:                                                .getMessage("FTPMessage.IB_MSG_PREFIX_HAS_PATTERN")));
0899:                    }
0900:                }
0901:                t = target.getMessageNamePrefixOB();
0902:                if (t != null && t.trim().length() > 0) {
0903:                    if (t.indexOf("%") >= 0) {
0904:                        // this is not an accurate check, but just do not allow % in the prefix,
0905:                        // period!
0906:                        results
0907:                                .add(new Validator.ResultItem(
0908:                                        this ,
0909:                                        Validator.ResultType.ERROR,
0910:                                        target,
0911:                                        Util
0912:                                                .getMessage("FTPMessage.OB_MSG_PREFIX_HAS_PATTERN")));
0913:                    }
0914:                }
0915:
0916:                // check polling interval
0917:                validatePollInterval(target.getPollInterval(), results, target);
0918:            }
0919:
0920:            /**
0921:            public void visit(FTPMessageActivePassive target) {
0922:                String t = null;
0923:                Collection<ResultItem> results =
0924:                        mValidationResult.getValidationResult();
0925:                if ( !doStructuralChecking(results, target) )
0926:                    return;
0927:                // validate that a messageRepository is specified
0928:                if ( target.getMessageRepository() == null
0929:                        || target.getMessageRepository().trim().length() == 0 ) {
0930:                    results.add(new Validator.ResultItem(this,
0931:                            Validator.ResultType.ERROR,
0932:                            target,
0933:                            Util.getMessage("FTPMessage.A_PATH_POINTING_TO_MESSAGE_EXCHANGE_AREA_REQUIRED", "")));
0934:                }
0935:                // validate use: if use="encoded", encodingStyle must be specified
0936:                if ( !Util.hasMigrationEnvVar(target.getUse()) ) {
0937:                    if ( target.getUse() != null && target.getUse().equals("encoded") ) {
0938:                            if ( target.getEncodingStyle() == null || target.getEncodingStyle().trim().length() == 0 ) {
0939:                            results.add(new Validator.ResultItem(this,
0940:                                    Validator.ResultType.ERROR,
0941:                                    target,
0942:                                    Util.getMessage("FTPMessage.MISSING_STYLE_WHEN_USE_ENCODED")));
0943:                            }
0944:                    }
0945:                }
0946:                // if messageName specified, and does not contain pattern chars (% escaped symbols)
0947:                // give warning (message name usually contains patterns, especially %u)
0948:                t = target.getMessageName();
0949:                if ( t != null && t.trim().length() > 0 ) {
0950:                    if ( !Util.hasMigrationEnvVar(t) ) {
0951:                        if ( t.indexOf("%") < 0 ) {
0952:                            results.add(new Validator.ResultItem(this,
0953:                                    Validator.ResultType.WARNING,
0954:                                    target,
0955:                                    Util.getMessage("FTPMessage.MSG_NAME_SPEC_DOES_NOT_INCLUDE_PATTERN")));
0956:                        }
0957:                    }
0958:                }
0959:                
0960:                // if messageNamePrefixIB or messageNamePrefixOB specified, and contains pattern chars (% escaped symbols)
0961:                // give warning (prefix must be a literal string)
0962:                t = target.getMessageNamePrefixIB();
0963:                if ( t != null && t.trim().length() > 0 ) {
0964:                    if ( t.indexOf("%") >= 0 ) {
0965:                        // this is not an accurate check, but just do not allow % in the prefix,
0966:                        // period!
0967:                        results.add(new Validator.ResultItem(this,
0968:                                Validator.ResultType.ERROR,
0969:                                target,
0970:                                Util.getMessage("FTPMessage.IB_MSG_PREFIX_HAS_PATTERN")));
0971:                    }
0972:                }
0973:                t = target.getMessageNamePrefixOB();
0974:                if ( t != null && t.trim().length() > 0 ) {
0975:                    if ( t.indexOf("%") >= 0 ) { 
0976:                        // this is not an accurate check, but just do not allow % in the prefix,
0977:                        // period!
0978:                        results.add(new Validator.ResultItem(this,
0979:                                Validator.ResultType.ERROR,
0980:                                target,
0981:                                Util.getMessage("FTPMessage.OB_MSG_PREFIX_HAS_PATTERN")));
0982:                    }
0983:                }
0984:
0985:                // check polling interval
0986:                validatePollInterval(target.getPollInterval(), results, target);
0987:            }
0988:             */
0989:
0990:            private boolean checkPartReference(BindingOperation bop,
0991:                    boolean isInputChild, String part) {
0992:                boolean result = false;
0993:                if (bop != null) {
0994:                    Reference<Operation> opRef = bop.getOperation();
0995:                    if (opRef != null) {
0996:                        Operation op = opRef.get();
0997:                        if (op != null) {
0998:                            if (isInputChild) {
0999:                                if (op.getInput() != null) {
1000:                                    result = hasPart(
1001:                                            op.getInput().getMessage(), part);
1002:                                }
1003:                            } else {
1004:                                if (op.getOutput() != null) {
1005:                                    result = hasPart(op.getOutput()
1006:                                            .getMessage(), part);
1007:                                }
1008:                            }
1009:                        }
1010:                    }
1011:                }
1012:                return result;
1013:            }
1014:
1015:            private boolean hasPart(NamedComponentReference<Message> msgRef,
1016:                    String part) {
1017:                boolean result = false;
1018:                if (msgRef != null) {
1019:                    Message msg = msgRef.get();
1020:                    if (msg != null) {
1021:                        Part pt = null;
1022:                        Collection<Part> pts = msg.getParts();
1023:                        Iterator it = pts.iterator();
1024:                        while (it.hasNext()) {
1025:                            pt = (Part) it.next();
1026:                            if (pt.getName().equals(part)) {
1027:                                result = true;
1028:                                break;
1029:                            }
1030:                        }
1031:                    }
1032:                }
1033:                return result;
1034:            }
1035:
1036:            private boolean doStructuralChecking(
1037:                    Collection<ResultItem> results, FTPComponentEncodable target) {
1038:                Object parent = target.getParent();
1039:                WSDLComponent wsdlComp = null;
1040:                BindingOperation bop = null;
1041:                if (parent == null) {
1042:                    results
1043:                            .add(new Validator.ResultItem(
1044:                                    this ,
1045:                                    Validator.ResultType.ERROR,
1046:                                    target,
1047:                                    Util
1048:                                            .getMessage("FTPTransfer.CAN_NOT_LOCATE_PARENT_WSDL_COMP_FOR_TRANSFER")));
1049:                    return false;
1050:                }
1051:
1052:                boolean asInputChild = true;
1053:
1054:                if (parent instanceof  BindingInput) {
1055:                    // <input>
1056:                    wsdlComp = ((BindingInput) parent).getParent();
1057:                } else {
1058:                    // <output>
1059:                    asInputChild = false;
1060:                    wsdlComp = ((BindingOutput) parent).getParent();
1061:                }
1062:
1063:                if (wsdlComp == null) {
1064:                    results
1065:                            .add(new Validator.ResultItem(
1066:                                    this ,
1067:                                    Validator.ResultType.ERROR,
1068:                                    target,
1069:                                    Util
1070:                                            .getMessage("FTPTransfer.CAN_NOT_LOCATE_OPERATION_BINDING")));
1071:                    return false;
1072:                }
1073:
1074:                if (wsdlComp instanceof  BindingOperation) {
1075:                    // if part is specified, need to resolve it here
1076:                    String t = target.getPart();
1077:                    if (t != null && t.trim().length() > 0) {
1078:                        bop = (BindingOperation) wsdlComp;
1079:                        if (!checkPartReference(bop, asInputChild, t)) {
1080:                            results
1081:                                    .add(new Validator.ResultItem(
1082:                                            this ,
1083:                                            Validator.ResultType.ERROR,
1084:                                            target,
1085:                                            Util
1086:                                                    .getMessage("FTPExt.PART_REFERENCE_INVALID")));
1087:                            return false;
1088:                        }
1089:                    }
1090:
1091:                    if (((BindingOperation) wsdlComp).getBindingInput() != null
1092:                            && ((BindingOperation) wsdlComp).getBindingOutput() != null) {
1093:                        // in-out
1094:                    } else if (((BindingOperation) wsdlComp).getBindingInput() != null
1095:                            || ((BindingOperation) wsdlComp).getBindingOutput() != null) {
1096:                        // one-way
1097:                    } else {
1098:                        // no way
1099:                        results
1100:                                .add(new Validator.ResultItem(
1101:                                        this ,
1102:                                        Validator.ResultType.ERROR,
1103:                                        target,
1104:                                        Util
1105:                                                .getMessage("FTPTransfer.OPERATION_BINDING_COMP_DOES_NOT_HAVE_INPUT_NOR_OUTPUT")));
1106:                        return false;
1107:                    }
1108:                } else {
1109:                    results
1110:                            .add(new Validator.ResultItem(
1111:                                    this ,
1112:                                    Validator.ResultType.ERROR,
1113:                                    target,
1114:                                    Util
1115:                                            .getMessage("FTPTransfer.INVALID_PARENT_FOR_INPUT_OUTPUT_WSDL_COMP")));
1116:                    return false;
1117:                }
1118:                return true;
1119:            }
1120:
1121:            private void validateFTPChannelTimeout(String t,
1122:                    Collection<ResultItem> results, FTPAddress target) {
1123:                if (t != null && t.trim().length() > 0) {
1124:                    int timeout = getInt(t);
1125:                    if (timeout < 0) {
1126:                        results.add(new Validator.ResultItem(this ,
1127:                                Validator.ResultType.ERROR, target,
1128:                                Util.getMessage(
1129:                                        "FTPAddress.INVALID_FTP_CH_TIMEOUT",
1130:                                        new Object[] { t })));
1131:                    }
1132:                }
1133:            }
1134:
1135:            /**
1136:             * it can be left blank - runtime will take a default 5000 millis
1137:             */
1138:            private void validatePollInterval(String t,
1139:                    Collection<ResultItem> results, FTPComponentEncodable target) {
1140:                if (t != null && t.trim().length() > 0) {
1141:                    if (!Util.hasMigrationEnvVar(t)) { // skip validation if is a env var
1142:                        int interval = getInt(t);
1143:                        if (interval <= 0)
1144:                            results.add(new Validator.ResultItem(this ,
1145:                                    Validator.ResultType.ERROR, target,
1146:                                    Util.getMessage(
1147:                                            "FTPExt.INVALID_POLL_INTERVAL",
1148:                                            new Object[] { t })));
1149:                    }
1150:                }
1151:            }
1152:
1153:            private int getInt(String t) {
1154:                int val = -1;
1155:                if (t != null && t.trim().length() > 0) {
1156:                    try {
1157:                        val = Integer.parseInt(t);
1158:                    } catch (Exception e) {
1159:                    }
1160:                }
1161:                return val;
1162:            }
1163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.