Package org.rhq.core.domain.content.transfer

Examples of org.rhq.core.domain.content.transfer.DeployIndividualPackageResponse


     * @see ContentFacet#deployPackages(Set, ContentServices)
     */
    public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails> packages, ContentServices contentServices) {
        Submit client = getBytemanClient();
        DeployPackagesResponse response = new DeployPackagesResponse();
        DeployIndividualPackageResponse individualResponse;

        for (ResourcePackageDetails detail : packages) {
            PackageDetailsKey packageKey = detail.getKey();
            String packageType = detail.getPackageTypeName();

            individualResponse = new DeployIndividualPackageResponse(packageKey);
            response.addPackageResponse(individualResponse);

            try {
                Boolean isBootJar = null; // null if not a classpath jar (this is for the future; today, it will always get set)
                // if necessary, create the data directory where the file should be deployed
                if (PKG_TYPE_NAME_BOOT_JAR.equals(packageType)) {
                    this.bootJarsDataDir.mkdirs();
                    isBootJar = Boolean.TRUE;
                } else if (PKG_TYPE_NAME_SYSTEM_JAR.equals(packageType)) {
                    this.systemJarsDataDir.mkdirs();
                    isBootJar = Boolean.FALSE;
                } else {
                    throw new UnsupportedOperationException("Cannot deploy package of type [" + packageType + "]");
                }

                // download the package to our data directory
                File newFile = getPackageFile(detail);
                FileOutputStream fos = new FileOutputStream(newFile);
                try {
                    ContentContext contentContext = this.resourceContext.getContentContext();
                    contentServices.downloadPackageBits(contentContext, packageKey, fos, true);
                } finally {
                    fos.close();
                }

                // tell the byteman agent to add it to the proper classloader
                if (isBootJar != null) {
                    if (isBootJar.booleanValue()) {
                        client.addJarsToBootClassloader(Arrays.asList(newFile.getAbsolutePath()));
                    } else {
                        client.addJarsToSystemClassloader(Arrays.asList(newFile.getAbsolutePath()));
                    }
                }

                // everything is OK
                individualResponse.setResult(ContentResponseResult.SUCCESS);
            } catch (Exception e) {
                individualResponse.setErrorMessage(ThrowableUtil.getStackAsString(e));
                individualResponse.setResult(ContentResponseResult.FAILURE);
            }
        }

        return response;
    }
View Full Code Here


            return failApplicationDeployment(errorMessage, packageDetails);
        }

        DeployPackagesResponse response = new DeployPackagesResponse(ContentResponseResult.SUCCESS);
        DeployIndividualPackageResponse packageResponse = new DeployIndividualPackageResponse(packageDetails.getKey(),
            ContentResponseResult.SUCCESS);
        response.addPackageResponse(packageResponse);

        return response;
    }
View Full Code Here

     * @return response populated to reflect a failure
     */
    private DeployPackagesResponse failApplicationDeployment(String errorMessage, ResourcePackageDetails packageDetails) {
        DeployPackagesResponse response = new DeployPackagesResponse(ContentResponseResult.FAILURE);

        DeployIndividualPackageResponse packageResponse = new DeployIndividualPackageResponse(packageDetails.getKey(),
            ContentResponseResult.FAILURE);
        packageResponse.setErrorMessage(errorMessage);

        response.addPackageResponse(packageResponse);

        return response;
    }
View Full Code Here

                    pkgInfo = pkgInfo + "-" + version;
                }
                log.info("Adding <" + pkgInfo + "> to list of packages to deploy, original package object was: " + p);
                pkgs.add(pkgInfo);
                result
                    .addPackageResponse(new DeployIndividualPackageResponse(p.getKey(), ContentResponseResult.SUCCESS));
            }

            yumProxy.install(pkgs);
            return result;
        } catch (Exception e) {
View Full Code Here

        Set<ResourcePackageDetails> packageDetails = new HashSet<ResourcePackageDetails>();
        packageDetails.add(detail);
        DeployPackagesRequest deployPackagesRequest = new DeployPackagesRequest(1, this.resource.getId(), packageDetails);

        ContentManager contentManager = PluginContainer.getInstance().getContentManager();
        DeployIndividualPackageResponse deployPackageResponse;
        try
        {
            DeployPackagesResponse deployPackagesResponse = contentManager.deployPackagesImmediately(deployPackagesRequest);
            deployPackageResponse = deployPackagesResponse.getPackageResponses().iterator().next();
        }
        catch (Exception e)
        {
            facesMessages.add(FacesMessage.SEVERITY_FATAL, e.getLocalizedMessage());
            return FAILURE_OUTCOME;
        }

        switch (deployPackageResponse.getResult())
        {
            case SUCCESS:
                facesMessages.add(FacesMessage.SEVERITY_INFO, "{0} {1} updated.", this.packageType.getDisplayName(),
                        this.packageDetails.getFileName());
                return SUCCESS_OUTCOME;
            default:
                String cause = (deployPackageResponse.getErrorMessage() != null) ?
                        deployPackageResponse.getErrorMessage() : "unknown";
                facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_ERROR, "content.resourceInstance.update.failure",
                        getFileName(), cause);
                return FAILURE_OUTCOME;
        }
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.content.transfer.DeployIndividualPackageResponse

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.