org.sakaiproject.component.legacy.assignment
Class BaseAssignmentService

java.lang.Object
  extended byorg.sakaiproject.component.legacy.assignment.BaseAssignmentService
All Implemented Interfaces:
AssignmentService, EntityProducer
Direct Known Subclasses:
DbAssignmentService

public abstract class BaseAssignmentService
extends Object
implements AssignmentService

BaseAssignmentService is the abstract service class for Assignments.

The Concrete Service classes extending this are the XmlFile and DbCached storage classes.

Version:
$Revision: 6750 $
Author:
University of Michigan, CHEF Software Development Team
See Also:
org.chefproject.core.Assignment

Nested Class Summary
protected  class BaseAssignmentService.AssignmentCacheRefresher
          AssignmentCacheRefresher implementation
protected  class BaseAssignmentService.AssignmentContentCacheRefresher
          AssignmentContentCacheRefresher implementation
protected static interface BaseAssignmentService.AssignmentContentStorage
          AssignmentContent Storage
protected  class BaseAssignmentService.AssignmentContentStorageUser
          AssignmentContentStorageUser implementation
protected static interface BaseAssignmentService.AssignmentStorage
          Assignment Storage
protected  class BaseAssignmentService.AssignmentStorageUser
          AssignmentStorageUser implementation
protected  class BaseAssignmentService.AssignmentSubmissionCacheRefresher
          AssignmentSubmissionCacheRefresher implementation
protected static interface BaseAssignmentService.AssignmentSubmissionStorage
          AssignmentSubmission Storage
protected  class BaseAssignmentService.AssignmentSubmissionStorageUser
          SubmissionStorageUser implementation
 class BaseAssignmentService.BaseAssignment
          Assignment Implementation
 class BaseAssignmentService.BaseAssignmentContent
          AssignmentContent Implementation
 class BaseAssignmentService.BaseAssignmentContentEdit
          BaseAssignmentContentEdit is an implementation of the CHEF AssignmentContentEdit object.
 class BaseAssignmentService.BaseAssignmentEdit
          BaseAssignmentEdit is an implementation of the CHEF AssignmentEdit object.
 class BaseAssignmentService.BaseAssignmentSubmission
          AssignmentSubmission implementation
 class BaseAssignmentService.BaseAssignmentSubmissionEdit
          BaseAssignmentSubmissionEdit is an implementation of the CHEF AssignmentSubmissionEdit object.
 
Nested classes inherited from class org.sakaiproject.service.legacy.entity.EntityProducer
EntityProducer.ChangeType
 
Field Summary
static String EVENT_ACCESS_ASSIGNMENT
          Event for accessing an assignment.
static String EVENT_ACCESS_ASSIGNMENT_CONTENT
          Event for accessing an assignment content.
static String EVENT_ACCESS_ASSIGNMENT_SUBMISSION
          Event for accessing an assignment submission.
static String EVENT_ADD_ASSIGNMENT
          Event for adding an assignment.
static String EVENT_ADD_ASSIGNMENT_CONTENT
          Event for adding an assignment.
static String EVENT_ADD_ASSIGNMENT_SUBMISSION
          Event for adding an assignment submission.
static String EVENT_REMOVE_ASSIGNMENT
          Event for removing an assignment.
static String EVENT_REMOVE_ASSIGNMENT_CONTENT
          Event for removing an assignment content.
static String EVENT_REMOVE_ASSIGNMENT_SUBMISSION
          Event for removing an assignment submission.
static String EVENT_SAVE_ASSIGNMENT_SUBMISSION
          Event for saving an assignment submission.
static String EVENT_SUBMIT_ASSIGNMENT_SUBMISSION
          Event for submitting an assignment submission.
static String EVENT_UPDATE_ASSIGNMENT
          Event for updating an assignment.
static String EVENT_UPDATE_ASSIGNMENT_CONTENT
          Event for updating an assignment content.
static String EVENT_UPDATE_ASSIGNMENT_SUBMISSION
          Event for updating an assignment submission.
protected  Cache m_assignmentCache
          A Cache for this service - Assignments keyed by reference.
protected  BaseAssignmentService.AssignmentStorage m_assignmentStorage
          A Storage object for persistent storage of Assignments.
protected  boolean m_caching
          Configuration: cache, or not.
protected  Cache m_contentCache
          A Cache for this service - AssignmentContents keyed by reference.
protected  BaseAssignmentService.AssignmentContentStorage m_contentStorage
          A Storage object for persistent storage of Assignments.
protected  EntityManager m_entityManager
          Dependency: EntityManager.
protected  Logger m_logger
          Dependency: logging service
protected  MemoryService m_memoryService
          Dependency: MemoryService.
protected  String m_relativeAccessPoint
          The access point URL.
protected  ServerConfigurationService m_serverConfigurationService
          Dependency: ServerConfigurationService.
protected  Cache m_submissionCache
          A Cache for this service - AssignmentSubmissions keyed by reference.
protected  BaseAssignmentService.AssignmentSubmissionStorage m_submissionStorage
          A Storage object for persistent storage of Assignments.
 
Fields inherited from interface org.sakaiproject.service.legacy.assignment.AssignmentService
REF_TYPE_ASSIGNMENT, REF_TYPE_CONTENT, REF_TYPE_GRADES, REF_TYPE_SUBMISSION, REF_TYPE_SUBMISSIONS, REFERENCE_ROOT, SECURE_ACCESS_ASSIGNMENT, SECURE_ACCESS_ASSIGNMENT_CONTENT, SECURE_ACCESS_ASSIGNMENT_SUBMISSION, SECURE_ADD_ASSIGNMENT, SECURE_ADD_ASSIGNMENT_CONTENT, SECURE_ADD_ASSIGNMENT_SUBMISSION, SECURE_GRADE_ASSIGNMENT_SUBMISSION, SECURE_REMOVE_ASSIGNMENT, SECURE_REMOVE_ASSIGNMENT_CONTENT, SECURE_REMOVE_ASSIGNMENT_SUBMISSION, SECURE_UPDATE_ASSIGNMENT, SECURE_UPDATE_ASSIGNMENT_CONTENT, SECURE_UPDATE_ASSIGNMENT_SUBMISSION, SERVICE_NAME
 
