Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/CheckCredentialTicketBeforeAdvice.java =================================================================== diff -u -rd140daaaa506ac792804b3ce302724b3dde9c830 -rea80430beb4497f12c92db2580341f21750a5a43 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/CheckCredentialTicketBeforeAdvice.java (.../CheckCredentialTicketBeforeAdvice.java) (revision d140daaaa506ac792804b3ce302724b3dde9c830) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/CheckCredentialTicketBeforeAdvice.java (.../CheckCredentialTicketBeforeAdvice.java) (revision ea80430beb4497f12c92db2580341f21750a5a43) @@ -21,6 +21,7 @@ * **************************************************************** */ + package org.lamsfoundation.lams.contentrepository; import java.lang.reflect.Method; @@ -62,8 +63,8 @@ + (args != null && args.length > 0 ? args[0] : "null")); } - if (m != null && ("toString".equals(m.getName()) || m.getName().startsWith("dao"))) { - // don't check toString and dao* methods - let them through + if (m != null && "toString".equals(m.getName())) { + // don't check toString - let it through return; } Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/applicationContext.xml =================================================================== diff -u -r3791c3762ccaf55b7df9d5799be6149b7155adef -rea80430beb4497f12c92db2580341f21750a5a43 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/applicationContext.xml (.../applicationContext.xml) (revision 3791c3762ccaf55b7df9d5799be6149b7155adef) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/applicationContext.xml (.../applicationContext.xml) (revision ea80430beb4497f12c92db2580341f21750a5a43) @@ -46,7 +46,6 @@ PROPAGATION_REQUIRED PROPAGATION_REQUIRED PROPAGATION_REQUIRED - PROPAGATION_REQUIRED @@ -60,19 +59,20 @@ - - - + + - + + + - - + + Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/dao/INodeDAO.java =================================================================== diff -u -rd140daaaa506ac792804b3ce302724b3dde9c830 -rea80430beb4497f12c92db2580341f21750a5a43 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/dao/INodeDAO.java (.../INodeDAO.java) (revision d140daaaa506ac792804b3ce302724b3dde9c830) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/dao/INodeDAO.java (.../INodeDAO.java) (revision ea80430beb4497f12c92db2580341f21750a5a43) @@ -21,6 +21,7 @@ * **************************************************************** */ + package org.lamsfoundation.lams.contentrepository.dao; import java.util.List; @@ -36,6 +37,8 @@ */ public interface INodeDAO extends IBaseDAO { + public void saveOrUpdate(Object object); + public List findChildNodes(CrNodeVersion parentNodeVersion); public CrNode findChildNode(CrNodeVersion parentNodeVersion, String relPath); Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/dao/hibernate/NodeDAO.java =================================================================== diff -u -rd140daaaa506ac792804b3ce302724b3dde9c830 -rea80430beb4497f12c92db2580341f21750a5a43 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/dao/hibernate/NodeDAO.java (.../NodeDAO.java) (revision d140daaaa506ac792804b3ce302724b3dde9c830) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/dao/hibernate/NodeDAO.java (.../NodeDAO.java) (revision ea80430beb4497f12c92db2580341f21750a5a43) @@ -21,6 +21,7 @@ * **************************************************************** */ + package org.lamsfoundation.lams.contentrepository.dao.hibernate; import java.util.List; @@ -41,6 +42,11 @@ public class NodeDAO extends LAMSBaseDAO implements INodeDAO { protected Logger log = Logger.getLogger(NodeDAO.class); + @Override + public void saveOrUpdate(Object object) { + insertOrUpdate(object); + } + /** * Get all child nodes for a node/version. * Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/INodeFactory.java =================================================================== diff -u -rd140daaaa506ac792804b3ce302724b3dde9c830 -rea80430beb4497f12c92db2580341f21750a5a43 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/INodeFactory.java (.../INodeFactory.java) (revision d140daaaa506ac792804b3ce302724b3dde9c830) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/INodeFactory.java (.../INodeFactory.java) (revision ea80430beb4497f12c92db2580341f21750a5a43) @@ -21,12 +21,14 @@ * **************************************************************** */ + package org.lamsfoundation.lams.contentrepository.service; import java.io.InputStream; import org.lamsfoundation.lams.contentrepository.CrNode; import org.lamsfoundation.lams.contentrepository.CrWorkspace; +import org.lamsfoundation.lams.contentrepository.dao.INodeDAO; import org.lamsfoundation.lams.contentrepository.exception.FileException; import org.lamsfoundation.lams.contentrepository.exception.InvalidParameterException; import org.lamsfoundation.lams.contentrepository.exception.ItemNotFoundException; @@ -41,7 +43,7 @@ /** * Create a new file node (which is assumed to be a newly created Spring * bean) with relPath and node type. - * + * * @param relPath * The path of the new Node that is to be created, * the last item of this path will be the name of the new Node. @@ -57,7 +59,7 @@ /** * Create a new package node (which is assumed to be a newly created Spring * bean) with the default file and node type. Package node cannot have a parent node. - * + * * @param initialPath * The path of the default content. * @throws org.lamsfoundation.lams.contentrepository.exception.InvalidParameterException @@ -72,7 +74,7 @@ /** * Create a new data node (which is assumed to be a newly created Spring * bean). This node may have a parent node. - * + * * @throws org.lamsfoundation.lams.contentrepository.exception.InvalidParameterException * if the file parameters are invalid * @throws RepositoryRuntimeException @@ -85,7 +87,7 @@ /** * Build a SimpleVersionedNode, given a CrNode from the database. If versionId == null * then gets the latest version. - * + * * @see org.lamsfoundation.lams.contentrepository.IVersionedNode#getNode(String relPath) */ public abstract SimpleVersionedNode getNode(CrNode databaseNode, Long versionId); @@ -95,12 +97,12 @@ * Creates the CrNode and CrNodeVersion objects. * Equivalent of createFileNode/createPackageNode for existing nodes * Checks that the workspace found in the database is the expected workspace. - * + * * If this node object is returned to a web app, then the * crNode and crNodeVersion objects will be disconnected * from the session, as the session will have been ended * with the Spring transaction. - * + * * If versionId is null, then gets the latest version */ public abstract SimpleVersionedNode getNode(Long workspaceId, Long uuid, Long versionId) @@ -116,9 +118,9 @@ * crNode and crNodeVersion objects will be disconnected * from the session, as the session will have been ended * with the Spring transaction. - * + * * @throws ItemNotFoundException - * + * * @throws RepositoryRuntimeException * if an internal error occurs. * @see org.lamsfoundation.lams.contentrepository.IVersionedNode#createNewVersion(java.lang.String, @@ -130,11 +132,11 @@ /** * Copy the supplied node/version to a new node. Does not copy the history * of the node. Copies any child nodes of the current version. All files are duplicated. - * + * * This method only works as we know that we have two levels of nodes - the * childNodes can't have their own childNodes. If this is no longer the case, * this method and SimpleVersionedNode.save() will need to be changed. - * + * * @throws FileException * will occur if there is a problem reading a file from the repository * @throws InvalidParameterException @@ -146,4 +148,16 @@ */ public abstract SimpleVersionedNode copy(SimpleVersionedNode originalNode, Integer userId) throws FileException, ValueFormatException, InvalidParameterException; + + /** + * @return Returns the nodeDAO. + */ + public abstract INodeDAO getNodeDAO(); + + /** + * @param nodeDAO + * The nodeDAO to set. + */ + public abstract void setNodeDAO(INodeDAO nodeDAO); + } \ No newline at end of file Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/IRepositoryService.java =================================================================== diff -u -rd140daaaa506ac792804b3ce302724b3dde9c830 -rea80430beb4497f12c92db2580341f21750a5a43 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/IRepositoryService.java (.../IRepositoryService.java) (revision d140daaaa506ac792804b3ce302724b3dde9c830) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/IRepositoryService.java (.../IRepositoryService.java) (revision ea80430beb4497f12c92db2580341f21750a5a43) @@ -29,8 +29,6 @@ import java.util.SortedMap; import java.util.SortedSet; -import org.lamsfoundation.lams.contentrepository.CrNode; -import org.lamsfoundation.lams.contentrepository.CrNodeVersion; import org.lamsfoundation.lams.contentrepository.CrWorkspace; import org.lamsfoundation.lams.contentrepository.ICredentials; import org.lamsfoundation.lams.contentrepository.ITicket; @@ -487,43 +485,4 @@ public boolean workspaceExists(ICredentials credentials, Long workspaceId); public boolean workspaceExists(ICredentials credentials, String workspaceName); - - // Below are methods which are just transactional proxy to DAO metods - // They are prefixed DAO so CheckCredentialTicketBeforeAdvice does not pick them up - - /** - * Write out a file to the repository. Closes the stream. Overwrites any existing files. - * - * @return the path to which the file was written - */ - public String daoWriteFile(Long uuid, Long versionId, InputStream is) throws FileException; - - /** - * Gets a file from the repository. - */ - public InputStream daoGetFile(Long uuid, Long versionId) throws FileException; - - /** - * Delete a file from the repository. If this makes the directory - * empty, then the directory should be deleted. - * - * @return 1 if deleted okay, 0 if file not found, -1 if file found but a delete error occured. - */ - public int daoDelete(Long uuid, Long versionId) throws FileException; - - /** - * Get the actual path of the file ie the path on disk - */ - public String daoGetFilePath(Long uuid, Long versionId) throws FileException; - - /** - * Is there a file on disk? - *

- * Used to validate file nodes. - */ - public boolean daoFileExists(Long uuid, Long versionId) throws FileException; - - public List daoFindChildNodes(CrNodeVersion parentNodeVersion); - - public CrNode daoFindChildNode(CrNodeVersion parentNodeVersion, String relPath); } \ No newline at end of file Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/NodeFactory.java =================================================================== diff -u -r1e26200cec472e799b29f548270b1a67027e9167 -rea80430beb4497f12c92db2580341f21750a5a43 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/NodeFactory.java (.../NodeFactory.java) (revision 1e26200cec472e799b29f548270b1a67027e9167) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/NodeFactory.java (.../NodeFactory.java) (revision ea80430beb4497f12c92db2580341f21750a5a43) @@ -21,6 +21,7 @@ * **************************************************************** */ + package org.lamsfoundation.lams.contentrepository.service; import java.io.InputStream; @@ -36,11 +37,11 @@ import org.lamsfoundation.lams.contentrepository.IValue; import org.lamsfoundation.lams.contentrepository.NodeType; import org.lamsfoundation.lams.contentrepository.PropertyName; +import org.lamsfoundation.lams.contentrepository.dao.INodeDAO; import org.lamsfoundation.lams.contentrepository.exception.FileException; import org.lamsfoundation.lams.contentrepository.exception.InvalidParameterException; import org.lamsfoundation.lams.contentrepository.exception.ItemNotFoundException; import org.lamsfoundation.lams.contentrepository.exception.ValueFormatException; -import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; @@ -59,11 +60,15 @@ protected Logger log = Logger.getLogger(NodeFactory.class); private BeanFactory beanFactory = null; - private IUserManagementService userManagementService = null; + private INodeDAO nodeDAO = null; + public NodeFactory() { + super(); + } + /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.service.INodeFactory#createFileNode(org.lamsfoundation.lams. * contentrepository.CrWorkspace, org.lamsfoundation.lams.contentrepository.service.SimpleVersionedNode, * java.lang.String, java.io.InputStream, java.lang.String, java.lang.String, java.lang.String) @@ -82,7 +87,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.service.INodeFactory#createPackageNode(org.lamsfoundation.lams. * contentrepository.CrWorkspace, java.lang.String, java.lang.String) */ @@ -99,7 +104,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.service.INodeFactory#createDataNode(org.lamsfoundation.lams. * contentrepository.CrWorkspace, org.lamsfoundation.lams.contentrepository.service.SimpleVersionedNode, * java.lang.String) @@ -139,7 +144,7 @@ /* * (non-Javadoc) - * + * * @see * org.lamsfoundation.lams.contentrepository.service.INodeFactory#getNode(org.lamsfoundation.lams.contentrepository. * CrNode, java.lang.Long) @@ -154,7 +159,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.service.INodeFactory#getNode(java.lang.Long, java.lang.Long, * java.lang.Long) */ @@ -171,7 +176,7 @@ CrNode node = null; - node = (CrNode) getUserManagementService().findById(CrNode.class, uuid); + node = (CrNode) nodeDAO.find(CrNode.class, uuid); if (node == null) { throw new ItemNotFoundException("Node " + uuid + " not found."); @@ -189,7 +194,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.service.INodeFactory#getNode(java.lang.Long, java.lang.Long, * java.lang.Long, java.lang.String) */ @@ -215,7 +220,7 @@ /* * (non-Javadoc) - * + * * @see * org.lamsfoundation.lams.contentrepository.service.INodeFactory#copy(org.lamsfoundation.lams.contentrepository. * service.SimpleVersionedNode) @@ -230,7 +235,7 @@ /** * Private method to handle the recursive copy. The parent node is needed to set up the * node -> parent link in the CrNode object. - * + * * @param originalNode * @param parentNode * @return new Node @@ -263,7 +268,7 @@ } } - // copy any attached file. don't actually copy the file - set up + // copy any attached file. don't actually copy the file - set up // and input stream and the file will be copied when the node is saved. // this is likely to recopy the Filename and Mimetype properties. if (originalNode.isNodeType(NodeType.FILENODE)) { @@ -293,10 +298,31 @@ * ********************************************************** */ + /* + * (non-Javadoc) + * + * @see org.lamsfoundation.lams.contentrepository.service.INodeFactory#getNodeDAO() + */ + @Override + public INodeDAO getNodeDAO() { + return nodeDAO; + } + + /* + * (non-Javadoc) + * + * @see org.lamsfoundation.lams.contentrepository.service.INodeFactory#setNodeDAO(org.lamsfoundation.lams. + * contentrepository.dao.INodeDAO) + */ + @Override + public void setNodeDAO(INodeDAO nodeDAO) { + this.nodeDAO = nodeDAO; + } + /* **** Method for BeanFactoryAware interface *****************/ /* * (non-Javadoc) - * + * * @see * org.lamsfoundation.lams.contentrepository.service.INodeFactory#setBeanFactory(org.springframework.beans.factory. * BeanFactory) @@ -306,12 +332,4 @@ this.beanFactory = beanFactory; } - public IUserManagementService getUserManagementService() { - // this can not be done by injection as bean factory is not fully initialised when it happens and we get an exception on start up - if (userManagementService == null) { - userManagementService = beanFactory.getBean("userManagementService", IUserManagementService.class); - } - return userManagementService; - } - -} \ No newline at end of file +} Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/SimpleRepository.java =================================================================== diff -u -r1e26200cec472e799b29f548270b1a67027e9167 -rea80430beb4497f12c92db2580341f21750a5a43 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/SimpleRepository.java (.../SimpleRepository.java) (revision 1e26200cec472e799b29f548270b1a67027e9167) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/SimpleRepository.java (.../SimpleRepository.java) (revision ea80430beb4497f12c92db2580341f21750a5a43) @@ -21,6 +21,7 @@ * **************************************************************** */ + package org.lamsfoundation.lams.contentrepository.service; import java.io.FileNotFoundException; @@ -42,7 +43,6 @@ import org.apache.log4j.Logger; import org.lamsfoundation.lams.contentrepository.CrCredential; import org.lamsfoundation.lams.contentrepository.CrNode; -import org.lamsfoundation.lams.contentrepository.CrNodeVersion; import org.lamsfoundation.lams.contentrepository.CrWorkspace; import org.lamsfoundation.lams.contentrepository.CrWorkspaceCredential; import org.lamsfoundation.lams.contentrepository.ICredentials; @@ -54,8 +54,6 @@ import org.lamsfoundation.lams.contentrepository.NodeType; import org.lamsfoundation.lams.contentrepository.PropertyName; import org.lamsfoundation.lams.contentrepository.dao.ICredentialDAO; -import org.lamsfoundation.lams.contentrepository.dao.IFileDAO; -import org.lamsfoundation.lams.contentrepository.dao.INodeDAO; import org.lamsfoundation.lams.contentrepository.dao.IWorkspaceDAO; import org.lamsfoundation.lams.contentrepository.exception.AccessDeniedException; import org.lamsfoundation.lams.contentrepository.exception.FileException; @@ -89,7 +87,7 @@ * run separately and without suitable AOP support then * each transaction method must check that the credential is okay * or that the ticket is a known ticket (isTicketOkay() method). - * + * * This class also depends on the transactions defined in the * application context for the hibernate sessions to work properly. * If the method isn't transactioned, then there won't be a proper @@ -110,8 +108,6 @@ private ICredentialDAO credentialDAO = null; private IWorkspaceDAO workspaceDAO = null; private INodeFactory nodeFactory = null; - private IFileDAO fileDAO = null; - private INodeDAO nodeDAO = null; private Set ticketIdSet = new HashSet(); // set of currently known tickets. @@ -138,10 +134,10 @@ } return user.getUserID(); } - throw new AccessDeniedException( - "Cannot get user details for content repository. No session found - user not logged in or the webservice call has not set up the session details."); + throw new AccessDeniedException( + "Cannot get user details for content repository. No session found - user not logged in or the webservice call has not set up the session details."); - } + } /** * @param workspaceId @@ -159,7 +155,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IRepository#login(org.lamsfoundation.lams.contentrepository. * ICredentials, java.lang.String) */ @@ -186,7 +182,7 @@ } // okay, we should now be able to create a ticket - // make ticket, create new credentials without the password + // make ticket, create new credentials without the password ITicket ticket = new SimpleTicket(workspace.getWorkspaceId()); ticketIdSet.add(ticket.getTicketId()); return ticket; @@ -195,7 +191,7 @@ /** * Add a workspace, giving the credentials as the user of this workspace. * It does not clear the password in the credentials - * + * * @param credentials * this user/password must already exist in the repository. Password will be checked. * @param workspaceName @@ -270,7 +266,7 @@ * The password must be at least 6 chars. * Possibly this should only be available to an internal management tool * *** Security Risk - I'm converting the password to a string... *** - * + * * @throws LoginException * if the oldCredential fails login test (e.g. wrong password) * @throws RepositoryCheckedException @@ -308,9 +304,9 @@ /** * Checks that a password meets our password criteria. This could be implemented * as a Strategy, but that's overkill! - * + * * Checks that the password is six or more characters. - * + * * @param password * @throws RepositoryCheckedException * if @@ -408,7 +404,7 @@ /* * (non-Javadoc) - * + * * @see * org.lamsfoundation.lams.contentrepository.IRepository#logout(org.lamsfoundation.lams.contentrepository.ITicket) */ @@ -430,7 +426,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IRepository#addFileItem(org.lamsfoundation.lams.contentrepository. * ITicket, java.io.InputStream, java.lang.String, java.lang.String, java.lang.String) */ @@ -456,7 +452,7 @@ /* * (non-Javadoc) - * + * * @see * org.lamsfoundation.lams.contentrepository.IRepository#addPackageItem(org.lamsfoundation.lams.contentrepository. * ITicket, java.lang.String, java.lang.String, java.lang.String) @@ -490,7 +486,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IRepository#getFileItem(org.lamsfoundation.lams.contentrepository. * ITicket, java.lang.Long, java.lang.Long) */ @@ -503,7 +499,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IRepository#getFileItem(org.lamsfoundation.lams.contentrepository. * ITicket, java.lang.Long, java.lang.Long, java.lang.String) */ @@ -534,7 +530,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IRepository#getFileItem(org.lamsfoundation.lams.contentrepository. * ITicket, java.lang.Long, java.lang.Long, java.lang.String) */ @@ -560,7 +556,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IRepository#getNodeList(org.lamsfoundation.lams.contentrepository. * ITicket) */ @@ -586,7 +582,7 @@ /* * (non-Javadoc) - * + * * @see * org.lamsfoundation.lams.contentrepository.IRepository#getVersionHistory(org.lamsfoundation.lams.contentrepository * .ITicket, java.lang.Long) @@ -600,7 +596,7 @@ /* * (non-Javadoc) - * + * * @see * org.lamsfoundation.lams.contentrepository.IRepository#updateFileItem(org.lamsfoundation.lams.contentrepository. * ITicket, java.lang.Long, java.lang.String, java.io.InputStream, java.lang.String, java.lang.String) @@ -631,7 +627,7 @@ /* * (non-Javadoc) - * + * * @see * org.lamsfoundation.lams.contentrepository.IRepository#updatePackageItem(org.lamsfoundation.lams.contentrepository * .ITicket, java.lang.Long, java.lang.String, java.lang.String, java.lang.String) @@ -694,7 +690,7 @@ /* * (non-Javadoc) - * + * * @see * org.lamsfoundation.lams.contentrepository.IRepository#copyNodeVersion(org.lamsfoundation.lams.contentrepository. * ITicket, java.lang.Long, java.lang.Long) @@ -727,7 +723,7 @@ /* * (non-Javadoc) - * + * * @see * org.lamsfoundation.lams.contentrepository.IRepository#saveFile(org.lamsfoundation.lams.contentrepository.ITicket, * java.lang.Long, java.lang.String, java.lang.String, java.lang.String) @@ -808,7 +804,7 @@ /* * (non-Javadoc) - * + * * @see * org.lamsfoundation.lams.contentrepository.IRepository#updatePackageItem(org.lamsfoundation.lams.contentrepository * .ITicket, java.lang.Long, java.lang.String, java.lang.String, java.lang.String) @@ -834,7 +830,7 @@ /* * (non-Javadoc) - * + * * @see * org.lamsfoundation.lams.contentrepository.IRepository#updatePackageItem(org.lamsfoundation.lams.contentrepository * .ITicket, java.lang.Long, java.lang.String, java.lang.String, java.lang.String) @@ -854,53 +850,22 @@ } - @Override public boolean workspaceExists(ICredentials credentials, Long workspaceId) { return workspaceDAO.find(CrWorkspace.class, workspaceId) != null; } - @Override public boolean workspaceExists(ICredentials credentials, String workspaceName) { return workspaceDAO.findByName(workspaceName) != null; } - @Override - public InputStream daoGetFile(Long uuid, Long versionId) throws FileException { - return fileDAO.getFile(uuid, versionId); + /* ********** setters and getters for DAOs *******************/ + /** + * @return Returns the workspaceDAO. + */ + public IWorkspaceDAO getWorkspaceDAO() { + return workspaceDAO; } - @Override - public String daoWriteFile(Long uuid, Long versionId, InputStream is) throws FileException { - return fileDAO.writeFile(uuid, versionId, is); - } - - @Override - public int daoDelete(Long uuid, Long versionId) throws FileException { - return fileDAO.delete(uuid, versionId); - } - - @Override - public String daoGetFilePath(Long uuid, Long versionId) throws FileException { - return fileDAO.getFilePath(uuid, versionId); - } - - @Override - public boolean daoFileExists(Long uuid, Long versionId) throws FileException { - return fileDAO.fileExists(uuid, versionId); - } - - @Override - public List daoFindChildNodes(CrNodeVersion parentNodeVersion) { - return nodeDAO.findChildNodes(parentNodeVersion); - } - - @Override - public CrNode daoFindChildNode(CrNodeVersion parentNodeVersion, String relPath) { - return nodeDAO.findChildNode(parentNodeVersion, relPath); - } - - /* ********** setters and getters for DAOs *******************/ - /** * @param workspaceDAO * The workspaceDAO to set. @@ -910,22 +875,26 @@ } /** + * @return Returns the credentialDAO. + */ + public ICredentialDAO getCredentialDAO() { + return credentialDAO; + } + + /** * @param credentialDAO * The credentialDAO to set. */ public void setCredentialDAO(ICredentialDAO credentialDAO) { this.credentialDAO = credentialDAO; } + public INodeFactory getNodeFactory() { + return nodeFactory; + } + public void setNodeFactory(INodeFactory nodeFactory) { this.nodeFactory = nodeFactory; } - public void setFileDAO(IFileDAO fileDAO) { - this.fileDAO = fileDAO; - } - - public void setNodeDAO(INodeDAO nodeDAO) { - this.nodeDAO = nodeDAO; - } -} \ No newline at end of file +} Index: lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/SimpleVersionedNode.java =================================================================== diff -u -rd140daaaa506ac792804b3ce302724b3dde9c830 -rea80430beb4497f12c92db2580341f21750a5a43 --- lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/SimpleVersionedNode.java (.../SimpleVersionedNode.java) (revision d140daaaa506ac792804b3ce302724b3dde9c830) +++ lams_contentrepository/src/java/org/lamsfoundation/lams/contentrepository/service/SimpleVersionedNode.java (.../SimpleVersionedNode.java) (revision ea80430beb4497f12c92db2580341f21750a5a43) @@ -21,6 +21,7 @@ * **************************************************************** */ + package org.lamsfoundation.lams.contentrepository.service; import java.io.File; @@ -52,13 +53,14 @@ import org.lamsfoundation.lams.contentrepository.NodeType; import org.lamsfoundation.lams.contentrepository.PropertyName; import org.lamsfoundation.lams.contentrepository.PropertyType; +import org.lamsfoundation.lams.contentrepository.dao.IFileDAO; +import org.lamsfoundation.lams.contentrepository.dao.INodeDAO; import org.lamsfoundation.lams.contentrepository.exception.FileException; import org.lamsfoundation.lams.contentrepository.exception.InvalidParameterException; import org.lamsfoundation.lams.contentrepository.exception.ItemNotFoundException; import org.lamsfoundation.lams.contentrepository.exception.RepositoryRuntimeException; import org.lamsfoundation.lams.contentrepository.exception.ValidationException; import org.lamsfoundation.lams.contentrepository.exception.ValueFormatException; -import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.FileUtil; /** @@ -103,11 +105,10 @@ private ITicket ticket = null; // transient data - using for grouping nodes in a session /* Spring configured varibles */ - private IRepositoryService repositoryService; - private IUserManagementService userManagementService; + private INodeDAO nodeDAO = null; + private IFileDAO fileDAO = null; + private INodeFactory nodeFactory = null; - private INodeFactory nodeFactory; - // TODO This is a case for AOP! /** * Check that all the necessary objects exists - node, nodeVersion, nodeDAO and fileDAO @@ -123,10 +124,13 @@ throw new RepositoryRuntimeException("Node details missing (nodeVersion=null). " + specialisedMessage); } - if (repositoryService == null) { - throw new RepositoryRuntimeException( - "Node details missing (repositoryService=null). " + specialisedMessage); + if (nodeDAO == null) { + throw new RepositoryRuntimeException("Node details missing (nodeDAO=null). " + specialisedMessage); } + + if (fileDAO == null) { + throw new RepositoryRuntimeException("Node details missing (fileDAO=null). " + specialisedMessage); + } } /** Add a child to the node. To be used by SimpleVersionedNode and the NodeFactory only */ @@ -144,7 +148,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IVersionedNode#setProperty(java.lang.String, java.lang.String, * int) */ @@ -156,7 +160,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IVersionedNode#setProperty(java.lang.String, java.lang.String) */ @Override @@ -167,7 +171,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IVersionedNode#setProperty(java.lang.String, boolean) */ @Override @@ -178,7 +182,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IVersionedNode#setProperty(java.lang.String, double) */ @Override @@ -189,7 +193,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IVersionedNode#setProperty(java.lang.String, long) */ @Override @@ -200,7 +204,7 @@ /* * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IVersionedNode#setProperty(java.lang.String, java.util.Calendar) */ @Override @@ -267,7 +271,7 @@ /** * (non-Javadoc) - * + * * @see org.lamsfoundation.lams.contentrepository.IVersionedNode#isNodeType(java.lang.String) */ @Override @@ -280,7 +284,7 @@ * Get the history for this node. Quite intensive operation * as it has to build all the data structures. Can't be easily * cached. - * + * * @return SortedSet of IVersionDetail objects, ordered by version */ @Override @@ -376,7 +380,7 @@ * of the caller to close the stream. Note: this should only be * called once the node is saved - do not call it directly after * setting the file stream - * + * * If the node is a package node, it will get the input stream * of the first file. */ @@ -386,7 +390,7 @@ if (isNodeType(NodeType.FILENODE)) { - return repositoryService.daoGetFile(node.getNodeId(), nodeVersion.getVersionId()); + return fileDAO.getFile(node.getNodeId(), nodeVersion.getVersionId()); } else if (isNodeType(NodeType.PACKAGENODE)) { @@ -412,7 +416,7 @@ /** * Set the file, passed in as an inputstream. The stream will be closed * when the file is saved. Only nodes of type FILENODE can have a file! - * + * * @param iStream * mandatory * @param filename @@ -474,7 +478,7 @@ * we could just be doing a setProperty save, in which case the file * will already exist. *

  • Package nodes must not have a file, must have a INITIALPATH property - * + * * @throws ValidationException * if problems exist. */ @@ -506,7 +510,7 @@ // if it is a new node or a new version then it must have a file, otherwise check on disk. // version id will always be set. uuid isn't set until the record is written to the db, // but don't want to rely on that if we can help it in case it changes in future. - if (newIStream == null && (uuid == null || !repositoryService.daoFileExists(uuid, versionId))) { + if (newIStream == null && (uuid == null || !fileDAO.fileExists(uuid, versionId))) { errors = errors + "\nNode is a file node but the file is missing. "; } } catch (FileException fe) { @@ -537,19 +541,19 @@ * Save the changes to this node. This method must be called when saving a file * or package node for the first time - it does both the database and the file * saves. - * + * * If it is a file node, then it writes out the db changes and then saves * the file. - * + * * If is is a package node, then it writes out the db changes for all the nodes, * then saves all the file. Why do it this way - we want to do all the file * changes at the end as they cannot be rolled back if there is a db error. - * + * * This method only works as we know that we have two levels of nodes - the * childNodes can't have their own childNodes. If this is no longer the case, * this method and copy() will need to be changed. + * * - * * TODO This needs a lot of testing */ protected Long save() throws ValidationException, FileException { @@ -602,7 +606,7 @@ SimpleVersionedNode element = (SimpleVersionedNode) writtenIter.next(); int delStatus = -1; try { - delStatus = repositoryService.daoDelete(element.getUUID(), element.getVersion()); + delStatus = fileDAO.delete(element.getUUID(), element.getVersion()); } catch (Exception e2) { // things are getting bad - throwing exceptions on the delete! } @@ -611,8 +615,7 @@ : element.getFilePath(); } else { failedDeleted = failedDeleted != null - ? failedDeleted + File.pathSeparator + element.getFilePath() - : element.getFilePath(); + ? failedDeleted + File.pathSeparator + element.getFilePath() : element.getFilePath(); } } String msg = "Result of rolling back file changes:"; @@ -647,7 +650,7 @@ // nodeDAO to take care of insert or update (uses saveOrUpdate) // the nodeVersion and nodeVersionProperty collections cascade // updates and deletes, so we can just save the node! - userManagementService.save(node); + nodeDAO.saveOrUpdate(node); // child nodes are done manually as the set is lazy loaded // and can't work out how to do that properly using the DAO template! @@ -656,21 +659,21 @@ Iterator iter = childNodes.iterator(); while (iter.hasNext()) { SimpleVersionedNode node = (SimpleVersionedNode) iter.next(); - userManagementService.save(node.getNode()); + nodeDAO.saveOrUpdate(node.getNode()); } } } /** * Write the file out (if one exists). Sets the private attribute filePath. - * + * * @return the path to which the file was written */ private void writeFile() throws FileException { String filePath = null; if (newIStream != null) { - filePath = repositoryService.daoWriteFile(node.getNodeId(), nodeVersion.getVersionId(), newIStream); + filePath = fileDAO.writeFile(node.getNodeId(), nodeVersion.getVersionId(), newIStream); } setFilePath(filePath); } @@ -692,7 +695,7 @@ /** * Another case for the factory? - * + * * @see org.lamsfoundation.lams.contentrepository.IVersionedNode#getNode(String relPath) */ @Override @@ -704,7 +707,7 @@ log.debug("getNode for path " + relPath + " start."); } - CrNode childNode = repositoryService.daoFindChildNode(nodeVersion, relPath); + CrNode childNode = nodeDAO.findChildNode(nodeVersion, relPath); if (childNode != null) { return nodeFactory.getNode(childNode, null); @@ -716,12 +719,12 @@ /** * If no nodes are found, returns an empty set. - * + * * @see org.lamsfoundation.lams.contentrepository.IVersionedNode#getChildNodes() */ @Override public Set getChildNodes() { - List childCrNodes = repositoryService.daoFindChildNodes(nodeVersion); + List childCrNodes = nodeDAO.findChildNodes(nodeVersion); Set childNodes = new HashSet(); if (childCrNodes != null) { @@ -772,20 +775,20 @@ */ @Override public boolean hasNodes() { - List childNodes = repositoryService.daoFindChildNodes(nodeVersion); + List childNodes = nodeDAO.findChildNodes(nodeVersion); return (childNodes != null && childNodes.size() > 0); } /** * Delete all versions of this node, returning the number of nodes * deleted. If it is a package node, all child nodes will be deleted. - * + * * @see org.lamsfoundation.lams.contentrepository.IVersionedNodeAdmin#deleteNode() */ @Override public List deleteNode() { - // first make a list of all the versions to delete. + // first make a list of all the versions to delete. // don't iterate over the set, deleting as we go so that // we can't run into any issues trying to access something // that is deleted or belongs to an iterator. @@ -819,16 +822,16 @@ // doing file system changes if the db would fail later. deleteVersionFromDB(nodeKeysDeleted); - // now delete the files. If it fails due to the file not being found, then + // now delete the files. If it fails due to the file not being found, then // that's fine. ArrayList failedList = new ArrayList(); Iterator iter = nodeKeysDeleted.iterator(); while (iter.hasNext()) { NodeKey nk = (NodeKey) iter.next(); try { - int delStatus = repositoryService.daoDelete(nk.getUuid(), nk.getVersion()); + int delStatus = fileDAO.delete(nk.getUuid(), nk.getVersion()); if (delStatus == -1) { - failedList.add(repositoryService.daoGetFilePath(nk.getUuid(), nk.getVersion())); + failedList.add(fileDAO.getFilePath(nk.getUuid(), nk.getVersion())); } } catch (FileException e) { log.error("FileException occured while deleting files for " + nodeDescription, e); @@ -879,15 +882,15 @@ // if this was the last version for the node, delete the node if (node.getCrNodeVersions() == null || node.getCrNodeVersions().size() == 0) { - userManagementService.delete(node); + nodeDAO.delete(node); } } /** * Process files in the package. Create a List of file nodes but do not persist * the nodes. - * + * * @param dirPath: * the directory from which to get files. Mandatory. * @param packageNode: @@ -1006,11 +1009,11 @@ /** * Copy the supplied node/version to a new node. Does not copy the history * of the node. Copies any child nodes of the current version. All files are duplicated. - * + * * This method only works as we know that we have two levels of nodes - the * childNodes can't have their own childNodes. If this is no longer the case, * this method and SimpleVersionedNode.save() will need to be changed. - * + * * @throws FileException * will occur if there is a problem reading a file from the repository * @throws InvalidParameterException @@ -1061,19 +1064,45 @@ * ********************************************************** */ - public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; + /** + * @return Returns the nodeDAO. + */ + public INodeDAO getNodeDAO() { + return nodeDAO; } - public void setNodeFactory(INodeFactory nodeFactory) { - this.nodeFactory = nodeFactory; + /** + * @param nodeDAO + * The nodeDAO to set. + */ + public void setNodeDAO(INodeDAO nodeDAO) { + this.nodeDAO = nodeDAO; } - public void setUserManagementService(IUserManagementService userManagementService) { - this.userManagementService = userManagementService; + /** + * @return Returns the fileDAO. + */ + public IFileDAO getFileDAO() { + return fileDAO; } /** + * @param fileDAO + * The fileDAO to set. + */ + public void setFileDAO(IFileDAO fileDAO) { + this.fileDAO = fileDAO; + } + + public INodeFactory getNodeFactory() { + return nodeFactory; + } + + public void setNodeFactory(INodeFactory nodeFactory) { + this.nodeFactory = nodeFactory; + } + + /** * Clean up any resources that will not be cleaned up by the garbage * collector after this object is destroyed. At present, all it does is * close the filestream if needed @@ -1088,4 +1117,5 @@ log.debug("Unable to close stream - was it already closed perhaps?", e); } } -} \ No newline at end of file + +} Index: lams_learning/src/java/org/lamsfoundation/lams/learning/command/CommandWebsocketServer.java =================================================================== diff -u -rd140daaaa506ac792804b3ce302724b3dde9c830 -rea80430beb4497f12c92db2580341f21750a5a43 --- lams_learning/src/java/org/lamsfoundation/lams/learning/command/CommandWebsocketServer.java (.../CommandWebsocketServer.java) (revision d140daaaa506ac792804b3ce302724b3dde9c830) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/command/CommandWebsocketServer.java (.../CommandWebsocketServer.java) (revision ea80430beb4497f12c92db2580341f21750a5a43) @@ -122,7 +122,7 @@ static { // run the singleton thread -// CommandWebsocketServer.sendWorker.start(); + CommandWebsocketServer.sendWorker.start(); } /**