diff --git a/config/alfresco/subsystems/fileServers/default/network-protocol-context.xml b/config/alfresco/subsystems/fileServers/default/network-protocol-context.xml index c55c67a3db..f5525cecd1 100644 --- a/config/alfresco/subsystems/fileServers/default/network-protocol-context.xml +++ b/config/alfresco/subsystems/fileServers/default/network-protocol-context.xml @@ -425,6 +425,7 @@ + {http://www.alfresco.org/model/forum/1.0}forum diff --git a/source/java/org/alfresco/filesys/repo/CifsHelper.java b/source/java/org/alfresco/filesys/repo/CifsHelper.java index 96c2cbaa49..323c00dc0e 100644 --- a/source/java/org/alfresco/filesys/repo/CifsHelper.java +++ b/source/java/org/alfresco/filesys/repo/CifsHelper.java @@ -18,6 +18,7 @@ package org.alfresco.filesys.repo; import java.io.FileNotFoundException; +import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; @@ -30,6 +31,7 @@ import java.util.Stack; import java.util.StringTokenizer; import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.filesys.repo.CommandExecutorImpl.PropagatingException; import org.alfresco.jlan.server.filesys.FileAttribute; import org.alfresco.jlan.server.filesys.FileExistsException; import org.alfresco.jlan.server.filesys.FileName; @@ -38,6 +40,8 @@ import org.alfresco.jlan.util.WildCard; import org.alfresco.model.ContentModel; import org.alfresco.repo.model.filefolder.HiddenAspect; import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.lock.LockService; import org.alfresco.service.cmr.lock.LockStatus; @@ -79,6 +83,7 @@ public class CifsHelper private PermissionService permissionService; private LockService lockService; private HiddenAspect hiddenAspect; + private RetryingTransactionHelper retryingTransactionHelper; private Set excludedTypes = new HashSet(); @@ -99,6 +104,7 @@ public class CifsHelper PropertyCheck.mandatory(this, "permissionService",permissionService); PropertyCheck.mandatory(this, "lockService",lockService); PropertyCheck.mandatory(this, "mimetypeService",mimetypeService); + PropertyCheck.mandatory(this, "transactionHelper",getRetryingTransactionHelper()); } public void setDictionaryService(DictionaryService dictionaryService) @@ -184,6 +190,89 @@ public class CifsHelper return false; } } + + /** + * Extract a single node's file info, where the node is reference by + * a path relative to an ancestor node. + * + * @param pathRootNodeRef + * @param path the path + * @return Returns the existing node reference + * @throws FileNotFoundException + */ + public ContentFileInfo getFileInformation(final NodeRef pathRootNodeRef, final String path, final boolean readOnly, final boolean lockedFilesAsOffline) throws FileNotFoundException + { + + RetryingTransactionCallback cb = new RetryingTransactionCallback() + { + /** + * Perform a set of commands as a unit of transactional work. + * + * @return Return the result of the unit of work + * @throws Throwable This can be anything and will guarantee either a retry or a rollback + */ + public ContentFileInfo execute() throws IOException + { + try + { + return getFileInformationImpl(pathRootNodeRef, path, readOnly, lockedFilesAsOffline); + } + catch (FileNotFoundException e) + { + // Ensure original checked IOExceptions get propagated + throw new PropagatingException(e); + } + } + }; + + try + { + return getRetryingTransactionHelper().doInTransaction(cb, true); + } + catch(PropagatingException pe) + { + // Unwrap checked exceptions + throw (FileNotFoundException) pe.getCause(); + } + } + + + public ContentFileInfo getFileInformation(final NodeRef nodeRef, final boolean readOnly, final boolean lockedFilesAsOffline) throws FileNotFoundException + { + RetryingTransactionCallback cb = new RetryingTransactionCallback() + { + /** + * Perform a set of commands as a unit of transactional work. + * + * @return Return the result of the unit of work + * @throws Throwable This can be anything and will guarantee either a retry or a rollback + */ + public ContentFileInfo execute() throws IOException + { + try + { + return getFileInformationImpl(nodeRef, readOnly, lockedFilesAsOffline); + } + catch (FileNotFoundException e) + { + // Ensure original checked IOExceptions get propagated + throw new PropagatingException(e); + } + } + }; + + try + { + return getRetryingTransactionHelper().doInTransaction(cb, true); + } + catch(PropagatingException pe) + { + // Unwrap checked exceptions + throw (FileNotFoundException) pe.getCause(); + } + + } + /** * Extract a single node's file info, where the node is reference by @@ -194,13 +283,14 @@ public class CifsHelper * @return Returns the existing node reference * @throws FileNotFoundException */ - public ContentFileInfo getFileInformation(NodeRef pathRootNodeRef, String path, boolean readOnly, boolean lockedFilesAsOffline) throws FileNotFoundException + public ContentFileInfo getFileInformationImpl(NodeRef pathRootNodeRef, String path, boolean readOnly, boolean lockedFilesAsOffline) throws FileNotFoundException { // get the node being referenced NodeRef nodeRef = getNodeRef(pathRootNodeRef, path); - return getFileInformation(nodeRef, readOnly, lockedFilesAsOffline); + return getFileInformationImpl(nodeRef, readOnly, lockedFilesAsOffline); } + /** * Helper method to extract file info from a specific node. @@ -215,7 +305,7 @@ public class CifsHelper * @return Returns the file information pertinent to the node * @throws FileNotFoundException if the path refers to a non-existent file */ - public ContentFileInfo getFileInformation(NodeRef nodeRef, boolean readOnly, boolean lockedFilesAsOffline) throws FileNotFoundException + private ContentFileInfo getFileInformationImpl(NodeRef nodeRef, boolean readOnly, boolean lockedFilesAsOffline) throws FileNotFoundException { // get the file info org.alfresco.service.cmr.model.FileInfo fileFolderInfo = fileFolderService.getFileInfo(nodeRef); @@ -732,6 +822,31 @@ public class CifsHelper } } + /** + * Return the file name for a node + * + * @param nodeRef NodeRef of node to get the file name + * @return String or null if the nodeRef is not valid + */ + public String getFileName(final NodeRef nodeRef) + { + RetryingTransactionCallback cb = new RetryingTransactionCallback() + { + /** + * Perform a set of commands as a unit of transactional work. + * + * @return Return the result of the unit of work + * @throws Throwable This can be anything and will guarantee either a retry or a rollback + */ + public String execute() throws IOException + { + return getFileName(nodeRef); + } + }; + + return getRetryingTransactionHelper().doInTransaction(cb, true); + + } /** * Return the file name for a node * @@ -739,7 +854,7 @@ public class CifsHelper * @return String * @throws FileNotFoundException */ - public String getFileName(NodeRef node) + public String getFileNameImpl(NodeRef node) { String fname = null; @@ -782,4 +897,12 @@ public class CifsHelper return lockService; } + public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) { + this.retryingTransactionHelper = retryingTransactionHelper; + } + + public RetryingTransactionHelper getRetryingTransactionHelper() { + return retryingTransactionHelper; + } + } diff --git a/source/java/org/alfresco/filesys/repo/ContentSearchContext.java b/source/java/org/alfresco/filesys/repo/ContentSearchContext.java index 591d3eb80a..b9c4faf406 100644 --- a/source/java/org/alfresco/filesys/repo/ContentSearchContext.java +++ b/source/java/org/alfresco/filesys/repo/ContentSearchContext.java @@ -287,13 +287,7 @@ public class ContentSearchContext extends SearchContext StringBuilder pathStr = new StringBuilder( m_relPath); pathStr.append ( info.getFileName()); - // Set the file id - - long id = DefaultTypeConverter.INSTANCE.convert(Long.class, cifsHelper.getNodeService().getProperty(nextNodeRef, ContentModel.PROP_NODE_DBID)); - info.setFileId((int) (id & 0xFFFFFFFFL)); - // Check if this is a link node - if ( nextInfo.isLinkNode()) { // Set a dummy file size for the link data that will be generated if/when the file is opened diff --git a/source/test-java/org/alfresco/filesys/FTPServerTest.java b/source/test-java/org/alfresco/filesys/FTPServerTest.java index 740f433057..75373e4bf5 100644 --- a/source/test-java/org/alfresco/filesys/FTPServerTest.java +++ b/source/test-java/org/alfresco/filesys/FTPServerTest.java @@ -679,10 +679,10 @@ public class FTPServerTest extends TestCase } boolean login = ftpOne.login(USER_THREE, PASSWORD_THREE); - assertTrue("user one login not successful", login); + assertTrue("user three login not successful", login); boolean success = ftpOne.changeWorkingDirectory("Alfresco"); - assertTrue("user one unable to cd to Alfreco", success); + assertTrue("user three unable to cd to Alfreco", success); success = ftpOne.changeWorkingDirectory("User*Homes"); assertTrue("user one unable to cd to User*Homes", success); success = ftpOne.changeWorkingDirectory(USER_THREE); diff --git a/source/test-java/org/alfresco/filesys/repo/ContentDiskDriverTest.java b/source/test-java/org/alfresco/filesys/repo/ContentDiskDriverTest.java index cdcd1a3741..2f96940f26 100644 --- a/source/test-java/org/alfresco/filesys/repo/ContentDiskDriverTest.java +++ b/source/test-java/org/alfresco/filesys/repo/ContentDiskDriverTest.java @@ -842,18 +842,28 @@ public class ContentDiskDriverTest extends TestCase * Step 5: Rename to another directory */ String DIR_NEW_PATH = TEST_ROOT_DOS_PATH + "\\NewDir"; - String NEW_PATH = DIR_NEW_PATH + "\\File2"; + final String NEW_PATH = DIR_NEW_PATH + "\\File2"; FileOpenParams params5 = new FileOpenParams(DIR_NEW_PATH, 0, AccessMode.ReadWrite, FileAttribute.NTNormal, 0); driver.createDirectory(testSession, testConnection, params5); - NodeRef newDirNodeRef = getNodeForPath(testConnection, DIR_NEW_PATH); + final NodeRef newDirNodeRef = getNodeForPath(testConnection, DIR_NEW_PATH); driver.renameFile(testSession, testConnection, FILE_PATH2, NEW_PATH); - NodeRef file5NodeRef = getNodeForPath(testConnection, NEW_PATH); - ChildAssociationRef parentRef5 = nodeService.getPrimaryParent(file5NodeRef); - - assertTrue(parentRef5.getParentRef().equals(newDirNodeRef)); + RetryingTransactionCallback validateStep5CB = new RetryingTransactionCallback() { + + @Override + public Void execute() throws Throwable + { + NodeRef file5NodeRef = getNodeForPath(testConnection, NEW_PATH); + ChildAssociationRef parentRef5 = nodeService.getPrimaryParent(file5NodeRef); + + assertTrue(parentRef5.getParentRef().equals(newDirNodeRef)); + + return null; + } + }; + tran.doInTransaction(validateStep5CB, false, true); // /** // * Step 5: rename to self - check no damage.