Constructor Summary
BaseAssignmentService()
           
 
Method Summary
 AssignmentEdit addAssignment(String context)
          Creates and adds a new Assignment to the service.
 AssignmentContentEdit addAssignmentContent(String context)
          Creates and adds a new AssignmentContent to the service.
 AssignmentEdit addDuplicateAssignment(String context, String assignmentReference)
          Creates and adds a new Assignment to the service which is a copy of an existing Assignment.
 AssignmentContentEdit addDuplicateAssignmentContent(String context, String contentReference)
          Creates and adds a new AssignmentContent to the service which is a copy of an existing AssignmentContent.
protected  void addLiveProperties(ResourcePropertiesEdit props)
          Create the live properties for the object.
protected  void addLiveUpdateProperties(ResourcePropertiesEdit props)
          Update the live properties for an object when modified.
 AssignmentSubmissionEdit addSubmission(String context, String assignmentId)
          Adds an AssignmentSubmission to the service.
 boolean allowAddAssignment(String context)
          Check permissions for adding an Assignment.
 boolean allowAddAssignmentContent(String context)
          Check permissions for adding an AssignmentContent.
 List allowAddAssignmentUsers(String context)
          Get the List of Users who can add assignment
 boolean allowAddSubmission(String context)
          Check permissions for add AssignmentSubmission
 List allowAddSubmissionUsers(String assignmentReference)
          Get the List of Users who can addSubmission() for this assignment.
 boolean allowGetAssignment(String assignmentReference)
          Check permissions for accessing an Assignment.
 boolean allowGetAssignmentContent(String contentReference)
          Check permissions for get AssignmentContent
 boolean allowGetSubmission(String submissionReference)
          Check permissions for accessing a Submission.
 boolean allowGradeSubmission(String context)
          Check permissions for grading Submission
 boolean allowRemoveAssignment(String assignmentReference)
          Check permissions for removing an Assignment.
 boolean allowRemoveAssignmentContent(String contentReference)
          Check permissions for remove the AssignmentContent
 boolean allowRemoveSubmission(String submissionReference)
          Check permissions for remove Submission
 boolean allowUpdateAssignment(String assignmentReference)
          Check permissions for updateing an Assignment.
 boolean allowUpdateAssignmentContent(String contentReference)
          Check permissions for updating AssignmentContent
 boolean allowUpdateSubmission(String submissionReference)
          Check permissions for updating Submission.
 String archive(String siteId, Document doc, Stack stack, String archivePath, List attachments)
          Archive the resources for the given site.
protected  String assignmentId(String ref)
          Access the assignment id extracted from an assignment reference.
 String assignmentReference(String context, String id)
          Access the internal reference which can be used to assess security clearance.
 void cancelEdit(AssignmentContentEdit content)
          Cancel the changes made to a AssignmentContentEdit object, and release the lock.
 void cancelEdit(AssignmentEdit assignment)
          Cancel the changes made to a AssignmentEdit object, and release the lock.
 void cancelEdit(AssignmentSubmissionEdit submission)
          Cancel the changes made to a AssignmentSubmissionEdit object, and release the lock.
 void commitEdit(AssignmentContentEdit content)
          Commit the changes made to an AssignmentContentEdit object, and release the lock.
 void commitEdit(AssignmentEdit assignment)
          Commit the changes made to an AssignmentEdit object, and release the lock.
 void commitEdit(AssignmentSubmissionEdit submission)
          Commit the changes made to an AssignmentSubmissionEdit object, and release the lock.
protected  String contentId(String ref)
          Access the content id extracted from a content reference.
 String contentReference(String context, String id)
          Access the internal reference which can be used to access the resource from within the system.
 void destroy()
          Returns to uninitialized state.
 AssignmentEdit editAssignment(String assignmentReference)
          Get a locked assignment object for editing.
 AssignmentContentEdit editAssignmentContent(String contentReference)
          Get a locked AssignmentContent object for editing.
 AssignmentSubmissionEdit editSubmission(String submissionReference)
          Get a locked AssignmentSubmission object for editing.
protected  String getAccessPoint(boolean relative)
          Access the partial URL that forms the root of resource URLs.
 Assignment getAssignment(String assignmentReference)
          Access the Assignment with the specified reference.
 AssignmentContent getAssignmentContent(String contentReference)
          Access the AssignmentContent with the specified reference.
protected  List getAssignmentContents(String context)
          Access all AssignmentContent objects - known to us (not from external providers).
 Iterator getAssignmentContents(User owner)
          Access list of all AssignmentContents created by the User.
 Iterator getAssignments(AssignmentContent content)
          Access all the Assignments which have the specified AssignmentContent.
protected  List getAssignments(String context)
          Access all assignment objects - known to us (not from external providers).
 Iterator getAssignmentsForContext(String context)
          Access all the Assignemnts associated with a group.
protected  boolean getBool(String s)
          Utility function which returns a boolean value from a string.
protected  String getBoolString(boolean b)
          Utility function which returns a string from a boolean value.
 Entity getEntity(Reference ref)
          Access the referenced Entity - the entity will belong to the service.
 Collection getEntityAuthzGroups(Reference ref)
          Access a collection of authorization group ids for security on the for the referenced entity - the entity will belong to the service.
 String getEntityDescription(Reference ref)
          Create an entity description for the entity referenced - the entity will belong to the service.
 ResourceProperties getEntityResourceProperties(Reference ref)
          Access the resource properties for the referenced entity - the entity will belong to the service.
 String getEntityUrl(Reference ref)
          Access a URL for the referenced entity - the entity will belong to the service.
 byte[] getGradesSpreadsheet(String ref)
          Access the grades spreadsheet for the reference, either for an assignment or all assignments in a context.
protected  String getGroupNameFromContext(String context)
           
 HttpAccess getHttpAccess()
          Get the HttpAccess object that supports entity access via the access servlet for my entities.
 String getLabel()
          
protected  String getReferenceRoot()
          Return the reference root for use in resource references and urls.
 AssignmentSubmission getSubmission(String submissionReference)
          Access the AssignmentSubmission with the specified id.
 AssignmentSubmission getSubmission(String assignmentReference, User person)
          Access a User's AssignmentSubmission to a particular Assignment.
 Iterator getSubmissions(Assignment assignment)
          Get the submissions for an assignment.
