Package com.sun.enterprise.deploy.shared

Examples of com.sun.enterprise.deploy.shared.FileArchive


        if(moduleDirectory != null){
            try {
                File module = new File(moduleDirectory);
                if (module.exists()) {

                    FileArchive fileArchive = new FileArchive();
                    fileArchive.open(module.toURI())// directory where rar is exploded
                    Set<String> extensionList = InstalledLibrariesResolver.getInstalledLibraries(fileArchive);

                    URL[] extensionListLibraries = ASClassLoaderUtil.getLibrariesAsURLs(extensionList, env);
                    for (URL url : extensionListLibraries) {
                        libURIs.add(url.toURI());
View Full Code Here


     * @return status indicating whether .rar is exploded successfully or not
     */
    public static boolean extractRar(String fileName, String rarName, String destDir) {
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(rarName);
        if (is != null) {
            FileArchive fa = new FileArchive();
            OutputStream os = null;
            try {
                os = fa.putNextEntry(fileName);

                FileUtils.copy(is, os, 0);
            } catch (IOException e) {
                Object args[] = new Object[]{rarName, e};
                _logger.log(Level.WARNING, "error.extracting.archive", args);
                return false;
            } finally {
                try {
                    if (os != null) {
                        fa.closeEntry();
                    }

                } catch (IOException ioe) {
                    if (_logger.isLoggable(Level.FINEST)) {
                        _logger.log(Level.FINEST, "Exception while closing archive [ " + fileName + " ]", ioe);
View Full Code Here

        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        try {

            File module = new File(moduleDir);

            FileArchive fileArchive = new FileArchive();
            fileArchive.open(module.toURI())// directory where rar is exploded
            ConnectorRuntime runtime = ConnectorRuntime.getRuntime();
            ClassLoader loader ;
            if(ConnectorsUtil.belongsToSystemRA(rarModuleName)){
                loader = ConnectorRuntime.getRuntime().getSystemRARClassLoader(rarModuleName);
                Thread.currentThread().setContextClassLoader(loader);
View Full Code Here

        try {
            String appName = rarName.substring(0, rarName.indexOf(ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER));
            //String actualRarName = rarName.substring(rarName.indexOf(ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER) + 1);
            String appDeployLocation = ResourcesUtil.createInstance().getApplicationDeployLocation(appName);

            FileArchive in = ConnectorRuntime.getRuntime().getFileArchive();
            in.open(new URI(appDeployLocation));
            ApplicationArchivist archivist = ConnectorRuntime.getRuntime().getApplicationArchivist();
            com.sun.enterprise.deployment.Application application = archivist.open(in);
            return application.getRarDescriptorByUri(raLoc);
        } catch (Exception e) {
            Object params[] = new Object[]{rarName, e};
View Full Code Here

                    /*
                     * Delete the repository directory as an archive to allow
                     * any special processing (such as stale file handling)
                     * to run.
                     */
                    final FileArchive arch = DeploymentUtils.openAsFileArchive(reposDir, archiveFactory);
                    arch.delete();
                }
            }

            if (!DeploymentUtils.isDomainTarget(target) && enabled) {
                // try to disable the enabled version, if exist
                try {
                    versioningService.handleDisable(name,target, report);
                } catch (VersioningSyntaxException e) {
                    report.failure(logger, e.getMessage());
                    return;
                }
            }

            File source = new File(archive.getURI().getSchemeSpecificPart());
            boolean isDirectoryDeployed = true;
            if (!source.isDirectory()) {
                isDirectoryDeployed = false;
                expansionDir = new File(domain.getApplicationRoot(), VersioningUtils.getRepositoryName(name));
                path = expansionDir;
            } else {
                // test if a version is already directory deployed from this dir
                String versionFromSameDir =
                        versioningService.getVersionFromSameDir(source);
                if (!force && versionFromSameDir != null) {
                    report.failure(logger,
                            VersioningUtils.LOCALSTRINGS.getLocalString(
                                "versioning.deployment.dual.inplace",
                                "GlassFish do not support versioning for directory deployment when using the same directory. The directory {0} is already assigned to the version {1}.",
                                source.getPath(),
                                versionFromSameDir));
                    return;
                }
            }

            // create the parent class loader
            deploymentContext =
                    deployment.getBuilder(logger, this, report).
                            source(archive).archiveHandler(archiveHandler).build(initialContext);
            if (tracing!=null) {
                tracing.addMark(DeploymentTracing.Mark.CONTEXT_CREATED);
                deploymentContext.addModuleMetaData(tracing);
            }

            // reset the properties (might be null) set by the deployers when undeploying.
            if (undeployProps!=null) {
                deploymentContext.getAppProps().putAll(undeployProps);
            }

            if (properties != null || property != null) {
                // if one of them is not null, let's merge them
                // to properties so we don't need to always
                // check for both
                if (properties == null) {
                    properties = new Properties();
                }
                if (property != null) {
                    properties.putAll(property);
                }
            }

            if (properties != null) {
                deploymentContext.getAppProps().putAll(properties);
                validateDeploymentProperties(properties, deploymentContext);
            }

            // clean up any generated files
            deploymentContext.clean();

            Properties appProps = deploymentContext.getAppProps();
            /*
             * If the app's location is within the domain's directory then
             * express it in the config as ${com.sun.aas.instanceRootURI}/rest-of-path
             * so users can relocate the entire installation without having
             * to modify the app locations.  Leave the location alone if
             * it does not fall within the domain directory.
             */
            String appLocation = DeploymentUtils.relativizeWithinDomainIfPossible( deploymentContext.getSource().getURI());
           
            appProps.setProperty(ServerTags.LOCATION, appLocation);
            // set to default "user", deployers can override it
            // during processing
            appProps.setProperty(ServerTags.OBJECT_TYPE, "user");
            if (contextroot!=null) {
                appProps.setProperty(ServerTags.CONTEXT_ROOT, contextroot);
            }
            appProps.setProperty(ServerTags.DIRECTORY_DEPLOYED, String.valueOf(isDirectoryDeployed));
            if (type == null) {
                type = archiveHandler.getArchiveType();
            }
            appProps.setProperty(Application.ARCHIVE_TYPE_PROP_NAME, type);

            savedAppConfig.store(appProps);

            deploymentContext.addTransientAppMetaData(DeploymentProperties.PREVIOUS_TARGETS, previousTargets);
            deploymentContext.addTransientAppMetaData(DeploymentProperties.PREVIOUS_VIRTUAL_SERVERS, previousVirtualServers);
            deploymentContext.addTransientAppMetaData(DeploymentProperties.PREVIOUS_ENABLED_ATTRIBUTES, previousEnabledAttributes);

            Transaction t = deployment.prepareAppConfigChanges(deploymentContext);
            if (tracing!=null) {
                tracing.addMark(DeploymentTracing.Mark.DEPLOY);
            }
            ApplicationInfo appInfo;
            appInfo = deployment.deploy(deploymentContext);

            /*
             * Various deployers might have added to the downloadable or
             * generated artifacts.  Extract them and, if the command succeeded,
             * persist both into the app properties (which will be recorded
             * in domain.xml).
             */
            final Artifacts downloadableArtifacts =
                    DeploymentUtils.downloadableArtifacts(deploymentContext);
            final Artifacts generatedArtifacts =
                    DeploymentUtils.generatedArtifacts(deploymentContext);
           
            if (report.getActionExitCode()==ActionReport.ExitCode.SUCCESS) {
                try {
                    moveAppFilesToPermanentLocation(
                            deploymentContext, logger);
                    recordFileLocations(appProps);

                    downloadableArtifacts.record(appProps);
                    generatedArtifacts.record(appProps);

                    // register application information in domain.xml
                    deployment.registerAppInDomainXML(appInfo, deploymentContext, t);
                    if (tracing!=null) {
                        tracing.addMark(DeploymentTracing.Mark.REGISTRATION);
                    }
                    if (retrieve != null) {
                        retrieveArtifacts(context, downloadableArtifacts.getArtifacts(), retrieve, false, name);
                    }
                    suppInfo.setDeploymentContext(deploymentContext);
                    //Fix for issue 14442
                    //We want to report the worst subreport value.
                    ActionReport.ExitCode worstExitCode = ExitCode.SUCCESS;
                    for (ActionReport subReport : report.getSubActionsReport()) {
                        ActionReport.ExitCode actionExitCode = subReport.getActionExitCode();

                        if ( actionExitCode.isWorse(worstExitCode) ){
                           worstExitCode = actionExitCode;
                       }
                    }
                    report.setActionExitCode(worstExitCode);
                    report.setResultType(String.class, name);

                } catch (Exception e) {
                    // roll back the deployment and re-throw the exception
                    deployment.undeploy(name, deploymentContext);
                    deploymentContext.clean();
                    throw e;
                }
            }
        } catch(Throwable e) {
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(e.getMessage());
            report.setFailureCause(e);
        } finally {
            events.unregister(this);
            try {
                archive.close();
            } catch(IOException e) {
                logger.log(Level.FINE, localStrings.getLocalString(
                        "errClosingArtifact",
                        "Error while closing deployable artifact : ",
                        path.getAbsolutePath()), e);
            }
           
            if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) {
                // Set the app name in the result so that embedded deployer can retrieve it.
                report.setResultType(String.class, name);
                report.setMessage(localStrings.getLocalString("deploy.command.success","Application deployed with name {0}", name));

                logger.info(localStrings.getLocalString(
                        "deploy.done",
                        "Deployment of {0} done is {1} ms",
                        name,
                        timing.elapsed()));
            } else if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
                String errorMessage = report.getMessage();
                Throwable cause = report.getFailureCause();
                if (cause != null) {
                    String causeMessage = cause.getMessage();
                    if (causeMessage != null &&
                        !causeMessage.equals(errorMessage)) {
                        errorMessage = errorMessage + " : " + cause.getMessage();
                    }
                    logger.log(Level.SEVERE, errorMessage, cause.getCause());
                }
                report.setMessage(localStrings.getLocalString("deploy.errDuringDepl", "Error occur during deployment: {0}.", errorMessage));
                // reset the failure cause so command framework will not try
                // to print the same message again
                report.setFailureCause(null);
                if (expansionDir!=null) {
                    final FileArchive arch;
                        try {
                            /*
                             * Open and then delete the expansion directory as
                             * a file archive so stale file handling can run.
                             */
                            arch = DeploymentUtils.openAsFileArchive(expansionDir, archiveFactory);
                            arch.delete();
                        } catch (IOException ex) {
                            final String msg = localStrings.getLocalString(
                                    "deploy.errDelRepos",
                                    "Error deleting repository directory {0}",
                                    expansionDir.getAbsolutePath());
View Full Code Here

        if(moduleDirectory != null){
            try {
                File module = new File(moduleDirectory);
                if (module.exists()) {

                    FileArchive fileArchive = new FileArchive();
                    fileArchive.open(module.toURI())// directory where rar is exploded
                    Set<String> extensionList = InstalledLibrariesResolver.getInstalledLibraries(fileArchive);

                    URL[] extensionListLibraries = ASClassLoaderUtil.getLibrariesAsURLs(extensionList, env);
                    for (URL url : extensionListLibraries) {
                        libURIs.add(url.toURI());
View Full Code Here

     * @return status indicating whether .rar is exploded successfully or not
     */
    public static boolean extractRar(String fileName, String rarName, String destDir) {
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(rarName);
        if (is != null) {
            FileArchive fa = new FileArchive();
            OutputStream os = null;
            try {
                os = fa.putNextEntry(fileName);

                FileUtils.copy(is, os, 0);
            } catch (IOException e) {
                Object args[] = new Object[]{rarName, e};
                _logger.log(Level.WARNING, "error.extracting.archive", args);
                return false;
            } finally {
                try {
                    if (os != null) {
                        fa.closeEntry();
                    }

                } catch (IOException ioe) {
                    if (_logger.isLoggable(Level.FINEST)) {
                        _logger.log(Level.FINEST, "Exception while closing archive [ " + fileName + " ]", ioe);
View Full Code Here

                    /*
                     * Delete the repository directory as an archive to allow
                     * any special processing (such as stale file handling)
                     * to run.
                     */
                    final FileArchive arch = DeploymentUtils.openAsFileArchive(reposDir, archiveFactory);
                    arch.delete();
                }
            }

            if (!DeploymentUtils.isDomainTarget(target) && enabled) {
                // try to disable the enabled version, if exist
                try {
                    versioningService.handleDisable(name,target, report);
                } catch (VersioningSyntaxException e) {
                    report.failure(logger, e.getMessage());
                    return;
                }
            }

            File source = new File(archive.getURI().getSchemeSpecificPart());
            boolean isDirectoryDeployed = true;
            if (!source.isDirectory()) {
                isDirectoryDeployed = false;
                expansionDir = new File(domain.getApplicationRoot(), name);
                path = expansionDir;
            } else {
                // test if a version is already directory deployed from this dir
                String versionFromSameDir =
                        versioningService.getVersionFromSameDir(source);
                if (!force && versionFromSameDir != null) {
                    report.failure(logger,
                            VersioningUtils.LOCALSTRINGS.getLocalString(
                                "versioning.deployment.dual.inplace",
                                "GlassFish do not support versioning for directory deployment when using the same directory. The directory {0} is already assigned to the version {1}.",
                                source.getPath(),
                                versionFromSameDir));
                    return;
                }
            }

            // create the parent class loader
            deploymentContext =
                    deployment.getBuilder(logger, this, report).
                            source(archive).archiveHandler(archiveHandler).build(initialContext);
            if (tracing!=null) {
                tracing.addMark(DeploymentTracing.Mark.CONTEXT_CREATED);
                deploymentContext.addModuleMetaData(tracing);
            }

            // reset the properties (might be null) set by the deployers when undeploying.
            if (undeployProps!=null) {
                deploymentContext.getAppProps().putAll(undeployProps);
            }

            if (properties != null || property != null) {
                // if one of them is not null, let's merge them
                // to properties so we don't need to always
                // check for both
                if (properties == null) {
                    properties = new Properties();
                }
                if (property != null) {
                    properties.putAll(property);
                }
            }

            if (properties != null) {
                deploymentContext.getAppProps().putAll(properties);
                validateDeploymentProperties(properties, deploymentContext);
            }

            // clean up any generated files
            deploymentContext.clean();

            Properties appProps = deploymentContext.getAppProps();
            /*
             * If the app's location is within the domain's directory then
             * express it in the config as ${com.sun.aas.instanceRootURI}/rest-of-path
             * so users can relocate the entire installation without having
             * to modify the app locations.  Leave the location alone if
             * it does not fall within the domain directory.
             */
            String appLocation = DeploymentUtils.relativizeWithinDomainIfPossible( deploymentContext.getSource().getURI());
           
            appProps.setProperty(ServerTags.LOCATION, appLocation);
            // set to default "user", deployers can override it
            // during processing
            appProps.setProperty(ServerTags.OBJECT_TYPE, "user");
            if (contextroot!=null) {
                appProps.setProperty(ServerTags.CONTEXT_ROOT, contextroot);
            }
            appProps.setProperty(ServerTags.DIRECTORY_DEPLOYED, String.valueOf(isDirectoryDeployed));

            savedAppConfig.store(appProps);

            deploymentContext.addTransientAppMetaData(DeploymentProperties.PREVIOUS_TARGETS, previousTargets);
            deploymentContext.addTransientAppMetaData(DeploymentProperties.PREVIOUS_VIRTUAL_SERVERS, previousVirtualServers);
            deploymentContext.addTransientAppMetaData(DeploymentProperties.PREVIOUS_ENABLED_ATTRIBUTES, previousEnabledAttributes);

            Transaction t = deployment.prepareAppConfigChanges(deploymentContext);
            if (tracing!=null) {
                tracing.addMark(DeploymentTracing.Mark.DEPLOY);
            }
            ApplicationInfo appInfo;
            if (type==null) {
                appInfo = deployment.deploy(deploymentContext);
            } else {
                appInfo = deployment.deploy(deployment.prepareSniffersForOSGiDeployment(type, deploymentContext), deploymentContext);
            }

            /*
             * Various deployers might have added to the downloadable or
             * generated artifacts.  Extract them and, if the command succeeded,
             * persist both into the app properties (which will be recorded
             * in domain.xml).
             */
            final Artifacts downloadableArtifacts =
                    DeploymentUtils.downloadableArtifacts(deploymentContext);
            final Artifacts generatedArtifacts =
                    DeploymentUtils.generatedArtifacts(deploymentContext);
           
            if (report.getActionExitCode()==ActionReport.ExitCode.SUCCESS) {
                try {
                    moveAppFilesToPermanentLocation(
                            deploymentContext, logger);
                    recordFileLocations(appProps);

                    downloadableArtifacts.record(appProps);
                    generatedArtifacts.record(appProps);

                    // register application information in domain.xml
                    deployment.registerAppInDomainXML(appInfo, deploymentContext, t);
                    suppInfo.setDeploymentContext(deploymentContext);
                    //Fix for issue 14442
                    //We want to report the worst subreport value.
                    ActionReport.ExitCode worstExitCode = ExitCode.SUCCESS;
                    for (ActionReport subReport : report.getSubActionsReport()) {
                        ActionReport.ExitCode actionExitCode = subReport.getActionExitCode();

                        if ( actionExitCode.isWorse(worstExitCode) ){
                           worstExitCode = actionExitCode;
                       }
                    }
                    report.setActionExitCode(worstExitCode);
                    report.setResultType(String.class, name);
                } catch (Exception e) {
                    // roll back the deployment and re-throw the exception
                    deployment.undeploy(name, deploymentContext);
                    deploymentContext.clean();
                    throw e;
                }

            }
            if (tracing!=null) {
                tracing.addMark(DeploymentTracing.Mark.REGISTRATION);
            }
            if(retrieve != null) {
                retrieveArtifacts(context, downloadableArtifacts.getArtifacts(),
                        retrieve,
                        false);
            }
        } catch(Throwable e) {
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(e.getMessage());
            report.setFailureCause(e);
        } finally {
            try {
                archive.close();
            } catch(IOException e) {
                logger.log(Level.FINE, localStrings.getLocalString(
                        "errClosingArtifact",
                        "Error while closing deployable artifact : ",
                        path.getAbsolutePath()), e);
            }
            if (tracing!=null) {
                tracing.print(System.out);
                TracingUtilities.dump("org.glassfish.javaee.core.deployment.DolProvider", System.out);
            }
            if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) {
                // Set the app name in the result so that embedded deployer can retrieve it.
                report.setResultType(String.class, name);
                report.setMessage(localStrings.getLocalString("deploy.command.success","Application deployed with name {0}", name));

                logger.info(localStrings.getLocalString(
                        "deploy.done",
                        "Deployment of {0} done is {1} ms",
                        name,
                        timing.elapsed()));
            } else if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
                String errorMessage = report.getMessage();
                Throwable cause = report.getFailureCause();
                if (cause != null) {
                    String causeMessage = cause.getMessage();
                    if (causeMessage != null &&
                        !causeMessage.equals(errorMessage)) {
                        errorMessage = errorMessage + " : " + cause.getMessage();
                    }
                    logger.log(Level.SEVERE, errorMessage, cause.getCause());
                }
                report.setMessage(localStrings.getLocalString("deploy.errDuringDepl", "Error occur during deployment: {0}.", errorMessage));
                // reset the failure cause so command framework will not try
                // to print the same message again
                report.setFailureCause(null);
                if (expansionDir!=null) {
                    final FileArchive arch;
                        try {
                            /*
                             * Open and then delete the expansion directory as
                             * a file archive so stale file handling can run.
                             */
                            arch = DeploymentUtils.openAsFileArchive(expansionDir, archiveFactory);
                            arch.delete();
                        } catch (IOException ex) {
                            final String msg = localStrings.getLocalString(
                                    "deploy.errDelRepos",
                                    "Error deleting repository directory {0}",
                                    expansionDir.getAbsolutePath());
View Full Code Here

                    /*
                     * Delete the repository directory as an archive to allow
                     * any special processing (such as stale file handling)
                     * to run.
                     */
                    final FileArchive arch = DeploymentUtils.openAsFileArchive(reposDir, archiveFactory);
                    arch.delete();
                }
            }

            if (!DeploymentUtils.isDomainTarget(target) && enabled) {
                // try to disable the enabled version, if exist
                try {
                    versioningService.handleDisable(name,target, report, context.getSubject());
                } catch (VersioningSyntaxException e) {
                    report.failure(logger, e.getMessage());
                    return;
                }
            }

            File source = new File(archive.getURI().getSchemeSpecificPart());
            boolean isDirectoryDeployed = true;
            if (!source.isDirectory()) {
                isDirectoryDeployed = false;
                expansionDir = new File(domain.getApplicationRoot(), VersioningUtils.getRepositoryName(name));
                path = expansionDir;
            } else {
                // test if a version is already directory deployed from this dir
                String versionFromSameDir =
                        versioningService.getVersionFromSameDir(source);
                if (!force && versionFromSameDir != null) {
                    report.failure(logger,
                            VersioningUtils.LOCALSTRINGS.getLocalString(
                                "versioning.deployment.dual.inplace",
                                "GlassFish do not support versioning for directory deployment when using the same directory. The directory {0} is already assigned to the version {1}.",
                                source.getPath(),
                                versionFromSameDir));
                    return;
                }
            }

            // create the parent class loader
            deploymentContext =
                    deployment.getBuilder(logger, this, report).
                            source(archive).archiveHandler(archiveHandler).build(initialContext);
            if (tracing!=null) {
                tracing.addMark(DeploymentTracing.Mark.CONTEXT_CREATED);
                deploymentContext.addModuleMetaData(tracing);
            }

            // reset the properties (might be null) set by the deployers when undeploying.
            if (undeployProps!=null) {
                deploymentContext.getAppProps().putAll(undeployProps);
            }

            if (properties != null || property != null) {
                // if one of them is not null, let's merge them
                // to properties so we don't need to always
                // check for both
                if (properties == null) {
                    properties = new Properties();
                }
                if (property != null) {
                    properties.putAll(property);
                }
            }

            if (properties != null) {
                deploymentContext.getAppProps().putAll(properties);
                validateDeploymentProperties(properties, deploymentContext);
            }

            // clean up any generated files
            deploymentContext.clean();

            Properties appProps = deploymentContext.getAppProps();
            /*
             * If the app's location is within the domain's directory then
             * express it in the config as ${com.sun.aas.instanceRootURI}/rest-of-path
             * so users can relocate the entire installation without having
             * to modify the app locations.  Leave the location alone if
             * it does not fall within the domain directory.
             */
            String appLocation = DeploymentUtils.relativizeWithinDomainIfPossible( deploymentContext.getSource().getURI());
           
            appProps.setProperty(ServerTags.LOCATION, appLocation);
            // set to default "user", deployers can override it
            // during processing
            appProps.setProperty(ServerTags.OBJECT_TYPE, "user");
            if (contextroot!=null) {
                appProps.setProperty(ServerTags.CONTEXT_ROOT, contextroot);
            }
            appProps.setProperty(ServerTags.DIRECTORY_DEPLOYED, String.valueOf(isDirectoryDeployed));
            if (type == null) {
                type = archiveHandler.getArchiveType();
            }
            appProps.setProperty(Application.ARCHIVE_TYPE_PROP_NAME, type);

            savedAppConfig.store(appProps);

            deploymentContext.addTransientAppMetaData(DeploymentProperties.PREVIOUS_TARGETS, previousTargets);
            deploymentContext.addTransientAppMetaData(DeploymentProperties.PREVIOUS_VIRTUAL_SERVERS, previousVirtualServers);
            deploymentContext.addTransientAppMetaData(DeploymentProperties.PREVIOUS_ENABLED_ATTRIBUTES, previousEnabledAttributes);

            Transaction t = deployment.prepareAppConfigChanges(deploymentContext);
            if (tracing!=null) {
                tracing.addMark(DeploymentTracing.Mark.DEPLOY);
            }
            ApplicationInfo appInfo;
            appInfo = deployment.deploy(deploymentContext);

            /*
             * Various deployers might have added to the downloadable or
             * generated artifacts.  Extract them and, if the command succeeded,
             * persist both into the app properties (which will be recorded
             * in domain.xml).
             */
            final Artifacts downloadableArtifacts =
                    DeploymentUtils.downloadableArtifacts(deploymentContext);
            final Artifacts generatedArtifacts =
                    DeploymentUtils.generatedArtifacts(deploymentContext);
           
            if (report.getActionExitCode()==ActionReport.ExitCode.SUCCESS) {
                try {
                    moveAppFilesToPermanentLocation(
                            deploymentContext, logger);
                    recordFileLocations(appProps);

                    downloadableArtifacts.record(appProps);
                    generatedArtifacts.record(appProps);

                    // register application information in domain.xml
                    deployment.registerAppInDomainXML(appInfo, deploymentContext, t);
                    if (tracing!=null) {
                        tracing.addMark(DeploymentTracing.Mark.REGISTRATION);
                    }
                    if (retrieve != null) {
                        retrieveArtifacts(context, downloadableArtifacts.getArtifacts(), retrieve, false, name);
                    }
                    suppInfo.setDeploymentContext(deploymentContext);
                    //Fix for issue 14442
                    //We want to report the worst subreport value.
                    ActionReport.ExitCode worstExitCode = ExitCode.SUCCESS;
                    for (ActionReport subReport : report.getSubActionsReport()) {
                        ActionReport.ExitCode actionExitCode = subReport.getActionExitCode();

                        if ( actionExitCode.isWorse(worstExitCode) ){
                           worstExitCode = actionExitCode;
                       }
                    }
                    report.setActionExitCode(worstExitCode);
                    report.setResultType(String.class, name);

                } catch (Exception e) {
                    // roll back the deployment and re-throw the exception
                    deployment.undeploy(name, deploymentContext);
                    deploymentContext.clean();
                    throw e;
                }
            }
        } catch(Throwable e) {
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(e.getMessage());
            report.setFailureCause(e);
        } finally {
            events.unregister(this);
            try {
                archive.close();
            } catch(IOException e) {
                logger.log(Level.FINE, localStrings.getLocalString(
                        "errClosingArtifact",
                        "Error while closing deployable artifact : ",
                        path.getAbsolutePath()), e);
            }
           
            if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) {
                // Set the app name in the result so that embedded deployer can retrieve it.
                report.setResultType(String.class, name);
                report.setMessage(localStrings.getLocalString("deploy.command.success","Application deployed with name {0}", name));

                logger.info(localStrings.getLocalString(
                        "deploy.done",
                        "Deployment of {0} done is {1} ms",
                        name,
                        timing.elapsed()));
            } else if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
                String errorMessage = report.getMessage();
                Throwable cause = report.getFailureCause();
                if (cause != null) {
                    String causeMessage = cause.getMessage();
                    if (causeMessage != null &&
                        !causeMessage.equals(errorMessage)) {
                        errorMessage = errorMessage + " : " + cause.getMessage();
                    }
                    logger.log(Level.SEVERE, errorMessage, cause.getCause());
                }
                report.setMessage(localStrings.getLocalString("deploy.errDuringDepl", "Error occur during deployment: {0}.", errorMessage));
                // reset the failure cause so command framework will not try
                // to print the same message again
                report.setFailureCause(null);
                if (expansionDir!=null) {
                    final FileArchive arch;
                        try {
                            /*
                             * Open and then delete the expansion directory as
                             * a file archive so stale file handling can run.
                             */
                            arch = DeploymentUtils.openAsFileArchive(expansionDir, archiveFactory);
                            arch.delete();
                        } catch (IOException ex) {
                            final String msg = localStrings.getLocalString(
                                    "deploy.errDelRepos",
                                    "Error deleting repository directory {0}",
                                    expansionDir.getAbsolutePath());
View Full Code Here

        InputStream deploymentEntry=null;
        String uri = null;

  try {
                uri = getAbstractArchiveUri(descriptor);
                 FileArchive arch = new FileArchive();
                 arch.open(uri);
                 deploymentEntry = arch.getEntry(DescriptorConstants.EJB_DD_ENTRY);

      if (deploymentEntry != null) {
    BufferedReader in = new BufferedReader(new InputStreamReader(deploymentEntry));
    String s = in.readLine();
    boolean foundDOCTYPE = false, foundPubid = false, foundURL = false;
View Full Code Here

TOP

Related Classes of com.sun.enterprise.deploy.shared.FileArchive

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.