org.rhq.enterprise.server.content
Class ContentManagerBean

java.lang.Object
  extended by org.rhq.enterprise.server.content.ContentManagerBean
All Implemented Interfaces:
ContentManagerLocal, ContentManagerRemote

public class ContentManagerBean
extends Object
implements ContentManagerLocal, ContentManagerRemote

EJB that handles content subsystem interaction with resources, including content discovery reports and create/delete functionality.

Author:
Jason Dobies

Field Summary
 
Fields inherited from interface org.rhq.enterprise.server.content.ContentManagerLocal
UPLOAD_DISPLAY_VERSION, UPLOAD_FILE_INSTALL_DATE, UPLOAD_FILE_NAME, UPLOAD_FILE_SIZE, UPLOAD_MD5, UPLOAD_OWNER, UPLOAD_SHA256
 
Constructor Summary
ContentManagerBean()
           
 
Method Summary
 void checkForTimedOutRequests(org.rhq.core.domain.auth.Subject subject)
          For internal use only - Will check to see if any in progress content request jobs are taking too long to finish and if so marks them as failed.
 void completeDeletePackageRequest(org.rhq.core.domain.content.transfer.RemovePackagesResponse response)
          For documentation, see ContentServerService.completeDeletePackageRequest(org.rhq.core.domain.content.transfer.RemovePackagesResponse) .
 void completeDeployPackageRequest(org.rhq.core.domain.content.transfer.DeployPackagesResponse response)
          For documentation, see ContentServerService.completeDeployPackageRequest(org.rhq.core.domain.content.transfer.DeployPackagesResponse) .
 void completeRetrievePackageBitsRequest(ContentServiceResponse response, InputStream bitStream)
          For documentation, see ContentServerService.completeRetrievePackageBitsRequest(org.rhq.core.clientapi.server.content.ContentServiceResponse, java.io.InputStream) )}.
 org.rhq.core.domain.content.ContentServiceRequest createDeployRequest(int resourceId, String username, Set<org.rhq.core.domain.content.transfer.ResourcePackageDetails> packages, String notes)
          For internal use only - Adds a request entry to the database to track the deployment of a group of packages.
 org.rhq.core.domain.content.PackageVersion createPackageVersion(org.rhq.core.domain.auth.Subject subject, String packageName, int packageTypeId, String version, Integer architectureId, byte[] packageBytes)
          Creates a new package version in the system.
 org.rhq.core.domain.content.PackageVersion createPackageVersionWithDisplayVersion(org.rhq.core.domain.auth.Subject subject, String packageName, int packageTypeId, String version, String displayVersion, Integer architectureId, byte[] packageBytes)
          Creates a new package version in the system.
 org.rhq.core.domain.content.PackageVersion createPackageVersionWithDisplayVersion(org.rhq.core.domain.auth.Subject subject, String packageName, int packageTypeId, String version, String displayVersion, int architectureId, InputStream packageBitStream)
          Creates a new package version in the system.
 org.rhq.core.domain.content.ContentServiceRequest createRemoveRequest(int resourceId, String username, int[] installedPackageIds, String requestNotes)
          For internal use only - Adds a request entry to the database to track the deleting of currently installed packages from the resource.
 org.rhq.core.domain.content.ContentServiceRequest createRetrieveBitsRequest(int resourceId, String username, int installedPackageId)
          For internal use only - Adds a request entry to the database to track the request for a package's bits.
 void deletePackages(org.rhq.core.domain.auth.Subject user, int[] resourceIds, int[] installedPackageIds)
          Deletes the specified package from the resource.
 void deletePackages(org.rhq.core.domain.auth.Subject user, int resourceId, int[] installedPackageIds, String requestNotes)
          Deletes the specified package from the resource.
 void deletePackageVersion(org.rhq.core.domain.auth.Subject subject, int packageVersionId)
          Deletes the specified PackageVersion from the system.
 void deployPackages(org.rhq.core.domain.auth.Subject user, int[] resourceIds, int[] packageVersionIds)
          Deploys packages on the specified resources.
 void deployPackages(org.rhq.core.domain.auth.Subject user, int resourceId, Set<org.rhq.core.domain.content.transfer.ResourcePackageDetails> packages, String requestNotes)
          Deploys a package on the specified resource.
 void deployPackagesWithNote(org.rhq.core.domain.auth.Subject user, int[] resourceIds, int[] packageVersionIds, String requestNotes)
          Deploys packages on the specified resources.
 void failRequest(int requestId, Throwable error)
          For internal use only - Updates a persisted ContentServiceRequest in the case a failure is encountered during one of the use case methods (i.e.
 List<org.rhq.core.domain.content.Architecture> findArchitectures(org.rhq.core.domain.auth.Subject subject)
          Returns all architectures known to the system.
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.InstalledPackage> findInstalledPackagesByCriteria(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.criteria.InstalledPackageCriteria criteria)
           
 List<String> findInstalledPackageVersions(org.rhq.core.domain.auth.Subject user, int resourceId)
          Returns list of version strings for installed packages on the resource.
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.Package> findPackagesByCriteria(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.criteria.PackageCriteria criteria)
          If the criteria object filters on repo id, the subject needs to be able to access that repo.
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.composite.PackageAndLatestVersionComposite> findPackagesWithLatestVersion(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.criteria.PackageCriteria criteria)
          Akin to ContentManagerRemote.findPackagesByCriteria(Subject, PackageCriteria) but also determines the latest version of the returned packages.
 org.rhq.core.domain.content.PackageType findPackageType(org.rhq.core.domain.auth.Subject subject, Integer resourceTypeId, String packageTypeName)
          This re tries to find a package type of given name defined by the resource type provided.
 List<org.rhq.core.domain.content.PackageType> findPackageTypes(org.rhq.core.domain.auth.Subject subject, String resourceTypeName, String pluginName)
          This gets the package types that can be deployed to the given resource.
 org.rhq.core.domain.content.composite.PackageTypeAndVersionFormatComposite findPackageTypeWithVersionFormat(org.rhq.core.domain.auth.Subject subject, Integer resourceTypeId, String packageTypeName)
          Similar to ContentManagerRemote.findPackageType(Subject, Integer, String) but returns the package type along with the version format specification.
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.PackageVersion> findPackageVersionsByCriteria(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.criteria.PackageVersionCriteria criteria)
          If a resourceId filter is not set via PackageVersionCriteria.addFilterResourceId() then this method requires InventoryManager permissions.
 org.rhq.core.domain.content.InstalledPackage getBackingPackageForResource(org.rhq.core.domain.auth.Subject subject, int resourceId)
          For a resource that is content-backed (aka package-backed), this call will return InstalledPackage information for the backing content (package).
 org.rhq.core.domain.content.Architecture getNoArchitecture()
          Returns the entity associated with no architecture.
 byte[] getPackageBytes(org.rhq.core.domain.auth.Subject user, int resourceId, int installedPackageId)
          This can be a dangerous call for large packages as the entire package will attempt to be loaded.
 org.rhq.core.domain.content.PackageType getResourceCreationPackageType(int resourceTypeId)
          Returns the package type that backs resources of the specified type.
 org.rhq.core.domain.content.PackageVersion getUploadedPackageVersion(org.rhq.core.domain.auth.Subject subject, String packageName, int packageTypeId, String version, int architectureId, InputStream packageBitStream, Map<String,String> packageUploadDetails, Integer repoId)
          Does much of same functionality as createPackageVersion, but uses same named query as the agent side discovery mechanism, and passes in additional parameters available when file has been uploaded via the UI.
 Set<org.rhq.core.domain.content.transfer.ResourcePackageDetails> loadDependencies(int requestId, Set<org.rhq.core.domain.content.PackageDetailsKey> keys)
          For documentation, see ContentServerService.loadDependencies(int, java.util.Set)
 void mergeDiscoveredPackages(ContentDiscoveryReport report)
          For documentation, see ContentServerService.mergeDiscoveredPackages(org.rhq.core.clientapi.server.content.ContentDiscoveryReport) .
 org.rhq.core.domain.content.Package persistOrMergePackageSafely(org.rhq.core.domain.content.Package pkg)
          Finds, and if it doesn't exist, persists the package.
 org.rhq.core.domain.content.PackageVersion persistOrMergePackageVersionSafely(org.rhq.core.domain.content.PackageVersion pv)
          Finds, and if it doesn't exist, persists the package version.
 org.rhq.core.domain.content.Package persistPackage(org.rhq.core.domain.content.Package pkg)
          Very simple method that pesists the given package within its own transaction.
 org.rhq.core.domain.content.PackageVersion persistPackageVersion(org.rhq.core.domain.content.PackageVersion pv)
          Very simple method that persists the given package version within its own transaction.
 org.rhq.core.domain.content.PackageType persistServersidePackageType(org.rhq.core.domain.content.PackageType packageType)
          This method is used to persist new package types that are defined on the server-side by some kind of plugin.
 void retrieveBitsFromResource(org.rhq.core.domain.auth.Subject user, int resourceId, int installedPackageId)
          Requests the plugin load and send the actual bits for the specified package.
 List<org.rhq.core.domain.content.transfer.DeployPackageStep> translateInstallationSteps(int resourceId, org.rhq.core.domain.content.transfer.ResourcePackageDetails packageDetails)
          Requests the plugin translate the installation steps of the specified package.
 void updateBlobStream(InputStream stream, org.rhq.core.domain.content.PackageBits bits, Map<String,String> contentDetails)
          Takes an input stream and copies it into the PackageBits table using Hibernate Blob mechanism with PreparedStatements.
 void writeBlobOutToStream(OutputStream stream, org.rhq.core.domain.content.PackageBits bits, boolean closeStreams)
          For Testing only

Writes the contents of a the Blob out to the stream passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentManagerBean

public ContentManagerBean()
Method Detail

mergeDiscoveredPackages

public void mergeDiscoveredPackages(ContentDiscoveryReport report)
Description copied from interface: ContentManagerLocal
For documentation, see ContentServerService.mergeDiscoveredPackages(org.rhq.core.clientapi.server.content.ContentDiscoveryReport) .

Specified by:
mergeDiscoveredPackages in interface ContentManagerLocal

deployPackages

public void deployPackages(org.rhq.core.domain.auth.Subject user,
                           int[] resourceIds,
                           int[] packageVersionIds)
Description copied from interface: ContentManagerRemote
Deploys packages on the specified resources. Each installed package entry should be populated with the PackageVersion being installed, along with the deployment configuration values if any. This method will take care of populating the rest of the values in each installed package object.

Specified by:
deployPackages in interface ContentManagerRemote
Parameters:
user - The logged in subject
resourceIds - identifies the resources against which the package will be deployed
packageVersionIds - packageVersions we want to install

deployPackagesWithNote

public void deployPackagesWithNote(org.rhq.core.domain.auth.Subject user,
                                   int[] resourceIds,
                                   int[] packageVersionIds,
                                   String requestNotes)
Description copied from interface: ContentManagerRemote
Deploys packages on the specified resources. Each installed package entry should be populated with the PackageVersion being installed, along with the deployment configuration values if any. This method will take care of populating the rest of the values in each installed package object.

Specified by:
deployPackagesWithNote in interface ContentManagerLocal
Specified by:
deployPackagesWithNote in interface ContentManagerRemote
Parameters:
user - The logged in subject
resourceIds - identifies the resources against which the package will be deployed
packageVersionIds - packageVersions we want to install
requestNotes - request notes
See Also:
ContentManagerRemote#deployPackagesWithNote(Subject, int[], int[], String)}

deployPackages

public void deployPackages(org.rhq.core.domain.auth.Subject user,
                           int resourceId,
                           Set<org.rhq.core.domain.content.transfer.ResourcePackageDetails> packages,
                           String requestNotes)
Description copied from interface: ContentManagerLocal
Deploys a package on the specified resource. Each installed package entry should be populated with the PackageVersion being installed, along with the deployment configuration values if any. This method will take care of populating the rest of the values in each installed package object.

Specified by:
deployPackages in interface ContentManagerLocal
Parameters:
user - the user who is requesting the creation
resourceId - identifies the resource against which the package will be deployed
packages - packages (with their deployment time configuration values) to deploy
requestNotes - user-specified notes on what is contained in this request

createDeployRequest

public org.rhq.core.domain.content.ContentServiceRequest createDeployRequest(int resourceId,
                                                                             String username,
                                                                             Set<org.rhq.core.domain.content.transfer.ResourcePackageDetails> packages,
                                                                             String notes)
Description copied from interface: ContentManagerLocal
For internal use only - Adds a request entry to the database to track the deployment of a group of packages. This will be performed in a new transaction.

Specified by:
createDeployRequest in interface ContentManagerLocal
Parameters:
resourceId - resource against which the package request was executed
username - user who made the request
packages - packages being deployed in the request
notes - user-specified notes on what the request entails
Returns:
request entity after being persisted to the database (it's ID will be populated)

completeDeployPackageRequest

public void completeDeployPackageRequest(org.rhq.core.domain.content.transfer.DeployPackagesResponse response)
Description copied from interface: ContentManagerLocal
For documentation, see ContentServerService.completeDeployPackageRequest(org.rhq.core.domain.content.transfer.DeployPackagesResponse) .

Specified by:
completeDeployPackageRequest in interface ContentManagerLocal

deletePackages

public void deletePackages(org.rhq.core.domain.auth.Subject user,
                           int[] resourceIds,
                           int[] installedPackageIds)
Description copied from interface: ContentManagerLocal
Deletes the specified package from the resource.

Specified by:
deletePackages in interface ContentManagerLocal
Parameters:
user - the user who is requesting the delete
resourceIds - identifies the resources from which the packages should be deleted
installedPackageIds - identifies all of the packages to be deleted

deletePackages

public void deletePackages(org.rhq.core.domain.auth.Subject user,
                           int resourceId,
                           int[] installedPackageIds,
                           String requestNotes)
Description copied from interface: ContentManagerRemote
Deletes the specified package from the resource.

Specified by:
deletePackages in interface ContentManagerLocal
Specified by:
deletePackages in interface ContentManagerRemote
Parameters:
user - The logged in subject
resourceId - identifies the resource from which the packages should be deleted
installedPackageIds - identifies all of the packages to be deleted
See Also:
ContentManagerRemote#deletePackages(Subject, int, int[], String)}

deletePackageVersion

public void deletePackageVersion(org.rhq.core.domain.auth.Subject subject,
                                 int packageVersionId)
Description copied from interface: ContentManagerRemote
Deletes the specified PackageVersion from the system. The PackageVersion must be an orphan to be deleted. If it is referenced by a content source, repo or installed package it must be removed via the higher level construct and this call will have no effect.

Specified by:
deletePackageVersion in interface ContentManagerLocal
Specified by:
deletePackageVersion in interface ContentManagerRemote
Parameters:
subject - The logged in subject
See Also:
ContentManagerRemote#deletePackageVersion(Subject, int)}

createRemoveRequest

public org.rhq.core.domain.content.ContentServiceRequest createRemoveRequest(int resourceId,
                                                                             String username,
                                                                             int[] installedPackageIds,
                                                                             String requestNotes)
Description copied from interface: ContentManagerLocal
For internal use only - Adds a request entry to the database to track the deleting of currently installed packages from the resource. This will be performed in a new transaction.

Specified by:
createRemoveRequest in interface ContentManagerLocal
Parameters:
resourceId - resource against which the package request was executed
username - user who made the request
installedPackageIds - identifies the installed packages that are to be deleted; ids in this list must be of valid InstalledPackage objects on the resource
requestNotes - user-specified notes on what the request entails
Returns:
request entity after being persisted to the database (it's ID will be populated)

completeDeletePackageRequest

public void completeDeletePackageRequest(org.rhq.core.domain.content.transfer.RemovePackagesResponse response)
Description copied from interface: ContentManagerLocal
For documentation, see ContentServerService.completeDeletePackageRequest(org.rhq.core.domain.content.transfer.RemovePackagesResponse) .

Specified by:
completeDeletePackageRequest in interface ContentManagerLocal

retrieveBitsFromResource

public void retrieveBitsFromResource(org.rhq.core.domain.auth.Subject user,
                                     int resourceId,
                                     int installedPackageId)
Description copied from interface: ContentManagerLocal
Requests the plugin load and send the actual bits for the specified package.

Specified by:
retrieveBitsFromResource in interface ContentManagerLocal
Parameters:
user - the user who is requesting the update
resourceId - identifies the resource against which the package exists
installedPackageId - id of the installed package to retrieve bits

getPackageBytes

public byte[] getPackageBytes(org.rhq.core.domain.auth.Subject user,
                              int resourceId,
                              int installedPackageId)
Description copied from interface: ContentManagerRemote
This can be a dangerous call for large packages as the entire package will attempt to be loaded.

Specified by:
getPackageBytes in interface ContentManagerLocal
Specified by:
getPackageBytes in interface ContentManagerRemote
Returns:
the package bytes
See Also:
ContentManagerRemote#getPackageBytes(Subject, int, int)

translateInstallationSteps

public List<org.rhq.core.domain.content.transfer.DeployPackageStep> translateInstallationSteps(int resourceId,
                                                                                               org.rhq.core.domain.content.transfer.ResourcePackageDetails packageDetails)
                                                                                        throws Exception
Description copied from interface: ContentManagerLocal
Requests the plugin translate the installation steps of the specified package.

Specified by:
translateInstallationSteps in interface ContentManagerLocal
Parameters:
resourceId - resource against which the package is being installed
packageDetails - package being installed
Returns:
list of deployment steps if the plugin specified them; null if they cannot be determined for this package
Throws:
Exception - if there is an error either contacting the agent or in the plugin's generation of the steps

createRetrieveBitsRequest

public org.rhq.core.domain.content.ContentServiceRequest createRetrieveBitsRequest(int resourceId,
                                                                                   String username,
                                                                                   int installedPackageId)
Description copied from interface: ContentManagerLocal
For internal use only - Adds a request entry to the database to track the request for a package's bits. This will be performed in a new transaction.

Specified by:
createRetrieveBitsRequest in interface ContentManagerLocal
Parameters:
resourceId - resource against which the package request was executed
username - user who made the request
installedPackageId - package whose bits are being retrieved by the request; this must be the ID of a valid InstalledPackage on the resource.
Returns:
request entity after being persisted to the database (it's ID will be populated)

completeRetrievePackageBitsRequest

public void completeRetrievePackageBitsRequest(ContentServiceResponse response,
                                               InputStream bitStream)
Description copied from interface: ContentManagerLocal
For documentation, see ContentServerService.completeRetrievePackageBitsRequest(org.rhq.core.clientapi.server.content.ContentServiceResponse, java.io.InputStream) )}.

Specified by:
completeRetrievePackageBitsRequest in interface ContentManagerLocal

loadDependencies

public Set<org.rhq.core.domain.content.transfer.ResourcePackageDetails> loadDependencies(int requestId,
                                                                                         Set<org.rhq.core.domain.content.PackageDetailsKey> keys)
Description copied from interface: ContentManagerLocal
For documentation, see ContentServerService.loadDependencies(int, java.util.Set)

Specified by:
loadDependencies in interface ContentManagerLocal

failRequest

public void failRequest(int requestId,
                        Throwable error)
Description copied from interface: ContentManagerLocal
For internal use only - Updates a persisted ContentServiceRequest in the case a failure is encountered during one of the use case methods (i.e. create, delete).

Specified by:
failRequest in interface ContentManagerLocal
Parameters:
requestId - identifies the previously persisted request
error - error encountered to cause the failure

findArchitectures

public List<org.rhq.core.domain.content.Architecture> findArchitectures(org.rhq.core.domain.auth.Subject subject)
Description copied from interface: ContentManagerRemote
Returns all architectures known to the system.

Specified by:
findArchitectures in interface ContentManagerLocal
Specified by:
findArchitectures in interface ContentManagerRemote
Parameters:
subject - The logged in subject
Returns:
list of all architectures in the database
See Also:
ContentManagerRemote#findArchitectures(Subject)}

getNoArchitecture

public org.rhq.core.domain.content.Architecture getNoArchitecture()
Description copied from interface: ContentManagerLocal
Returns the entity associated with no architecture.

Specified by:
getNoArchitecture in interface ContentManagerLocal
Returns:
no architecture entity

findPackageTypes

public List<org.rhq.core.domain.content.PackageType> findPackageTypes(org.rhq.core.domain.auth.Subject subject,
                                                                      String resourceTypeName,
                                                                      String pluginName)
                                                               throws ResourceTypeNotFoundException
Description copied from interface: ContentManagerRemote
This gets the package types that can be deployed to the given resource. It is a function of the resource type of the resource.

Specified by:
findPackageTypes in interface ContentManagerLocal
Specified by:
findPackageTypes in interface ContentManagerRemote
Parameters:
subject - The logged in subject
resourceTypeName - The resource type in question
Returns:
The requested list of package types. Can be empty.
Throws:
ResourceTypeNotFoundException
See Also:
ContentManagerRemote#findPackageTypes(Subject, String, String)}

findPackageType

public org.rhq.core.domain.content.PackageType findPackageType(org.rhq.core.domain.auth.Subject subject,
                                                               Integer resourceTypeId,
                                                               String packageTypeName)
Description copied from interface: ContentManagerRemote
This re tries to find a package type of given name defined by the resource type provided.

The resource type id can be null, in which case only the serverside defined package types are searched for.

Specified by:
findPackageType in interface ContentManagerLocal
Specified by:
findPackageType in interface ContentManagerRemote
Parameters:
subject - the authenticated user
resourceTypeId - the id of the resource type associated with the package type or null if only server-side package types should be searched for
packageTypeName - the name of the package type to find
Returns:
See Also:
ContentManagerRemote#findPackageType(Subject, Integer, String)}

findPackageTypeWithVersionFormat

public org.rhq.core.domain.content.composite.PackageTypeAndVersionFormatComposite findPackageTypeWithVersionFormat(org.rhq.core.domain.auth.Subject subject,
                                                                                                                   Integer resourceTypeId,
                                                                                                                   String packageTypeName)
Description copied from interface: ContentManagerRemote
Similar to ContentManagerRemote.findPackageType(Subject, Integer, String) but returns the package type along with the version format specification.

Specified by:
findPackageTypeWithVersionFormat in interface ContentManagerLocal
Specified by:
findPackageTypeWithVersionFormat in interface ContentManagerRemote
Returns:
See Also:
ContentManagerRemote#findPackageTypeWithVersionFormat(Subject, Integer, String)}

checkForTimedOutRequests

public void checkForTimedOutRequests(org.rhq.core.domain.auth.Subject subject)
Description copied from interface: ContentManagerLocal
For internal use only - Will check to see if any in progress content request jobs are taking too long to finish and if so marks them as failed. This method will be periodically called by the Server.

Specified by:
checkForTimedOutRequests in interface ContentManagerLocal
Parameters:
subject - only the overlord may execute this system operation

createPackageVersion

public org.rhq.core.domain.content.PackageVersion createPackageVersion(org.rhq.core.domain.auth.Subject subject,
                                                                       String packageName,
                                                                       int packageTypeId,
                                                                       String version,
                                                                       Integer architectureId,
                                                                       byte[] packageBytes)
Description copied from interface: ContentManagerRemote
Creates a new package version in the system. If the parent package (identified by the packageName parameter) does not exist, it will be created. If a package version exists with the specified version ID, a new one will not be created and the existing package version instance will be returned.

Specified by:
createPackageVersion in interface ContentManagerLocal
Specified by:
createPackageVersion in interface ContentManagerRemote
Parameters:
subject - The logged in subject
packageName - parent package name; uniquely identifies the package under which this version goes
packageTypeId - identifies the type of package in case the general package needs to be created
version - identifies the version to be create
architectureId - architecture of the newly created package version. If null then no architecture restriction.
Returns:
newly created package version if one did not exist; existing package version that matches these data if one was found
See Also:
createPackageVersion(Subject, String, int, String, int, byte[]);

createPackageVersionWithDisplayVersion

public org.rhq.core.domain.content.PackageVersion createPackageVersionWithDisplayVersion(org.rhq.core.domain.auth.Subject subject,
                                                                                         String packageName,
                                                                                         int packageTypeId,
                                                                                         String version,
                                                                                         String displayVersion,
                                                                                         Integer architectureId,
                                                                                         byte[] packageBytes)
Description copied from interface: ContentManagerRemote
Creates a new package version in the system. If the parent package (identified by the packageName parameter) does not exist, it will be created. If a package version exists with the specified version ID, a new one will not be created and the existing package version instance will be returned.

Specified by:
createPackageVersionWithDisplayVersion in interface ContentManagerLocal
Specified by:
createPackageVersionWithDisplayVersion in interface ContentManagerRemote
Parameters:
subject - The logged in subject
packageName - parent package name; uniquely identifies the package under which this version goes
packageTypeId - identifies the type of package in case the general package needs to be created
version - identifies the version to be create
architectureId - architecture of the newly created package version. If null then no architecture restriction.
Returns:
newly created package version if one did not exist; existing package version that matches these data if one was found
See Also:
createPackageVersion(Subject, String, int, String, int, byte[]);

createPackageVersionWithDisplayVersion

public org.rhq.core.domain.content.PackageVersion createPackageVersionWithDisplayVersion(org.rhq.core.domain.auth.Subject subject,
                                                                                         String packageName,
                                                                                         int packageTypeId,
                                                                                         String version,
                                                                                         String displayVersion,
                                                                                         int architectureId,
                                                                                         InputStream packageBitStream)
Description copied from interface: ContentManagerLocal
Creates a new package version in the system. If the parent package (identified by the packageName parameter) does not exist, it will be created. If a package version exists with the specified version ID, a new one will not be created and the existing package version instance will be returned.

Specified by:
createPackageVersionWithDisplayVersion in interface ContentManagerLocal
Parameters:
subject - the user requesting the package creation
packageName - parent package name; uniquely identifies the package under which this version goes
packageTypeId - identifies the type of package in case the general package needs to be created
version - identifies the version to be create
displayVersion - package display version
architectureId - architecture of the newly created package version
Returns:
newly created package version if one did not exist; existing package version that matches these data if one was found

persistPackageVersion

public org.rhq.core.domain.content.PackageVersion persistPackageVersion(org.rhq.core.domain.content.PackageVersion pv)
Description copied from interface: ContentManagerLocal
Very simple method that persists the given package version within its own transaction.

This method is here to support ContentManagerLocal.persistOrMergePackageVersionSafely(PackageVersion), it is not meant for general consumption.

Specified by:
persistPackageVersion in interface ContentManagerLocal
Parameters:
pv - the package version to persist
Returns:
the newly persisted package version

persistOrMergePackageVersionSafely

public org.rhq.core.domain.content.PackageVersion persistOrMergePackageVersionSafely(org.rhq.core.domain.content.PackageVersion pv)
Description copied from interface: ContentManagerLocal
Finds, and if it doesn't exist, persists the package version. If it already exists, it will return the merge the given PV with the object it found and return the merged PV. This performs its tasks safely; that is, it makes sure that no contraint violations occur if the package version already exists.

This method is for a very specific use case - that is, when creating a package version in a place where, concurrently, someone else might try to create the same package version. It is not for general persisting/merging of package versions.

Specified by:
persistOrMergePackageVersionSafely in interface ContentManagerLocal
Parameters:
pv - the package version to find and possibly persist to the database
Returns:
the package version that was found/persisted

persistPackage

public org.rhq.core.domain.content.Package persistPackage(org.rhq.core.domain.content.Package pkg)
Description copied from interface: ContentManagerLocal
Very simple method that pesists the given package within its own transaction.

This method is here to support ContentManagerLocal.persistOrMergePackageSafely(Package), it is not meant for general consumption.

Specified by:
persistPackage in interface ContentManagerLocal
Parameters:
pkg - the package to persist
Returns:
the newly persisted package

persistOrMergePackageSafely

public org.rhq.core.domain.content.Package persistOrMergePackageSafely(org.rhq.core.domain.content.Package pkg)
Description copied from interface: ContentManagerLocal
Finds, and if it doesn't exist, persists the package. If it already exists, it will return the merge the given package with the object it found and return the merged package. This performs its tasks safely; that is, it makes sure that no contraint violations occur if the package already exists.

This method is for a very specific use case - that is, when creating a package in a place where, concurrently, someone else might try to create the same package. It is not for general persisting/merging of packages.

Specified by:
persistOrMergePackageSafely in interface ContentManagerLocal
Parameters:
pkg - the package to find and possibly persist to the database
Returns:
the package that was found/persisted

getResourceCreationPackageType

public org.rhq.core.domain.content.PackageType getResourceCreationPackageType(int resourceTypeId)
Description copied from interface: ContentManagerLocal
Returns the package type that backs resources of the specified type.

Specified by:
getResourceCreationPackageType in interface ContentManagerLocal
Parameters:
resourceTypeId - identifies the resource type.
Returns:
backing package type if one exists; null otherwise

findInstalledPackageVersions

public List<String> findInstalledPackageVersions(org.rhq.core.domain.auth.Subject user,
                                                 int resourceId)
Description copied from interface: ContentManagerLocal
Returns list of version strings for installed packages on the resource.

Specified by:
findInstalledPackageVersions in interface ContentManagerLocal
Returns:
List of InstalledPackage versions

findInstalledPackagesByCriteria

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.InstalledPackage> findInstalledPackagesByCriteria(org.rhq.core.domain.auth.Subject subject,
                                                                                                                       org.rhq.core.domain.criteria.InstalledPackageCriteria criteria)
Specified by:
findInstalledPackagesByCriteria in interface ContentManagerLocal
Specified by:
findInstalledPackagesByCriteria in interface ContentManagerRemote
criteria - InstalledPackageCriteria
Returns:
InstalledPackages for the criteria
See Also:
ContentManagerRemote#findInstalledPackagesByCriteria(Subject, InstalledPackageCriteria)}

findPackageVersionsByCriteria

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.PackageVersion> findPackageVersionsByCriteria(org.rhq.core.domain.auth.Subject subject,
                                                                                                                   org.rhq.core.domain.criteria.PackageVersionCriteria criteria)
Description copied from interface: ContentManagerRemote
If a resourceId filter is not set via PackageVersionCriteria.addFilterResourceId() then this method requires InventoryManager permissions. When set the user must have permission to view the resource.

Specified by:
findPackageVersionsByCriteria in interface ContentManagerLocal
Specified by:
findPackageVersionsByCriteria in interface ContentManagerRemote
Returns:
Installed PackageVersions for the resource
See Also:
ContentManagerRemote#findPackageVersionsByCriteria(Subject, PackageVersionCriteria)}

findPackagesByCriteria

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.Package> findPackagesByCriteria(org.rhq.core.domain.auth.Subject subject,
                                                                                                     org.rhq.core.domain.criteria.PackageCriteria criteria)
Description copied from interface: ContentManagerRemote
If the criteria object filters on repo id, the subject needs to be able to access that repo. If there is no filter on repos, the subject needs to have MANAGE_REPOSITORIES permission.

Specified by:
findPackagesByCriteria in interface ContentManagerLocal
Specified by:
findPackagesByCriteria in interface ContentManagerRemote
Returns:
See Also:
ContentManagerRemote.findPackagesByCriteria(Subject, PackageCriteria)

findPackagesWithLatestVersion

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.composite.PackageAndLatestVersionComposite> findPackagesWithLatestVersion(org.rhq.core.domain.auth.Subject subject,
                                                                                                                                               org.rhq.core.domain.criteria.PackageCriteria criteria)
Description copied from interface: ContentManagerRemote
Akin to ContentManagerRemote.findPackagesByCriteria(Subject, PackageCriteria) but also determines the latest version of the returned packages.

The provided criteria has to be limited to a specific repo using PackageCriteria.addFilterRepoId(Integer).

Specified by:
findPackagesWithLatestVersion in interface ContentManagerLocal
Specified by:
findPackagesWithLatestVersion in interface ContentManagerRemote
Returns:
See Also:
ContentManagerRemote.findPackagesWithLatestVersion(Subject, PackageCriteria)

getBackingPackageForResource

public org.rhq.core.domain.content.InstalledPackage getBackingPackageForResource(org.rhq.core.domain.auth.Subject subject,
                                                                                 int resourceId)
Description copied from interface: ContentManagerRemote
For a resource that is content-backed (aka package-backed), this call will return InstalledPackage information for the backing content (package).

Specified by:
getBackingPackageForResource in interface ContentManagerLocal
Specified by:
getBackingPackageForResource in interface ContentManagerRemote
resourceId - a valid resource
Returns:
The InstalledPackage object for the content-packed resource. Or null for non-existent or non-package backed resource.
See Also:
ContentManagerRemote#getBackingPackageForResource(Subject, int)

getUploadedPackageVersion

public org.rhq.core.domain.content.PackageVersion getUploadedPackageVersion(org.rhq.core.domain.auth.Subject subject,
                                                                            String packageName,
                                                                            int packageTypeId,
                                                                            String version,
                                                                            int architectureId,
                                                                            InputStream packageBitStream,
                                                                            Map<String,String> packageUploadDetails,
                                                                            Integer repoId)
Does much of same functionality as createPackageVersion, but uses same named query as the agent side discovery mechanism, and passes in additional parameters available when file has been uploaded via the UI.

Specified by:
getUploadedPackageVersion in interface ContentManagerLocal
Parameters:
subject - the current user
packageName - the name of the package (the general package will be created if none exists)
packageTypeId - the id of the package type. This is ignored if the newResourceTypeId is not null
version - the version of the package version being created
architectureId - the architecture of the package version
packageBitStream - the input stream with the package bits
packageUploadDetails - additional details about the package. See the constants defined in this interface
repoId - an optional id of the repo to insert the package version in
Returns:
the newly create package version

persistServersidePackageType

public org.rhq.core.domain.content.PackageType persistServersidePackageType(org.rhq.core.domain.content.PackageType packageType)
Description copied from interface: ContentManagerLocal
This method is used to persist new package types that are defined on the server-side by some kind of plugin.

Server-side package types are used to identify data stored in the content subsystem which don't have any agent-side counter-part. Such package types are required to have the resource type set to null.

Specified by:
persistServersidePackageType in interface ContentManagerLocal
Parameters:
packageType - the package type to persist
Returns:
the persisted package type

updateBlobStream

public void updateBlobStream(InputStream stream,
                             org.rhq.core.domain.content.PackageBits bits,
                             Map<String,String> contentDetails)
Takes an input stream and copies it into the PackageBits table using Hibernate Blob mechanism with PreparedStatements. As all content into Bits are not stored as type OID, t

Specified by:
updateBlobStream in interface ContentManagerLocal
Parameters:
stream -
contentDetails - Map to store content details in used in PackageVersioning

writeBlobOutToStream

public void writeBlobOutToStream(OutputStream stream,
                                 org.rhq.core.domain.content.PackageBits bits,
                                 boolean closeStreams)
For Testing only

Writes the contents of a the Blob out to the stream passed in.

Specified by:
writeBlobOutToStream in interface ContentManagerLocal
Parameters:
stream - non null stream where contents to be written to.


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