org.rhq.core.pluginapi.content
Interface ContentServices


public interface ContentServices

This is the interface to the content services provided to a plugin's ContentFacet. A content facet implementation can use these services to request information from the plugin container.


Method Summary
 long downloadPackageBits(ContentContext context, PackageDetailsKey packageDetailsKey, OutputStream outputStream, boolean resourceExists)
          Requests that the plugin container download and stream the bits for the specified package.
 long downloadPackageBitsForChildResource(ContentContext context, String childResourceTypeName, PackageDetailsKey key, OutputStream outputStream)
          Requests the plugin container download and stream the bits for the specified package.
 long downloadPackageBitsRange(ContentContext context, PackageDetailsKey packageDetailsKey, OutputStream outputStream, long startByte, long endByte, boolean resourceExists)
          Requests that the plugin container download and stream the bits for the specified package.
 long getPackageBitsLength(ContentContext context, PackageDetailsKey packageDetailsKey)
          Requests the size, in bytes, of the identified package version.
 PageList<PackageVersionMetadataComposite> getPackageVersionMetadata(ContentContext context, PageControl pc)
          Requests all metadata for all package versions that the calling resource component is subscribed to see.
 String getResourceSubscriptionMD5(ContentContext context)
          Gets the MD5 hash which identifies a resource "content subscription".
 

Method Detail

downloadPackageBits

long downloadPackageBits(ContentContext context,
                         PackageDetailsKey packageDetailsKey,
                         OutputStream outputStream,
                         boolean resourceExists)
Requests that the plugin container download and stream the bits for the specified package. If the package cannot be found, an exception will be thrown.

Parameters:
context - identifies the resource requesting the bits
packageDetailsKey - identifies the package
outputStream - an output stream where the plugin container should write the package contents. It is up to the plugin, before making this call, to prepare this output stream in order to write the package content to an appropriate location. It is also up to the plugin to close this stream after this call completes.
Returns:
the number of bytes written to the output stream - this is the size of the package version that was downloaded

downloadPackageBitsRange

long downloadPackageBitsRange(ContentContext context,
                              PackageDetailsKey packageDetailsKey,
                              OutputStream outputStream,
                              long startByte,
                              long endByte,
                              boolean resourceExists)
Requests that the plugin container download and stream the bits for the specified package. If the package cannot be found, an exception will be thrown.

Parameters:
context - identifies the resource requesting the bits
packageDetailsKey - identifies the package
outputStream - an output stream where the plugin container should write the package contents. It is up to the plugin, before making this call, to prepare this output stream in order to write the package content to an appropriate location.
startByte - the first byte (inclusive) of the byte range to retrieve and output (bytes start at index 0)
endByte - the last byte (inclusive) of the byte range to retrieve and output (-1 means up to EOF) (bytes start at index 0)
Returns:
the number of bytes written to the output stream - this is the size of the chunk downloaded

downloadPackageBitsForChildResource

long downloadPackageBitsForChildResource(ContentContext context,
                                         String childResourceTypeName,
                                         PackageDetailsKey key,
                                         OutputStream outputStream)
Requests the plugin container download and stream the bits for the specified package. This method should be used when retrieving the bits for a package being installed during the creation of a new resource.

Parameters:
context - identifies the parent resource onto which the child resource will be created
childResourceTypeName - identifies the type of child resource being created
key - identifies the specific package being deployed for the resource creation
outputStream - an output stream where the plugin container should write the package contents. It is up to the plugin, before making this call, to prepare this output stream in order to write the package content to an appropriate location. It is also up to the caller to close this stream once the write is completed.
Returns:
the number of bytes written to the output stream

getPackageBitsLength

long getPackageBitsLength(ContentContext context,
                          PackageDetailsKey packageDetailsKey)
Requests the size, in bytes, of the identified package version.

Parameters:
context - identifies the resource requesting the info
packageDetailsKey - identifies the package whose size is to be returned
Returns:
the size, in number of bytes, of the package version

getPackageVersionMetadata

PageList<PackageVersionMetadataComposite> getPackageVersionMetadata(ContentContext context,
                                                                    PageControl pc)
Requests all metadata for all package versions that the calling resource component is subscribed to see. The returned object has the metadata bytes that are meaningful to the calling plugin component.

Because the result set is potentially large, callers should consider caching the returned data. You can use getResourceSubscriptionMD5(ContentContext) to determine when the cached data is stale.

Parameters:
context - identifies the resource requesting the data
pc - this method can potentially return a large set; this page control object allows the caller to page through that large set, as opposed to requesting the entire set in one large chunk
Returns:
the list of all package versions' metadata

getResourceSubscriptionMD5

String getResourceSubscriptionMD5(ContentContext context)
Gets the MD5 hash which identifies a resource "content subscription". This MD5 hash will change when any channel the resource is subscribed to has changed its contents (that is, if a package version was added/updated/removed from it).

Parameters:
context - identifies the resource requesting the data
Returns:
the MD5 of all package versions' metadata
See Also:
getPackageVersionMetadata(ContentContext, PageControl)


Copyright © 2008-2009 RHQ Project Advisory Board (Red Hat, Inc.). All Rights Reserved.