org.rhq.enterprise.server.content
Class RepoManagerBean

java.lang.Object
  extended by org.rhq.enterprise.server.content.RepoManagerBean
All Implemented Interfaces:
RepoManagerLocal, RepoManagerRemote

public class RepoManagerBean
extends java.lang.Object
implements RepoManagerLocal, RepoManagerRemote


Constructor Summary
RepoManagerBean()
           
 
Method Summary
 void addContentSourcesToRepo(Subject subject, int repoId, int[] contentSourceIds)
           
 void addPackageVersionsToRepo(Subject subject, int repoId, int[] packageVersionIds)
          Associates the package versions (identified by their IDs) to the given repo (also identified by its ID).
 void addRepoRelationship(Subject subject, int repoId, int relatedRepoId, java.lang.String relationshipTypeName)
          Creates a relationship between two repos.
 java.lang.String calculateSyncStatus(Subject subject, int repoId)
          Get the overall sync status of this Repository.
 Repo createCandidateRepo(Subject subject, Repo repo)
          Functions similar to RepoManagerRemote.createRepo(Subject, Repo) except that it will ensure the candidate bit on the repo parameter is correctly set.
 Repo createRepo(Subject subject, Repo repo)
          Creates a new Repo.
 RepoGroup createRepoGroup(Subject subject, RepoGroup repoGroup)
          Creates a new RepoGroup in the server.
 void deleteCandidatesWithOnlyContentSource(Subject subject, int contentSourceId)
          Removes candidate repos whose only content source is the indicated content source.
 void deleteRepo(Subject subject, int repoId)
          Deletes the indicated repo.
 void deleteRepoGroup(Subject subject, int repoGroupId)
          Deletes the indicated repo group.
 PageList<ContentSource> findAssociatedContentSources(Subject subject, int repoId, PageControl pc)
           
 PageList<Distribution> findAssociatedDistributions(Subject subject, int repoid, PageControl pc)
          gets a list of all associated distributions
 java.util.List<RepoComposite> findAvailableResourceSubscriptions(int resourceId)
          Gets all repos that aren't subscribed to for the given resource.
 PageList<RepoComposite> findAvailableResourceSubscriptions(Subject subject, int resourceId, PageControl pc)
          Gets all repos that aren't subscribed to for the given resource.
 PageList<PackageVersion> findPackageVersionsInRepo(Subject subject, int repoId, PageControl pc)
          Returns the set of package versions that can currently be accessed via the given repo.
 PageList<PackageVersion> findPackageVersionsInRepo(Subject subject, int repoId, java.lang.String filter, PageControl pc)
          Returns the set of package versions that can currently be accessed via the given repo.
 PageList<PackageVersion> findPackageVersionsInRepoByCriteria(Subject subject, PackageVersionCriteria criteria)
           
 PageList<Repo> findRepos(Subject subject, PageControl pc)
          Returns all imported repos in the server.
 PageList<Repo> findReposByCriteria(Subject subject, RepoCriteria criteria)
          Returns all repos that match the given criteria.
 java.util.List<RepoComposite> findResourceSubscriptions(int resourceId)
          Gets all repos that are subscribed to by the given resource.
 PageList<RepoComposite> findResourceSubscriptions(Subject subject, int resourceId, PageControl pc)
          Gets all repos that are subscribed to by the given resource.
 PageList<Resource> findSubscribedResources(Subject subject, int repoId, PageControl pc)
          Gets all resources that are subscribed to the given repo.
 long getDistributionCountFromRepo(Subject subject, int repoId)
           
 long getPackageVersionCountFromRepo(Subject subject, int repoId)
           
 long getPackageVersionCountFromRepo(Subject subject, java.lang.String filter, int repoId)
           
 Repo getRepo(Subject subject, int repoId)
          Returns the repo with the given id; throws an error if one does not exist at that id.
 java.util.List<Repo> getRepoByName(java.lang.String name)
          Returns all repos that match the given name.
 RepoGroup getRepoGroup(Subject subject, int repoGroupId)
          Returns the repo group with the given id; throws an error if one does not exist at that id.
 RepoGroup getRepoGroupByName(java.lang.String name)
          Returns the repo group with the given name if it exists.
 RepoGroupType getRepoGroupTypeByName(Subject subject, java.lang.String name)
          Returns the repo group type with the given name.
 void importCandidateRepo(Subject subject, java.util.List<java.lang.Integer> repoIds)
          Changes the specified repos from being candidates in the system into full blown repositories, allowing their packages to be syncced and resources to subscribe to them.
 void processRepoImportReport(Subject subject, RepoImportReport report, int contentSourceId, java.lang.StringBuilder result)
          Handles a repo report from a content provider, adding and removing candidate repos as necessary into the database.
 void removeContentSourcesFromRepo(Subject subject, int repoId, int[] contentSourceIds)
           
 void subscribeResourceToRepos(Subject subject, int resourceId, int[] repoIds)
          Subscribes the identified resource to the set of identified repos.
 int synchronizeRepos(Subject subject, java.lang.Integer[] repoIds)
          Syncronize the content associated with the repoIds passed in.
 void unsubscribeResourceFromRepos(Subject subject, int resourceId, int[] repoIds)
          Unsubscribes the identified resource from the set of identified repos.
 Repo updateRepo(Subject subject, Repo repo)
          Update an existing Repo object's basic fields, like name, description, etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepoManagerBean

