FileDocCategorySizeDatePackage
OptPkgDependencySatisfied.javaAPI DocGlassfish v2 API4578Fri May 04 22:33:28 BST 2007com.sun.enterprise.tools.verifier.tests.app

OptPkgDependencySatisfied

public class OptPkgDependencySatisfied extends ApplicationTest implements AppCheck
author
ss141213 This checks to see that all the installed optional packages that this ear depends on are indeed available in the system or not.

Fields Summary
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(com.sun.enterprise.deployment.Application descriptor)

        Result result = getInitializedResult();
        try{
            String earURI=getAbstractArchiveUri(descriptor);
            com.sun.enterprise.tools.verifier.apiscan.packaging.Archive jar=new com.sun.enterprise.tools.verifier.apiscan.packaging.Archive(new File(earURI));
            //See we do not care about bundled opt packages, as for an ear file
            //there should not be any Class-Path entry.
            com.sun.enterprise.tools.verifier.apiscan.packaging.ExtensionRef[] extRefs=jar.getExtensionRefs();
            com.sun.enterprise.tools.verifier.apiscan.packaging.Archive[] allOptPkgs=com.sun.enterprise.tools.verifier.apiscan.packaging.Archive.getAllOptPkgsInstalledInJRE();
            ArrayList<ExtensionRef> notFounds=new ArrayList<ExtensionRef>();
            for(int i=0;i<extRefs.length;++i){
                ExtensionRef ref=extRefs[i];
                boolean found=false;
                for(int j=0;j<allOptPkgs.length;++j){
                    if(ref.isSatisfiedBy(allOptPkgs[j])) {
                        found=true;
                        break;
                    }
                }
                if(!found) notFounds.add(ref);
            }//for

            if(notFounds.isEmpty()){
                result.passed(smh.getLocalString(getClass().getName() + ".passed",
                                             "All opt package dependency satisfied for this ear file."));
                result.passed("");
            }else{
                result.failed(smh.getLocalString(getClass().getName() + ".failed","Some dependencies could not be satisfied for this ear file. See info below..."));
                for(Iterator i=notFounds.iterator();i.hasNext();){
                    result.addErrorDetails(i.next().toString());
                }
            }
        }catch(IOException e){
            result.failed(e.toString());
        }
        return result;