org.olat.repository
Class RepositoryManager

java.lang.Object
  extended by org.olat.repository.RepositoryManager

public class RepositoryManager
extends java.lang.Object

Initial Date: Mar 31, 2004

Author:
Mike Stock Comment:

Field Summary
static java.lang.String SEND_DELETE_EMAIL_ACTION
           
 
Method Summary
 void addOwners(Identity ureqIdentity, IdentitiesAddEvent iae, RepositoryEntry re)
          add provided list of identities as owners to the repo entry.
 int countByTypeLimitAccess(java.lang.String restrictedType, int restrictedAccess)
          Count by type, limit by role accessability.
 RepositoryEntry createRepositoryEntryInstance(java.lang.String initialAuthor)
           
 RepositoryEntry createRepositoryEntryInstance(java.lang.String initialAuthor, java.lang.String resourceName, java.lang.String description)
           
 RepositoryEntryStatus createRepositoryEntryStatus(int repositoryEntryStatusCode)
           
 void deleteRepositoryEntry(RepositoryEntry re)
          Delete repo entry.
 java.util.List genericANDQueryWithRolesRestriction(java.lang.String displayName, java.lang.String author, java.lang.String desc, java.util.List resourceTypes, Roles roles, java.lang.String institution)
          Query repository If any input data contains "*", then it replaced by "%" (search me*er -> sql: me%er).
static RepositoryManager getInstance()
           
 java.util.List<RepositoryEntry> getLearningResourcesAsStudent(Identity identity)
          Gets all learning resources where the user is in a learning group as participant.
 java.util.List<RepositoryEntry> getLearningResourcesAsTeacher(Identity identity)
          Gets all learning resources where the user is coach of a learning group or where he is in the repo entry owner group (course administrator)
 void incrementDownloadCounter(RepositoryEntry re)
          Increment the download counter.
 void incrementLaunchCounter(RepositoryEntry re)
          Increment the launch counter.
 boolean isAllowedToLaunch(Identity identity, Roles roles, RepositoryEntry re)
          Test a repo entry if identity is allowed to launch.
 boolean isAllowedToLaunch(UserRequest ureq, RepositoryEntry re)
          Test a repo entry if identity is allowed to launch.
 boolean isInstitutionalRessourceManagerFor(RepositoryEntry repositoryEntry, Identity identity)
          has one owner of repository entry the same institution like the resource manager
 boolean isOwnerOfRepositoryEntry(Identity identity, RepositoryEntry entry)
          check ownership of identiy for a resource
 java.lang.String lookupDisplayNameByOLATResourceableId(java.lang.Long resId)
          Convenience method to access the repositoryEntry displayname by the referenced OLATResourceable id.
 RepositoryEntry lookupRepositoryEntry(java.lang.Long key)
          Lookup repo entry by key.
 RepositoryEntry lookupRepositoryEntry(OLATResourceable resourceable, boolean strict)
          Lookup the repository entry which references the given olat resourceable.
 RepositoryEntry lookupRepositoryEntryBySoftkey(java.lang.String softkey, boolean strict)
          Lookup a repository entry by its softkey.
 java.util.List queryByInitialAuthor(java.lang.String initialAuthor)
          Query by initial-author
 java.util.List queryByOwner(Identity identity, java.lang.String limitType)
          Query by ownership, optionally limit by type.
 java.util.List queryByOwner(Identity identity, java.lang.String[] limitTypes)
           
 java.util.List queryByOwnerLimitAccess(Identity identity, int limitAccess)
          Query by ownership, limit by access.
 java.util.List queryByType(java.lang.String restrictedType)
          Query by type without any other limitations
 java.util.List queryByTypeLimitAccess(java.lang.String restrictedType, Roles roles)
          Query by type, limit by ownership or role accessability.
 java.util.List queryByTypeLimitAccess(java.lang.String restrictedType, UserRequest ureq)
          Query by type, limit by ownership or role accessability.
 java.util.List queryReferencableResourcesLimitType(Identity identity, Roles roles, java.util.List resourceTypes, java.lang.String displayName, java.lang.String author, java.lang.String desc)
          Search for resources that can be referenced by an author.
 void removeOwners(Identity ureqIdentity, java.util.List<Identity> removeIdentities, RepositoryEntry re)
          remove list of identities as owners of given repository entry.
 void saveRepositoryEntry(RepositoryEntry re)
          Save repo entry.
 void setAccess(RepositoryEntry re, int access)
           
 void setDescriptionAndName(RepositoryEntry re, java.lang.String displayName, java.lang.String description)
           