public RepoManagerBean()
Method Detail

deleteRepo

public void deleteRepo(Subject subject,
                       int repoId)
Description copied from interface: RepoManagerRemote
Deletes the indicated repo. If this deletion orphans package versions (that is, its originating resource or content source has been deleted), this will also purge those orphaned package versions.

Specified by:
deleteRepo in interface RepoManagerLocal
Specified by:
deleteRepo in interface RepoManagerRemote
Parameters:
subject - The logged in user's subject.
repoId - identifies the repo to delete
See Also:
RepoManagerRemote.deleteRepo(Subject, int)

deleteRepoGroup

public void deleteRepoGroup(Subject subject,
                            int repoGroupId)
Description copied from interface: RepoManagerRemote
Deletes the indicated repo group.

Specified by:
deleteRepoGroup in interface RepoManagerLocal
Specified by:
deleteRepoGroup in interface RepoManagerRemote
Parameters:
subject - user deleting the group
repoGroupId - identifies the group being deleted
See Also:
RepoManagerRemote.deleteRepoGroup(Subject, int)

findRepos

public PageList<Repo> findRepos(Subject subject,
                                PageControl pc)
Description copied from interface: RepoManagerRemote
Returns all imported repos in the server.

Specified by:
findRepos in interface RepoManagerLocal
Specified by:
findRepos in interface RepoManagerRemote
Parameters:
subject - user making the request
pc - used for pagination
Returns:
paged list
See Also:
RepoManagerRemote.findRepos(Subject, PageControl)

getRepo

public Repo getRepo(Subject subject,
                    int repoId)
Description copied from interface: RepoManagerRemote
Returns the repo with the given id; throws an error if one does not exist at that id.

Specified by:
getRepo in interface RepoManagerLocal
Specified by:
getRepo in interface RepoManagerRemote
Parameters:
subject - user whose permissions will be checked for access to the repo
repoId - identifies the repo to be retrieved
Returns:
details describing the repo
See Also:
RepoManagerRemote.getRepo(Subject, int)

getRepoGroup

public RepoGroup getRepoGroup(Subject subject,
                              int repoGroupId)
Description copied from interface: RepoManagerRemote
Returns the repo group with the given id; throws an error if one does not exist at that id.

