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

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


        }
        return cnt;
    }

    static ResourcePackageDetails getTestDeploymentPackageDetails(TestDeployments deployment) {
        ResourcePackageDetails details = new ResourcePackageDetails(new PackageDetailsKey(
            deployment.getDeploymentName(), "1.0", "file", "noarch"));
        details.setFileName(deployment.getDeploymentName());
        details.setDeploymentTimeConfiguration(new Configuration());
        return details;
    }
View Full Code Here


            null, null, null, null, null, null);
        bc.start(context);

        String bytes_value = uploadToAs(TEST_WAR_PATH);

        ResourcePackageDetails details = new ResourcePackageDetails(new PackageDetailsKey(TEST_WAR_FILE_NAME, "1.0",
            "deployment", "all"));
        CreateResourceReport report = new CreateResourceReport(TEST_WAR_FILE_NAME, rt, new Configuration(),
            new Configuration(), details);
        try {
            report = bc.runDeploymentMagicOnServer(report, TEST_WAR_FILE_NAME, TEST_WAR_FILE_NAME, bytes_value);
View Full Code Here

            null, null, null, null, null, null);
        bc.start(context);

        String bytes_value = uploadToAs(TEST_WAR_PATH);

        ResourcePackageDetails details = new ResourcePackageDetails(new PackageDetailsKey(TEST_WAR_FILE_NAME, "1.0",
            "deployment", "all"));
        CreateResourceReport report = new CreateResourceReport(TEST_WAR_FILE_NAME, rt, new Configuration(),
            new Configuration(), details);
        try {
            report = bc.runDeploymentMagicOnServer(report, TEST_WAR_FILE_NAME, TEST_WAR_FILE_NAME, bytes_value);
View Full Code Here

        Set<ResourcePackageDetails> resultSet = objectUnderTest.discoverDeployedPackages();

        //verify the results (Assert and mock verification)
        Assert.assertEquals(resultSet.size(), 1);

        ResourcePackageDetails resultPackageDetails = (ResourcePackageDetails) resultSet.toArray()[0];
       
        Assert.assertEquals(resultPackageDetails.getVersion(), "[sha256=abcd1234]");
        Assert.assertEquals(resultPackageDetails.getSHA256(), "abcd1234");
    }
View Full Code Here

            return report;
        }
       
        File dataDir = getJobJarDataDir();
       
        ResourcePackageDetails packageDetails = report.getPackageDetails();
       
        File jobJar = new File(dataDir, packageDetails.getFileName());
       
        FileOutputStream jobJarStream = null;
        try {
            jobJarStream = new FileOutputStream(jobJar);
        } catch (FileNotFoundException e) {
            report.setErrorMessage("Could not create the job jar file on the agent: " + e.getMessage());
            return report;
        }
       
        ContentContext contentContext = getResourceContext().getContentContext();
        ContentServices contentServices = contentContext.getContentServices();
        contentServices.downloadPackageBitsForChildResource(contentContext, JobJarComponent.RESOURCE_TYPE_NAME, packageDetails.getKey(), jobJarStream);
       
        try {
            jobJarStream.close();
        } catch (IOException e) {
            //hmmm, do I care?
View Full Code Here

        Set<ResourcePackageDetails> result = objectUnderTest.discoverDeployedPackages(mockPackageType);

        //verify the results (Assert and mock verification)
        Assert.assertEquals(result.size(), 1);

        ResourcePackageDetails resultPackageDetails = (ResourcePackageDetails) result.toArray()[0];

        verifyNoMoreInteractions(mockPackageType);

        Assert.assertEquals(resultPackageDetails.getVersion(), "[sha256=abcd1234]");
        Assert.assertEquals(resultPackageDetails.getDisplayVersion(), "testDisplayVersion");
        Assert.assertEquals(resultPackageDetails.getSHA256(), "abcd1234");

        verify(mockFileContentDelegate).getSHA(any(File.class));
        verify(mockJarContentFileInfo).getVersion(isNull(String.class));
    }
View Full Code Here

            ProfileServiceConnection profileServiceConnection = resourceContext.getParentResourceComponent()
                .getConnection();

            ScriptDeployer deployer = new ScriptDeployer(jbossHomeDir, systemInfo, new RemoteDownloader(
                resourceContext, true, profileServiceConnection));
            ResourcePackageDetails packageDetails = packages.iterator().next();

            DeployIndividualPackageResponse scriptUpdateResult = deployer.update(packageDetails,
                resourceContext.getResourceType());

            response.setOverallRequestResult(scriptUpdateResult.getResult());
View Full Code Here

                log.warn("Failed to compute the SHA256 digest of the script: " + scriptFile.getAbsolutePath(), e);
            }

            PackageDetailsKey key = new PackageDetailsKey(scriptFile.getName(), this.getVersion(sha256), PACKAGE_TYPE,
                PACKAGE_ARCHITECTURE);
            ResourcePackageDetails details = new ResourcePackageDetails(key);
            details.setDisplayName(scriptFile.getName());
            details.setFileName(scriptFile.getAbsolutePath());
            details.setFileSize(scriptFile.length());
            details.setLocation(scriptFile.getAbsolutePath());
            details.setFileCreatedDate(scriptFile.lastModified());
            details.setInstallationTimestamp(System.currentTimeMillis());
            details.setSHA256(sha256);

            results.add(details);
        }

        return results;
View Full Code Here

        if (packages.size() != 1) {
            DeployPackagesResponse response = new DeployPackagesResponse(ContentResponseResult.FAILURE);
            response.setOverallRequestErrorMessage("When deploying WAR files only one 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(PROPERTY_FILENAME).getStringValue());
        if (!appFile.exists()) {
            return failApplicationDeployment("Could not find application to update at location: " + appFile,
                packageDetails);
        }
        boolean isExploded = appFile.isDirectory();

        // save the new version of the app to a temp location
        File tempFile;
        try {
            tempFile = writeAppBitsToTempFile(appFile, contentServices, packageDetails);
        } catch (Exception e) {
            return failApplicationDeployment("Error writing new application bits to temporary file - cause: " + e,
                packageDetails);
        }

        // delete the current app but don't undeploy.  This option should maintain the existing mbeans while
        // removing the app. Back up the bits in case we need to restore if the new app fails to deploy
        File backupFile = null;
        try {
            backupFile = deleteApp(pluginConfig, appFile, true, false);
        } catch (Exception e) {
            if (appFile.exists()) {
                return failApplicationDeployment("Error undeploying existing app - cause: " + e, packageDetails);
            }
            // log but proceed with no backup
            log.warn("Failed to create app backup but proceeding with redeploy of " + appFile.getPath() + ": " + e);
        }

        FileContentDelegate contentDelegate = new FileContentDelegate(appFile.getParentFile());

        try {
            // Write the new bits for the application. If successful Tomcat will pick it up and complete the deploy.
            contentDelegate.createContent(appFile, tempFile, isExploded);
        } catch (Exception e) {
            // Deploy failed - rollback to the original app file...
            String errorMessage = ThrowableUtil.getAllMessages(e);
            try {
                FileUtils.purge(appFile, true);
                contentDelegate.createContent(appFile, backupFile, isExploded);
                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);
        }

        // Deploy was successful!

        deleteBackupOfOriginalFile(backupFile);

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

        return response;
    }
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(null); // TODO: get created date via SIGAR
            details.setInstallationTimestamp(System.currentTimeMillis()); // TODO: anything better than discovery time
            details.setSHA256(sha256);
            details.setDisplayVersion(displayVersion);

            packages.add(details);
        }

        return packages;
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.