Index: lams_common/src/java/org/lamsfoundation/lams/contentrepository/client/IToolContentHandler.java =================================================================== diff -u -r9d017688cf84d7a7c26203a3b0e13a5301b9c756 -racfb79c9b7ee82c20ad2797b17396e9bb60266a2 --- lams_common/src/java/org/lamsfoundation/lams/contentrepository/client/IToolContentHandler.java (.../IToolContentHandler.java) (revision 9d017688cf84d7a7c26203a3b0e13a5301b9c756) +++ lams_common/src/java/org/lamsfoundation/lams/contentrepository/client/IToolContentHandler.java (.../IToolContentHandler.java) (revision acfb79c9b7ee82c20ad2797b17396e9bb60266a2) @@ -62,8 +62,15 @@ * @throws RepositoryCheckedException * Some other error occured. */ - public NodeKey uploadFile(InputStream stream, String fileName, String mimeType) + NodeKey uploadFile(InputStream stream, String fileName, String mimeType) throws RepositoryCheckedException, InvalidParameterException, RepositoryCheckedException; + + /** + * Method is identical to uploadFile(InputStream stream, String fileName, String mimeType), except for it allows to + * specify userId of the uploading user as a parameter, whereas original method gets it from the session. + */ + NodeKey uploadFile(InputStream stream, String fileName, String mimeType, Integer userId) + throws RepositoryCheckedException, InvalidParameterException, RepositoryCheckedException; /** * Update an existing file in the repository. This will create a new version of this file (its version number will @@ -86,8 +93,15 @@ * @throws RepositoryCheckedException * Some other error occured. */ - public NodeKey updateFile(Long uuid, InputStream stream, String fileName, String mimeType) + NodeKey updateFile(Long uuid, InputStream stream, String fileName, String mimeType) throws RepositoryCheckedException, InvalidParameterException, RepositoryCheckedException; + + /** + * Method is identical to updateFile(Long uuid, InputStream stream, String fileName, String mimeType), except for it + * allows to specify userId of the uploading user as a parameter, whereas original method gets it from the session. + */ + NodeKey updateFile(Long uuid, InputStream stream, String fileName, String mimeType, Integer userId) + throws RepositoryCheckedException, InvalidParameterException, RepositoryCheckedException; /** * Save a directory of files in the content repository. @@ -106,7 +120,7 @@ * @throws RepositoryCheckedException * Some other error occured. */ - public NodeKey uploadPackage(String dirPath, String startFile) + NodeKey uploadPackage(String dirPath, String startFile) throws RepositoryCheckedException, InvalidParameterException, RepositoryCheckedException; /** @@ -119,7 +133,7 @@ * @throws RepositoryCheckedException * Some other error occured. */ - public void deleteFile(Long uuid) throws InvalidParameterException, RepositoryCheckedException; + void deleteFile(Long uuid) throws InvalidParameterException, RepositoryCheckedException; /** * Get the file, as an inputstream. @@ -133,7 +147,7 @@ * @throws RepositoryCheckedException * Some other error occured. */ - public InputStream getFileInputStream(Long uuid) + InputStream getFileInputStream(Long uuid) throws ItemNotFoundException, FileException, RepositoryCheckedException; /** @@ -150,6 +164,6 @@ * @throws RepositoryCheckedException * @throws IOException */ - public void saveFile(Long uuid, String toFileName) + void saveFile(Long uuid, String toFileName) throws ItemNotFoundException, RepositoryCheckedException, IOException; } \ No newline at end of file Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/client/ToolContentHandler.java =================================================================== diff -u -r9d017688cf84d7a7c26203a3b0e13a5301b9c756 -racfb79c9b7ee82c20ad2797b17396e9bb60266a2 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/client/ToolContentHandler.java (.../ToolContentHandler.java) (revision 9d017688cf84d7a7c26203a3b0e13a5301b9c756) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/client/ToolContentHandler.java (.../ToolContentHandler.java) (revision acfb79c9b7ee82c20ad2797b17396e9bb60266a2) @@ -175,6 +175,12 @@ @Override public NodeKey uploadFile(InputStream stream, String fileName, String mimeType) throws RepositoryCheckedException, InvalidParameterException, RepositoryCheckedException { + return uploadFile(stream, fileName, mimeType, null); + } + + @Override + public NodeKey uploadFile(InputStream stream, String fileName, String mimeType, Integer userId) + throws RepositoryCheckedException, InvalidParameterException, RepositoryCheckedException { NodeKey nodeKey = null; try { try { @@ -191,12 +197,18 @@ throw e2; } - return nodeKey; + return nodeKey; } @Override public NodeKey updateFile(Long uuid, InputStream stream, String fileName, String mimeType) throws RepositoryCheckedException, InvalidParameterException, RepositoryCheckedException { + return updateFile(uuid, stream, fileName, mimeType, null); + } + + @Override + public NodeKey updateFile(Long uuid, InputStream stream, String fileName, String mimeType, Integer userId) + throws RepositoryCheckedException, InvalidParameterException, RepositoryCheckedException { NodeKey nodeKey = null; try { try { @@ -254,11 +266,11 @@ NodeKey nodeKey = null; try { try { - nodeKey = repositoryService.addPackageItem(getTicket(false), dirPath, startFile, null); + nodeKey = repositoryService.addPackageItem(getTicket(false), dirPath, startFile); } catch (AccessDeniedException e) { log.warn("Unable to access repository to add directory of files. AccessDeniedException: " + e.getMessage() + " Retrying login."); - nodeKey = repositoryService.addPackageItem(getTicket(true), dirPath, startFile, null); + nodeKey = repositoryService.addPackageItem(getTicket(true), dirPath, startFile); } } catch (RepositoryCheckedException e2) { Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/IRepositoryService.java =================================================================== diff -u -rb67c428939ed96f08f56192d54b8ee55d8ab89d2 -racfb79c9b7ee82c20ad2797b17396e9bb60266a2 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/IRepositoryService.java (.../IRepositoryService.java) (revision b67c428939ed96f08f56192d54b8ee55d8ab89d2) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/IRepositoryService.java (.../IRepositoryService.java) (revision acfb79c9b7ee82c20ad2797b17396e9bb60266a2) @@ -88,7 +88,7 @@ * @throws WorkspaceNotFoundException * Workspace name doesn't exist. */ - public ITicket login(ICredentials credentials, String workspaceName) + ITicket login(ICredentials credentials, String workspaceName) throws LoginException, AccessDeniedException, WorkspaceNotFoundException; /** @@ -106,7 +106,7 @@ * @throws RepositoryCheckedException * if parameters are missing. */ - public CrWorkspace addWorkspace(ICredentials credentials, String workspaceName) + CrWorkspace addWorkspace(ICredentials credentials, String workspaceName) throws LoginException, AccessDeniedException, ItemExistsException, RepositoryCheckedException; /** @@ -126,7 +126,7 @@ * @throws ItemExistsException * if the credential already exists. */ - public void createCredentials(ICredentials newCredential) + void createCredentials(ICredentials newCredential) throws AccessDeniedException, RepositoryCheckedException, ItemExistsException; /** @@ -143,7 +143,7 @@ * @throws RepositoryCheckedException * if one of the credentials objects are missing */ - public void updateCredentials(ICredentials oldCredential, ICredentials newCredential) + void updateCredentials(ICredentials oldCredential, ICredentials newCredential) throws AccessDeniedException, RepositoryCheckedException; /** @@ -157,9 +157,9 @@ * new file, as an input stream - mandatory * @param mimeType * mime type of file - optional - * @param versionDescription - * human readable comment about the version - optional - * @return nodeKey (uuid and version) + * @param userId + * id of the user uploading the file. If not provided it will be derived from the HttpSession + * * @throws AccessDeniedException * if ticket doesn't allow this action * @throws FileException @@ -169,8 +169,8 @@ * @throws RepositoryRuntimeException * if any internal errors have occured */ - public abstract NodeKey addFileItem(ITicket ticket, InputStream istream, String filename, String mimeType, - String versionDescription) throws FileException, AccessDeniedException, InvalidParameterException; + abstract NodeKey addFileItem(ITicket ticket, InputStream istream, String filename, String mimeType, + Integer userId) throws FileException, AccessDeniedException, InvalidParameterException; /** * Add a new package of files to the repository. If startFile @@ -186,9 +186,8 @@ * directory path containing files - mandatory * @param startFile * relative path of initial file - optional - * @param versionDescription - * human readable comment about the version - optional * @return nodeKey (uuid and version) + * * @throws AccessDeniedException * if ticket doesn't allow this action * @throws FileException @@ -198,7 +197,7 @@ * @throws RepositoryRuntimeException * if any internal errors have occured */ - public abstract NodeKey addPackageItem(ITicket ticket, String dirPath, String startFile, String versionDescription) + abstract NodeKey addPackageItem(ITicket ticket, String dirPath, String startFile) throws AccessDeniedException, InvalidParameterException, FileException; /** @@ -211,10 +210,11 @@ * unique id of the file - mandatory * @param istream * new file, as an input stream - mandatory - * @param versionDescription - * human readable comment about the version - optional * @param mimeType * mime type of file - optional + * @param userId + * id of the user uploading the file. If not provided it will be derived from the HttpSession + * * @throws AccessDeniedException * if ticket doesn't allow this action * @throws ItemNotFoundException @@ -226,8 +226,8 @@ * @throws RepositoryRuntimeException * if any internal errors have occured */ - public NodeKey updateFileItem(ITicket ticket, Long uuid, String filename, InputStream istream, String mimeType, - String versionDescription) + NodeKey updateFileItem(ITicket ticket, Long uuid, String filename, InputStream istream, String mimeType, + Integer userId) throws AccessDeniedException, ItemNotFoundException, FileException, InvalidParameterException; /** @@ -246,9 +246,8 @@ * directory path containing files - mandatory * @param startFile * relative path of initial file - optional - * @param versionDescription - * human readable comment about the version - optional * @return nodeKey (uuid and version) + * * @throws AccessDeniedException * if ticket doesn't allow this action * @throws ItemNotFoundException @@ -260,8 +259,7 @@ * @throws RepositoryRuntimeException * if any internal errors have occured */ - public abstract NodeKey updatePackageItem(ITicket ticket, Long uuid, String dirPath, String startFile, - String versionDescription) + abstract NodeKey updatePackageItem(ITicket ticket, Long uuid, String dirPath, String startFile) throws AccessDeniedException, ItemNotFoundException, FileException, InvalidParameterException; /** @@ -285,7 +283,7 @@ * is incompatible with the type of the specified property or if * value is incompatible with (i.e. can not be converted to) type. */ - public void setProperty(ITicket ticket, Long uuid, Long versionId, String name, Object value, int type) + void setProperty(ITicket ticket, Long uuid, Long versionId, String name, Object value, int type) throws AccessDeniedException, ItemNotFoundException, ValidationException; /** @@ -311,7 +309,7 @@ * @throws ItemNotFoundException * if the node cannot be found */ - public NodeKey copyNodeVersion(ITicket ticket, Long uuid, Long versionId) + NodeKey copyNodeVersion(ITicket ticket, Long uuid, Long versionId) throws AccessDeniedException, ItemNotFoundException; /** @@ -326,7 +324,7 @@ * desired version - if null gets latest version * @return node. */ - public abstract IVersionedNode getFileItem(ITicket ticket, Long uuid, Long version) + abstract IVersionedNode getFileItem(ITicket ticket, Long uuid, Long version) throws AccessDeniedException, ItemNotFoundException, FileException; /** @@ -360,7 +358,7 @@ * if any internal errors have occured * @return node. */ - public abstract IVersionedNode getFileItem(ITicket ticket, Long uuid, Long versionId, String relPath) + abstract IVersionedNode getFileItem(ITicket ticket, Long uuid, Long versionId, String relPath) throws AccessDeniedException, ItemNotFoundException, FileException; /** @@ -377,7 +375,7 @@ * @throws ItemNotFoundException * @throws FileException */ - public List getPackageNodes(ITicket ticket, Long uuid, Long version) + List getPackageNodes(ITicket ticket, Long uuid, Long version) throws AccessDeniedException, ItemNotFoundException, FileException; /** @@ -389,7 +387,7 @@ * ticket issued on login. Identifies tool and workspace - mandatory * @return SortedSet of IVersionDetail objects, ordered by version */ - public SortedSet getVersionHistory(ITicket ticket, Long uuid) throws ItemNotFoundException, AccessDeniedException; + SortedSet getVersionHistory(ITicket ticket, Long uuid) throws ItemNotFoundException, AccessDeniedException; /** * Delete the current version of a node, returning a list of the files @@ -416,7 +414,7 @@ * @return the list of file(paths) that could not be deleted. The db entries * will have been deleted but these files could not be deleted. */ - public String[] deleteVersion(ITicket ticket, Long uuid, Long version) + String[] deleteVersion(ITicket ticket, Long uuid, Long version) throws AccessDeniedException, InvalidParameterException, ItemNotFoundException; /** @@ -438,7 +436,7 @@ * @return the list of file(paths) that could not be deleted. The db entries * will have been deleted but these files could not be deleted. */ - public String[] deleteNode(ITicket ticket, Long uuid) + String[] deleteNode(ITicket ticket, Long uuid) throws AccessDeniedException, InvalidParameterException, ItemNotFoundException; /** @@ -448,7 +446,7 @@ * @param ticket * ticket issued on login. Identifies tool and workspace - mandatory */ - public void logout(ITicket ticket) throws AccessDeniedException; + void logout(ITicket ticket) throws AccessDeniedException; /** * Get a complete list of all nodes in the workspace and their @@ -462,7 +460,7 @@ * ticket issued on login. Identifies tool and workspace - mandatory * @return SortedMap key Long uuid, value IVersionDetail version history */ - public SortedMap getNodeList(ITicket ticket) throws AccessDeniedException; + SortedMap getNodeList(ITicket ticket) throws AccessDeniedException; /** * Save current version of a node to local file by given file name. If the toFileName is @@ -479,10 +477,10 @@ * @param toFileName * the local file name with directory information. */ - public void saveFile(ITicket ticket, Long uuid, Long versionId, String toFileName) + void saveFile(ITicket ticket, Long uuid, Long versionId, String toFileName) throws RepositoryCheckedException, AccessDeniedException, ItemNotFoundException, IOException; - public boolean workspaceExists(ICredentials credentials, Long workspaceId); + boolean workspaceExists(ICredentials credentials, Long workspaceId); - public boolean workspaceExists(ICredentials credentials, String workspaceName); + boolean workspaceExists(ICredentials credentials, String workspaceName); } \ No newline at end of file Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/RepositoryProxy.java =================================================================== diff -u -rb67c428939ed96f08f56192d54b8ee55d8ab89d2 -racfb79c9b7ee82c20ad2797b17396e9bb60266a2 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/RepositoryProxy.java (.../RepositoryProxy.java) (revision b67c428939ed96f08f56192d54b8ee55d8ab89d2) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/RepositoryProxy.java (.../RepositoryProxy.java) (revision acfb79c9b7ee82c20ad2797b17396e9bb60266a2) @@ -24,7 +24,6 @@ package org.lamsfoundation.lams.contentrepository.service; -import org.apache.log4j.Logger; import org.lamsfoundation.lams.contentrepository.exception.RepositoryRuntimeException; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -47,9 +46,6 @@ * */ public class RepositoryProxy { - - private static Logger log = Logger.getLogger(RepositoryProxy.class); - public static IRepositoryService getRepositoryService() { String[] contextPaths = IRepositoryService.REPOSITORY_CONTEXT_PATH; Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/SimpleRepository.java =================================================================== diff -u -rb67c428939ed96f08f56192d54b8ee55d8ab89d2 -racfb79c9b7ee82c20ad2797b17396e9bb60266a2 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/SimpleRepository.java (.../SimpleRepository.java) (revision b67c428939ed96f08f56192d54b8ee55d8ab89d2) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/SimpleRepository.java (.../SimpleRepository.java) (revision acfb79c9b7ee82c20ad2797b17396e9bb60266a2) @@ -102,14 +102,13 @@ * @author Fiona Malikoff */ public class SimpleRepository implements IRepositoryAdmin { - protected Logger log = Logger.getLogger(SimpleRepository.class); private ICredentialDAO credentialDAO = null; private IWorkspaceDAO workspaceDAO = null; private INodeFactory nodeFactory = null; - private Set ticketIdSet = new HashSet(); // set of currently known tickets. + private Set ticketIdSet = new HashSet<>(); // set of currently known tickets. public SimpleRepository() { log.info("Repository singleton being created."); @@ -159,7 +158,6 @@ * @see org.lamsfoundation.lams.contentrepository.IRepository#login(org.lamsfoundation.lams.contentrepository. * ICredentials, java.lang.String) */ - @SuppressWarnings("unchecked") @Override public ITicket login(ICredentials credentials, String workspaceName) throws AccessDeniedException, LoginException, WorkspaceNotFoundException { @@ -432,13 +430,16 @@ */ @Override public NodeKey addFileItem(ITicket ticket, InputStream istream, String filename, String mimeType, - String versionDescription) throws FileException, AccessDeniedException, InvalidParameterException { + Integer userId) throws FileException, AccessDeniedException, InvalidParameterException { + //if userId is not provided, get it from HttpSession + if (userId == null) { + userId = getCurrentUserId(); + } try { CrWorkspace workspace = getWorkspace(ticket.getWorkspaceId()); - Integer userId = getCurrentUserId(); SimpleVersionedNode initialNodeVersion = nodeFactory.createFileNode(workspace, null, null, istream, - filename, mimeType, versionDescription, userId); + filename, mimeType, null, userId); initialNodeVersion.save(); return initialNodeVersion.getNodeKey(); } catch (ValidationException e) { @@ -458,7 +459,7 @@ * ITicket, java.lang.String, java.lang.String, java.lang.String) */ @Override - public NodeKey addPackageItem(ITicket ticket, String dirPath, String startFile, String versionDescription) + public NodeKey addPackageItem(ITicket ticket, String dirPath, String startFile) throws AccessDeniedException, InvalidParameterException, FileException { CrWorkspace workspace = null; @@ -471,10 +472,10 @@ Integer userId = getCurrentUserId(); SimpleVersionedNode packageNode = null; - packageNode = nodeFactory.createPackageNode(workspace, startFile, versionDescription, userId); + packageNode = nodeFactory.createPackageNode(workspace, startFile, null, userId); try { - packageNode.addPackageFiles(workspace, dirPath, versionDescription, userId); + packageNode.addPackageFiles(workspace, dirPath, null, userId); packageNode.save(); } catch (ValidationException e) { // if this is thrown, then it is bug - nothing external should cause it. @@ -603,12 +604,15 @@ */ @Override public NodeKey updateFileItem(ITicket ticket, Long uuid, String filename, InputStream istream, String mimeType, - String versionDescription) + Integer userId) throws AccessDeniedException, ItemNotFoundException, FileException, InvalidParameterException { + //if userId is not provided, get it from HttpSession + if (userId == null) { + userId = getCurrentUserId(); + } - Integer userId = getCurrentUserId(); - SimpleVersionedNode newNodeVersion = nodeFactory.getNodeNewVersion(ticket.getWorkspaceId(), uuid, null, - versionDescription, userId); + SimpleVersionedNode newNodeVersion = nodeFactory.getNodeNewVersion(ticket.getWorkspaceId(), uuid, null, null, + userId); if (!newNodeVersion.isNodeType(NodeType.FILENODE)) { throw new InvalidParameterException("Node is not a file node - it is a " + newNodeVersion.getNodeType() @@ -633,13 +637,12 @@ * .ITicket, java.lang.Long, java.lang.String, java.lang.String, java.lang.String) */ @Override - public NodeKey updatePackageItem(ITicket ticket, Long uuid, String dirPath, String startFile, - String versionDescription) + public NodeKey updatePackageItem(ITicket ticket, Long uuid, String dirPath, String startFile) throws AccessDeniedException, ItemNotFoundException, FileException, InvalidParameterException { Integer userId = getCurrentUserId(); - SimpleVersionedNode newNodeVersion = nodeFactory.getNodeNewVersion(ticket.getWorkspaceId(), uuid, null, - versionDescription, userId); + SimpleVersionedNode newNodeVersion = nodeFactory.getNodeNewVersion(ticket.getWorkspaceId(), uuid, null, null, + userId); if (!newNodeVersion.isNodeType(NodeType.PACKAGENODE)) { throw new InvalidParameterException("Node is not a package node - it is a " + newNodeVersion.getNodeType() @@ -651,7 +654,7 @@ try { CrWorkspace workspace = getWorkspace(ticket.getWorkspaceId()); - newNodeVersion.addPackageFiles(workspace, dirPath, versionDescription, userId); + newNodeVersion.addPackageFiles(workspace, dirPath, null, userId); newNodeVersion.save(); } catch (ValidationException e) {