mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
59886: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (Cloud/4.3) 59621: Merged DEV to V4.2-BUG-FIX 58258: MNT-10038 : CIFS and FTP accessing repo without transactions for MNT-9806 58307: MNT-10038 - MNT-9806 Corrected transaction test error in ContentDiskDriverTest git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62203 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -425,6 +425,7 @@
|
|||||||
<property name="permissionService"><ref bean="permissionService"/></property>
|
<property name="permissionService"><ref bean="permissionService"/></property>
|
||||||
<property name="hiddenAspect"><ref bean="hiddenAspect"/></property>
|
<property name="hiddenAspect"><ref bean="hiddenAspect"/></property>
|
||||||
<property name="lockService"><ref bean="lockService"/></property>
|
<property name="lockService"><ref bean="lockService"/></property>
|
||||||
|
<property name="retryingTransactionHelper"><ref bean="retryingTransactionHelper"/></property>
|
||||||
<property name="excludedTypes">
|
<property name="excludedTypes">
|
||||||
<list>
|
<list>
|
||||||
<value>{http://www.alfresco.org/model/forum/1.0}forum</value>
|
<value>{http://www.alfresco.org/model/forum/1.0}forum</value>
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
package org.alfresco.filesys.repo;
|
package org.alfresco.filesys.repo;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -30,6 +31,7 @@ import java.util.Stack;
|
|||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
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.FileAttribute;
|
||||||
import org.alfresco.jlan.server.filesys.FileExistsException;
|
import org.alfresco.jlan.server.filesys.FileExistsException;
|
||||||
import org.alfresco.jlan.server.filesys.FileName;
|
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.model.ContentModel;
|
||||||
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
||||||
import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility;
|
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.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.lock.LockService;
|
import org.alfresco.service.cmr.lock.LockService;
|
||||||
import org.alfresco.service.cmr.lock.LockStatus;
|
import org.alfresco.service.cmr.lock.LockStatus;
|
||||||
@@ -79,6 +83,7 @@ public class CifsHelper
|
|||||||
private PermissionService permissionService;
|
private PermissionService permissionService;
|
||||||
private LockService lockService;
|
private LockService lockService;
|
||||||
private HiddenAspect hiddenAspect;
|
private HiddenAspect hiddenAspect;
|
||||||
|
private RetryingTransactionHelper retryingTransactionHelper;
|
||||||
|
|
||||||
private Set<QName> excludedTypes = new HashSet<QName>();
|
private Set<QName> excludedTypes = new HashSet<QName>();
|
||||||
|
|
||||||
@@ -99,6 +104,7 @@ public class CifsHelper
|
|||||||
PropertyCheck.mandatory(this, "permissionService",permissionService);
|
PropertyCheck.mandatory(this, "permissionService",permissionService);
|
||||||
PropertyCheck.mandatory(this, "lockService",lockService);
|
PropertyCheck.mandatory(this, "lockService",lockService);
|
||||||
PropertyCheck.mandatory(this, "mimetypeService",mimetypeService);
|
PropertyCheck.mandatory(this, "mimetypeService",mimetypeService);
|
||||||
|
PropertyCheck.mandatory(this, "transactionHelper",getRetryingTransactionHelper());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
public void setDictionaryService(DictionaryService dictionaryService)
|
||||||
@@ -184,6 +190,89 @@ public class CifsHelper
|
|||||||
return false;
|
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<ContentFileInfo> cb = new RetryingTransactionCallback<ContentFileInfo>()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 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<ContentFileInfo> cb = new RetryingTransactionCallback<ContentFileInfo>()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 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
|
* 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
|
* @return Returns the existing node reference
|
||||||
* @throws FileNotFoundException
|
* @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
|
// get the node being referenced
|
||||||
NodeRef nodeRef = getNodeRef(pathRootNodeRef, path);
|
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.
|
* 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
|
* @return Returns the file information pertinent to the node
|
||||||
* @throws FileNotFoundException if the path refers to a non-existent file
|
* @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
|
// get the file info
|
||||||
org.alfresco.service.cmr.model.FileInfo fileFolderInfo = fileFolderService.getFileInfo(nodeRef);
|
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<String> cb = new RetryingTransactionCallback<String>()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 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
|
* Return the file name for a node
|
||||||
*
|
*
|
||||||
@@ -739,7 +854,7 @@ public class CifsHelper
|
|||||||
* @return String
|
* @return String
|
||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
*/
|
*/
|
||||||
public String getFileName(NodeRef node)
|
public String getFileNameImpl(NodeRef node)
|
||||||
{
|
{
|
||||||
String fname = null;
|
String fname = null;
|
||||||
|
|
||||||
@@ -782,4 +897,12 @@ public class CifsHelper
|
|||||||
return lockService;
|
return lockService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) {
|
||||||
|
this.retryingTransactionHelper = retryingTransactionHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RetryingTransactionHelper getRetryingTransactionHelper() {
|
||||||
|
return retryingTransactionHelper;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -287,13 +287,7 @@ public class ContentSearchContext extends SearchContext
|
|||||||
StringBuilder pathStr = new StringBuilder( m_relPath);
|
StringBuilder pathStr = new StringBuilder( m_relPath);
|
||||||
pathStr.append ( info.getFileName());
|
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
|
// Check if this is a link node
|
||||||
|
|
||||||
if ( nextInfo.isLinkNode())
|
if ( nextInfo.isLinkNode())
|
||||||
{
|
{
|
||||||
// Set a dummy file size for the link data that will be generated if/when the file is opened
|
// Set a dummy file size for the link data that will be generated if/when the file is opened
|
||||||
|
@@ -679,10 +679,10 @@ public class FTPServerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean login = ftpOne.login(USER_THREE, PASSWORD_THREE);
|
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");
|
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");
|
success = ftpOne.changeWorkingDirectory("User*Homes");
|
||||||
assertTrue("user one unable to cd to User*Homes", success);
|
assertTrue("user one unable to cd to User*Homes", success);
|
||||||
success = ftpOne.changeWorkingDirectory(USER_THREE);
|
success = ftpOne.changeWorkingDirectory(USER_THREE);
|
||||||
|
@@ -842,18 +842,28 @@ public class ContentDiskDriverTest extends TestCase
|
|||||||
* Step 5: Rename to another directory
|
* Step 5: Rename to another directory
|
||||||
*/
|
*/
|
||||||
String DIR_NEW_PATH = TEST_ROOT_DOS_PATH + "\\NewDir";
|
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);
|
FileOpenParams params5 = new FileOpenParams(DIR_NEW_PATH, 0, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
|
||||||
driver.createDirectory(testSession, testConnection, params5);
|
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);
|
driver.renameFile(testSession, testConnection, FILE_PATH2, NEW_PATH);
|
||||||
|
|
||||||
NodeRef file5NodeRef = getNodeForPath(testConnection, NEW_PATH);
|
RetryingTransactionCallback<Void> validateStep5CB = new RetryingTransactionCallback<Void>() {
|
||||||
ChildAssociationRef parentRef5 = nodeService.getPrimaryParent(file5NodeRef);
|
|
||||||
|
@Override
|
||||||
assertTrue(parentRef5.getParentRef().equals(newDirNodeRef));
|
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.
|
// * Step 5: rename to self - check no damage.
|
||||||
|
Reference in New Issue
Block a user