static void setLastUsageNowFor(RepositoryEntry re)
          Set last-usage date to to now for certain repository-entry.
 void setProperties(RepositoryEntry re, boolean canCopy, boolean canReference, boolean canLaunch, boolean canDownload)
           
 void updateRepositoryEntry(RepositoryEntry re)
          Update repo entry.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEND_DELETE_EMAIL_ACTION

public static final java.lang.String SEND_DELETE_EMAIL_ACTION
See Also:
Constant Field Values
Method Detail

getInstance

public static RepositoryManager getInstance()
Returns:
Singleton.

createRepositoryEntryInstance

public RepositoryEntry createRepositoryEntryInstance(java.lang.String initialAuthor)
Parameters:
initialAuthor -
Returns:
A repository instance which has not been persisted yet.

createRepositoryEntryInstance

public RepositoryEntry createRepositoryEntryInstance(java.lang.String initialAuthor,
                                                     java.lang.String resourceName,
                                                     java.lang.String description)
Parameters:
initialAuthor -
resourceName -
description -
Returns:
A repository instance which has not been persisted yet, initialized with given data.

createRepositoryEntryStatus

public RepositoryEntryStatus createRepositoryEntryStatus(int repositoryEntryStatusCode)
Parameters:
repositoryEntryStatusCode -

saveRepositoryEntry

public void saveRepositoryEntry(RepositoryEntry re)
Save repo entry.

Parameters:
re -

updateRepositoryEntry

public void updateRepositoryEntry(RepositoryEntry re)
Update repo entry.

Parameters:
re -

deleteRepositoryEntry

public void deleteRepositoryEntry(RepositoryEntry re)
Delete repo entry.

Parameters:
re -

lookupRepositoryEntry

public RepositoryEntry lookupRepositoryEntry(java.lang.Long key)
Lookup repo entry by key.

Parameters:
the - repository entry key (not the olatresourceable key)
Returns:
Repo entry represented by key or null if no such entry or key is null.

lookupRepositoryEntry

public RepositoryEntry lookupRepositoryEntry(OLATResourceable resourceable,
                                             boolean strict)
Lookup the repository entry which references the given olat resourceable.

Parameters:
resourceable -
strict - true: throws exception if not found, false: returns null if not found
Returns:
the RepositorEntry or null if strict=false
Throws:
AssertException - if the softkey could not be found (strict=true)

lookupRepositoryEntryBySoftkey

public RepositoryEntry lookupRepositoryEntryBySoftkey(java.lang.String softkey,
                                                      boolean strict)
Lookup a repository entry by its softkey.

Parameters:
softkey -
strict - true: throws exception if not found, false: returns null if not found
Returns:
the RepositorEntry or null if strict=false
Throws:
AssertException - if the softkey could not be found (strict=true)

lookupDisplayNameByOLATResourceableId

public java.lang.String lookupDisplayNameByOLATResourceableId(java.lang.Long resId)
Convenience method to access the repositoryEntry displayname by the referenced OLATResourceable id. This only works if a repository entry has an referenced olat resourceable like a course or an content package repo entry

Parameters:
resId -
Returns:
the repositoryentry displayname or null if not found

isAllowedToLaunch

public boolean isAllowedToLaunch(UserRequest ureq,
                                 RepositoryEntry re)
Test a repo entry if identity is allowed to launch.

Parameters:
ureq -
re -
Returns:
True if current identity is allowed to launch the given repo entry.

isAllowedToLaunch

public boolean isAllowedToLaunch(Identity identity,
                                 Roles roles,
                                 RepositoryEntry re)
Test a repo entry if identity is allowed to launch.

Parameters:
identity -
roles -
re -
Returns:
True if current identity is allowed to launch the given repo entry.

incrementLaunchCounter

public void incrementLaunchCounter(RepositoryEntry re)
Increment the launch counter.

Parameters:
re -

incrementDownloadCounter

public void incrementDownloadCounter(RepositoryEntry re)
Increment the download counter.

Parameters:
re -

setLastUsageNowFor

public static void setLastUsageNowFor(RepositoryEntry re)
Set last-usage date to to now for certain repository-entry.

Parameters:
-

setAccess

public void setAccess(RepositoryEntry re,
                      int access)

setDescriptionAndName

public void setDescriptionAndName(RepositoryEntry re,
                                  java.lang.String displayName,
                                  java.lang.String description)

setProperties

public void setProperties(RepositoryEntry re,
                          boolean canCopy,
                          boolean canReference,
                          boolean canLaunch,
                          boolean canDownload)

countByTypeLimitAccess

public int countByTypeLimitAccess(java.lang.String restrictedType,
                                  int restrictedAccess)