protected  List getSubmissions(String context)
          Access all AssignmentSubmission objects - known to us (not from external providers).
 byte[] getSubmissionsZip(String ref)
          Access the submissions zip for the assignment reference.
protected  Time getTimeObject(String timeString)
          Utility function which converts a string into a chef time object.
protected  String getTimeString(Time t)
          Utility function which returns the string representation of the long value of the time object.
 String gradesSpreadsheetReference(String context, String assignmentId)
          Get the string to form an assignment grade spreadsheet
 void importEntities(String fromContext, String toContext, List resourceIds)
          import tool(s) contents from the source context into the destination context
 void init()
          Final initialization, once all dependencies are set.
 String merge(String siteId, Element root, String archivePath, String fromSiteId, Map attachmentNames, Map userIdTrans, Set userListAllowImport)
          Merge the resources from the archive into the given site.
 AssignmentEdit mergeAssignment(Element el)
          Add a new assignment to the directory, from a definition in XML.
 AssignmentContentEdit mergeAssignmentContent(Element el)
          Add a new AssignmentContent to the directory, from a definition in XML.
 AssignmentSubmissionEdit mergeSubmission(Element el)
          Add a new AssignmentSubmission to the directory, from a definition in XML.
protected abstract  BaseAssignmentService.AssignmentStorage newAssignmentStorage()
          Construct a Storage object for Assignments.
protected abstract  BaseAssignmentService.AssignmentContentStorage newContentStorage()
          Construct a Storage object for AssignmentContents.
protected abstract  BaseAssignmentService.AssignmentSubmissionStorage newSubmissionStorage()
          Construct a Storage object for AssignmentSubmissions.
 boolean parseEntityReference(String reference, Reference ref)
          If the service recognizes the reference as its own, parse it and fill in the Reference
 void removeAssignment(AssignmentEdit assignment)
          Removes this Assignment and all references to it.
 void removeAssignmentContent(AssignmentContentEdit content)
          Removes an AssignmentContent
 void removeSubmission(AssignmentSubmissionEdit submission)
          Removes an AssignmentSubmission and all references to it
 void setCaching(String value)
          Configuration: set the locks-in-db
 void setEntityManager(EntityManager service)
          Dependency: EntityManager.
 void setLogger(Logger service)
          Dependency: logging service.
 void setMemoryService(MemoryService service)
          Dependency: MemoryService.
 void setServerConfigurationService(ServerConfigurationService service)
          Dependency: ServerConfigurationService.
protected  String submissionId(String ref)
          Access the submission id extracted from a submission reference.
 String submissionReference(String context, String id, String assignmentId)
          Access the internal reference which can be used to access the resource from within the system.
 String submissionsZipReference(String context, String assignmentReference)
          Get the string to form an assignment submissions zip file
 void syncWithSiteChange(Site site, EntityProducer.ChangeType change)
          Synchronize any entities related to the Site given this change in the Site, possibly a structural change where a tool is added or removed, or the site is new, or being deleted.
protected  void unlock(String lock, String resource)
          Check security permission.
protected  void unlock2(String lock1, String lock2, String resource)
          Check security permission.
protected  boolean unlockCheck(String lock, String resource)
          Check security permission.
protected  boolean unlockCheck2(String lock1, String lock2, String resource)
          Check security permission.
 boolean willArchiveMerge()
          
 boolean willImport()
          
protected  void WTUserIdTrans(Element el, Map userIdTrans)
          Replace the WT user id with the new qualified id
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_assignmentStorage

protected BaseAssignmentService.AssignmentStorage m_assignmentStorage
A Storage object for persistent storage of Assignments.


m_contentStorage

protected BaseAssignmentService.AssignmentContentStorage m_contentStorage
A Storage object for persistent storage of Assignments.


m_submissionStorage

protected BaseAssignmentService.AssignmentSubmissionStorage m_submissionStorage
A Storage object for persistent storage of Assignments.


m_assignmentCache

protected Cache m_assignmentCache
A Cache for this service - Assignments keyed by reference.


m_contentCache

protected Cache m_contentCache
A Cache for this service - AssignmentContents keyed by reference.


m_submissionCache

protected Cache m_submissionCache
A Cache for this service - AssignmentSubmissions keyed by reference.


m_relativeAccessPoint

protected String m_relativeAccessPoint
The access point URL.


EVENT_ADD_ASSIGNMENT

public static final String EVENT_ADD_ASSIGNMENT
Event for adding an assignment.

See Also:
Constant Field Values

EVENT_ADD_ASSIGNMENT_CONTENT

public static final String EVENT_ADD_ASSIGNMENT_CONTENT
Event for adding an assignment.

See Also:
Constant Field Values

EVENT_ADD_ASSIGNMENT_SUBMISSION

public static final String EVENT_ADD_ASSIGNMENT_SUBMISSION
Event for adding an assignment submission.

See Also:
Constant Field Values

EVENT_REMOVE_ASSIGNMENT

public static final String EVENT_REMOVE_ASSIGNMENT
Event for removing an assignment.

See Also:
Constant Field Values

EVENT_REMOVE_ASSIGNMENT_CONTENT

public static final String EVENT_REMOVE_ASSIGNMENT_CONTENT
Event for removing an assignment content.

See Also:
Constant Field Values

EVENT_REMOVE_ASSIGNMENT_SUBMISSION

public static final String EVENT_REMOVE_ASSIGNMENT_SUBMISSION
Event for removing an assignment submission.

See Also:
Constant Field Values

EVENT_ACCESS_ASSIGNMENT

public static final String EVENT_ACCESS_ASSIGNMENT
Event for accessing an assignment.

See Also:
Constant Field Values

EVENT_ACCESS_ASSIGNMENT_CONTENT

public static final String EVENT_ACCESS_ASSIGNMENT_CONTENT
Event for accessing an assignment content.

See Also:
Constant Field Values

EVENT_ACCESS_ASSIGNMENT_SUBMISSION

public static final String EVENT_ACCESS_ASSIGNMENT_SUBMISSION
Event for accessing an assignment submission.

