src/org/ohmage/service/UserDocumentServices.java
public void userCanModifyDocument(final String username, 
			final String documentId) throws ServiceException {
		try {
			List<Document.Role> roles = userDocumentQueries.getDocumentRolesForDocumentForUser(username, documentId);
			
			// To modify a document, the user must be a writer or owner or a
			// supervisor in any of the campaigns to which the document is 
			// associated or privileged in any of the classes to which the 
			// document is associated.
			if((! roles.contains(Document.Role.OWNER)) && 
			   (! roles.contains(Document.Role.WRITER)) &&
			   (! UserCampaignDocumentServices.instance().getUserIsSupervisorInAnyCampaignAssociatedWithDocument(username, documentId)) &&
			   (! UserClassDocumentServices.instance().getUserIsPrivilegedInAnyClassAssociatedWithDocument(username, documentId))) {
				throw new ServiceException(
						ErrorCode.DOCUMENT_INSUFFICIENT_PERMISSIONS, 
						"The user does not have sufficient permissions to modify the document.");
			}
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
/**
	 * Ensures that a user can modify a document.
	 * 
	 * @param username The username of the user that is being checkec that they
	 * 				   can modify this document.
	 * 
	 * @param documentId The unique identifier for the document.
	 * 
	 * @throws ServiceException Thrown if the user cannot modify this document
	 * 							or if there is an error.
	 */
Ensures that a user can modify a document.

@param username The username of the user that is being checkec that they
can modify this document.

@param documentId The unique identifier for the document.

@throws ServiceException Thrown if the user cannot modify this document
or if there is an error.
Ensures that a user can modify a document . @param username The username of the user that is being checkec that they can modify this document . @param documentId The unique identifier for the document . @throws ServiceException Thrown if the user cannot modify this document or if there is an error .
public void userCanModifyDocument(final String username, 
			final String documentId) throws ServiceException {
		try {
			List<Document.Role> roles = userDocumentQueries.getDocumentRolesForDocumentForUser(username, documentId);
			if((! roles.contains(Document.Role.OWNER)) && 
			   (! roles.contains(Document.Role.WRITER)) &&
			   (! UserCampaignDocumentServices.instance().getUserIsSupervisorInAnyCampaignAssociatedWithDocument(username, documentId)) &&
			   (! UserClassDocumentServices.instance().getUserIsPrivilegedInAnyClassAssociatedWithDocument(username, documentId))) {
				throw new ServiceException(
						ErrorCode.DOCUMENT_INSUFFICIENT_PERMISSIONS, 
						"The user does not have sufficient permissions to modify the document.");
			}
		}
		catch(DataAccessException e) {
			throw new ServiceException(e);
		}
	}
public void userCanModifyDocument ( final String username , final String documentId ) throws ServiceException { try { List < Document . Role > roles = userDocumentQueries . getDocumentRolesForDocumentForUser ( username , documentId ) ; if ( ( ! roles . contains ( Document . Role . OWNER ) ) && ( ! roles . contains ( Document . Role . WRITER ) ) && ( ! UserCampaignDocumentServices . instance ( ) . getUserIsSupervisorInAnyCampaignAssociatedWithDocument ( username , documentId ) ) && ( ! UserClassDocumentServices . instance ( ) . getUserIsPrivilegedInAnyClassAssociatedWithDocument ( username , documentId ) ) ) { throw new ServiceException ( ErrorCode . DOCUMENT_INSUFFICIENT_PERMISSIONS , "The user does not have sufficient permissions to modify the document." ) ; } } catch ( DataAccessException e ) { throw new ServiceException ( e ) ; } }
Ensures that a user can modify a document.
Ensures that a user can modify a document .
// To modify a document, the user must be a writer or owner or a // supervisor in any of the campaigns to which the document is  // associated or privileged in any of the classes to which the  // document is associated.