mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-16257: CIFS: Collaborator/editor could not edit file on Mac Os Mountain Lion
For DoubleRenameShuffle scenario for Mac Lion files add moveAsSystem flag to allow Editor to edit files. Add unit tests. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@55130 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -134,7 +134,7 @@ public interface RepositoryDiskInterface
|
||||
* @param newName java.lang.String
|
||||
* @exception java.io.IOException The exception description.
|
||||
*/
|
||||
public void renameFile(NodeRef rootNode, String oldName, String newName, boolean soft)
|
||||
public void renameFile(NodeRef rootNode, String oldName, String newName, boolean soft, boolean moveAsSystem)
|
||||
throws java.io.IOException;
|
||||
|
||||
|
||||
|
28
source/java/org/alfresco/filesys/repo/ClientHelper.java
Normal file
28
source/java/org/alfresco/filesys/repo/ClientHelper.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package org.alfresco.filesys.repo;
|
||||
|
||||
import org.alfresco.jlan.server.SrvSession;
|
||||
import org.alfresco.util.FileFilterMode.Client;
|
||||
|
||||
public class ClientHelper
|
||||
{
|
||||
public static Client getClient(SrvSession srvSession)
|
||||
{
|
||||
String clientStr = srvSession.getServer().getProtocolName().toLowerCase();
|
||||
if(clientStr.equals("cifs"))
|
||||
{
|
||||
return Client.cifs;
|
||||
}
|
||||
else if(clientStr.equals("nfs"))
|
||||
{
|
||||
return Client.nfs;
|
||||
}
|
||||
else if(clientStr.equals("ftp"))
|
||||
{
|
||||
return Client.ftp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -30,7 +30,6 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.FileFilterMode;
|
||||
import org.alfresco.util.FileFilterMode.Client;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -159,27 +158,6 @@ public class CommandExecutorImpl implements CommandExecutor
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Client getClient(SrvSession srvSession)
|
||||
{
|
||||
String clientStr = srvSession.getServer().getProtocolName().toLowerCase();
|
||||
if(clientStr.equals("cifs"))
|
||||
{
|
||||
return Client.cifs;
|
||||
}
|
||||
else if(clientStr.equals("nfs"))
|
||||
{
|
||||
return Client.nfs;
|
||||
}
|
||||
else if(clientStr.equals("ftp"))
|
||||
{
|
||||
return Client.ftp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sess
|
||||
* @param tree
|
||||
@@ -190,7 +168,7 @@ public class CommandExecutorImpl implements CommandExecutor
|
||||
*/
|
||||
private Object executeInternal(SrvSession sess, TreeConnection tree, Command command, Object result) throws IOException
|
||||
{
|
||||
FileFilterMode.setClient(getClient(sess));
|
||||
FileFilterMode.setClient(ClientHelper.getClient(sess));
|
||||
try
|
||||
{
|
||||
if(command instanceof CompoundCommand)
|
||||
@@ -255,13 +233,13 @@ public class CommandExecutorImpl implements CommandExecutor
|
||||
logger.debug("rename command");
|
||||
RenameFileCommand rename = (RenameFileCommand)command;
|
||||
|
||||
repositoryDiskInterface.renameFile(rename.getRootNode(), rename.getFromPath(), rename.getToPath(), rename.isSoft());
|
||||
repositoryDiskInterface.renameFile(rename.getRootNode(), rename.getFromPath(), rename.getToPath(), rename.isSoft(), false);
|
||||
}
|
||||
else if(command instanceof MoveFileCommand)
|
||||
{
|
||||
logger.debug("move command");
|
||||
MoveFileCommand move = (MoveFileCommand)command;
|
||||
repositoryDiskInterface.renameFile(move.getRootNode(), move.getFromPath(), move.getToPath(), false);
|
||||
repositoryDiskInterface.renameFile(move.getRootNode(), move.getFromPath(), move.getToPath(), false, move.isMoveAsSystem());
|
||||
}
|
||||
else if(command instanceof CopyContentCommand)
|
||||
{
|
||||
|
@@ -1337,7 +1337,7 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
|
||||
* @param newName path/name of new file
|
||||
* @exception java.io.IOException The exception description.
|
||||
*/
|
||||
public void renameFile(NodeRef rootNode, final String oldName, final String newName, boolean soft)
|
||||
public void renameFile(NodeRef rootNode, final String oldName, final String newName, boolean soft, boolean moveAsSystem)
|
||||
throws IOException
|
||||
{
|
||||
|
||||
@@ -1390,7 +1390,25 @@ public class ContentDiskDriver2 extends AlfrescoDiskDriver implements ExtendedD
|
||||
}
|
||||
else
|
||||
{
|
||||
fileFolderService.moveFrom(nodeToMoveRef, sourceFolderRef, targetFolderRef, name);
|
||||
if (moveAsSystem)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Run move as System for: " + oldName);
|
||||
}
|
||||
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
return fileFolderService.moveFrom(nodeToMoveRef, sourceFolderRef, targetFolderRef, name);
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
else
|
||||
{
|
||||
fileFolderService.moveFrom(nodeToMoveRef, sourceFolderRef, targetFolderRef, name);
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
"Moved between different folders: \n" +
|
||||
" Old name: " + oldName + "\n" +
|
||||
|
@@ -50,6 +50,7 @@ import org.alfresco.jlan.server.filesys.SearchContext;
|
||||
import org.alfresco.jlan.server.filesys.TreeConnection;
|
||||
import org.alfresco.jlan.smb.SharingMode;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.FileFilterMode;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -170,8 +171,15 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
|
||||
public void createDirectory(SrvSession sess, TreeConnection tree,
|
||||
FileOpenParams params) throws IOException
|
||||
{
|
||||
diskInterface.createDirectory(sess, tree, params);
|
||||
|
||||
FileFilterMode.setClient(ClientHelper.getClient(sess));
|
||||
try
|
||||
{
|
||||
diskInterface.createDirectory(sess, tree, params);
|
||||
}
|
||||
finally
|
||||
{
|
||||
FileFilterMode.clearClient();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -18,12 +18,10 @@
|
||||
*/
|
||||
package org.alfresco.filesys.repo.rules;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.alfresco.filesys.repo.rules.ScenarioInstance.Ranking;
|
||||
import org.alfresco.filesys.repo.rules.operations.CreateFileOperation;
|
||||
import org.alfresco.filesys.repo.rules.operations.RenameFileOperation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -46,8 +44,10 @@ public class ScenarioDoubleRenameShuffle implements Scenario
|
||||
*/
|
||||
private Pattern pattern;
|
||||
private String strPattern;
|
||||
private Pattern interimPattern;
|
||||
private String strInterimPattern;
|
||||
private boolean deleteBackup;
|
||||
|
||||
private boolean moveAsSystem;
|
||||
|
||||
private long timeout = 30000;
|
||||
|
||||
@@ -69,12 +69,17 @@ public class ScenarioDoubleRenameShuffle implements Scenario
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("New Scenario Double Rename Shuffle Instance strPattern:" + pattern + " matches" + r.getTo() );
|
||||
logger.debug("New Scenario Double Rename Shuffle Instance strPattern:" + pattern + " matches" + r.getTo());
|
||||
}
|
||||
ScenarioDoubleRenameShuffleInstance instance = new ScenarioDoubleRenameShuffleInstance();
|
||||
instance.setTimeout(timeout);
|
||||
instance.setRanking(ranking);
|
||||
instance.setDeleteBackup(deleteBackup);
|
||||
instance.setMoveAsSystem(moveAsSystem);
|
||||
if (interimPattern != null)
|
||||
{
|
||||
instance.setInterimPattern(interimPattern);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -124,4 +129,28 @@ public class ScenarioDoubleRenameShuffle implements Scenario
|
||||
{
|
||||
return deleteBackup;
|
||||
}
|
||||
|
||||
public boolean isMoveAsSystem()
|
||||
{
|
||||
return moveAsSystem;
|
||||
}
|
||||
|
||||
public void setMoveAsSystem(boolean retryAsSystem)
|
||||
{
|
||||
this.moveAsSystem = retryAsSystem;
|
||||
}
|
||||
|
||||
public void setInterimPattern(String intermediateMovePattern)
|
||||
{
|
||||
if (null != intermediateMovePattern)
|
||||
{
|
||||
this.interimPattern = Pattern.compile(intermediateMovePattern, Pattern.CASE_INSENSITIVE);
|
||||
this.strInterimPattern = intermediateMovePattern;
|
||||
}
|
||||
}
|
||||
|
||||
public String getInterimPattern()
|
||||
{
|
||||
return this.strInterimPattern;
|
||||
}
|
||||
}
|
||||
|
@@ -22,16 +22,14 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.alfresco.filesys.repo.OpenFileMode;
|
||||
import org.alfresco.filesys.repo.rules.commands.CompoundCommand;
|
||||
import org.alfresco.filesys.repo.rules.commands.CopyContentCommand;
|
||||
import org.alfresco.filesys.repo.rules.commands.DeleteFileCommand;
|
||||
import org.alfresco.filesys.repo.rules.commands.MoveFileCommand;
|
||||
import org.alfresco.filesys.repo.rules.commands.RenameFileCommand;
|
||||
import org.alfresco.filesys.repo.rules.operations.CreateFileOperation;
|
||||
import org.alfresco.filesys.repo.rules.operations.DeleteFileOperation;
|
||||
import org.alfresco.filesys.repo.rules.operations.OpenFileOperation;
|
||||
import org.alfresco.filesys.repo.rules.operations.MoveFileOperation;
|
||||
import org.alfresco.filesys.repo.rules.operations.RenameFileOperation;
|
||||
import org.alfresco.jlan.server.filesys.FileName;
|
||||
@@ -72,6 +70,8 @@ public class ScenarioDoubleRenameShuffleInstance implements ScenarioInstance
|
||||
|
||||
private Ranking ranking;
|
||||
private boolean deleteBackup;
|
||||
private boolean moveAsSystem;
|
||||
private Pattern interimPattern;
|
||||
|
||||
/**
|
||||
* Timeout in ms. Default 30 seconds.
|
||||
@@ -85,7 +85,7 @@ public class ScenarioDoubleRenameShuffleInstance implements ScenarioInstance
|
||||
/**
|
||||
* Keep track of re-names
|
||||
*/
|
||||
private Map<String, String>renames = new HashMap<String, String>();
|
||||
private Map<String, String> renames = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* Evaluate the next operation
|
||||
@@ -201,7 +201,7 @@ public class ScenarioDoubleRenameShuffleInstance implements ScenarioInstance
|
||||
}
|
||||
else
|
||||
{
|
||||
RenameFileCommand r2 = new RenameFileCommand(fileFrom, fileEnd, r.getRootNodeRef(), oldFolder + "\\" + fileFrom, oldFolder + "\\" + fileEnd);
|
||||
RenameFileCommand r2 = new RenameFileCommand(fileFrom, fileEnd, r.getRootNodeRef(), oldFolder + "\\" + fileFrom, oldFolder + "\\" + fileEnd);
|
||||
commands.add(r2);
|
||||
}
|
||||
|
||||
@@ -263,8 +263,8 @@ public class ScenarioDoubleRenameShuffleInstance implements ScenarioInstance
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveFileCommand m1 = new MoveFileCommand(fileFrom, fileEnd, r.getRootNodeRef(), oldFolder + "\\" + fileFrom, folderEnd + "\\" + fileEnd);
|
||||
commands.add(m1);
|
||||
MoveFileCommand m1 = new MoveFileCommand(fileFrom, fileEnd, r.getRootNodeRef(), oldFolder + "\\" + fileFrom, folderEnd + "\\" + fileEnd, isMoveAsSystem());
|
||||
commands.add(m1);
|
||||
}
|
||||
/**
|
||||
* TODO - we may need to copy a new node for the backup and delete the temp node.
|
||||
@@ -274,6 +274,22 @@ public class ScenarioDoubleRenameShuffleInstance implements ScenarioInstance
|
||||
isComplete = true;
|
||||
return new CompoundCommand(commands);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((interimPattern != null))
|
||||
{
|
||||
// ALF-16257: temporary Word file moved from .TemporaryItems
|
||||
Matcher m = interimPattern.matcher(r.getFromPath());
|
||||
if(m.matches() && r.getFrom().equals(r.getTo()))
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Got system move from temporary folder: " + r.getFrom() + " to " + r.getToPath());
|
||||
}
|
||||
return new MoveFileCommand(r.getFrom(), r.getTo(), r.getRootNodeRef(), r.getFromPath(), r.getToPath(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -282,6 +298,16 @@ public class ScenarioDoubleRenameShuffleInstance implements ScenarioInstance
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isMoveAsSystem()
|
||||
{
|
||||
return moveAsSystem;
|
||||
}
|
||||
|
||||
public void setMoveAsSystem(boolean moveAsSystem)
|
||||
{
|
||||
this.moveAsSystem = moveAsSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete()
|
||||
{
|
||||
@@ -323,4 +349,9 @@ public class ScenarioDoubleRenameShuffleInstance implements ScenarioInstance
|
||||
{
|
||||
return deleteBackup;
|
||||
}
|
||||
|
||||
public void setInterimPattern(Pattern interimPattern)
|
||||
{
|
||||
this.interimPattern = interimPattern;
|
||||
}
|
||||
}
|
||||
|
@@ -18,8 +18,6 @@
|
||||
*/
|
||||
package org.alfresco.filesys.repo.rules.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.filesys.repo.rules.Command;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -32,6 +30,7 @@ public class MoveFileCommand implements Command
|
||||
private NodeRef rootNode;
|
||||
private String fromPath;
|
||||
private String toPath;
|
||||
private boolean isMoveAsSystem = false;
|
||||
|
||||
public MoveFileCommand(String from, String to, NodeRef rootNode, String fromPath, String toPath)
|
||||
{
|
||||
@@ -42,7 +41,13 @@ public class MoveFileCommand implements Command
|
||||
this.toPath = toPath;
|
||||
}
|
||||
|
||||
|
||||
// ALF-16257: in shuffle scenarios if user has insufficient permissions rename should be done as System
|
||||
public MoveFileCommand(String from, String to, NodeRef rootNode, String fromPath, String toPath, boolean moveAsSystem)
|
||||
{
|
||||
this(from, to, rootNode, fromPath, toPath);
|
||||
this.isMoveAsSystem = moveAsSystem;
|
||||
}
|
||||
|
||||
public String getFrom()
|
||||
{
|
||||
return from;
|
||||
@@ -95,4 +100,9 @@ public class MoveFileCommand implements Command
|
||||
{
|
||||
return toPath;
|
||||
}
|
||||
|
||||
public boolean isMoveAsSystem()
|
||||
{
|
||||
return isMoveAsSystem;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user