See Also:
Constant Field Values

EVENT_UPDATE_ASSIGNMENT

public static final String EVENT_UPDATE_ASSIGNMENT
Event for updating an assignment.

See Also:
Constant Field Values

EVENT_UPDATE_ASSIGNMENT_CONTENT

public static final String EVENT_UPDATE_ASSIGNMENT_CONTENT
Event for updating an assignment content.

See Also:
Constant Field Values

EVENT_UPDATE_ASSIGNMENT_SUBMISSION

public static final String EVENT_UPDATE_ASSIGNMENT_SUBMISSION
Event for updating an assignment submission.

See Also:
Constant Field Values

EVENT_SAVE_ASSIGNMENT_SUBMISSION

public static final String EVENT_SAVE_ASSIGNMENT_SUBMISSION
Event for saving an assignment submission.

See Also:
Constant Field Values

EVENT_SUBMIT_ASSIGNMENT_SUBMISSION

public static final String EVENT_SUBMIT_ASSIGNMENT_SUBMISSION
Event for submitting an assignment submission.

See Also:
Constant Field Values

m_logger

protected Logger m_logger
Dependency: logging service


m_memoryService

protected MemoryService m_memoryService
Dependency: MemoryService.


m_caching

protected boolean m_caching
Configuration: cache, or not.


m_entityManager

protected EntityManager m_entityManager
Dependency: EntityManager.


m_serverConfigurationService

protected ServerConfigurationService m_serverConfigurationService
Dependency: ServerConfigurationService.

Constructor Detail

BaseAssignmentService

public BaseAssignmentService()
Method Detail

newAssignmentStorage

protected abstract BaseAssignmentService.AssignmentStorage newAssignmentStorage()
Construct a Storage object for Assignments.

Returns:
The new storage object.

newContentStorage

protected abstract BaseAssignmentService.AssignmentContentStorage newContentStorage()
Construct a Storage object for AssignmentContents.

Returns:
The new storage object.

newSubmissionStorage

protected abstract BaseAssignmentService.AssignmentSubmissionStorage newSubmissionStorage()
Construct a Storage object for AssignmentSubmissions.

Returns:
The new storage object.

getAccessPoint

protected String getAccessPoint(boolean relative)
Access the partial URL that forms the root of resource URLs.

Parameters:
relative - - if true, form within the access path only (i.e. starting with /msg)
Returns:
the partial URL that forms the root of resource URLs.

assignmentReference

public String assignmentReference(String context,
                                  String id)
Access the internal reference which can be used to assess security clearance.

Specified by:
assignmentReference in interface AssignmentService
Parameters:
id - The assignment id string.
Returns:
The the internal reference which can be used to access the resource from within the system.

contentReference

public String contentReference(String context,
                               String id)
Access the internal reference which can be used to access the resource from within the system.

Specified by:
contentReference in interface AssignmentService
Parameters:
id - The content id string.
Returns:
The the internal reference which can be used to access the resource from within the system.

submissionReference

public String submissionReference(String context,
                                  String id,
                                  String assignmentId)
Access the internal reference which can be used to access the resource from within the system.

Specified by:
submissionReference in interface AssignmentService
Parameters:
id - The submission id string.
Returns:
The the internal reference which can be used to access the resource from within the system.

assignmentId

protected String assignmentId(String ref)
Access the assignment id extracted from an assignment reference.

Parameters:
ref - The assignment reference string.
Returns:
The the assignment id extracted from an assignment reference.

contentId

protected String contentId(String ref)
Access the content id extracted from a content reference.

Parameters:
ref - The content reference string.
Returns:
The the content id extracted from a content reference.

submissionId

protected String submissionId(String ref)
Access the submission id extracted from a submission reference.

Parameters:
ref - The submission reference string.
Returns:
The the submission id extracted from a submission reference.

unlockCheck

protected boolean unlockCheck(String lock,
                              String resource)
Check security permission.

Parameters:
lock - - The lock id string.
resource - - The resource reference string, or null if no resource is involved.
Returns:
true if allowed, false if not

unlockCheck2

protected boolean unlockCheck2(String lock1,
                               String lock2,
                               String resource)
Check security permission.

Parameters:
lock1 - The lock id string.
lock2 - The lock id string.
resource - The resource reference string, or null if no resource is involved.
Returns:
true if either allowed, false if not

unlock

protected void unlock(String lock,
                      String resource)
               throws PermissionException
Check security permission.

Parameters:
lock - - The lock id string.
resource - - The resource reference string, or null if no resource is involved.
Throws:
PermissionException - Thrown if the user does not have access

unlock2

protected void unlock2(String lock1,
                       String lock2,
                       String resource)
                throws PermissionException
Check security permission.

Parameters:
lock1 - The lock id string.
lock2 - The lock id string.
resource - The resource reference string, or null if no resource is involved.
Throws:
PermissionException - Thrown if the user does not have access to either.

setLogger

public void setLogger(Logger service)
Dependency: logging service.

Parameters:
service - The logging service.

setMemoryService

public void setMemoryService(MemoryService service)
Dependency: MemoryService.

Parameters:
service - The MemoryService.

setCaching

public void setCaching(String value)
Configuration: set the locks-in-db


setEntityManager

public void setEntityManager(EntityManager service)
Dependency: EntityManager.

Parameters:
service - The EntityManager.

setServerConfigurationService

public void setServerConfigurationService(ServerConfigurationService service)
Dependency: ServerConfigurationService.

Parameters:
service - The ServerConfigurationService.

init

public void init()
Final initialization, once all dependencies are set.


destroy

public void destroy()
Returns to uninitialized state.


addAssignment

public AssignmentEdit addAssignment(String context)
                             throws PermissionException
Creates and adds a new Assignment to the service.

Specified by:
addAssignment in interface AssignmentService
Parameters:
context - - Describes the portlet context - generated with DefaultId.getChannel().
Returns:
The new Assignment object.
Throws:
IdInvalidException - if the id contains prohibited characers.
IdUsedException - if the id is already used in the service.
PermissionException - if current User does not have permission to do this.

mergeAssignment

