Search in sources :

Example 46 with FileArchive

use of com.sun.enterprise.deploy.shared.FileArchive in project Payara by payara.

the class WebServicesDeployer method populateWsdlFilesForPublish.

/**
 * Populate the wsdl files entries to download (if any) (Only for webservices which
 * use file publishing).
 *
 * TODO File publishing currently works only for wsdls packaged in the application for jax-ws.
 * Need to publish the dynamically generated wsdls as well. Lazy creation of WSEndpoint objects prohibits it now.
 */
private Set<String> populateWsdlFilesForPublish(DeploymentContext dc, Set<WebService> webservices) throws IOException {
    Set<String> publishedFiles = new HashSet<String>();
    for (WebService webService : webservices) {
        if (!webService.hasFilePublishing()) {
            continue;
        }
        copyExtraFilesToGeneratedFolder(dc);
        BundleDescriptor bundle = webService.getBundleDescriptor();
        ArchiveType moduleType = bundle.getModuleType();
        // only EAR, WAR and EJB archives could contain wsdl files for publish
        if (moduleType == null || !(moduleType.equals(DOLUtils.earType()) || moduleType.equals(DOLUtils.warType()) || moduleType.equals(DOLUtils.ejbType()))) {
            return publishedFiles;
        }
        File sourceDir = dc.getScratchDir("xml");
        File parent;
        try {
            URI clientPublishURI = webService.getClientPublishUrl().toURI();
            if (!clientPublishURI.isOpaque()) {
                parent = new File(clientPublishURI);
            } else {
                parent = new File(webService.getClientPublishUrl().getPath());
            }
        } catch (URISyntaxException e) {
            logger.log(Level.WARNING, LogUtils.EXCEPTION_THROWN, e);
            parent = new File(webService.getClientPublishUrl().getPath());
        }
        // Collect the names of all entries in or below the
        // dedicated wsdl directory.
        FileArchive archive = new FileArchive();
        archive.open(sourceDir.toURI());
        Enumeration entries = archive.entries(bundle.getWsdlDir());
        while (entries.hasMoreElements()) {
            String name = (String) entries.nextElement();
            String wsdlName = stripWsdlDir(name, bundle);
            File clientwsdl = new File(parent, wsdlName);
            File fulluriFile = new File(sourceDir, name);
            if (!fulluriFile.isDirectory()) {
                publishFile(fulluriFile, clientwsdl);
                publishedFiles.add(clientwsdl.getAbsolutePath());
            }
        }
    }
    return publishedFiles;
}
Also used : ArchiveType(org.glassfish.api.deployment.archive.ArchiveType) FileArchive(com.sun.enterprise.deploy.shared.FileArchive)

Aggregations

FileArchive (com.sun.enterprise.deploy.shared.FileArchive)46 File (java.io.File)11 IOException (java.io.IOException)7 InputStream (java.io.InputStream)6 URI (java.net.URI)5 JarFile (java.util.jar.JarFile)5 Result (com.sun.enterprise.tools.verifier.Result)4 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)4 Enumeration (java.util.Enumeration)4 URISyntaxException (java.net.URISyntaxException)3 Manifest (java.util.jar.Manifest)3 SAXParseException (org.xml.sax.SAXParseException)3 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)2 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)2 AppClientArchivist (com.sun.enterprise.deployment.archivist.AppClientArchivist)2 InputJarArchive (com.sun.enterprise.deployment.deploy.shared.InputJarArchive)2 MultiReadableArchive (com.sun.enterprise.deployment.deploy.shared.MultiReadableArchive)2 ClosureCompiler (com.sun.enterprise.tools.verifier.apiscan.classfile.ClosureCompiler)2 URL (java.net.URL)2 Attributes (java.util.jar.Attributes)2