Count by type, limit by role accessability.

Parameters:
restrictedType -
roles -
Returns:
Number of repo entries

queryByType

public java.util.List queryByType(java.lang.String restrictedType)
Query by type without any other limitations

Parameters:
restrictedType -
roles -
Returns:
Results

queryByTypeLimitAccess

public java.util.List queryByTypeLimitAccess(java.lang.String restrictedType,
                                             Roles roles)
Query by type, limit by ownership or role accessability.

Parameters:
restrictedType -
roles -
Returns:
Results

queryByTypeLimitAccess

public java.util.List queryByTypeLimitAccess(java.lang.String restrictedType,
                                             UserRequest ureq)
Query by type, limit by ownership or role accessability.

Parameters:
restrictedType -
roles -
Returns:
Results

queryByOwner

public java.util.List queryByOwner(Identity identity,
                                   java.lang.String limitType)
Query by ownership, optionally limit by type.

Parameters:
identity -
limitType -
Returns:
Results

queryByOwner

public java.util.List queryByOwner(Identity identity,
                                   java.lang.String[] limitTypes)

queryByInitialAuthor

public java.util.List queryByInitialAuthor(java.lang.String initialAuthor)
Query by initial-author

Parameters:
restrictedType -
roles -
Returns:
Results

queryReferencableResourcesLimitType

public java.util.List queryReferencableResourcesLimitType(Identity identity,
                                                          Roles roles,
                                                          java.util.List resourceTypes,
                                                          java.lang.String displayName,
                                                          java.lang.String author,
                                                          java.lang.String desc)
Search for resources that can be referenced by an author. This is the case: 1) the user is the owner of the resource 2) the user is author and the resource is at least visible to authors (BA) and the resource is set to canReference

Parameters:
identity - The user initiating the query
roles - The current users role set
resourceTypes - Limit search result to this list of repo types. Can be NULL
displayName - Limit search to this repo title. Can be NULL
author - Limit search to this user (Name, firstname, loginname). Can be NULL
desc - Limit search to description. Can be NULL
Returns:
List of repository entries

queryByOwnerLimitAccess

public java.util.List queryByOwnerLimitAccess(Identity identity,
                                              int limitAccess)
Query by ownership, limit by access.

Parameters:
identity -
limitAccess -
Returns:
Results

isOwnerOfRepositoryEntry

public boolean isOwnerOfRepositoryEntry(Identity identity,
                                        RepositoryEntry entry)
check ownership of identiy for a resource

Returns:
true if the identity is member of the security group of the repository entry

genericANDQueryWithRolesRestriction

public java.util.List genericANDQueryWithRolesRestriction(java.lang.String displayName,
                                                          java.lang.String author,
                                                          java.lang.String desc,
                                                          java.util.List resourceTypes,
                                                          Roles roles,
                                                          java.lang.String institution)
Query repository If any input data contains "*", then it replaced by "%" (search me*er -> sql: me%er).

Parameters:
ureq -
displayName - null -> no restriction
author - null -> no restriction
desc - null -> no restriction
resourceTypes - NOTE: for null -> no restriction, or a list of resourceTypeNames
roles - The calling user's roles
institution - null -> no restriction
Returns:
Results as List containing RepositoryEntries

addOwners

public void addOwners(Identity ureqIdentity,
                      IdentitiesAddEvent iae,
                      RepositoryEntry re)
add provided list of identities as owners to the repo entry. silently ignore if some identities were already owners before.

Parameters:
ureqIdentity -
addIdentities -
re -
userActivityLogger -

removeOwners

public void removeOwners(Identity ureqIdentity,
                         java.util.List<Identity> removeIdentities,
                         RepositoryEntry re)
remove list of identities as owners of given repository entry.

Parameters:
ureqIdentity -
removeIdentities -
re -
logger -

isInstitutionalRessourceManagerFor

public boolean isInstitutionalRessourceManagerFor(RepositoryEntry repositoryEntry,
                                                  Identity identity)
has one owner of repository entry the same institution like the resource manager

Parameters:
RepositoryEntry - repositoryEntry
Identity - identity

getLearningResourcesAsStudent

public java.util.List<RepositoryEntry> getLearningResourcesAsStudent(Identity identity)
Gets all learning resources where the user is in a learning group as participant.

Parameters:
identity -
Returns:
list of RepositoryEntries

getLearningResourcesAsTeacher

public java.util.List<RepositoryEntry> getLearningResourcesAsTeacher(Identity identity)
Gets all learning resources where the user is coach of a learning group or where he is in the repo entry owner group (course administrator)

Parameters:
identity -
Returns:
list of RepositoryEntries