org.rhq.core.pluginapi.content
Class FileContentDelegate

java.lang.Object
  extended by org.rhq.core.pluginapi.content.FileContentDelegate
Direct Known Subclasses:
JarContentDelegate

public class FileContentDelegate
extends Object

Delegate class used for manipulating artifacts in a JON plugin.


Constructor Summary
FileContentDelegate()
          Default constructor.
FileContentDelegate(File directory, String fileEnding)
           
 
Method Summary
 void createContent(PackageDetails details, File content, boolean unzip)
          Creates a new package described by the specified details.
 void deleteContent(PackageDetails details)
          Deletes the underlying file for the specified package.
 Set<ResourcePackageDetails> discoverDeployedPackages()
          This is a stub implementation, you need to implement a discovery for artifacts of your particular content type.
 InputStream getContent(PackageDetails details)
          Returns a stream from which the content of the specified package can be read.
 File getDirectory()
           
 String getFileEnding()
           
 String retrieveDeploymentSHA(File deployment, File resourceDataDirectory)
          Retrieves SHA256 for the deployment.
 String saveDeploymentSHA(File deployment, File resourceDataDirectory)
          Save the SHA256 for a deployment without knowing its original archived content.
 String saveDeploymentSHA(File originalArchive, File deployment, File resourceDataDirectory)
          Save the SHA256 for a deployment with knowledge of the original archived content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileContentDelegate

public FileContentDelegate()
Default constructor.


FileContentDelegate

public FileContentDelegate(File directory,
                           String fileEnding)
Method Detail

getFileEnding

public String getFileEnding()

getDirectory

public File getDirectory()

createContent

public void createContent(PackageDetails details,
                          File content,
                          boolean unzip)
Creates a new package described by the specified details. The destination of the content in the provided input stream will be determined by the package name.

Parameters:
details - describes the package being created
content - content to be written for the package. NOTE this Stream will be closed by this method.
unzip - if true, the content stream will be treated like a ZIP file and be unzipped as it is written, using the package name as the base directory; if false the
createBackup - If true, the original file will be backed up to file.bak

getContent

public InputStream getContent(PackageDetails details)
Returns a stream from which the content of the specified package can be read.

Parameters:
details - package being loaded
Returns:
buffered input stream containing the contents of the package; will not be null, an exception is thrown if the content cannot be loaded

deleteContent

public void deleteContent(PackageDetails details)
Deletes the underlying file for the specified package.

Parameters:
details - package to delete

discoverDeployedPackages

public Set<ResourcePackageDetails> discoverDeployedPackages()
This is a stub implementation, you need to implement a discovery for artifacts of your particular content type.

Returns:

retrieveDeploymentSHA

public String retrieveDeploymentSHA(File deployment,
                                    File resourceDataDirectory)
Retrieves SHA256 for the deployment. If this is an exploded deployment and SHA256 is missing from the data directory then compute the SHA256 and save in the data directory.

Parameters:
deployment - deployment location
resourceId - resource id
dataDirectory - data directory
Returns:
SHA256 of the package

saveDeploymentSHA

public String saveDeploymentSHA(File originalArchive,
                                File deployment,
                                File resourceDataDirectory)
Save the SHA256 for a deployment with knowledge of the original archived content. If the deployment is archived, do not save anything. Just return the SHA256 of the content.

Parameters:
originalArchive -
deployment -
resourceId -
dataDirectory -
Returns:

saveDeploymentSHA

public String saveDeploymentSHA(File deployment,
                                File resourceDataDirectory)
Save the SHA256 for a deployment without knowing its original archived content. If the deployment is archived, do not save anything. Just return the SHA256 of the content.

Parameters:
deployment - deployment
resourceId - resource id
dataDirectory - data directory
Returns:
the saved SHA256


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.