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

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


    private Configuration jbossPluginConfiguration;

    @BeforeMethod
    public void initPackageDetails() throws Exception {
        PackageDetailsKey key = new PackageDetailsKey("TestPackage", "1.0", "AS Patch", "noarch");
        packageDetails = new ResourcePackageDetails(key);

        Configuration extraProperties = new Configuration();
        extraProperties.put(new PropertySimple("instructionCompatibilityVersion", "1.4"));
        packageDetails.setExtraProperties(extraProperties);
View Full Code Here


            if (file.contains("."))
                t = file.substring(file.lastIndexOf(".") + 1);
            else
                t = "-none-";

            ResourcePackageDetails detail = new ResourcePackageDetails(new PackageDetailsKey(file, "1.0", t, "all"));
            details.add(detail);
        }
        return details;

    }
View Full Code Here

                            log.debug("Failed to generate sha256 for [" + file + "]");
                        }
                    }
                    String version = getVersion(file, sha256);
                    PackageDetailsKey detailsKey = new PackageDetailsKey(shortName, version, typeName, "noarch");
                    ResourcePackageDetails detail = new ResourcePackageDetails(detailsKey);
                    detail.setDisplayName(shortName);
                    detail.setFileCreatedDate(file.lastModified());
                    detail.setFileName(shortName);
                    detail.setFileSize(file.length());
                    detail.setMD5(MessageDigestGenerator.getDigestString(file));
                    detail.setSHA256(sha256);
                    details.add(detail);
                }
            }
        } catch (Exception e) {
            log.error("Failed to perform discovery for packages of type [" + typeName + "]", e);
View Full Code Here

        try {
            this.scriptsDataDir.mkdirs();

            // determine where to store the script file when we download it;
            // do not allow the file to be placed in a subdirectory under our data dir (i.e. take out file separators)
            ResourcePackageDetails newDetails = report.getPackageDetails();
            String newName = report.getUserSpecifiedResourceName();
            if (newName == null) {
                newName = newDetails.getName();
                if (newName == null) {
                    throw new NullPointerException("was not given a name for the new script");
                }
            }
            newName = newName.replace('/', '-').replace('\\', '-');

            File newFile = new File(this.scriptsDataDir, newName);
            String newFileAbsolutePath = newFile.getAbsolutePath();

            // download the file from the server
            ContentContext contentContext = this.resourceContext.getContentContext();
            ContentServices contentServices = contentContext.getContentServices();
            ResourceType newChildResourceType = report.getResourceType();
            FileOutputStream fos = new FileOutputStream(newFile);
            BufferedOutputStream outputStream = new BufferedOutputStream(fos);
            try {
                contentServices.downloadPackageBitsForChildResource(contentContext, newChildResourceType.getName(),
                    newDetails.getKey(), outputStream);
            } finally {
                outputStream.close();
            }

            // deploy the scripts rules in byteman agent
            getBytemanClient().addRulesFromFiles(Arrays.asList(newFileAbsolutePath));

            // we know where we put the file, fill in the details
            newDetails.setDisplayName(newName);
            newDetails.setFileName(newFileAbsolutePath);
            newDetails.setFileSize(newFile.length());
            newDetails.setInstallationTimestamp(newFile.lastModified());
            newDetails.setMD5(MessageDigestGenerator.getDigestString(newFile));

            // complete the report
            report.setResourceKey(newFileAbsolutePath);
            report.setResourceName(newName);
            report.setStatus(CreateResourceStatus.SUCCESS);
View Full Code Here

            String sha256 = getSHA256(file);
            String version = getVersion(sha256);
            String displayVersion = getDisplayVersion(file);

            PackageDetailsKey key = new PackageDetailsKey(fileName, version, PKG_TYPE_FILE, ARCHITECTURE);
            ResourcePackageDetails details = new ResourcePackageDetails(key);
            details.setFileName(fileName);
            details.setLocation(file.getPath());
            if (!file.isDirectory())
                details.setFileSize(file.length());

            details.setFileCreatedDate(file.lastModified()); // TODO: get created date via SIGAR           
            details.setSHA256(sha256);
            details.setInstallationTimestamp(Long.valueOf(System.currentTimeMillis()));
            details.setDisplayVersion(displayVersion);

            packages.add(details);
        }

        return packages;
View Full Code Here

            response
                .setOverallRequestErrorMessage("When deploying an EAR/WAR, only one EAR/WAR can be updated at a time.");
            return response;
        }

        ResourcePackageDetails packageDetails = packages.iterator().next();

        // Find location of existing application
        Configuration pluginConfig = getResourceContext().getPluginConfiguration();
        File appFile = new File(pluginConfig.getSimple(FILENAME_PLUGIN_CONFIG_PROP).getStringValue());
        if (!appFile.exists()) {
            return failApplicationDeployment("Could not find application to update at location: " + appFile,
                packageDetails);
        }

        File tempFile;
        try {
            tempFile = writeNewAppBitsToTempFile(appFile, contentServices, packageDetails);
        } catch (Exception e) {
            return failApplicationDeployment("Error writing new application bits to temporary file - cause: " + e,
                packageDetails);
        }

        //Before the backup find out if the current deployment is exploded or not.
        //Do not do this after the backup because the original files are no longer
        //on disk and thus .isDirectory() always returns false.
        boolean isExploded = appFile.isDirectory();

        // Backup the existing app file/dir to <filename>.rej.
        File backupOfOriginalFile = new File(appFile.getPath() + BACKUP_FILE_SUFFIX);
        appFile.renameTo(backupOfOriginalFile);

        // Write the new bits for the application
        moveTempFileToDeployLocation(tempFile, appFile, isExploded);

        // The file has been written successfully to the deploy dir. Now try to actually deploy it.
        MainDeployer mainDeployer = getParentResourceComponent().getMainDeployer();
        try {
            mainDeployer.redeploy(appFile);

            // Deploy was successful, delete the backup
            try {
                FileUtils.purge(backupOfOriginalFile, true);
            } catch (Exception e) {
                log.warn("Failed to delete backup of original file: " + backupOfOriginalFile);
            }
        } catch (Exception e) {
            // Deploy failed - rollback to the original app file...
            String errorMessage = ThrowableUtil.getAllMessages(e);
            try {
                FileUtils.purge(appFile, true);
                backupOfOriginalFile.renameTo(appFile);

                // Need to redeploy the original file - this generally should succeed.
                mainDeployer.redeploy(appFile);
                errorMessage += " ***** ROLLED BACK TO ORIGINAL APPLICATION FILE. *****";
            } catch (Exception e1) {
                errorMessage += " ***** FAILED TO ROLLBACK TO ORIGINAL APPLICATION FILE. *****: "
                    + ThrowableUtil.getAllMessages(e1);
            }

            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

        // TODO: Allow user to specify version?
        String version = String.valueOf(System.currentTimeMillis());
        PackageDetailsKey key = new PackageDetailsKey(tempFile.getPath(), version, this.packageType.getName(),
                PACKAGE_ARCHITECTURE);
        ResourcePackageDetails detail = new ResourcePackageDetails(key);
        //detail.setDeploymentTimeConfiguration(this.packageDetails.getDeploymentTimeConfiguration());

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

        catch (PluginContainerException e)
        {
            throw new Exception("Failed to discover underlying " + this.packageType.getName() + " package for "
                    + this.resourceType.getName() + " Resource.", e);
        }
        ResourcePackageDetails packageDetails = report.getDeployedPackages().iterator().next();
        log.debug("Backing package for " + this.resource + " is " + packageDetails + ".");
        return packageDetails;
    }
View Full Code Here

            return FAILURE_OUTCOME;
        }

        PackageDetailsKey key = new PackageDetailsKey(tempFile.getPath(), INITIAL_PACKAGE_VERSION, this.packageType.getName(),
                PACKAGE_ARCHITECTURE);
        ResourcePackageDetails detail = new ResourcePackageDetails(key);
        detail.setDeploymentTimeConfiguration(this.configuration);

        Configuration pluginConfiguration = null;

        JONTreeNode currentNode = navigationAction.getSelectedNode();
        Resource ancestorResource = currentNode.getClosestResource();
View Full Code Here

TOP

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

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.