public AssignmentEdit mergeAssignment(Element el)
                               throws IdInvalidException,
                                      IdUsedException,
                                      PermissionException
Add a new assignment to the directory, from a definition in XML. Must commitEdit() to make official, or cancelEdit() when done!

Specified by:
mergeAssignment in interface AssignmentService
Parameters:
el - The XML DOM Element defining the assignment.
Returns:
A locked AssignmentEdit object (reserving the id).
Throws:
IdInvalidException - if the assignment id is invalid.
IdUsedException - if the assignment id is already used.
PermissionException - if the current user does not have permission to add an assignnment.

addDuplicateAssignment

public AssignmentEdit addDuplicateAssignment(String context,
                                             String assignmentReference)
                                      throws PermissionException,
                                             IdInvalidException,
                                             IdUsedException,
                                             IdUnusedException
Creates and adds a new Assignment to the service which is a copy of an existing Assignment.

Specified by:
addDuplicateAssignment in interface AssignmentService
Parameters:
context - - From DefaultId.getChannel(RunData)
assignmentReference - - The reference of the Assignment to be duplicated.
Returns:
The new Assignment object, or null if the original Assignment does not exist.
Throws:
PermissionException - if current User does not have permission to do this.
IdInvalidException
IdUsedException
IdUnusedException

getAssignment

public Assignment getAssignment(String assignmentReference)
                         throws IdUnusedException,
                                PermissionException
Access the Assignment with the specified reference.

Specified by:
getAssignment in interface AssignmentService
Parameters:
assignmentReference - - The reference of the Assignment.
Returns:
The Assignment corresponding to the reference, or null if it does not exist.
Throws:
IdUnusedException - if there is no object with this reference.
PermissionException - if the current user is not allowed to access this.

getAssignments

protected List getAssignments(String context)
Access all assignment objects - known to us (not from external providers).

Returns:
A list of assignment objects.

editAssignment

public AssignmentEdit editAssignment(String assignmentReference)
                              throws IdUnusedException,
                                     PermissionException,
                                     InUseException
Get a locked assignment object for editing. Must commitEdit() to make official, or cancelEdit() when done!

Specified by:
editAssignment in interface AssignmentService
Parameters:
assignmentReference - The assignment id string.
Returns:
An AssignmentEdit object for editing.
Throws:
IdUnusedException - if not found, or if not an AssignmentEdit object
PermissionException - if the current user does not have permission to edit this assignment.
InUseException - if the assignment is being edited by another user.

commitEdit

public void commitEdit(AssignmentEdit assignment)
Commit the changes made to an AssignmentEdit object, and release the lock.

Specified by:
commitEdit in interface AssignmentService
Parameters:
assignment - The AssignmentEdit object to commit.

cancelEdit

public void cancelEdit(AssignmentEdit assignment)
Cancel the changes made to a AssignmentEdit object, and release the lock.

Specified by:
cancelEdit in interface AssignmentService
Parameters:
assignment - The AssignmentEdit object to commit.

removeAssignment

public void removeAssignment(AssignmentEdit assignment)
                      throws PermissionException
Removes this Assignment and all references to it.

Specified by:
removeAssignment in interface AssignmentService
Parameters:
assignment - - The Assignment to remove.
Throws:
PermissionException - if current User does not have permission to do this.

addAssignmentContent

public AssignmentContentEdit addAssignmentContent(String context)
                                           throws PermissionException
Creates and adds a new AssignmentContent to the service.

Specified by:
addAssignmentContent in interface AssignmentService
Parameters:
context - - Describes the portlet context - generated with DefaultId.getChannel().
Returns:
AssignmentContent The new AssignmentContent object.
Throws:
PermissionException - if current User does not have permission to do this.

mergeAssignmentContent

public AssignmentContentEdit mergeAssignmentContent(Element el)
                                             throws IdInvalidException,
                                                    IdUsedException,
                                                    PermissionException
Add a new AssignmentContent to the directory, from a definition in XML. Must commitEdit() to make official, or cancelEdit() when done!

Specified by:
mergeAssignmentContent in interface AssignmentService
Parameters:
el - The XML DOM Element defining the AssignmentContent.
Returns:
A locked AssignmentContentEdit object (reserving the id).
Throws:
IdInvalidException - if the AssignmentContent id is invalid.
IdUsedException - if the AssignmentContent id is already used.
PermissionException - if the current user does not have permission to add an AssignnmentContent.

addDuplicateAssignmentContent

public AssignmentContentEdit addDuplicateAssignmentContent(String context,
                                                           String contentReference)
                                                    throws PermissionException,
                                                           IdInvalidException,
                                                           IdUnusedException
Creates and adds a new AssignmentContent to the service which is a copy of an existing AssignmentContent.

Specified by:
addDuplicateAssignmentContent in interface AssignmentService
Parameters:
context - - From DefaultId.getChannel(RunData)
contentReference - - The id of the AssignmentContent to be duplicated.
Returns:
AssignmentContentEdit The new AssignmentContentEdit object, or null if the original does not exist.
Throws:
PermissionException - if current User does not have permission to do this.
IdInvalidException
IdUnusedException

getAssignmentContent

public AssignmentContent getAssignmentContent(String contentReference)
                                       throws IdUnusedException,
                                              PermissionException
Access the AssignmentContent with the specified reference.

Specified by:
getAssignmentContent in interface AssignmentService
Parameters:
contentReference - - The reference of the AssignmentContent.
Returns:
The AssignmentContent corresponding to the reference, or null if it does not exist.
Throws:
IdUnusedException - if there is no object with this reference.
PermissionException - if the current user is not allowed to access this.

getAssignmentContents

protected List getAssignmentContents(String context)
Access all AssignmentContent objects - known to us (not from external providers).

Returns:
A list of AssignmentContent objects.

editAssignmentContent

public AssignmentContentEdit editAssignmentContent(String contentReference)
                                            throws IdUnusedException,
                                                   PermissionException,
                                                   InUseException
Get a locked AssignmentContent object for editing. Must commitEdit() to make official, or cancelEdit() when done!

Specified by:
editAssignmentContent in interface AssignmentService
Parameters:
contentReference - The content id string.
Returns:
An AssignmentContentEdit object for editing.
Throws:
IdUnusedException - if not found, or if not an AssignmentContentEdit object
PermissionException - if the current user does not have permission to edit this content.
InUseException - if the assignment is being edited by another user.

