FileDocCategorySizeDatePackage
MappingFileCheck.javaAPI DocGlassfish v2 API5709Fri May 04 22:34:16 BST 2007com.sun.enterprise.tools.verifier.tests.webservices

MappingFileCheck

public class MappingFileCheck extends WSTest implements WSCheck

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(WebServiceEndpoint descriptor)

param
descriptor the WebServices descriptor
return
Result the results for this assertion


        Result result = getInitializedResult();
        ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
        String mappingFile = descriptor.getWebService().getMappingFileUri();
        if (getVerifierContext().getSchemaVersion().compareTo("1.1") > 0) {
            if (mappingFile != null) {
                addWarningDetails(result, compName);
                result.warning(smh.getLocalString (getClass().getName() + ".warning",
                        "The mapping file as specified in location [ {0} ] is not required.",
                        new Object[] {mappingFile}));
                return result;
            }
        } else {
            InputStream deploymentEntry=null;
            try {
                String uri = getAbstractArchiveUri(descriptor);
                try {
                    FileArchive arch = new FileArchive();
                    arch.open(uri);
                    deploymentEntry = arch.getEntry(mappingFile);
                }catch (IOException e) { throw e;}
                if (deploymentEntry == null) {
                    //result.fail, mapping file does not exist at that location
                    result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                            "For [ {0} ]", new Object[] {compName.toString()}));
                    result.failed(smh.getLocalString (getClass().getName() + ".failed",
                            "The mapping file does not exist at the specified location [{0}] in the archive.",
                            new Object[] {mappingFile}));

                }
            }catch (Exception e) {
                result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                        "For [ {0} ]", new Object[] {compName.toString()}));
                result.failed(smh.getLocalString (getClass().getName() + ".failed",
                        "The mapping file does not exist at the specified location [{0}] in the archive.",
                        new Object[] {mappingFile}));
            }
            finally {
                try {
                    if (deploymentEntry != null)
                        deploymentEntry.close();
                }catch(IOException e) {}
            }
        }
        if(result.getStatus() != Result.FAILED || result.getStatus() != Result.WARNING) {
            addGoodDetails(result, compName);
            result.passed(smh.getLocalString (getClass().getName() + ".passed",
                    "mapping file requirements are satisfied"));
        }
        return result;