Specified by:
getRepoGroup in interface RepoManagerLocal
Specified by:
getRepoGroup in interface RepoManagerRemote
Parameters:
subject - user whose permissions will be checked for access to the repo
repoGroupId - identifies the repo group to be retrieved
Returns:
details describing the repo group
See Also:
RepoManagerRemote.getRepoGroup(Subject, int)

findAssociatedContentSources

public PageList<ContentSource> findAssociatedContentSources(Subject subject,
                                                            int repoId,
                                                            PageControl pc)
Specified by:
findAssociatedContentSources in interface RepoManagerLocal

findSubscribedResources

public PageList<Resource> findSubscribedResources(Subject subject,
                                                  int repoId,
                                                  PageControl pc)
Description copied from interface: RepoManagerRemote
Gets all resources that are subscribed to the given repo.

Specified by:
findSubscribedResources in interface RepoManagerLocal
Specified by:
findSubscribedResources in interface RepoManagerRemote
Parameters:
subject - The logged in user's subject.
Returns:
the list of subscribers
See Also:
RepoManagerRemote.findSubscribedResources(Subject, int, PageControl)

findResourceSubscriptions

public PageList<RepoComposite> findResourceSubscriptions(Subject subject,
                                                         int resourceId,
                                                         PageControl pc)
Description copied from interface: RepoManagerLocal
Gets all repos that are subscribed to by the given resource.

Specified by:
findResourceSubscriptions in interface RepoManagerLocal
Returns:
the list of subscriptions

findAvailableResourceSubscriptions

public PageList<RepoComposite> findAvailableResourceSubscriptions(Subject subject,
                                                                  int resourceId,
                                                                  PageControl pc)
Description copied from interface: RepoManagerLocal
Gets all repos that aren't subscribed to for the given resource.

Specified by:
findAvailableResourceSubscriptions in interface RepoManagerLocal
Returns:
the list of available repos for the given resource

findResourceSubscriptions

public java.util.List<RepoComposite> findResourceSubscriptions(int resourceId)
Description copied from interface: RepoManagerLocal
Gets all repos that are subscribed to by the given resource.

Specified by:
findResourceSubscriptions in interface RepoManagerLocal
Returns:
the list of subscriptions

findAvailableResourceSubscriptions

public java.util.List<RepoComposite> findAvailableResourceSubscriptions(int resourceId)
Description copied from interface: RepoManagerLocal
Gets all repos that aren't subscribed to for the given resource.

Specified by:
findAvailableResourceSubscriptions in interface RepoManagerLocal
Returns:
the list of available repos for the given resource

findPackageVersionsInRepo

public PageList<PackageVersion> findPackageVersionsInRepo(Subject subject,
                                                          int repoId,
                                                          PageControl pc)
Description copied from interface: RepoManagerLocal
Returns the set of package versions that can currently be accessed via the given repo.

Specified by:
findPackageVersionsInRepo in interface RepoManagerLocal
Parameters:
subject - user asking to perform this
repoId - identifies the repo
pc - pagination controls
Returns:
the package versions that are available in the repo

findPackageVersionsInRepo

public PageList<PackageVersion> findPackageVersionsInRepo(Subject subject,
                                                          int repoId,
                                                          java.lang.String filter,
                                                          PageControl pc)
Description copied from interface: RepoManagerRemote
Returns the set of package versions that can currently be accessed via the given repo.

Specified by:
findPackageVersionsInRepo in interface RepoManagerLocal
Specified by:
findPackageVersionsInRepo in interface RepoManagerRemote
Parameters:
subject - The logged in user's subject.
repoId - identifies the repo
filter - A repo filter.
pc - pagination controls
Returns:
the package versions that are available in the repo
See Also:
RepoManagerRemote.findPackageVersionsInRepo(Subject, int, String, PageControl)

updateRepo

public Repo updateRepo(Subject subject,
                       Repo repo)
                throws RepoException
