org.rhq.enterprise.server.content
Class ContentSourceManagerBean

java.lang.Object
  extended by org.rhq.enterprise.server.content.ContentSourceManagerBean
All Implemented Interfaces:
ContentSourceManagerLocal

public class ContentSourceManagerBean
extends Object
implements ContentSourceManagerLocal

A SLSB wrapper around our server-side content source plugin container. This bean provides access to the ContentSource objects deployed in the server, thus allows the callers to access data about and from remote content repositories.

Author:
John Mazzitelli

Field Summary
static String FILESYSTEM_PROPERTY
          The location we store the bits and distro files
 
Constructor Summary
ContentSourceManagerBean()
           
 
Method Summary
 org.rhq.core.domain.content.RepoSyncResults _mergeAdvisorySyncReportADD(org.rhq.core.domain.content.ContentSource contentSource, AdvisorySyncReport report, org.rhq.core.domain.content.RepoSyncResults syncResults, StringBuilder progress)
           
 org.rhq.core.domain.content.RepoSyncResults _mergeAdvisorySyncReportREMOVE(org.rhq.core.domain.content.ContentSource contentSource, AdvisorySyncReport report, org.rhq.core.domain.content.RepoSyncResults syncResults, StringBuilder progress)
           
 org.rhq.core.domain.content.RepoSyncResults _mergeDistributionSyncReportADD(org.rhq.core.domain.content.ContentSource contentSource, DistributionSyncReport report, org.rhq.core.domain.content.RepoSyncResults syncResults, StringBuilder progress)
           
 org.rhq.core.domain.content.RepoSyncResults _mergeDistributionSyncReportREMOVE(org.rhq.core.domain.content.ContentSource contentSource, DistributionSyncReport report, org.rhq.core.domain.content.RepoSyncResults syncResults, StringBuilder progress)
           
 org.rhq.core.domain.content.RepoSyncResults _mergePackageSyncReportADD(org.rhq.core.domain.content.ContentSource contentSource, org.rhq.core.domain.content.Repo repo, Collection<ContentProviderPackageDetails> newPackages, Map<ContentProviderPackageDetailsKey,org.rhq.core.domain.content.PackageVersionContentSource> previous, org.rhq.core.domain.content.RepoSyncResults syncResults, StringBuilder progress, int addCount)
           
 org.rhq.core.domain.content.RepoSyncResults _mergePackageSyncReportREMOVE(org.rhq.core.domain.content.ContentSource contentSource, org.rhq.core.domain.content.Repo repo, PackageSyncReport report, Map<ContentProviderPackageDetailsKey,org.rhq.core.domain.content.PackageVersionContentSource> previous, org.rhq.core.domain.content.RepoSyncResults syncResults, StringBuilder progress)
           
 org.rhq.core.domain.content.RepoSyncResults _mergePackageSyncReportUPDATE(org.rhq.core.domain.content.ContentSource contentSource, PackageSyncReport report, Map<ContentProviderPackageDetailsKey,org.rhq.core.domain.content.PackageVersionContentSource> previous, org.rhq.core.domain.content.RepoSyncResults syncResults, StringBuilder progress)
           
 void _mergePackageSyncReportUpdateRepo(int contentSourceId)
           
 org.rhq.core.domain.content.ContentSource createContentSource(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.content.ContentSource contentSource)
          Create the specified content source.
 void deleteContentSource(org.rhq.core.domain.auth.Subject subject, int contentSourceId)
          Deletes the identified content source.
 void deleteContentSourceSyncResults(org.rhq.core.domain.auth.Subject subject, int[] ids)
          Allow a user to purge content source sync results.
 void downloadDistributionBits(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.content.ContentSource contentSource)
          This will download all the distribution bits associated with a specific content source.
 boolean downloadPackageBits(int resourceId, org.rhq.core.domain.content.PackageDetailsKey packageDetailsKey)
          This will download the actual package bits for that package version from that content source's remote repository.
 org.rhq.core.domain.content.PackageBits downloadPackageBits(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.content.PackageVersionContentSource pvcs)
          Given a PackageVersionContentSource which contains the ID of a content source, an ID of a package version, and the location of that package version on the remote content source repo, this will download the actual package bits for that package version from that content source's remote repository.
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.ContentSource> getAllContentSources(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.util.PageControl pc)
          Returns all ContentSource objects that are configured in the system.
 Set<org.rhq.core.domain.content.ContentSourceType> getAllContentSourceTypes()
          Returns all ContentSourceType objects that are configured in the system.
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.Repo> getAssociatedRepos(org.rhq.core.domain.auth.Subject subject, int contentSourceId, org.rhq.core.domain.util.PageControl pc)
          Gets the list of imported repos that are associated with a given content source.
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.ContentSource> getAvailableContentSourcesForRepo(org.rhq.core.domain.auth.Subject subject, Integer repoId, org.rhq.core.domain.util.PageControl pc)
          Returns all ContentSource objects that are configured in the system but not presently associated with the repo identified by repoId
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.Repo> getCandidateRepos(org.rhq.core.domain.auth.Subject subject, int contentSourceId, org.rhq.core.domain.util.PageControl pc)
          Gets the list of candidate repos that are associated with a given content source.
 org.rhq.core.domain.content.ContentSource getContentSource(org.rhq.core.domain.auth.Subject subject, int contentSourceId)
          Returns the ContentSource from its ID.
 org.rhq.core.domain.content.ContentSource getContentSourceByNameAndType(org.rhq.core.domain.auth.Subject subject, String name, String typeName)
          Get a ContentSource by name and ContentSourceType name.
 org.rhq.core.domain.content.ContentSourceSyncResults getContentSourceSyncResults(int resultsId)
          Returns the full sync results object.
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.ContentSourceSyncResults> getContentSourceSyncResults(org.rhq.core.domain.auth.Subject subject, int contentSourceId, org.rhq.core.domain.util.PageControl pc)
          Allows the caller to page through a list of historical sync results for a content source.
 org.rhq.core.domain.content.ContentSourceType getContentSourceType(String name)
          Get a ContentSourceType by name.
 long getPackageBitsLength(int resourceId, org.rhq.core.domain.content.PackageDetailsKey packageDetailsKey)
          Returns the length of the package version identified by its PackageDetailsKey.
 long getPackageVersionCountFromContentSource(org.rhq.core.domain.auth.Subject subject, int contentSourceId)
          Returns count of PackageVersions associated with the given content source.
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.composite.PackageVersionMetadataComposite> getPackageVersionMetadata(int resourceId, org.rhq.core.domain.util.PageControl pc)
          Requests all metadata for all package versions that the given resource component is subscribed to (see Repo.getResources().
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.PackageVersionContentSource> getPackageVersionsFromContentSource(org.rhq.core.domain.auth.Subject subject, int contentSourceId, org.rhq.core.domain.util.PageControl pc)
          Returns all the package versions that are served by the content source identified by the given ID.
 List<org.rhq.core.domain.content.PackageVersionContentSource> getPackageVersionsFromContentSourceForRepo(org.rhq.core.domain.auth.Subject subject, int contentSourceId, int repoId)
          Returns all packages from the given repo.
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.PackageVersionContentSource> getPackageVersionsFromContentSources(org.rhq.core.domain.auth.Subject subject, int[] contentSourceIds, org.rhq.core.domain.util.PageControl pc)
          Returns all the package versions that are served by all the content sources identified by the given IDs.
 String getResourceSubscriptionMD5(int resourceId)
          Gets the MD5 hash which identifies a resource "content subscription".
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.PackageVersionContentSource> getUnloadedPackageVersionsFromContentSourceInRepo(org.rhq.core.domain.auth.Subject subject, int contentSourceId, int repoId, org.rhq.core.domain.util.PageControl pc)
          Returns all the package versions that are served by the content source identified by the given ID but whose package bits have not been loaded yet.
 boolean internalSynchronizeContentSource(int contentSourceId)
          Requests that the identified content source be synchronized.
 org.rhq.core.domain.content.RepoSyncResults mergeAdvisorySyncReport(org.rhq.core.domain.content.ContentSource contentSource, AdvisorySyncReport report, org.rhq.core.domain.content.RepoSyncResults syncResults)
          After a sync has happened, this is responsible for persisting the results.
 org.rhq.core.domain.content.ContentSourceSyncResults mergeContentSourceSyncResults(org.rhq.core.domain.content.ContentSourceSyncResults results)
          Updates an existing sync results object.
 org.rhq.core.domain.content.RepoSyncResults mergeDistributionSyncReport(org.rhq.core.domain.content.ContentSource contentSource, DistributionSyncReport report, org.rhq.core.domain.content.RepoSyncResults syncResults)
          After a sync has happened, this is responsible for persisting the results.
 org.rhq.core.domain.content.RepoSyncResults mergePackageSyncReport(org.rhq.core.domain.content.ContentSource contentSource, org.rhq.core.domain.content.Repo repo, PackageSyncReport report, Map<ContentProviderPackageDetailsKey,org.rhq.core.domain.content.PackageVersionContentSource> previous, org.rhq.core.domain.content.RepoSyncResults syncResults)
          After a sync has happened, this is responsible for persisting the results.
 void mergeRepoImportResults(List<RepoDetails> repos)
          Updates the server with the results of a repo import from a content source.
 long outputDistributionFileBits(org.rhq.core.domain.content.DistributionFile distFile, OutputStream outputStream)
          Requests the bits of a distribution file be streamed down to the caller over the given output stream.
 long outputPackageBitsForChildResource(int parentResourceId, String resourceTypeName, org.rhq.core.domain.content.PackageDetailsKey packageDetailsKey, OutputStream outputStream)
          Requests the bits of a package being used to create a child resource be stream down to the caller over the given output stream.
 long outputPackageVersionBits(org.rhq.core.domain.content.PackageVersion packageVersion, OutputStream outputStream)
          Requests the bits of a package be streamed down to the caller over the given output stream.
 long outputPackageVersionBits(org.rhq.core.domain.content.PackageVersion packageVersion, OutputStream outputStream, long startByte, long endByte)
          Requests a range of bits from a package.
 long outputPackageVersionBitsGivenResource(int resourceId, org.rhq.core.domain.content.PackageDetailsKey packageDetailsKey, OutputStream outputStream)
          Requests that the actual content data (the "bits") of the identified package version be streamed down to the caller over the given output stream that the caller provides.
 long outputPackageVersionBitsRangeGivenResource(int resourceId, org.rhq.core.domain.content.PackageDetailsKey packageDetailsKey, OutputStream outputStream, long startByte, long endByte)
          Requests that the actual content data (the "bits") of the identified package version be streamed down to the caller over the given output stream that the caller provides.
 org.rhq.core.domain.content.ContentSourceSyncResults persistContentSourceSyncResults(org.rhq.core.domain.content.ContentSourceSyncResults results)
          Creates a new sync results object.
 void purgeOrphanedPackageVersions(org.rhq.core.domain.auth.Subject subject)
          This will look for any PackageVersions that are "orphaned" (that is, is not related to any existing content source or repo and is not installed anywhere) and will remove any orphans that it finds.
 org.rhq.core.domain.content.ContentSource simpleCreateContentSource(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.content.ContentSource contentSource)
          Adds the specified content source to the database but does not attempt to create or start the server-side plugin provider implementation associated with it.
 void synchronizeAndLoadContentSource(org.rhq.core.domain.auth.Subject subject, int contentSourceId)
          Requests that the identified content source be synchronized and if not lazy-loading to also download its packages' bits.
 void testContentSourceConnection(int contentSourceId)
          Given a content source ID, this will test that the adapter responsible for pulling data from the content source's remote repository can actually connect to that repository, and if not, throw an Exception.
 org.rhq.core.domain.content.ContentSource updateContentSource(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.content.ContentSource contentSource, boolean syncNow)
          Update an existing ContentSource object and restarts its underlying adapter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILESYSTEM_PROPERTY

public static final String FILESYSTEM_PROPERTY
The location we store the bits and distro files

See Also:
Constant Field Values
Constructor Detail

ContentSourceManagerBean

public ContentSourceManagerBean()
Method Detail

purgeOrphanedPackageVersions

public void purgeOrphanedPackageVersions(org.rhq.core.domain.auth.Subject subject)
Description copied from interface: ContentSourceManagerLocal
This will look for any PackageVersions that are "orphaned" (that is, is not related to any existing content source or repo and is not installed anywhere) and will remove any orphans that it finds. This means it will delete orphaned PackageVersion definitions and (if loaded) their PackageBits.

Specified by:
purgeOrphanedPackageVersions in interface ContentSourceManagerLocal
Parameters:
subject - user requesting the purge

deleteContentSource

public void deleteContentSource(org.rhq.core.domain.auth.Subject subject,
                                int contentSourceId)
Description copied from interface: ContentSourceManagerLocal
Deletes the identified content source. Any package versions that originated from this content source but are still related to one or more repos will remain.

Specified by:
deleteContentSource in interface ContentSourceManagerLocal
Parameters:
subject - An authenticated user making the request.
contentSourceId - The id of the content source to be deleted.

getAllContentSourceTypes

public Set<org.rhq.core.domain.content.ContentSourceType> getAllContentSourceTypes()
Description copied from interface: ContentSourceManagerLocal
Returns all ContentSourceType objects that are configured in the system.

Specified by:
getAllContentSourceTypes in interface ContentSourceManagerLocal
Returns:
all content source types

getAllContentSources

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.ContentSource> getAllContentSources(org.rhq.core.domain.auth.Subject subject,
                                                                                                         org.rhq.core.domain.util.PageControl pc)
Description copied from interface: ContentSourceManagerLocal
Returns all ContentSource objects that are configured in the system.

Specified by:
getAllContentSources in interface ContentSourceManagerLocal
Parameters:
subject - user asking to perform this
pc - pagination controls
Returns:
all content sources

getAvailableContentSourcesForRepo

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.ContentSource> getAvailableContentSourcesForRepo(org.rhq.core.domain.auth.Subject subject,
                                                                                                                      Integer repoId,
                                                                                                                      org.rhq.core.domain.util.PageControl pc)
Description copied from interface: ContentSourceManagerLocal
Returns all ContentSource objects that are configured in the system but not presently associated with the repo identified by repoId

Specified by:
getAvailableContentSourcesForRepo in interface ContentSourceManagerLocal
Parameters:
subject - user asking to perform this
repoId - the identifier for the repo
pc - pagination controls
Returns:
all content sources that are not presently associated with the repo identified by repoId

getContentSourceType

public org.rhq.core.domain.content.ContentSourceType getContentSourceType(String name)
Description copied from interface: ContentSourceManagerLocal
Get a ContentSourceType by name. null will be returned if there is no content source type by that name.

Specified by:
getContentSourceType in interface ContentSourceManagerLocal
Parameters:
name - the name of the ContentSourceType to be returned
Returns:
ContentSourceType found. null if none found

getContentSource

public org.rhq.core.domain.content.ContentSource getContentSource(org.rhq.core.domain.auth.Subject subject,
                                                                  int contentSourceId)
Description copied from interface: ContentSourceManagerLocal
Returns the ContentSource from its ID.

Specified by:
getContentSource in interface ContentSourceManagerLocal
Parameters:
subject - user asking to perform this
contentSourceId - identifies the content source to return
Returns:
the content source object, null if the ID is invalid

getContentSourceByNameAndType

public org.rhq.core.domain.content.ContentSource getContentSourceByNameAndType(org.rhq.core.domain.auth.Subject subject,
                                                                               String name,
                                                                               String typeName)
Description copied from interface: ContentSourceManagerLocal
Get a ContentSource by name and ContentSourceType name. null will be returned if there is no content source with the given criteria.

Specified by:
getContentSourceByNameAndType in interface ContentSourceManagerLocal
Parameters:
subject - user asking to perform this
name - the name of the ContentSource to be returned
typeName - the name of the ContentSourceType
Returns:
ContentSource found. null if none found

getAssociatedRepos

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.Repo> getAssociatedRepos(org.rhq.core.domain.auth.Subject subject,
                                                                                              int contentSourceId,
                                                                                              org.rhq.core.domain.util.PageControl pc)
Description copied from interface: ContentSourceManagerLocal
Gets the list of imported repos that are associated with a given content source.

Specified by:
getAssociatedRepos in interface ContentSourceManagerLocal
Parameters:
subject - user asking to perform this
contentSourceId - the id of a content source.
pc - pagination controls
Returns:
list of associated repos

getCandidateRepos

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.Repo> getCandidateRepos(org.rhq.core.domain.auth.Subject subject,
                                                                                             int contentSourceId,
                                                                                             org.rhq.core.domain.util.PageControl pc)
Description copied from interface: ContentSourceManagerLocal
Gets the list of candidate repos that are associated with a given content source.

Specified by:
getCandidateRepos in interface ContentSourceManagerLocal
Parameters:
subject - user asking to perform this
contentSourceId - the id of a content source.
pc - pagination controls
Returns:
list of candidate repos

getContentSourceSyncResults

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.ContentSourceSyncResults> getContentSourceSyncResults(org.rhq.core.domain.auth.Subject subject,
                                                                                                                           int contentSourceId,
                                                                                                                           org.rhq.core.domain.util.PageControl pc)
Description copied from interface: ContentSourceManagerLocal
Allows the caller to page through a list of historical sync results for a content source.

Specified by:
getContentSourceSyncResults in interface ContentSourceManagerLocal
Parameters:
subject - user asking to perform this
contentSourceId - The id of a content source.
pc - pagination controls
Returns:
the list of results

mergeRepoImportResults

public void mergeRepoImportResults(List<RepoDetails> repos)
Description copied from interface: ContentSourceManagerLocal
Updates the server with the results of a repo import from a content source.

Specified by:
mergeRepoImportResults in interface ContentSourceManagerLocal
Parameters:
repos - list of repo data received from the content source; should not be null

deleteContentSourceSyncResults

public void deleteContentSourceSyncResults(org.rhq.core.domain.auth.Subject subject,
                                           int[] ids)
Description copied from interface: ContentSourceManagerLocal
Allow a user to purge content source sync results.

Specified by:
deleteContentSourceSyncResults in interface ContentSourceManagerLocal
Parameters:
subject - user asking to perform this
ids - the IDs of the ContentSourceSyncResults to delete

createContentSource

public org.rhq.core.domain.content.ContentSource createContentSource(org.rhq.core.domain.auth.Subject subject,
                                                                     org.rhq.core.domain.content.ContentSource contentSource)
                                                              throws ContentSourceException
Description copied from interface: ContentSourceManagerLocal
Create the specified content source.

Specified by:
createContentSource in interface ContentSourceManagerLocal
Parameters:
subject - The user making the request.
contentSource - A content source to be created.
Returns:
The created content source.
Throws:
ContentSourceException

simpleCreateContentSource

public org.rhq.core.domain.content.ContentSource simpleCreateContentSource(org.rhq.core.domain.auth.Subject subject,
                                                                           org.rhq.core.domain.content.ContentSource contentSource)
                                                                    throws ContentSourceException
Description copied from interface: ContentSourceManagerLocal
Adds the specified content source to the database but does not attempt to create or start the server-side plugin provider implementation associated with it.

This should only be used for test purposes.

Specified by:
simpleCreateContentSource in interface ContentSourceManagerLocal
Parameters:
subject - may not be null
contentSource - may not be null
Returns:
instance after being persisted; will contain a populated ID value
Throws:
ContentSourceException - if the content source cannot be created, such as if the data in the given object are not valid

updateContentSource

public org.rhq.core.domain.content.ContentSource updateContentSource(org.rhq.core.domain.auth.Subject subject,
                                                                     org.rhq.core.domain.content.ContentSource contentSource,
                                                                     boolean syncNow)
                                                              throws ContentSourceException
Description copied from interface: ContentSourceManagerLocal
Update an existing ContentSource object and restarts its underlying adapter. This also forces the adapter to immediately sync with the remote repository. Note that this will only update the content source's basic fields like name, description, etc. as well as its configuration. Specifically, it will not update the other relationships like its repos. Use #addContentSourcesToRepo(Subject, int, int[]) for things like that.

Specified by:
updateContentSource in interface ContentSourceManagerLocal
Parameters:
subject - wanting to update the ContentSource
contentSource - to be updated
syncNow - if you wish to resync the ContentSource after updating
Returns:
the ContentSource that was updated
Throws:
ContentSourceException

testContentSourceConnection

public void testContentSourceConnection(int contentSourceId)
                                 throws Exception
Description copied from interface: ContentSourceManagerLocal
Given a content source ID, this will test that the adapter responsible for pulling data from the content source's remote repository can actually connect to that repository, and if not, throw an Exception.

Specified by:
testContentSourceConnection in interface ContentSourceManagerLocal
Parameters:
contentSourceId - the id of the content source on which to test the connection
Throws:
Exception - if the test failed

synchronizeAndLoadContentSource

public void synchronizeAndLoadContentSource(org.rhq.core.domain.auth.Subject subject,
                                            int contentSourceId)
Description copied from interface: ContentSourceManagerLocal
Requests that the identified content source be synchronized and if not lazy-loading to also download its packages' bits. This ensures that the server maintains an accurate list of what is available on the content source by seeing what was added, removed or updated since the last time the content source was synchronized. This method is performed asynchronously - the calling thread will not block and will return immediately.

Specified by:
synchronizeAndLoadContentSource in interface ContentSourceManagerLocal
Parameters:
subject - the user asking to perform this
contentSourceId - identifies the content source to synchronize

getPackageVersionsFromContentSource

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.PackageVersionContentSource> getPackageVersionsFromContentSource(org.rhq.core.domain.auth.Subject subject,
                                                                                                                                      int contentSourceId,
                                                                                                                                      org.rhq.core.domain.util.PageControl pc)
Description copied from interface: ContentSourceManagerLocal
Returns all the package versions that are served by the content source identified by the given ID.

Specified by:
getPackageVersionsFromContentSource in interface ContentSourceManagerLocal
Parameters:
subject - the user asking to perform this
contentSourceId - The id of a content source.
pc - pagination controls
Returns:
all package versions that the content source will be providing content for. The object returned also contains the location where those package versions are located in the content source

getPackageVersionsFromContentSourceForRepo

public List<org.rhq.core.domain.content.PackageVersionContentSource> getPackageVersionsFromContentSourceForRepo(org.rhq.core.domain.auth.Subject subject,
                                                                                                                int contentSourceId,
                                                                                                                int repoId)
Description copied from interface: ContentSourceManagerLocal
Returns all packages from the given repo. This call takes into account the content source to provide any extra data on the package versions that exist for the particular mapping of content source and package, such as the location attribute.

Specified by:
getPackageVersionsFromContentSourceForRepo in interface ContentSourceManagerLocal
Parameters:
subject - user retrieving the data
contentSourceId - content source from which the packages are retrieved
repoId - repo from which the packages are retrieved
Returns:
all package versions that the content source will be providing content for. The object returned also contains the location where those package versions are located in the content source

getPackageVersionCountFromContentSource

public long getPackageVersionCountFromContentSource(org.rhq.core.domain.auth.Subject subject,
                                                    int contentSourceId)
Description copied from interface: ContentSourceManagerLocal
Returns count of PackageVersions associated with the given content source.

Specified by:
getPackageVersionCountFromContentSource in interface ContentSourceManagerLocal
Parameters:
subject - caller requesting count
contentSourceId - to lookup
Returns:
count if any

getPackageBitsLength

public long getPackageBitsLength(int resourceId,
                                 org.rhq.core.domain.content.PackageDetailsKey packageDetailsKey)
Description copied from interface: ContentSourceManagerLocal
Returns the length of the package version identified by its PackageDetailsKey. This method ensures that the given resource is subscribed to a repo that contains the package version.

Specified by:
getPackageBitsLength in interface ContentSourceManagerLocal
Returns:
the length of the package version

getPackageVersionsFromContentSources

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.PackageVersionContentSource> getPackageVersionsFromContentSources(org.rhq.core.domain.auth.Subject subject,
                                                                                                                                       int[] contentSourceIds,
                                                                                                                                       org.rhq.core.domain.util.PageControl pc)
Description copied from interface: ContentSourceManagerLocal
Returns all the package versions that are served by all the content sources identified by the given IDs.

Specified by:
getPackageVersionsFromContentSources in interface ContentSourceManagerLocal
Parameters:
subject - the user asking to perform this
Returns:
all package versions that the content sources will be providing content for. The object returned also contains the location where those package versions are located in the content source

getUnloadedPackageVersionsFromContentSourceInRepo

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.PackageVersionContentSource> getUnloadedPackageVersionsFromContentSourceInRepo(org.rhq.core.domain.auth.Subject subject,
                                                                                                                                                    int contentSourceId,
                                                                                                                                                    int repoId,
                                                                                                                                                    org.rhq.core.domain.util.PageControl pc)
Description copied from interface: ContentSourceManagerLocal
Returns all the package versions that are served by the content source identified by the given ID but whose package bits have not been loaded yet.

Specified by:
getUnloadedPackageVersionsFromContentSourceInRepo in interface ContentSourceManagerLocal
Parameters:
subject - the user asking to perform this
Returns:
all unloaded package versions that the content source will be providing content for. The object returned also contains the location where those package versions are located in the content source

downloadDistributionBits

public void downloadDistributionBits(org.rhq.core.domain.auth.Subject subject,
                                     org.rhq.core.domain.content.ContentSource contentSource)
Description copied from interface: ContentSourceManagerLocal
This will download all the distribution bits associated with a specific content source.

Specified by:
downloadDistributionBits in interface ContentSourceManagerLocal

downloadPackageBits

public org.rhq.core.domain.content.PackageBits downloadPackageBits(org.rhq.core.domain.auth.Subject subject,
                                                                   org.rhq.core.domain.content.PackageVersionContentSource pvcs)
Description copied from interface: ContentSourceManagerLocal
Given a PackageVersionContentSource which contains the ID of a content source, an ID of a package version, and the location of that package version on the remote content source repo, this will download the actual package bits for that package version from that content source's remote repository.

An exception will be thrown if the package bits could not be loaded.

This method is potentially a long running operation. Its transaction timeout should be extended appropriately.

If the content source where the package version is found is flagged to NEVER download package bits, this will immediately return null.

Specified by:
downloadPackageBits in interface ContentSourceManagerLocal
Parameters:
subject - the user asking to perform this
Returns:
information about the package bits that were downloaded - note that this will NOT have the actual bits inside it - we will not load the package bits in memory for obvious reasons. This will be null if the content source is configured to never actually download package bits.

internalSynchronizeContentSource

public boolean internalSynchronizeContentSource(int contentSourceId)
                                         throws Exception
Description copied from interface: ContentSourceManagerLocal
Requests that the identified content source be synchronized. This ensures that the server maintains an accurate list of what is available on the content source by seeing what was added, removed or updated since the last time the content source was synchronized.

Do not call this method unless you know what you are doing. It is potentially a long running process and will block the calling thread. In addition, this method must never be called from inside a transaction, because it can be long running. You probably want to call #synchronizeAndLoadContentSource(int).

Specified by:
internalSynchronizeContentSource in interface ContentSourceManagerLocal
Parameters:
contentSourceId - identifies the content source to synchronize
Returns:
true if the synchronization is complete; false if there is already a synchronization already in progress and this call did nothing and aborted.
Throws:
Exception - if failed to synchronize

persistContentSourceSyncResults

public org.rhq.core.domain.content.ContentSourceSyncResults persistContentSourceSyncResults(org.rhq.core.domain.content.ContentSourceSyncResults results)
Description copied from interface: ContentSourceManagerLocal
Creates a new sync results object. Note that this will return null if the given results object has a status of INPROGRESS but there is already a sync results object that is still INPROGRESS and has been in that state for less than 24 hours. Use this to prohibit the system from synchronizing on the same content source concurrently.

Specified by:
persistContentSourceSyncResults in interface ContentSourceManagerLocal
Parameters:
results - the results that should be persisted
Returns:
the persisted object, or null if another sync is currently inprogress.

mergeContentSourceSyncResults

public org.rhq.core.domain.content.ContentSourceSyncResults mergeContentSourceSyncResults(org.rhq.core.domain.content.ContentSourceSyncResults results)
Description copied from interface: ContentSourceManagerLocal
Updates an existing sync results object. Do not use this method to create a new sync results object - use ContentSourceManagerLocal.persistContentSourceSyncResults(ContentSourceSyncResults) for that.

Specified by:
mergeContentSourceSyncResults in interface ContentSourceManagerLocal
Parameters:
results - the existing results that should be or merged
Returns:
the merged object

getContentSourceSyncResults

public org.rhq.core.domain.content.ContentSourceSyncResults getContentSourceSyncResults(int resultsId)
Description copied from interface: ContentSourceManagerLocal
Returns the full sync results object.

Specified by:
getContentSourceSyncResults in interface ContentSourceManagerLocal
Parameters:
resultsId - the ID of the object to return
Returns:
the full sync results

mergeDistributionSyncReport

public org.rhq.core.domain.content.RepoSyncResults mergeDistributionSyncReport(org.rhq.core.domain.content.ContentSource contentSource,
                                                                               DistributionSyncReport report,
                                                                               org.rhq.core.domain.content.RepoSyncResults syncResults)
Description copied from interface: ContentSourceManagerLocal
After a sync has happened, this is responsible for persisting the results.

Specified by:
mergeDistributionSyncReport in interface ContentSourceManagerLocal
Parameters:
contentSource - content source that was just sync'ed
report - information on what the current inventory should look like
syncResults - sync results object that should be updated to track this method's progress
Returns:
the updated syncResults that includes more summary information in the results string that indicates what was done

mergePackageSyncReport

public org.rhq.core.domain.content.RepoSyncResults mergePackageSyncReport(org.rhq.core.domain.content.ContentSource contentSource,
                                                                          org.rhq.core.domain.content.Repo repo,
                                                                          PackageSyncReport report,
                                                                          Map<ContentProviderPackageDetailsKey,org.rhq.core.domain.content.PackageVersionContentSource> previous,
                                                                          org.rhq.core.domain.content.RepoSyncResults syncResults)
Description copied from interface: ContentSourceManagerLocal
After a sync has happened, this is responsible for persisting the results.

Specified by:
mergePackageSyncReport in interface ContentSourceManagerLocal
Parameters:
contentSource - content source that was just sync'ed
report - information on what the current inventory should look like
previous - information from the previous inventory, before the sync happened
syncResults - sync results object that should be updated to track this method's progress
Returns:
the updated syncResults that includes more summary information in the results string that indicates what was done

mergeAdvisorySyncReport

public org.rhq.core.domain.content.RepoSyncResults mergeAdvisorySyncReport(org.rhq.core.domain.content.ContentSource contentSource,
                                                                           AdvisorySyncReport report,
                                                                           org.rhq.core.domain.content.RepoSyncResults syncResults)
Description copied from interface: ContentSourceManagerLocal
After a sync has happened, this is responsible for persisting the results.

Specified by:
mergeAdvisorySyncReport in interface ContentSourceManagerLocal
Parameters:
contentSource - content source that was just sync'ed
report - information on what the current inventory should look like
syncResults - sync results object that should be updated to track this method's progress
Returns:
the updated syncResults that includes more summary information in the results string that indicates what was done

_mergeAdvisorySyncReportADD

public org.rhq.core.domain.content.RepoSyncResults _mergeAdvisorySyncReportADD(org.rhq.core.domain.content.ContentSource contentSource,
                                                                               AdvisorySyncReport report,
                                                                               org.rhq.core.domain.content.RepoSyncResults syncResults,
                                                                               StringBuilder progress)
Specified by:
_mergeAdvisorySyncReportADD in interface ContentSourceManagerLocal

_mergeAdvisorySyncReportREMOVE

public org.rhq.core.domain.content.RepoSyncResults _mergeAdvisorySyncReportREMOVE(org.rhq.core.domain.content.ContentSource contentSource,
                                                                                  AdvisorySyncReport report,
                                                                                  org.rhq.core.domain.content.RepoSyncResults syncResults,
                                                                                  StringBuilder progress)
Specified by:
_mergeAdvisorySyncReportREMOVE in interface ContentSourceManagerLocal

_mergePackageSyncReportUpdateRepo

public void _mergePackageSyncReportUpdateRepo(int contentSourceId)
Specified by:
_mergePackageSyncReportUpdateRepo in interface ContentSourceManagerLocal

_mergePackageSyncReportREMOVE

public org.rhq.core.domain.content.RepoSyncResults _mergePackageSyncReportREMOVE(org.rhq.core.domain.content.ContentSource contentSource,
                                                                                 org.rhq.core.domain.content.Repo repo,
                                                                                 PackageSyncReport report,
                                                                                 Map<ContentProviderPackageDetailsKey,org.rhq.core.domain.content.PackageVersionContentSource> previous,
                                                                                 org.rhq.core.domain.content.RepoSyncResults syncResults,
                                                                                 StringBuilder progress)
Specified by:
_mergePackageSyncReportREMOVE in interface ContentSourceManagerLocal

_mergePackageSyncReportADD

public org.rhq.core.domain.content.RepoSyncResults _mergePackageSyncReportADD(org.rhq.core.domain.content.ContentSource contentSource,
                                                                              org.rhq.core.domain.content.Repo repo,
                                                                              Collection<ContentProviderPackageDetails> newPackages,
                                                                              Map<ContentProviderPackageDetailsKey,org.rhq.core.domain.content.PackageVersionContentSource> previous,
                                                                              org.rhq.core.domain.content.RepoSyncResults syncResults,
                                                                              StringBuilder progress,
                                                                              int addCount)
Specified by:
_mergePackageSyncReportADD in interface ContentSourceManagerLocal

_mergePackageSyncReportUPDATE

public org.rhq.core.domain.content.RepoSyncResults _mergePackageSyncReportUPDATE(org.rhq.core.domain.content.ContentSource contentSource,
                                                                                 PackageSyncReport report,
                                                                                 Map<ContentProviderPackageDetailsKey,org.rhq.core.domain.content.PackageVersionContentSource> previous,
                                                                                 org.rhq.core.domain.content.RepoSyncResults syncResults,
                                                                                 StringBuilder progress)
Specified by:
_mergePackageSyncReportUPDATE in interface ContentSourceManagerLocal

_mergeDistributionSyncReportREMOVE

public org.rhq.core.domain.content.RepoSyncResults _mergeDistributionSyncReportREMOVE(org.rhq.core.domain.content.ContentSource contentSource,
                                                                                      DistributionSyncReport report,
                                                                                      org.rhq.core.domain.content.RepoSyncResults syncResults,
                                                                                      StringBuilder progress)
Specified by:
_mergeDistributionSyncReportREMOVE in interface ContentSourceManagerLocal

_mergeDistributionSyncReportADD

public org.rhq.core.domain.content.RepoSyncResults _mergeDistributionSyncReportADD(org.rhq.core.domain.content.ContentSource contentSource,
                                                                                   DistributionSyncReport report,
                                                                                   org.rhq.core.domain.content.RepoSyncResults syncResults,
                                                                                   StringBuilder progress)
Specified by:
_mergeDistributionSyncReportADD in interface ContentSourceManagerLocal

getPackageVersionMetadata

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.content.composite.PackageVersionMetadataComposite> getPackageVersionMetadata(int resourceId,
                                                                                                                                          org.rhq.core.domain.util.PageControl pc)
Description copied from interface: ContentSourceManagerLocal
Requests all metadata for all package versions that the given resource component is subscribed to (see Repo.getResources(). The returned object has the metadata bytes that are meaningful to the calling plugin component.

Note that the returned object has the package version IDs that can be used to retrieve the actual content bits of the package versions via a call to #retrievePackageVersionBits(int, int).

Callers should consider caching the returned metadata. Use ContentSourceManagerLocal.getResourceSubscriptionMD5(int) to get the MD5 hashcode of the metadata for the resource to aid in determining when a cache of metadata is stale.

Specified by:
getPackageVersionMetadata in interface ContentSourceManagerLocal
Parameters:
resourceId - identifies the resource requesting the data; all package versions in all the resource's subscribed repos will be represented in the returned map
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
See Also:
ContentSourceManagerLocal.getResourceSubscriptionMD5(int)

getResourceSubscriptionMD5

public String getResourceSubscriptionMD5(int resourceId)
Description copied from interface: ContentSourceManagerLocal
Gets the MD5 hash which identifies a resource "content subscription". This MD5 hash will change when any repo the resource is subscribed to has changed its contents (that is, if a package version was added/updated/removed from it).

Specified by:
getResourceSubscriptionMD5 in interface ContentSourceManagerLocal
Parameters:
resourceId - identifies the resource requesting the MD5; any change to any package version in any of the resource's subscribed repos will determine the MD5
Returns:
the MD5
See Also:
ContentSourceManagerLocal.getPackageVersionMetadata(int, PageControl)

outputPackageVersionBitsGivenResource

public long outputPackageVersionBitsGivenResource(int resourceId,
                                                  org.rhq.core.domain.content.PackageDetailsKey packageDetailsKey,
                                                  OutputStream outputStream)
Description copied from interface: ContentSourceManagerLocal
Requests that the actual content data (the "bits") of the identified package version be streamed down to the caller over the given output stream that the caller provides. This method will not be responsible for closing the stream when its done, the caller needs to close it. This may be a time-consuming method call because if the bits have not yet been loaded (i.e. the content source where the package version lives is lazy loading then this may be the time when it is downloaded from the remote repository.

This is the same as calling ContentSourceManagerLocal.outputPackageVersionBitsRangeGivenResource(int, PackageDetailsKey, OutputStream, long, long) with the start/end bytes of 0 and -1 respectively.

Specified by:
outputPackageVersionBitsGivenResource in interface ContentSourceManagerLocal
Parameters:
resourceId - identifies the resource making the request; if this resource is not allowed to see the package version (due to the fact that it is not subscribed to a repo that is serving that package version), an exception is thrown
packageDetailsKey - identifies the PackageVersion whose PackageBits are to be streamed
outputStream - a stream that the caller prepared where this method will write the actual content
Returns:
the number of bytes written to the output stream

outputPackageBitsForChildResource

public long outputPackageBitsForChildResource(int parentResourceId,
                                              String resourceTypeName,
                                              org.rhq.core.domain.content.PackageDetailsKey packageDetailsKey,
                                              OutputStream outputStream)
Description copied from interface: ContentSourceManagerLocal
Requests the bits of a package being used to create a child resource be stream down to the caller over the given output stream. This method will not take care of closing the stream when it is finished; it is the caller's responsibility. This may be a time-consuming method call because if the bits have not yet been loaded (i.e. the content source where the package version lives is lazy loading then this may be the time when it is downloaded from the remote repository.

Specified by:
outputPackageBitsForChildResource in interface ContentSourceManagerLocal
Parameters:
parentResourceId - identifies the parent resource under which the new resource is being created
resourceTypeName - type of child resource being created
packageDetailsKey - package being used to create the child resource
outputStream - an output stream where the server should write the package contents. It is up to the caller to prepare this output stream in order to write the package content to an appropriate location.
Returns:
the number of bytes written to the output stream

outputPackageVersionBitsRangeGivenResource

public long outputPackageVersionBitsRangeGivenResource(int resourceId,
                                                       org.rhq.core.domain.content.PackageDetailsKey packageDetailsKey,
                                                       OutputStream outputStream,
                                                       long startByte,
                                                       long endByte)
Description copied from interface: ContentSourceManagerLocal
Requests that the actual content data (the "bits") of the identified package version be streamed down to the caller over the given output stream that the caller provides. This method will not be responsible for closing the stream when its done, the caller needs to close it. This may be a time-consuming method call because if the bits have not yet been loaded (i.e. the content source where the package version lives is lazy loading then this may be the time when it is downloaded from the remote repository.

Specified by:
outputPackageVersionBitsRangeGivenResource in interface ContentSourceManagerLocal
Parameters:
resourceId - identifies the resource making the request; if this resource is not allowed to see the package version (due to the fact that it is not subscribed to a repo that is serving that package version), an exception is thrown
packageDetailsKey - identifies the PackageVersion whose PackageBits are to be streamed
outputStream - a stream that the caller prepared where this method will write the actual content
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

outputPackageVersionBits

public long outputPackageVersionBits(org.rhq.core.domain.content.PackageVersion packageVersion,
                                     OutputStream outputStream)
Description copied from interface: ContentSourceManagerLocal
Requests the bits of a package be streamed down to the caller over the given output stream. This method will not take care of closing the stream when it is finished; it is the caller's responsibility. This may be a time-consuming method call because if the bits have not yet been loaded (i.e. the content source where the package version lives is lazy loading then this may be the time when it is downloaded from the remote repository.

Specified by:
outputPackageVersionBits in interface ContentSourceManagerLocal
Parameters:
packageVersion - packageVersion to fetch
outputStream - an output stream where the server should write the package contents. It is up to the caller to prepare this output stream in order to write the package content to an appropriate location.
Returns:
the number of bytes written to the output stream

outputPackageVersionBits

public long outputPackageVersionBits(org.rhq.core.domain.content.PackageVersion packageVersion,
                                     OutputStream outputStream,
                                     long startByte,
                                     long endByte)
Description copied from interface: ContentSourceManagerLocal
Requests a range of bits from a package. This range of bits will be streamed down to the caller over the given output stream. This method will not take care of closing the stream when it is finished; it is the caller's responsibility. This may be a time-consuming method call because if the bits have not yet been loaded (i.e. the content source where the package version lives is lazy loading then this may be the time when it is downloaded from the remote repository.

Specified by:
outputPackageVersionBits in interface ContentSourceManagerLocal
Parameters:
packageVersion - packageVersion to fetch
outputStream - an output stream where the server should write the package contents. It is up to the caller to prepare this output stream in order to write the package content to an appropriate location.
startByte - start index
endByte - end index
Returns:
the number of bytes written to the output stream

downloadPackageBits

public boolean downloadPackageBits(int resourceId,
                                   org.rhq.core.domain.content.PackageDetailsKey packageDetailsKey)
Description copied from interface: ContentSourceManagerLocal
This will download the actual package bits for that package version from that content source's remote repository.

Specified by:
downloadPackageBits in interface ContentSourceManagerLocal
Returns:

outputDistributionFileBits

public long outputDistributionFileBits(org.rhq.core.domain.content.DistributionFile distFile,
                                       OutputStream outputStream)
Description copied from interface: ContentSourceManagerLocal
Requests the bits of a distribution file be streamed down to the caller over the given output stream. This method will not take care of closing the stream when it is finished; it is the caller's responsibility.

Specified by:
outputDistributionFileBits in interface ContentSourceManagerLocal
Parameters:
distFile - distribution file to fetch
outputStream - an output stream where the server should write the package contents. It is up to the caller to prepare this output stream in order to write the package content to an appropriate location.
Returns:
the number of bytes written to the output stream


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