package org.alfresco.filesys.repo;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.util.List;
import org.alfresco.filesys.alfresco.ExtendedDiskInterface;
import org.alfresco.filesys.alfresco.RepositoryDiskInterface;
import org.alfresco.filesys.repo.rules.Command;
import org.alfresco.filesys.repo.rules.commands.CloseFileCommand;
import org.alfresco.filesys.repo.rules.commands.CompoundCommand;
import org.alfresco.filesys.repo.rules.commands.CopyContentCommand;
import org.alfresco.filesys.repo.rules.commands.CreateFileCommand;
import org.alfresco.filesys.repo.rules.commands.DeleteFileCommand;
import org.alfresco.filesys.repo.rules.commands.DoNothingCommand;
import org.alfresco.filesys.repo.rules.commands.MoveFileCommand;
import org.alfresco.filesys.repo.rules.commands.OpenFileCommand;
import org.alfresco.filesys.repo.rules.commands.ReduceQuotaCommand;
import org.alfresco.filesys.repo.rules.commands.RemoveNoContentFileOnError;
import org.alfresco.filesys.repo.rules.commands.RemoveTempFileCommand;
import org.alfresco.filesys.repo.rules.commands.RenameFileCommand;
import org.alfresco.filesys.repo.rules.commands.ReturnValueCommand;
import org.alfresco.jlan.server.SrvSession;
import org.alfresco.jlan.server.filesys.TreeConnection;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
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;
/**
* Content Disk Driver Command Executor
*
* Executes commands against the repository.
*/
public class CommandExecutorImpl implements CommandExecutor
{
private static Log logger = LogFactory.getLog(CommandExecutorImpl.class);
// Services go here.
private TransactionService transactionService;
private RepositoryDiskInterface repositoryDiskInterface;
private ExtendedDiskInterface diskInterface;
public void init()
{
PropertyCheck.mandatory(this, "transactionService", transactionService);
PropertyCheck.mandatory(this, "diskInterface", diskInterface);
PropertyCheck.mandatory(this, "repositoryDiskInterface", getRepositoryDiskInterface());
}
@Override
public Object execute(final SrvSession sess, final TreeConnection tree, final Command command) throws IOException
{
TxnReadState readState = command.getTransactionRequired();
Object ret = null;
// No transaction required.
if(readState == TxnReadState.TXN_NONE)
{
ret = executeInternal(sess, tree, command, null);
}
else
{
// Yes a transaction is required.
RetryingTransactionHelper helper = transactionService.getRetryingTransactionHelper();
boolean readOnly = readState == TxnReadState.TXN_READ_ONLY;
RetryingTransactionCallback