Description copied from interface: RepoManagerRemote
Update an existing Repo object's basic fields, like name, description, etc. Note that the given repo's relationships will be ignored and not merged with the existing repo (e.g. is subscribed resources will not be changed, regardless of what the given repo's subscribed resources set it).

Specified by:
updateRepo in interface RepoManagerLocal
Specified by:
updateRepo in interface RepoManagerRemote
Parameters:
subject - The logged in user's subject.
repo - to be updated
Returns:
Repo that was updated
Throws:
RepoException
See Also:
RepoManagerRemote.updateRepo(Subject, Repo)

createRepo

public Repo createRepo(Subject subject,
                       Repo repo)
                throws RepoException
Description copied from interface: RepoManagerRemote
Creates a new Repo. Note that the created repo will not have any content sources assigned and no resources will be subscribed. It is a virgin repo.

Specified by:
createRepo in interface RepoManagerLocal
Specified by:
createRepo in interface RepoManagerRemote
Parameters:
subject - The logged in user's subject.
repo - a new repo object.
Returns:
the newly created repo
Throws:
RepoException - if a repo already exists with the same name
See Also:
RepoManagerRemote.createRepo(Subject, Repo)

createCandidateRepo

public Repo createCandidateRepo(Subject subject,
                                Repo repo)
                         throws RepoException
Description copied from interface: RepoManagerLocal
Functions similar to RepoManagerRemote.createRepo(Subject, Repo) except that it will ensure the candidate bit on the repo parameter is correctly set.

Specified by:
createCandidateRepo in interface RepoManagerLocal
Parameters:
subject - user creating the repo
repo - repo data to create
Returns:
persisted repo (ID will be populated)
Throws:
RepoException - if the repo contains invalid data

deleteCandidatesWithOnlyContentSource

public void deleteCandidatesWithOnlyContentSource(Subject subject,
                                                  int contentSourceId)
Description copied from interface: RepoManagerLocal
Removes candidate repos whose only content source is the indicated content source.

Specified by:
deleteCandidatesWithOnlyContentSource in interface RepoManagerLocal
Parameters:
subject - user performing the delete
contentSourceId - identifies the content source

processRepoImportReport

public void processRepoImportReport(Subject subject,
                                    RepoImportReport report,
                                    int contentSourceId,
                                    java.lang.StringBuilder result)
Description copied from interface: RepoManagerLocal
Handles a repo report from a content provider, adding and removing candidate repos as necessary into the database.

Specified by:
processRepoImportReport in interface RepoManagerLocal
Parameters:
subject - user triggering the report processing
report - cannot be null
contentSourceId - identifies the content source that
result - buffer used to store the results of dealing with the report

importCandidateRepo

public void importCandidateRepo(Subject subject,
                                java.util.List<java.lang.Integer> repoIds)
                         throws RepoException
Description copied from interface: RepoManagerLocal
Changes the specified repos from being candidates in the system into full blown repositories, allowing their packages to be syncced and resources to subscribe to them.

Specified by:
importCandidateRepo in interface RepoManagerLocal
Parameters:
subject - user performing the import
repoIds - the repos being imported; they must refer to repos in the database and must be flagged as candidates (i.e. an error will occur if an already imported repo is specified)
Throws:
RepoException - if one or more of the repo IDs does not exist in the DB or is not a candidate

createRepoGroup

public RepoGroup createRepoGroup(Subject subject,
                                 RepoGroup repoGroup)
                          throws RepoException
Description copied from interface: RepoManagerRemote
Creates a new RepoGroup in the server.

Specified by:
createRepoGroup in interface RepoManagerLocal
Specified by:
createRepoGroup in interface RepoManagerRemote
Parameters:
subject - represents the user creating the group
repoGroup - group data to create
Returns:
group instance populated after persisting
Throws:
RepoException - if a repo group already exists with this name
See Also:
RepoManagerRemote.createRepoGroup(Subject, RepoGroup)

getRepoByName

public java.util.List<Repo> getRepoByName(java.lang.String name)
Description copied from interface: RepoManagerLocal
Returns all repos that match the given name. The returned list should only be of size 0 or 1.

Specified by:
getRepoByName in interface RepoManagerLocal
Parameters:
name - name of the repo to match
Returns:
list of matching repos; presumably of size 0 or 1

getRepoGroupByName

public RepoGroup getRepoGroupByName(java.lang.String name)
Description copied from interface: RepoManagerLocal
Returns the repo group with the given name if it exists.

Specified by:
getRepoGroupByName in interface RepoManagerLocal
Parameters:
name - name of the repo group to match
Returns:
repo group with the given name; null if one does not

getRepoGroupTypeByName

public RepoGroupType getRepoGroupTypeByName(Subject subject,
                                            java.lang.String name)
Description copied from interface: RepoManagerRemote
Returns the repo group type with the given name.

Specified by:
getRepoGroupTypeByName in interface RepoManagerLocal
Specified by:
getRepoGroupTypeByName in interface RepoManagerRemote
Parameters:
subject - user whose permissions will be checked for access to the group type
name - identifies the repo group type
Returns:
details of the group type; null if no group is found with the name
See Also:
RepoManagerRemote.getRepoGroupTypeByName(Subject, String)

addContentSourcesToRepo

public void addContentSourcesToRepo(Subject subject,
                                    int repoId,
                                    int[] contentSourceIds)
                             throws java.lang.Exception
Specified by:
addContentSourcesToRepo in interface RepoManagerLocal
Throws:
java.lang.Exception

addPackageVersionsToRepo

public void addPackageVersionsToRepo(Subject subject,
                                     int repoId,
                                     int[] packageVersionIds)
Description copied from interface: RepoManagerRemote
Associates the package versions (identified by their IDs) to the given repo (also identified by its ID).

Specified by:
addPackageVersionsToRepo in interface RepoManagerLocal
Specified by:
addPackageVersionsToRepo in interface RepoManagerRemote
Parameters:
subject - The logged in user's subject.
repoId - the ID of the repo
packageVersionIds - the list of package version IDs to add to the repo
See Also:
RepoManagerRemote.addPackageVersionsToRepo(Subject, int, int[])

removeContentSourcesFromRepo

public void removeContentSourcesFromRepo(Subject subject,
                                         int repoId,
                                         int[] contentSourceIds)
                                  throws RepoException
Specified by:
removeContentSourcesFromRepo in interface RepoManagerLocal
Throws:
RepoException

subscribeResourceToRepos

public void subscribeResourceToRepos(Subject subject,
                                     int resourceId,
                                     int[] repoIds)
Description copied from interface: RepoManagerRemote
Subscribes the identified resource to the set of identified repos. Once complete, the resource will be able to access all package content from all content sources that are assigned to the given repos.

Specified by:
subscribeResourceToRepos in interface RepoManagerLocal
Specified by:
subscribeResourceToRepos in interface RepoManagerRemote
Parameters:
subject - The logged in user's subject.
resourceId - The id of the resource to be subscribed.
repoIds - A list of repos to which the resource is subscribed.
See Also:
RepoManagerRemote.subscribeResourceToRepos(Subject, int, int[])

unsubscribeResourceFromRepos

public void unsubscribeResourceFromRepos(Subject subject,
                                         int resourceId,
                                         int[] repoIds)
Description copied from interface: RepoManagerRemote
Unsubscribes the identified resource from the set of identified repos.

Specified by:
unsubscribeResourceFromRepos in interface RepoManagerLocal
Specified by:
unsubscribeResourceFromRepos in interface RepoManagerRemote
Parameters:
subject - The logged in user's subject.
resourceId - The id of the resource to be subscribed.
repoIds - A list of repos to which the resource is subscribed.
See Also:
RepoManagerRemote.unsubscribeResourceFromRepos(Subject, int, int[])

getPackageVersionCountFromRepo

public long getPackageVersionCountFromRepo(Subject subject,
                                           java.lang.String filter,
                                           int repoId)

getPackageVersionCountFromRepo

public long getPackageVersionCountFromRepo(Subject subject,
                                           int repoId)
Specified by:
getPackageVersionCountFromRepo in interface RepoManagerLocal

findReposByCriteria

public PageList<Repo> findReposByCriteria(Subject subject,
                                          RepoCriteria criteria)
Description copied from interface: RepoManagerRemote
Returns all repos that match the given criteria.

Specified by:
findReposByCriteria in interface RepoManagerLocal
Specified by:
findReposByCriteria in interface RepoManagerRemote
Parameters:
subject - user making the query
criteria - describes how the query should function; may not be null
Returns:
any repos that match the given criteria; empty list if none match
See Also:
RepoManagerRemote.findPackageVersionsInRepoByCriteria(Subject, PackageVersionCriteria)

findPackageVersionsInRepoByCriteria

public PageList<PackageVersion> findPackageVersionsInRepoByCriteria(Subject subject,
                                                                    PackageVersionCriteria criteria)
Specified by:
findPackageVersionsInRepoByCriteria in interface RepoManagerLocal
Specified by:
findPackageVersionsInRepoByCriteria in interface RepoManagerRemote
criteria - Caller must add a valid repoId via PackageVersionCriteria.addFilterRepoId(Integer)}
Returns:
PackageVersions for the repo
See Also:
RepoManagerRemote.findPackageVersionsInRepo(Subject, int, String, PageControl)