commitEdit

public void commitEdit(AssignmentContentEdit content)
Commit the changes made to an AssignmentContentEdit object, and release the lock.

Specified by:
commitEdit in interface AssignmentService
Parameters:
content - The AssignmentContentEdit object to commit.

cancelEdit

public void cancelEdit(AssignmentContentEdit content)
Cancel the changes made to a AssignmentContentEdit object, and release the lock.

Specified by:
cancelEdit in interface AssignmentService
Parameters:
content - The AssignmentContentEdit object to commit.

removeAssignmentContent

public void removeAssignmentContent(AssignmentContentEdit content)
                             throws AssignmentContentNotEmptyException,
                                    PermissionException
Removes an AssignmentContent

Specified by:
removeAssignmentContent in interface AssignmentService
Parameters:
content - - the AssignmentContent to remove.
Throws:
an - AssignmentContentNotEmptyException if this content still has related Assignments.
PermissionException - if current User does not have permission to do this.
AssignmentContentNotEmptyException

addSubmission

public AssignmentSubmissionEdit addSubmission(String context,
                                              String assignmentId)
                                       throws PermissionException
Adds an AssignmentSubmission to the service.

Specified by:
addSubmission in interface AssignmentService
Parameters:
context - - Describes the portlet context - generated with DefaultId.getChannel().
Returns:
The new AssignmentSubmission.
Throws:
IdInvalidException - if the submission id is invalid.
IdUsedException - if the submission id is already used.
PermissionException - if the current User does not have permission to do this.

mergeSubmission

public AssignmentSubmissionEdit mergeSubmission(Element el)
                                         throws IdInvalidException,
                                                IdUsedException,
                                                PermissionException
Add a new AssignmentSubmission to the directory, from a definition in XML. Must commitEdit() to make official, or cancelEdit() when done!

Specified by:
mergeSubmission in interface AssignmentService
Parameters:
el - The XML DOM Element defining the submission.
Returns:
A locked AssignmentSubmissionEdit object (reserving the id).
Throws:
IdInvalidException - if the submission id is invalid.
IdUsedException - if the submission id is already used.
PermissionException - if the current user does not have permission to add a submission.

editSubmission

public AssignmentSubmissionEdit editSubmission(String submissionReference)
                                        throws IdUnusedException,
                                               PermissionException,
                                               InUseException
Get a locked AssignmentSubmission object for editing. Must commitEdit() to make official, or cancelEdit() when done!

Specified by:
editSubmission in interface AssignmentService
Parameters:
submissionReference - The submission id string.
Returns:
An AssignmentSubmissionEdit object for editing.
Throws:
IdUnusedException - if not found, or if not an AssignmentSubmissionEdit object
PermissionException - if the current user does not have permission to edit this submission.
InUseException - if the assignment is being edited by another user.

commitEdit

public void commitEdit(AssignmentSubmissionEdit submission)
Commit the changes made to an AssignmentSubmissionEdit object, and release the lock.

Specified by:
commitEdit in interface AssignmentService
Parameters:
submission - The AssignmentSubmissionEdit object to commit.

cancelEdit

public void cancelEdit(AssignmentSubmissionEdit submission)
Cancel the changes made to a AssignmentSubmissionEdit object, and release the lock.

Specified by:
cancelEdit in interface AssignmentService
Parameters:
submission - The AssignmentSubmissionEdit object to commit.

removeSubmission

public void removeSubmission(AssignmentSubmissionEdit submission)
                      throws PermissionException
Removes an AssignmentSubmission and all references to it

Specified by:
removeSubmission in interface AssignmentService
Parameters:
submission - - the AssignmentSubmission to remove.
Throws:
PermissionException - if current User does not have permission to do this.

getSubmissions

protected List getSubmissions(String context)
Access all AssignmentSubmission objects - known to us (not from external providers).

Returns:
A list of AssignmentSubmission objects.

getAssignmentContents

public Iterator getAssignmentContents(User owner)
Access list of all AssignmentContents created by the User.

Specified by:
getAssignmentContents in interface AssignmentService
Parameters:
owner - - The User who's AssignmentContents are requested.
Returns:
Iterator over all AssignmentContents owned by this User.

getAssignments

public Iterator getAssignments(AssignmentContent content)
Access all the Assignments which have the specified AssignmentContent.

Specified by:
getAssignments in interface AssignmentService
Parameters:
content - - The particular AssignmentContent.
Returns:
Iterator over all the Assignments with the specified AssignmentContent.

getAssignmentsForContext

public Iterator getAssignmentsForContext(String context)
Access all the Assignemnts associated with a group.

Specified by:
getAssignmentsForContext in interface AssignmentService
Parameters:
context - - Describes the portlet context - generated with DefaultId.getChannel().
Returns:
Iterator over all the Assignments associated with a group.

getSubmission

public AssignmentSubmission getSubmission(String assignmentReference,
                                          User person)
                                   throws IdUnusedException,
                                          PermissionException
Access a User's AssignmentSubmission to a particular Assignment.

Specified by:
getSubmission in interface AssignmentService
Parameters:
assignmentReference - The reference of the assignment.
person - - The User who's Submission you would like.
Returns:
AssignmentSubmission The user's submission for that Assignment.
Throws:
IdUnusedException - if there is no object with this id.
PermissionException - if the current user is not allowed to access this.

getSubmissions

public Iterator getSubmissions(Assignment assignment)
Get the submissions for an assignment.

Specified by:
getSubmissions in interface AssignmentService
Parameters:
assignment - - the Assignment who's submissions you would like.
Returns:
Iterator over all the submissions for an Assignment.

getSubmission

public AssignmentSubmission getSubmission(String submissionReference)
                                   throws IdUnusedException,
                                          PermissionException
Access the AssignmentSubmission with the specified id.

Specified by:
getSubmission in interface AssignmentService
Parameters:
submissionReference - - The reference of the AssignmentSubmission.
Returns:
The AssignmentSubmission corresponding to the id, or null if it does not exist.
Throws:
IdUnusedException - if there is no object with this id.
PermissionException - if the current user is not allowed to access this.

