diff --git a/config/alfresco/hibernate-context.xml b/config/alfresco/hibernate-context.xml index d15722adb6..7c417efaa2 100644 --- a/config/alfresco/hibernate-context.xml +++ b/config/alfresco/hibernate-context.xml @@ -274,6 +274,9 @@ + + + diff --git a/config/alfresco/model/recordsModel.xml b/config/alfresco/model/recordsModel.xml deleted file mode 100644 index cf135f6a5a..0000000000 --- a/config/alfresco/model/recordsModel.xml +++ /dev/null @@ -1,458 +0,0 @@ - - - - - - - - - Records Management Model - John Newton - 1.0 - - - - - - - - - - - - - - - - - - - - - - RM: User Specified Data - - - Privacy Act System - d:text - false - - - - - - - - RM: File Plan - - - Record Category Identifier - d:text - true - - - Disposition Authority - d:text - true - - - Permanent Record Indicator - d:boolean - true - - - Disposition Instructions - d:text - true - - - Contains Records Folders - d:boolean - true - - - Name of Folders - d:text - false - - - Default Media Format - d:category - false - - - Default Marking List - d:category - false - true - - - Default Originating Org - d:text - false - - - - - Vital Record Indicator - d:boolean - true - - - Vital Record Review Period - d:category - true - - - - - Process Cutoff - d:boolean - false - - - Event Trigger - d:text - false - - - Cutoff Period - d:category - false - - - Cutoff When Obsolete - d:boolean - false - - - Cutoff When Superseded - d:boolean - false - - - - - Process Hold - d:boolean - false - - - Hold Period in Years - d:float - false - - - Discretionary Hold - d:boolean - false - - - - - Process Transfer - d:boolean - false - - - Transfer Location - d:text - false - - - Transfer Blocksize in Years - d:float - false - - - - - Process Accession - d:boolean - false - - - Time to Accession in Years - d:float - false - - - Accession Location - d:text - false - - - Accession Blocksize in Years - d:float - false - - - - - Process Destruction - d:boolean - false - - - Destruction Location - d:text - false - - - - - Note - d:text - false - - - Record Counter - d:int - false - - - - rma:userSpecifiedData - - - - - - RM: Superseded - - - Superceded By - - rma:supersededBy - false - true - - - cm:content - rma:supersedes - false - true - - - - - - - - - RM: Record - - - Unique Record Identifier - d:text - true - - - Subject - d:text - - - Format - d:text - true - - - Media Format - d:category - true - - - Date Filed - d:datetime - true - - - Publication Date - d:datetime - true - - - Date Received - d:datetime - false - - - Originator - d:text - true - - - Originating Organization - d:text - true - - - Addressee - d:text - true - - - Other Addressees - d:text - false - - - Supplemental Marking List - d:category - false - true - - - Obsolete - d:boolean - false - - - Note - d:text - false - - - - cm:auditable - cm:author - rma:userSpecifiedData - cm:referencing - rma:superseded - - - - - - RM: Vital Record - - - Vital Record - d:boolean - false - - - Last Review Date - d:datetime - false - - - Next Review Date - d:datetime - false - - - - - - - - RM: Cutoffable - - - Cutoff Executed - d:boolean - false - - - Cutoff Now - d:boolean - false - - - Cutoff Date - d:datetime - false - - - Cutoff Event - d:text - false - - - - - - - - RM: Holdable - - - Hold Executed - d:boolean - false - - - Hold Until - d:datetime - false - - - Hold Until Event - d:text - false - - - Freeze - d:boolean - false - - - - - - - - RM: Transferable - - - Transfer Executed - d:boolean - false - - - Transfer Date - d:datetime - false - - - - - - - - RM: Accessionable - - - Accession Executed - d:boolean - false - - - Accession Date - d:datetime - false - - - - - - - - RM: Destroyable - - - Destruction Date - d:datetime - false - - - - - sys:temporary - - - - - - \ No newline at end of file diff --git a/config/alfresco/rule-services-context.xml b/config/alfresco/rule-services-context.xml index d5697b927f..02a5b12361 100644 --- a/config/alfresco/rule-services-context.xml +++ b/config/alfresco/rule-services-context.xml @@ -56,9 +56,12 @@ - - - + + + + + + diff --git a/source/java/org/alfresco/filesys/server/auth/AlfrescoAuthenticator.java b/source/java/org/alfresco/filesys/server/auth/AlfrescoAuthenticator.java index aa7bf81ecb..70240a8a6e 100644 --- a/source/java/org/alfresco/filesys/server/auth/AlfrescoAuthenticator.java +++ b/source/java/org/alfresco/filesys/server/auth/AlfrescoAuthenticator.java @@ -394,7 +394,7 @@ public class AlfrescoAuthenticator extends CifsAuthenticator { // Start a transaction - sess.beginReadTransaction( m_transactionService); + sess.beginWriteTransaction( m_transactionService); // Default logon status to disallow diff --git a/source/java/org/alfresco/filesys/smb/server/repo/CifsHelper.java b/source/java/org/alfresco/filesys/smb/server/repo/CifsHelper.java index 0c9667dfaf..73b2283261 100644 --- a/source/java/org/alfresco/filesys/smb/server/repo/CifsHelper.java +++ b/source/java/org/alfresco/filesys/smb/server/repo/CifsHelper.java @@ -553,10 +553,15 @@ public class CifsHelper try { + // remove the tempory aspects from the nodes, this will be reapplied if the new name dictates it + nodeService.removeAspect(tempNodeRef, ContentModel.ASPECT_TEMPORARY); + // rename temp file to the new name fileFolderService.rename(tempNodeRef, newName); + // rename new file to old name fileFolderService.rename(nodeToMoveRef, tempName); + this.nodeService.addAspect(nodeToMoveRef, ContentModel.ASPECT_TEMPORARY, null); } catch (org.alfresco.service.cmr.model.FileNotFoundException e) { @@ -617,6 +622,36 @@ public class CifsHelper } } + /** + * Rename a node + * + * @param nodeToRenameRef Node to be renamed + * @param newName New name for the node + * @throws FileExistsException + */ + public void rename(NodeRef nodeToRenameRef, String newName) throws FileExistsException + { + try + { + // Check if the new file name is a temporary file name + if ( newName.endsWith(".tmp") || newName.endsWith(".temp")) + nodeService.addAspect(nodeToRenameRef, ContentModel.ASPECT_TEMPORARY, null); + + fileFolderService.rename(nodeToRenameRef, newName); + } + catch (org.alfresco.service.cmr.model.FileExistsException e) + { + throw new FileExistsException(newName); + } + catch (Throwable e) + { + throw new AlfrescoRuntimeException("Rename failed: \n" + + " node to rename: " + nodeToRenameRef + "\n" + + " new name: " + newName, + e); + } + } + /** * Return the file name for a node * diff --git a/source/java/org/alfresco/filesys/smb/server/repo/ContentDiskDriver.java b/source/java/org/alfresco/filesys/smb/server/repo/ContentDiskDriver.java index 8808c3a5d0..292d94b09c 100644 --- a/source/java/org/alfresco/filesys/smb/server/repo/ContentDiskDriver.java +++ b/source/java/org/alfresco/filesys/smb/server/repo/ContentDiskDriver.java @@ -1213,9 +1213,9 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa // Check for delete access - if ( params.hasAccessMode(AccessMode.NTDelete) && - permissionService.hasPermission(nodeRef, PermissionService.DELETE) == AccessStatus.DENIED) - throw new AccessDeniedException("No delete access to " + params.getFullPath()); +// if ( params.hasAccessMode(AccessMode.NTDelete) && +// permissionService.hasPermission(nodeRef, PermissionService.DELETE) == AccessStatus.DENIED) +// throw new AccessDeniedException("No delete access to " + params.getFullPath()); // Check if the file has a lock @@ -1899,6 +1899,14 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa NodeRef targetFolderRef = getNodeForPath(tree, splitPaths[0]); String name = splitPaths[1]; + // Check if this is a rename within the same folder + + String[] oldPaths = FileName.splitPath( oldName); + + boolean sameFolder = false; + if ( splitPaths[0].equalsIgnoreCase( oldPaths[0])) + sameFolder = true; + // Update the state table boolean relinked = false; @@ -1961,9 +1969,30 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa if (!relinked) { - // Move the file/folder + // Move or rename the file/folder - cifsHelper.move(nodeToMoveRef, targetFolderRef, name); + if ( sameFolder == true) + { + // Rename the file/folder + + cifsHelper.rename(nodeToMoveRef, name); + + // DEBUG + + if ( logger.isDebugEnabled()) + logger.debug("Renamed file: from: " + oldName + " to: " + newName); + } + else + { + // Move the file/folder + + cifsHelper.move(nodeToMoveRef, targetFolderRef, name); + + // DEBUG + + if ( logger.isDebugEnabled()) + logger.debug("Moved file: from: " + oldName + " to: " + newName); + } // Check if we renamed a file, if so then cache the rename details for a short period // in case another file renamed to the old name. MS Word uses renames to move a new @@ -2009,7 +2038,7 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa // DEBUG if (logger.isDebugEnabled()) - logger.debug("Moved node: " + " from: " + oldName + " to: " + newName); + logger.debug("Moved node: from: " + oldName + " to: " + newName); } catch (org.alfresco.repo.security.permissions.AccessDeniedException ex) { @@ -2042,7 +2071,7 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa // Convert to a general I/O exception - throw new IOException("Rename file " + oldName); + throw new AccessDeniedException("Rename file " + oldName); } } diff --git a/source/java/org/alfresco/repo/audit/hibernate/HibernateAuditDAO.java b/source/java/org/alfresco/repo/audit/hibernate/HibernateAuditDAO.java index f4fc64b7eb..4e9dbb45ae 100644 --- a/source/java/org/alfresco/repo/audit/hibernate/HibernateAuditDAO.java +++ b/source/java/org/alfresco/repo/audit/hibernate/HibernateAuditDAO.java @@ -34,9 +34,11 @@ import java.util.Collections; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.repo.audit.AuditComponentImpl; import org.alfresco.repo.audit.AuditConfiguration; import org.alfresco.repo.audit.AuditDAO; import org.alfresco.repo.audit.AuditState; @@ -52,8 +54,12 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.datatype.Duration; import org.alfresco.util.EqualsHelper; import org.alfresco.util.GUID; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.hibernate.Session; +import org.hibernate.mapping.Column; import org.springframework.orm.hibernate3.HibernateCallback; +import org.springframework.orm.hibernate3.LocalSessionFactoryBean; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; /** @@ -63,6 +69,11 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport; */ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, TransactionalDao { + /** + * Logging + */ + private static Log s_logger = LogFactory.getLog(HibernateAuditDAO.class); + public static final String QUERY_LAST_AUDIT_DATE = "audit.GetLatestAuditDate"; public static final String QUERY_LAST_AUDIT_CONFIG = "audit.GetLatestAuditConfig"; @@ -78,13 +89,13 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, public static final String QUERY_AUDIT_APP_SOURCE_MET = "method"; public static final String QUERY_AUDIT_TRAIL = "audit.GetAuditTrailForNode"; - + public static final String QUERY_AUDIT_PROTOCOL = "protocol"; - + public static final String QUERY_AUDIT_STORE_ID = "store_id"; - + public static final String QUERY_AUDIT_NODE_ID = "node_id"; - + public static final String QUERY_AUDIT_NODE_REF = "nodeRef"; /** a uuid identifying this unique instance */ @@ -97,9 +108,11 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, private ThreadLocal auditConfigImplId = new ThreadLocal(); private ThreadLocal auditDateImplId = new ThreadLocal(); - + private ThreadLocal> sourceIds = new ThreadLocal>(); + private LocalSessionFactoryBean localSessionFactory; + public HibernateAuditDAO() { super(); @@ -116,13 +129,18 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, this.contentStore = contentStore; } + public void setLocalSessionFactory(LocalSessionFactoryBean localSessionFactory) + { + this.localSessionFactory = localSessionFactory; + } + public void audit(AuditState auditInfo) { - if(auditInfo.getUserIdentifier() == null) + if (auditInfo.getUserIdentifier() == null) { auditInfo.setUserIdentifier(AuthenticationUtil.getSystemUserName()); } - if(AuthenticationUtil.getCurrentUserName() == null) + if (AuthenticationUtil.getCurrentUserName() == null) { AuthenticationUtil.setSystemUserAsCurrentUser(); try @@ -131,7 +149,7 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, } finally { - AuthenticationUtil.clearCurrentSecurityContext(); + AuthenticationUtil.clearCurrentSecurityContext(); } } else @@ -139,7 +157,7 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, audit0(auditInfo); } } - + private void audit0(AuditState auditInfo) { // Find/Build the configuraton entry @@ -163,25 +181,25 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, if (args != null) { + int length; switch (args.length) { default: case 5: - auditFact.setArg5(getStringOrNull(args[4])); + auditFact.setArg5(getStringOrNull(args[4], getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "arg5"))); case 4: - auditFact.setArg4(getStringOrNull(args[3])); + auditFact.setArg4(getStringOrNull(args[3], getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "arg4"))); case 3: - auditFact.setArg3(getStringOrNull(args[2])); + auditFact.setArg3(getStringOrNull(args[2], getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "arg3"))); case 2: - auditFact.setArg2(getStringOrNull(args[1])); + auditFact.setArg2(getStringOrNull(args[1], getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "arg2"))); case 1: - auditFact.setArg1(getStringOrNull(args[0])); + auditFact.setArg1(getStringOrNull(args[0], getColumnLength("org.alfresco.repo.audit.hibernate.AuditFactImpl", "arg1"))); case 0: } } - auditFact.setClientInetAddress(auditInfo.getClientAddress() == null ? null : auditInfo.getClientAddress() - .toString()); + auditFact.setClientInetAddress(auditInfo.getClientAddress() == null ? null : auditInfo.getClientAddress().toString()); auditFact.setDate(auditInfo.getDate()); auditFact.setException(auditInfo.getThrowable() == null ? null : auditInfo.getThrowable().getMessage()); auditFact.setFail(auditInfo.isFail()); @@ -206,7 +224,23 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, } - private String getStringOrNull(Object o) + private int getColumnLength(String entityName, String propertyName) + { + int length = -1; + Iterator it = localSessionFactory.getConfiguration().getClassMapping(entityName).getProperty(propertyName).getValue().getColumnIterator(); + if (it.hasNext()) + { + Column col = (Column) it.next(); + length = col.getLength(); + } + if (s_logger.isDebugEnabled()) + { + s_logger.debug(entityName + " "+propertyName+ " is of length " + length); + } + return length; + } + + private String getStringOrNull(Object o, int size) { if (o == null) { @@ -216,11 +250,21 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, { try { - return o.toString(); + String answer = o.toString(); + if((size > -1) && (answer.length() > size)) + { + answer = answer.substring(0, size); + } + return answer; } - catch(Throwable t) + catch (Throwable t) { - return "Throwable in toString implementation for "+o.getClass() + " was "+t.getMessage(); + String answer = "Throwable in toString implementation for " + o.getClass() + " was " + t.getMessage(); + if((size > -1) && (answer.length() > size)) + { + answer = answer.substring(0, size); + } + return answer; } } } @@ -228,28 +272,26 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, private AuditSource getAuditSource(AuditState auditInfo) { AuditSource auditSourceImpl; - + SourceKey sourceKey = new SourceKey(auditInfo.getAuditApplication(), auditInfo.getAuditService(), auditInfo.getAuditMethod()); - if(sourceIds.get() == null) + if (sourceIds.get() == null) { sourceIds.set(new HashMap()); } Long id = sourceIds.get().get(sourceKey); - if(id != null) + if (id != null) { auditSourceImpl = (AuditSource) getSession().get(AuditSourceImpl.class, id.longValue()); - if(auditSourceImpl != null) + if (auditSourceImpl != null) { return auditSourceImpl; } } - + if ((auditInfo.getAuditService() != null) - && (auditInfo.getAuditService().length() > 0) && (auditInfo.getAuditMethod() != null) - && (auditInfo.getAuditMethod().length() > 0)) + && (auditInfo.getAuditService().length() > 0) && (auditInfo.getAuditMethod() != null) && (auditInfo.getAuditMethod().length() > 0)) { - auditSourceImpl = AuditSourceImpl.getApplicationSource(getSession(), auditInfo.getAuditApplication(), - auditInfo.getAuditService(), auditInfo.getAuditMethod()); + auditSourceImpl = AuditSourceImpl.getApplicationSource(getSession(), auditInfo.getAuditApplication(), auditInfo.getAuditService(), auditInfo.getAuditMethod()); if (auditSourceImpl == null) { auditSourceImpl = new AuditSourceImpl(); @@ -350,8 +392,7 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, } catch (IOException e) { - throw new AlfrescoRuntimeException( - "Failed to read and validate current audit configuration against the last", e); + throw new AlfrescoRuntimeException("Failed to read and validate current audit configuration against the last", e); } if (currentValue != lastValue) { @@ -368,8 +409,7 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, } else { - auditConfig = (AuditConfig) getSession() - .get(AuditConfigImpl.class, auditConfigImplId.get().longValue()); + auditConfig = (AuditConfig) getSession().get(AuditConfigImpl.class, auditConfigImplId.get().longValue()); if (auditConfig == null) { auditConfig = createNewAuditConfigImpl(auditInfo); @@ -472,8 +512,7 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, } SourceKey other = (SourceKey) o; return EqualsHelper.nullSafeEquals(this.application, other.application) - && EqualsHelper.nullSafeEquals(this.service, other.service) - && EqualsHelper.nullSafeEquals(this.method, other.method); + && EqualsHelper.nullSafeEquals(this.service, other.service) && EqualsHelper.nullSafeEquals(this.method, other.method); } @Override @@ -494,20 +533,19 @@ public class HibernateAuditDAO extends HibernateDaoSupport implements AuditDAO, public List getAuditTrail(NodeRef nodeRef) { - if(nodeRef == null) + if (nodeRef == null) { - return Collections.emptyList(); + return Collections. emptyList(); } List internalTrail = AuditFactImpl.getAuditTrail(getSession(), nodeRef); - + ArrayList answer = new ArrayList(internalTrail.size()); - for(AuditFact auditFact : internalTrail) + for (AuditFact auditFact : internalTrail) { AuditInfo info = new AuditInfoImpl(auditFact); answer.add(info); } return answer; } - - + } diff --git a/source/java/org/alfresco/repo/avm/wf/AVMClearSubmittedHandler.java b/source/java/org/alfresco/repo/avm/wf/AVMClearSubmittedHandler.java index f2b5248c50..2cccc16df8 100644 --- a/source/java/org/alfresco/repo/avm/wf/AVMClearSubmittedHandler.java +++ b/source/java/org/alfresco/repo/avm/wf/AVMClearSubmittedHandler.java @@ -29,6 +29,7 @@ import java.util.List; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.workflow.jbpm.JBPMNode; import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler; +import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avmsync.AVMDifference; @@ -46,64 +47,82 @@ import org.springframework.beans.factory.BeanFactory; */ public class AVMClearSubmittedHandler extends JBPMSpringActionHandler { - private static final long serialVersionUID = 4113360751217684995L; + private static final long serialVersionUID = 4113360751217684995L; - /** - * The AVMService instance. - */ - private AVMService fAVMService; + /** + * The AVMService instance. + */ + private AVMService avmService; - /** - * The AVMSyncService instance. - */ - private AVMSyncService fAVMSyncService; + /** + * The AVMSyncService instance. + */ + private AVMSyncService avmSyncService; - /** - * The AVMSubmittedAspect instance. - */ - private AVMSubmittedAspect fAVMSubmittedAspect; + /** + * The AVMSubmittedAspect instance. + */ + private AVMSubmittedAspect avmSubmittedAspect; + /** + * Initialize service references. + * @param factory The BeanFactory to get references from. + */ + @Override + protected void initialiseHandler(BeanFactory factory) + { + this.avmService = (AVMService)factory.getBean(ServiceRegistry.AVM_SERVICE.getLocalName()); + this.avmSyncService = (AVMSyncService)factory.getBean(ServiceRegistry.AVM_SYNC_SERVICE.getLocalName()); + this.avmSubmittedAspect = (AVMSubmittedAspect)factory.getBean("AVMSubmittedAspect"); + } - - /** - * Initialize service references. - * @param factory The BeanFactory to get references from. - */ - @Override - protected void initialiseHandler(BeanFactory factory) - { - fAVMService = (AVMService)factory.getBean("AVMService"); - fAVMSyncService = (AVMSyncService)factory.getBean("AVMSyncService"); - fAVMSubmittedAspect = (AVMSubmittedAspect)factory.getBean("AVMSubmittedAspect"); - } - - /** - * Do the actual work. - * @param executionContext The context to get stuff from. - */ - public void execute(ExecutionContext executionContext) throws Exception - { - // TODO: Allow submit parameters to be passed into this action handler - // rather than pulling directly from execution context + /** + * Do the actual work. + * @param executionContext The context to get stuff from. + */ + public void execute(final ExecutionContext executionContext) + throws Exception + { + // TODO: Allow submit parameters to be passed into this action handler + // rather than pulling directly from execution context - // NOTE: Submitted items can only be marked as "submitted" if we know where they came from - String from = (String)executionContext.getContextInstance().getVariable("wcmwf_fromPath"); - if (from != null && from.length() > 0) - { - // retrieve list of changes in submitted package - NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef(); - Pair pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg); - AVMNodeDescriptor pkgDesc = fAVMService.lookup(pkgPath.getFirst(), pkgPath.getSecond()); - String targetPath = pkgDesc.getIndirection(); - List diffs = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath, null); + // NOTE: Submitted items can only be marked as "submitted" if we know where they came from + String from = (String)executionContext.getContextInstance().getVariable("wcmwf_fromPath"); + if (from == null || from.length() == 0) + { + return; + } + // retrieve list of changes in submitted package + NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef(); + Pair pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg); + AVMNodeDescriptor pkgDesc = this.avmService.lookup(pkgPath.getFirst(), pkgPath.getSecond()); + String targetPath = pkgDesc.getIndirection(); + final List diffs = this.avmSyncService.compare(pkgPath.getFirst(), + pkgPath.getSecond(), + -1, + targetPath, + null); - // for each change, mark original as submitted - for (AVMDifference diff : diffs) - { - String submittedPath = from + diff.getSourcePath().substring(pkgPath.getSecond().length()); - fAVMSubmittedAspect.clearSubmitted(-1, submittedPath); - } - } - } - + // for each change, mark original as submitted + for (final AVMDifference diff : diffs) + { + final String submittedPath = from + diff.getSourcePath().substring(pkgPath.getSecond().length()); + this.clearSubmitted(this.avmService.lookup(-1, submittedPath, true)); + } + } + + /** + * Recursively clear the submitted aspect. + */ + private void clearSubmitted(final AVMNodeDescriptor d) + { + this.avmSubmittedAspect.clearSubmitted(d.getVersionID(), d.getPath()); + if (d.isDirectory()) + { + for (final AVMNodeDescriptor c : this.avmService.getDirectoryListingArray(d, true)) + { + this.clearSubmitted(c); + } + } + } } diff --git a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java index bea6b5f70d..71e6a3bfcd 100644 --- a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java +++ b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java @@ -19,7 +19,8 @@ * and Open Source Software ("FLOSS") applications as described in Alfresco's * FLOSS exception. You should have recieved a copy of the text describing * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" */ + * http://www.alfresco.com/legal/licensing + */ package org.alfresco.repo.avm.wf; import java.io.Serializable; @@ -44,8 +45,9 @@ import org.alfresco.util.Pair; import org.jbpm.graph.exe.ExecutionContext; import org.springframework.beans.factory.BeanFactory; -public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements - Serializable +public class AVMSubmitPackageHandler + extends JBPMSpringActionHandler + implements Serializable { private static final long serialVersionUID = 4113360751217684995L; @@ -116,8 +118,9 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements final List stagingDiffs = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath, null); for (final AVMDifference diff : stagingDiffs) { - fAVMSubmittedAspect.clearSubmitted(diff.getSourceVersion(), diff.getSourcePath()); - recursivelyRemoveLocks(webProject, diff.getSourceVersion(), diff.getSourcePath()); + this.recursivelyRemoveLocksAndSubmittedAspect(webProject, + diff.getSourceVersion(), + diff.getSourcePath()); } // Allow AVMSubmitTransactionListener to inspect the staging diffs @@ -150,8 +153,9 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements * Recursively remove locks from a path. Walking child folders looking for files * to remove locks from. */ - private void recursivelyRemoveLocks(String webProject, int version, String path) + private void recursivelyRemoveLocksAndSubmittedAspect(final String webProject, final int version, final String path) { + fAVMSubmittedAspect.clearSubmitted(version, path); AVMNodeDescriptor desc = fAVMService.lookup(version, path, true); if (desc.isFile() || desc.isDeletedFile()) { @@ -159,10 +163,9 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements } else { - Map list = fAVMService.getDirectoryListing(version, path, true); - for (AVMNodeDescriptor child : list.values()) + for (final AVMNodeDescriptor child : fAVMService.getDirectoryListingArray(version, path, true)) { - recursivelyRemoveLocks(webProject, version, child.getPath()); + this.recursivelyRemoveLocksAndSubmittedAspect(webProject, version, child.getPath()); } } } diff --git a/source/java/org/alfresco/repo/rule/RuleTypeImpl.java b/source/java/org/alfresco/repo/rule/RuleTypeImpl.java index dce5fc2e01..a2019c98a8 100644 --- a/source/java/org/alfresco/repo/rule/RuleTypeImpl.java +++ b/source/java/org/alfresco/repo/rule/RuleTypeImpl.java @@ -27,9 +27,11 @@ package org.alfresco.repo.rule; import java.util.List; import org.alfresco.i18n.I18NUtil; +import org.alfresco.model.ContentModel; import org.alfresco.repo.action.CommonResourceAbstractBase; import org.alfresco.repo.rule.ruletrigger.RuleTrigger; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.rule.Rule; import org.alfresco.service.cmr.rule.RuleService; import org.alfresco.service.cmr.rule.RuleType; @@ -52,6 +54,11 @@ public class RuleTypeImpl extends CommonResourceAbstractBase implements RuleType * The rule service */ private RuleService ruleService; + + /** + * The node service + */ + private NodeService nodeService; /** * Constructor @@ -78,6 +85,16 @@ public class RuleTypeImpl extends CommonResourceAbstractBase implements RuleType { this.ruleService = ruleService; } + + /** + * Set the node service + * + * @param nodeService the node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } /** * Rule type initialise method @@ -108,7 +125,9 @@ public class RuleTypeImpl extends CommonResourceAbstractBase implements RuleType */ public void triggerRuleType(NodeRef nodeRef, NodeRef actionedUponNodeRef, boolean executeRuleImmediately) { - if (this.ruleService.isEnabled() == true) + if (this.ruleService.isEnabled() == true && + this.nodeService.exists(actionedUponNodeRef) == true && + this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_TEMPORARY) == false) { if (this.ruleService.hasRules(nodeRef) == true) { diff --git a/source/java/org/alfresco/repo/security/authentication/ntlm/NTLMAuthenticationComponentImpl.java b/source/java/org/alfresco/repo/security/authentication/ntlm/NTLMAuthenticationComponentImpl.java index 93691d65f4..1461b30c45 100644 --- a/source/java/org/alfresco/repo/security/authentication/ntlm/NTLMAuthenticationComponentImpl.java +++ b/source/java/org/alfresco/repo/security/authentication/ntlm/NTLMAuthenticationComponentImpl.java @@ -868,7 +868,7 @@ public class NTLMAuthenticationComponentImpl extends AbstractAuthenticationCompo // Wrap the service calls in a transaction - tx = m_transactionService.getUserTransaction( true); + tx = m_transactionService.getUserTransaction( false); tx.begin(); // Map the passthru username to an Alfresco person diff --git a/source/java/org/alfresco/repo/security/permissions/impl/model/PermissionModelTest.java b/source/java/org/alfresco/repo/security/permissions/impl/model/PermissionModelTest.java index 2d9fb7d24b..19215f2d51 100644 --- a/source/java/org/alfresco/repo/security/permissions/impl/model/PermissionModelTest.java +++ b/source/java/org/alfresco/repo/security/permissions/impl/model/PermissionModelTest.java @@ -64,7 +64,7 @@ public class PermissionModelTest extends AbstractPermissionTest Set grantees = permissionModelDAO.getGranteePermissions(new SimplePermissionReference(QName.createQName("cm", "cmobject", namespacePrefixResolver), "Contributor")); - assertEquals(14, grantees.size()); + assertEquals(16, grantees.size()); } public void testIncludePermissionGroups3() @@ -72,7 +72,7 @@ public class PermissionModelTest extends AbstractPermissionTest Set grantees = permissionModelDAO.getGranteePermissions(new SimplePermissionReference(QName.createQName("cm", "cmobject", namespacePrefixResolver), "Editor")); - assertEquals(17, grantees.size()); + assertEquals(19, grantees.size()); } public void testIncludePermissionGroups4() @@ -80,7 +80,7 @@ public class PermissionModelTest extends AbstractPermissionTest Set grantees = permissionModelDAO.getGranteePermissions(new SimplePermissionReference(QName.createQName("cm", "cmobject", namespacePrefixResolver), "Collaborator")); - assertEquals(24, grantees.size()); + assertEquals(26, grantees.size()); } public void testIncludePermissionGroups5()