addRepoRelationship

public void addRepoRelationship(Subject subject,
                                int repoId,
                                int relatedRepoId,
                                java.lang.String relationshipTypeName)
Description copied from interface: RepoManagerLocal
Creates a relationship between two repos. The relationship will be marked as being the specified type. For relationships where the order matters, think of the repoId as being the source of the relationship and relatedRepoId as being the destination or target of it.

Specified by:
addRepoRelationship in interface RepoManagerLocal
Parameters:
subject - user making the relationship
repoId - must reference a valid repo in the system the user has permissions to access
relatedRepoId - must reference a valid repo in the system the user has permissions to access
relationshipTypeName - must identify an existing relationship in the database

getDistributionCountFromRepo

public long getDistributionCountFromRepo(Subject subject,
                                         int repoId)

findAssociatedDistributions

public PageList<Distribution> findAssociatedDistributions(Subject subject,
                                                          int repoid,
                                                          PageControl pc)
Description copied from interface: RepoManagerRemote
gets a list of all associated distributions

Specified by:
findAssociatedDistributions in interface RepoManagerLocal
Specified by:
findAssociatedDistributions in interface RepoManagerRemote
Returns:
See Also:
RepoManagerRemote.findAssociatedDistributions(Subject, int, PageControl)

calculateSyncStatus

public java.lang.String calculateSyncStatus(Subject subject,
                                            int repoId)
Description copied from interface: RepoManagerLocal
Get the overall sync status of this Repository. This is a summation of all the syncs. There is a weight to the status since this returns the most 'relevant' status: 1) ContentSourceSyncStatus.FAILURE 2) ContentSourceSyncStatus.INPROGRESS 3) ContentSourceSyncStatus.SUCCESS

Specified by:
calculateSyncStatus in interface RepoManagerLocal
Parameters:
subject - caller
repoId - to calc status for
Returns:
String summary of the status of this Repository

synchronizeRepos

public int synchronizeRepos(Subject subject,
                            java.lang.Integer[] repoIds)
Description copied from interface: RepoManagerLocal
Syncronize the content associated with the repoIds passed in.

Specified by:
synchronizeRepos in interface RepoManagerLocal
Specified by:
synchronizeRepos in interface RepoManagerRemote
repoIds - to syncronize
Returns:
count of the number of repositories synced.


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