getReferenceRoot

protected String getReferenceRoot()
Return the reference root for use in resource references and urls.

Returns:
The reference root for use in resource references and urls.

addLiveUpdateProperties

protected void addLiveUpdateProperties(ResourcePropertiesEdit props)
Update the live properties for an object when modified.


addLiveProperties

protected void addLiveProperties(ResourcePropertiesEdit props)
Create the live properties for the object.


allowAddAssignment

public boolean allowAddAssignment(String context)
Check permissions for adding an Assignment.

Specified by:
allowAddAssignment in interface AssignmentService
Parameters:
context - - Describes the portlet context - generated with DefaultId.getChannel().
Returns:
True if the current User is allowed to add an Assignment, false if not.

allowGetAssignment

public boolean allowGetAssignment(String assignmentReference)
Check permissions for accessing an Assignment.

Specified by:
allowGetAssignment in interface AssignmentService
Parameters:
assignmentReference - - The Assignment's reference.
Returns:
True if the current User is allowed to access the Assignment, false if not.

allowUpdateAssignment

public boolean allowUpdateAssignment(String assignmentReference)
Check permissions for updateing an Assignment.

Specified by:
allowUpdateAssignment in interface AssignmentService
Parameters:
assignmentReference - - The Assignment's reference.
Returns:
True if the current User is allowed to update the Assignment, false if not.

allowRemoveAssignment

public boolean allowRemoveAssignment(String assignmentReference)
Check permissions for removing an Assignment.

Specified by:
allowRemoveAssignment in interface AssignmentService
Parameters:
assignmentReference - - The Assignment's reference.
Returns:
True if the current User is allowed to remove the Assignment, false if not.

allowGetAssignmentContent

public boolean allowGetAssignmentContent(String contentReference)
Check permissions for get AssignmentContent

Specified by:
allowGetAssignmentContent in interface AssignmentService
Parameters:
contentReference - - The AssignmentContent reference.
Returns:
True if the current User is allowed to access the AssignmentContent, false if not.

allowUpdateAssignmentContent

public boolean allowUpdateAssignmentContent(String contentReference)
Check permissions for updating AssignmentContent

Specified by:
allowUpdateAssignmentContent in interface AssignmentService
Parameters:
contentReference - - The AssignmentContent reference.
Returns:
True if the current User is allowed to update the AssignmentContent, false if not.

allowAddAssignmentContent

public boolean allowAddAssignmentContent(String context)
Check permissions for adding an AssignmentContent.

Specified by:
allowAddAssignmentContent in interface AssignmentService
Parameters:
context - - Describes the portlet context - generated with DefaultId.getChannel().
Returns:
True if the current User is allowed to add an AssignmentContent, false if not.

allowRemoveAssignmentContent

public boolean allowRemoveAssignmentContent(String contentReference)
Check permissions for remove the AssignmentContent

Specified by:
allowRemoveAssignmentContent in interface AssignmentService
Parameters:
contentReference - - The AssignmentContent reference.
Returns:
True if the current User is allowed to remove the AssignmentContent, false if not.

allowAddSubmission

public boolean allowAddSubmission(String context)
Check permissions for add AssignmentSubmission

Specified by:
allowAddSubmission in interface AssignmentService
Parameters:
context - - Describes the portlet context - generated with DefaultId.getChannel().
Returns:
True if the current User is allowed to add an AssignmentSubmission, false if not.

allowAddSubmissionUsers

public List allowAddSubmissionUsers(String assignmentReference)
Get the List of Users who can addSubmission() for this assignment.

Specified by:
allowAddSubmissionUsers in interface AssignmentService
Parameters:
assignmentReference - - a reference to an assignment
Returns:
the List (User) of users who can addSubmission() for this assignment.

allowAddAssignmentUsers

public List allowAddAssignmentUsers(String context)
Get the List of Users who can add assignment

Specified by:
allowAddAssignmentUsers in interface AssignmentService
Parameters:
context - - Describes the portlet context - generated with DefaultId.getChannel().
Returns:
the List (User) of users who can addSubmission() for this assignment.

allowGetSubmission

public boolean allowGetSubmission(String submissionReference)
Check permissions for accessing a Submission.

Specified by:
allowGetSubmission in interface AssignmentService
Parameters:
submissionReference - - The Submission's reference.
Returns:
True if the current User is allowed to get the AssignmentSubmission, false if not.

allowUpdateSubmission

public boolean allowUpdateSubmission(String submissionReference)
Check permissions for updating Submission.

Specified by:
allowUpdateSubmission in interface AssignmentService
Parameters:
submissionReference - - The Submission's reference.
Returns:
True if the current User is allowed to update the AssignmentSubmission, false if not.

allowRemoveSubmission

public boolean allowRemoveSubmission(String submissionReference)
Check permissions for remove Submission

Specified by:
allowRemoveSubmission in interface AssignmentService
Parameters:
submissionReference - - The Submission's reference.
Returns:
True if the current User is allowed to remove the AssignmentSubmission, false if not.

allowGradeSubmission

public boolean allowGradeSubmission(String context)
Description copied from interface: AssignmentService
Check permissions for grading Submission

Specified by:
allowGradeSubmission in interface AssignmentService
Parameters:
context - - The Submission's reference.
Returns:
True if the current User is allowed to grade the AssignmentSubmission, false if not.

getGradesSpreadsheet

public byte[] getGradesSpreadsheet(String ref)
                            throws IdUnusedException,
                                   PermissionException
Access the grades spreadsheet for the reference, either for an assignment or all assignments in a context.

Specified by:
getGradesSpreadsheet in interface AssignmentService
Parameters:
ref - The reference, either to a specific assignment, or just to an assignment context.
Returns:
The grades spreadsheet bytes.
Throws:
IdUnusedException - if there is no object with this id.
PermissionException - if the current user is not allowed to access this.

getSubmissionsZip

public byte[] getSubmissionsZip(String ref)
                         throws IdUnusedException,
                                PermissionException
Access the submissions zip for the assignment reference.

