Package org.rhq.core.pluginapi.content

Examples of org.rhq.core.pluginapi.content.ContentServices


            //The userSpecifiedName is used in case we renamed the file to add version.
            File contentCopy = new File(tempDir, userSpecifedName);

            os = new BufferedOutputStream(new FileOutputStream(contentCopy));
            ContentContext contentContext = resourceContext.getContentContext();
            ContentServices contentServices = contentContext.getContentServices();
            contentServices.downloadPackageBitsForChildResource(contentContext, resourceType.getName(), key, os);

            return contentCopy;
        } catch (IOException e) {
            throw new IllegalStateException("Failed to copy the deployed archive to destination.", e);
        } finally {
View Full Code Here


        return response;
    }

    public void downloadBits(PackageDetailsKey key, String destinationFileLocation) throws IOException,
        EmptyFileException {
        ContentServices contentServices = this.getContentContext().getContentServices();

        // Open a stream to where the downloaded file should go
        FileOutputStream output = new FileOutputStream(destinationFileLocation);
        BufferedOutputStream bufferedOutput = new BufferedOutputStream(output, 4096);

        // Request the bits from the server
        try {
            contentServices.downloadPackageBits(contentContext, key, bufferedOutput, true);
            bufferedOutput.close();

            // Verify the file was created correctly
            File downloadedFile = new File(destinationFileLocation);
            if (!downloadedFile.exists()) {
View Full Code Here

              File tempDir = resourceContext.getTemporaryDirectory();
              File tempFile = new File(tempDir.getAbsolutePath(), "esb.bin");
              OutputStream osForTempDir = new BufferedOutputStream(new FileOutputStream(tempFile));

              contentContext = resourceContext.getContentContext();
              ContentServices contentServices = contentContext.getContentServices();
              contentServices
                      .downloadPackageBitsForChildResource(contentContext, resourceTypeName, key, osForTempDir);

              osForTempDir.close();

              InputStream isForTempDir = new BufferedInputStream(new FileInputStream(tempFile));
View Full Code Here

        }
    }

    public void downloadBits(PackageDetailsKey key, ContentContext contentContext) throws IOException,
        ActionHandlerException {
        ContentServices contentServices = contentContext.getContentServices();

        // Open a stream to where the downloaded file should go
        FileOutputStream output = new FileOutputStream(destinationFileLocation);
        BufferedOutputStream bufferedOutput = new BufferedOutputStream(output, 4096);

        // Request the bits from the server
        try {
            contentServices.downloadPackageBits(contentContext, key, bufferedOutput, true);
            bufferedOutput.close();

            // Verify the file was created correctly
            File downloadedFile = new File(destinationFileLocation);
            if (!downloadedFile.exists()) {
View Full Code Here

            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

     */
    protected CreateResourceReport deployContent(CreateResourceReport report) {
        ContentContext cctx = context.getContentContext();
        ResourcePackageDetails details = report.getPackageDetails();

        ContentServices contentServices = cctx.getContentServices();
        String resourceTypeName = report.getResourceType().getName();

        ASUploadConnection uploadConnection = new ASUploadConnection(getServerComponent().getASConnection(), details
            .getKey().getName());

        OutputStream out = uploadConnection.getOutputStream();
        if (out == null) {
            report.setStatus(CreateResourceStatus.FAILURE);
            report.setErrorMessage("An error occured while the agent was preparing for content download");
            return report;
        }

        long size;
        try {
            size = contentServices.downloadPackageBitsForChildResource(cctx, resourceTypeName, details.getKey(), out);
        } catch (Exception e) {
            uploadConnection.cancelUpload();
            report.setStatus(CreateResourceStatus.FAILURE);
            LOG.debug("Failed to pull package from server", e);
            report.setErrorMessage("An error occured while the agent was uploading the content for ["
View Full Code Here

        return response;
    }

    public void downloadBits(PackageDetailsKey key, String destinationFileLocation) throws IOException,
        EmptyFileException {
        ContentServices contentServices = this.getContentContext().getContentServices();

        // Open a stream to where the downloaded file should go
        FileOutputStream output = new FileOutputStream(destinationFileLocation);
        BufferedOutputStream bufferedOutput = new BufferedOutputStream(output, 4096);

        // Request the bits from the server
        try {
            contentServices.downloadPackageBits(contentContext, key, bufferedOutput, true);

            // Verify the file was created correctly
            File downloadedFile = new File(destinationFileLocation);
            if (!downloadedFile.exists()) {
                throw new FileNotFoundException("File to download [" + destinationFileLocation + "] does not exist");
View Full Code Here

        }

        File tempDir = getResourceContext().getTemporaryDirectory();
        File tempFile = new File(tempDir.getAbsolutePath(), "tomcat-war.bin");
        ContentContext contentContext = getResourceContext().getContentContext();
        ContentServices contentServices = contentContext.getContentServices();
        OutputStream osForTempDir = null;

        try {
            osForTempDir = new BufferedOutputStream(new FileOutputStream(tempFile));
            contentServices.downloadPackageBitsForChildResource(contentContext, TomcatWarComponent.RESOURCE_TYPE_NAME,
                key, osForTempDir);
        } finally {
            if (null != osForTempDir) {
                try {
                    osForTempDir.close();
View Full Code Here

        File tempDir = resourceContext.getTemporaryDirectory();
        File tempFile = new File(tempDir.getAbsolutePath(), "ear_war.bin");
        OutputStream osForTempDir = new BufferedOutputStream(new FileOutputStream(tempFile));

        ContentServices contentServices = contentContext.getContentServices();
        contentServices.downloadPackageBitsForChildResource(contentContext, resourceTypeName, key, osForTempDir);

        osForTempDir.close();

        // check for content
        boolean valid = isOfType(tempFile, resourceTypeName);
View Full Code Here

        File mockResourceTemporaryDir = mock(File.class);

        ResourceContext mockResourceContext = mock(ResourceContext.class);
        when(mockResourceContext.getTemporaryDirectory()).thenReturn(mockResourceTemporaryDir);

        ContentServices mockContentServices = mock(ContentServices.class);
        ResourcePackageDetails mockResourcePackageDetails = mock(ResourcePackageDetails.class);

        File mockTempDir = mock(File.class);
        File mockTempFile = mock(File.class);
        when(mockTempFile.exists()).thenReturn(true);
View Full Code Here

TOP

Related Classes of org.rhq.core.pluginapi.content.ContentServices

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.