Specified by:
getSubmissionsZip in interface AssignmentService
Parameters:
ref - The assignment reference.
Returns:
The submissions zip bytes.
Throws:
IdUnusedException - if there is no object with this id.
PermissionException - if the current user is not allowed to access this.

gradesSpreadsheetReference

public String gradesSpreadsheetReference(String context,
                                         String assignmentId)
Get the string to form an assignment grade spreadsheet

Specified by:
gradesSpreadsheetReference in interface AssignmentService
Parameters:
context - The assignment context String
assignmentId - The id for the assignment object; when null, indicates all assignment in that context

submissionsZipReference

public String submissionsZipReference(String context,
                                      String assignmentReference)
Get the string to form an assignment submissions zip file

Specified by:
submissionsZipReference in interface AssignmentService
Parameters:
context - The assignment context String
assignmentReference - The reference for the assignment object;

getLabel

public String getLabel()

Specified by:
getLabel in interface EntityProducer
Returns:
a short string identifying the resources kept here, good for a file name or label.

willArchiveMerge

public boolean willArchiveMerge()

Specified by:
willArchiveMerge in interface EntityProducer
Returns:
true if the serice wants to be part of archive / merge, false if not.

willImport

public boolean willImport()

Specified by:
willImport in interface EntityProducer
Returns:
true if the serice wants to be part of import, false if not.

getHttpAccess

public HttpAccess getHttpAccess()
Get the HttpAccess object that supports entity access via the access servlet for my entities.

Specified by:
getHttpAccess in interface EntityProducer
Returns:
The HttpAccess object for my entities, or null if I do not support access.

parseEntityReference

public boolean parseEntityReference(String reference,
                                    Reference ref)
If the service recognizes the reference as its own, parse it and fill in the Reference

Specified by:
parseEntityReference in interface EntityProducer
Parameters:
reference - The reference string to examine.
ref - The Reference object to set with the results of the parse from a recognized reference.
Returns:
true if the reference belonged to the service, false if not.

getEntity

public Entity getEntity(Reference ref)
Access the referenced Entity - the entity will belong to the service.

Specified by:
getEntity in interface EntityProducer
Parameters:
ref - The entity reference.
Returns:
The Entity, or null if not found.

getEntityAuthzGroups

public Collection getEntityAuthzGroups(Reference ref)
Access a collection of authorization group ids for security on the for the referenced entity - the entity will belong to the service.

Specified by:
getEntityAuthzGroups in interface EntityProducer
Parameters:
ref - The entity reference.
Returns:
The entity's collection of authorization group ids, or null if this cannot be done.

getEntityUrl

public String getEntityUrl(Reference ref)
Access a URL for the referenced entity - the entity will belong to the service.

Specified by:
getEntityUrl in interface EntityProducer
Parameters:
ref - The entity reference.
Returns:
The entity's URL, or null if it does not have one.

archive

public String archive(String siteId,
                      Document doc,
                      Stack stack,
                      String archivePath,
                      List attachments)
Archive the resources for the given site.

Specified by:
archive in interface EntityProducer
Parameters:
siteId - the id of the site.
doc - The document to contain the xml.
stack - The stack of elements, the top of which will be the containing element of the "service.name" element.
archivePath - The path to the folder where we are writing auxilary files.
attachments - A list of attachments - add to this if any attachments need to be included in the archive.
Returns:
A log of status messages from the archive.

WTUserIdTrans

protected void WTUserIdTrans(Element el,
                             Map userIdTrans)
Replace the WT user id with the new qualified id

Parameters:
el - The XML element holding the perproties

merge

public String merge(String siteId,
                    Element root,
                    String archivePath,
                    String fromSiteId,
                    Map attachmentNames,
                    Map userIdTrans,
                    Set userListAllowImport)
Merge the resources from the archive into the given site.

Specified by:
merge in interface EntityProducer
Parameters:
siteId - The id of the site getting imported into.
root - The XML DOM tree of content to merge.
attachmentNames - A map of old attachment name (as found in the DOM) to new attachment name.
Returns:
A log of status messages from the merge.

importEntities

public void importEntities(String fromContext,
                           String toContext,
                           List resourceIds)
import tool(s) contents from the source context into the destination context

Specified by:
importEntities in interface EntityProducer
Parameters:
fromContext - The source context
toContext - The destination context
resourceIds - when null, all resources will be imported; otherwise, only resources with those ids will be imported

getEntityDescription

public String getEntityDescription(Reference ref)
Create an entity description for the entity referenced - the entity will belong to the service.

Specified by:
getEntityDescription in interface EntityProducer
Parameters:
ref - The entity reference.
Returns:
The entity description, or null if one cannot be made.

getEntityResourceProperties

public ResourceProperties getEntityResourceProperties(Reference ref)
Access the resource properties for the referenced entity - the entity will belong to the service.

Specified by:
getEntityResourceProperties in interface EntityProducer
Parameters:
ref - The entity reference.
Returns:
The ResourceProperties object for the entity, or null if it has none.

syncWithSiteChange

public void syncWithSiteChange(Site site,
                               EntityProducer.ChangeType change)
Synchronize any entities related to the Site given this change in the Site, possibly a structural change where a tool is added or removed, or the site is new, or being deleted.

Specified by:
syncWithSiteChange in interface EntityProducer
Parameters:
site - The site that has just changed.
change - The ChangeType for the site (newly added, updated, or just removed).

getTimeString

protected String getTimeString(Time t)
Utility function which returns the string representation of the long value of the time object.

Parameters:
t - - the Time object.
Returns:
A String representation of the long value of the time object.

getBoolString

protected String getBoolString(boolean b)
Utility function which returns a string from a boolean value.

Parameters:
b - - the boolean value.
Returns:
- "True" if the input value is true, "false" otherwise.

getBool

protected boolean getBool(String s)
Utility function which returns a boolean value from a string.

Parameters:
s - - The input string.
Returns:
the boolean true if the input string is "true", false otherwise.

getTimeObject

protected Time getTimeObject(String timeString)
Utility function which converts a string into a chef time object.

Parameters:
timeString - - String version of a time in long format, representing the standard ms since the epoch, Jan 1, 1970 00:00:00.
Returns:
A chef Time object.

getGroupNameFromContext

protected String getGroupNameFromContext(String context)