Merged V4.1-BUG-FIX to HEAD

44765: ALF-17164: Fix failing build in case build is not run in continuous mode
   44769: ALF-17097 60k Site Performance: Admin Console | Groups | Browse Groups (include sys groups): Results isn't appeared.
      - Group page now supports search and browse of large volumes of groups. Tested up to 300,000 sites (60k sites).
        Previously this would not return.
      - In order to support large volumes of groups it is not practical to search for all root groups.
        A functional change has taken place to fix this issue.
        [Browse] (which initially displayed only root groups) now uses the search value entered by the user and the same
        query as [Search]. It could be argued that the browse functionality was not very practical anyway if there were
        a large number of root groups as the user would have to page through all the pages one at a time to get to the
        required group in order to add a new sub group. As a result of this change it is now possible to get to the
        required group much faster. As the 'browse' function uses the search value and Include System Groups checkbox
        (it already used the checkbox value) it made little sense to revert to the Search results when either of these
        is changed. As this was taking place, this has now been changed too. The [Search] and [Browse] options both now
        use the authority canned query which has been enhanced to use the sortBy field supplied by the UI.
      - Uses the authority canned query for [Search] and [Browse] searches on the Groups page.
      - Canned query may sort on "shortName", "displayName" or "authorityName"
      - Filter on displayName uses regular expressions to support ? and * wildcards
      - Canned query returns fewer (unused) columns to speed up fetch time.
      - Canned query no longer joins to alf_store as none of the values were used.
   44772: CIFS Gedit support - rename open files.
   44776: ALF-17164: Fix failing build in case build is not run in continuous mode - move generation of version.properties out of continuous mode


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@44790 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2012-12-18 14:43:45 +00:00
parent 6bb340048a
commit c21a3d2740
23 changed files with 924 additions and 1668 deletions

View File

@@ -269,7 +269,7 @@ public class ContentDiskDriverTest extends TestCase
int openAction = FileAction.CreateNotExist;
final String FILE_NAME="testCreateFileA.new";
final String FILE_NAME="testCreateFile.new";
final String FILE_PATH="\\"+FILE_NAME;
FileOpenParams params = new FileOpenParams(FILE_PATH, openAction, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
@@ -366,7 +366,7 @@ public class ContentDiskDriverTest extends TestCase
* Step 1 : Create a new file in read/write mode and add some content.
*/
int openAction = FileAction.CreateNotExist;
String FILE_PATH="\\testDeleteFileX.new";
String FILE_PATH="\\testDeleteFile.new";
FileOpenParams params = new FileOpenParams(FILE_PATH, openAction, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
@@ -5679,7 +5679,7 @@ public class ContentDiskDriverTest extends TestCase
*/
public void testMacDragAndDrop() throws Exception
{
logger.debug("testMacDragAndDrop(");
logger.debug("testMacDragAndDrop()");
final String FILE_NAME = "ALF-15158.diff";
@@ -5843,6 +5843,7 @@ public class ContentDiskDriverTest extends TestCase
};
tran.doInTransaction(validateCB, true, true);
logger.debug("end testMacDragAndDrop");
} // testMacDragAndDrop
@@ -6192,6 +6193,218 @@ public class ContentDiskDriverTest extends TestCase
tran.doInTransaction(validateCB, false, true);
} // testScenarioMountainLionPreview
/**
* Gedit has the nasty behaviour of renaming an open file.
* 1) create file (gedit12345678.txt)
* 2) create temp file (.goutputStream-IRYDPW) write and flush
* 3) rename (fails name collision)
* 4) delete target
* 5) rename this one succeeds
* 6) close temp file
*
*/
public void testGedit() throws Exception
{
logger.debug("testGEdit");
final String FILE_NAME = "gedit12345678.txt";
final String FILE_TITLE = "Gedit";
final String FILE_DESCRIPTION = "This is a test document to test CIFS shuffle";
final String TEMP_FILE_NAME = ".goutputStream-IRYDPW";
final String UPDATE_TEXT = "Shuffle an open file";
class TestContext
{
NetworkFile firstFileHandle;
NetworkFile tempFileHandle;
NodeRef testNodeRef;
};
final TestContext testContext = new TestContext();
final String TEST_DIR = TEST_ROOT_DOS_PATH + "\\testGEdit";
ServerConfiguration scfg = new ServerConfiguration("testServer");
TestServer testServer = new TestServer("testServer", scfg);
final SrvSession testSession = new TestSrvSession(666, testServer, "test", "remoteName");
DiskSharedDevice share = getDiskSharedDevice();
final TreeConnection testConnection = testServer.getTreeConnection(share);
final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
/**
* Clean up from a previous run
*/
RetryingTransactionCallback<Void> deleteGarbageFileCB = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
driver.deleteFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NAME);
return null;
}
};
try
{
tran.doInTransaction(deleteGarbageFileCB);
}
catch (Exception e)
{
// expect to go here
}
/**
* Create a file in the test directory
*/
RetryingTransactionCallback<Void> createTestFileFirstTime = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
/**
* Create the test directory we are going to use
*/
FileOpenParams createRootDirParams = new FileOpenParams(TEST_ROOT_DOS_PATH, 0, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
FileOpenParams createDirParams = new FileOpenParams(TEST_DIR, 0, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
driver.createDirectory(testSession, testConnection, createRootDirParams);
driver.createDirectory(testSession, testConnection, createDirParams);
/**
* Create the file we are going to use
*/
FileOpenParams createFileParams = new FileOpenParams(TEST_DIR + "\\" + FILE_NAME, 0, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
testContext.firstFileHandle = driver.createFile(testSession, testConnection, createFileParams);
assertNotNull(testContext.firstFileHandle);
testContext.testNodeRef = getNodeForPath(testConnection, TEST_DIR + "\\" + FILE_NAME);
nodeService.setProperty(testContext.testNodeRef, ContentModel.PROP_TITLE, FILE_TITLE);
nodeService.setProperty(testContext.testNodeRef, ContentModel.PROP_DESCRIPTION, FILE_DESCRIPTION);
String testContent = "Gedit shuffle test";
byte[] testContentBytes = testContent.getBytes();
testContext.firstFileHandle.writeFile(testContentBytes, testContentBytes.length, 0, 0);
driver.closeFile(testSession, testConnection, testContext.firstFileHandle);
nodeService.addAspect(testContext.testNodeRef, ContentModel.ASPECT_VERSIONABLE, null);
return null;
}
};
tran.doInTransaction(createTestFileFirstTime, false, true);
/**
* Create the temp file
* add content
* leave open
*/
RetryingTransactionCallback<Void> createTempFile = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
FileOpenParams params = new FileOpenParams(TEST_DIR + "\\" + TEMP_FILE_NAME, FileAction.TruncateExisting, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
NetworkFile file = driver.createFile(testSession, testConnection, params);
testContext.tempFileHandle = file;
String testContent = UPDATE_TEXT;
byte[] testContentBytes = testContent.getBytes();
testContext.tempFileHandle.writeFile(testContentBytes, testContentBytes.length, 0, 0);
/** driver.closeFile(testSession, testConnection, file); **/
return null;
}
};
tran.doInTransaction(createTempFile, false, true);
/**
* rename the test file to the temp
*/
RetryingTransactionCallback<Void> renameTestFileToTemp = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
driver.renameFile(testSession, testConnection, TEST_DIR + "\\" + TEMP_FILE_NAME, TEST_DIR + "\\" + FILE_NAME);
return null;
}
};
// expect this one to fail
try
{
tran.doInTransaction(renameTestFileToTemp, false, true);
fail("should have failed");
}
catch (Exception e)
{
// expect to go here
}
/**
* delete the target file
*/
RetryingTransactionCallback<Void> deleteTargetFile = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
driver.deleteFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NAME);
return null;
}
};
tran.doInTransaction(deleteTargetFile, false, true);
// This one should succeed
tran.doInTransaction(renameTestFileToTemp, false, true);
RetryingTransactionCallback<Void> closeTempFile = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
driver.closeFile(testSession, testConnection, testContext.tempFileHandle);
return null;
}
};
tran.doInTransaction(closeTempFile, false, true);
// Now validate
RetryingTransactionCallback<Void> validate = new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
NodeRef shuffledNodeRef = getNodeForPath(testConnection, TEST_DIR + "\\" + FILE_NAME);
ContentReader reader = contentService.getReader(shuffledNodeRef, ContentModel.PROP_CONTENT);
String s = reader.getContentString();
assertEquals("content not written", UPDATE_TEXT, s);
assertTrue("node is not versionable", nodeService.hasAspect(shuffledNodeRef, ContentModel.ASPECT_VERSIONABLE));
assertEquals("shuffledNode ref is different", shuffledNodeRef, testContext.testNodeRef);
return null;
}
};
tran.doInTransaction(validate, false, true);
logger.debug("end testGedit");
} // testGedit
/**

View File

@@ -595,7 +595,25 @@ public class LegacyFileStateDriver implements ExtendedDiskInterface
public void renameFile(SrvSession sess, TreeConnection tree,
String oldName, String newName) throws IOException
{
diskInterface.renameFile(sess, tree, oldName, newName);
ContentContext tctx = (ContentContext) tree.getContext();
diskInterface.renameFile(sess, tree, oldName, newName);
if(tctx.hasStateCache())
{
FileStateCache cache = tctx.getStateCache();
FileState fstate = cache.findFileState( oldName, false);
if(fstate != null)
{
if(logger.isDebugEnabled())
{
logger.debug("rename file state from:" + oldName + ", to:" + newName);
}
cache.renameFileState(newName, fstate, fstate.isDirectory());
}
}
}
@Override

View File

@@ -161,6 +161,8 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
Command c = ruleEvaluator.evaluate(ctx, o);
commandExecutor.execute(sess, tree, c);
releaseEvaluatorContextIfEmpty(driverState, ctx, folder);
}
@@ -266,6 +268,8 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
Command c = ruleEvaluator.evaluate(ctx, o);
commandExecutor.execute(sess, tree, c);
releaseEvaluatorContextIfEmpty(driverState, ctx, folder);
} // End of deleteFile
@@ -424,6 +428,11 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
Operation o = new RenameFileOperation(oldFile, newFile, oldPath, newPath, rootNode);
Command c = ruleEvaluator.evaluate(ctx, o);
commandExecutor.execute(sess, tree, c);
ruleEvaluator.notifyRename(ctx, o, c);
releaseEvaluatorContextIfEmpty(driverState, ctx, oldFolder);
}
else
{
@@ -444,6 +453,8 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
commandExecutor.execute(sess, tree, c);
releaseEvaluatorContextIfEmpty(driverState, ctx2, newFolder);
// diskInterface.renameFile(sess, tree, oldPath, newPath);
}
@@ -592,6 +603,30 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
return ctx;
}
}
/**
* Release the evaluator context if there are no active scenarios.
* @param driverState
* @param ctx
* @param folder
*/
private void releaseEvaluatorContextIfEmpty(DriverState driverState, EvaluatorContext ctx, String folder)
{
synchronized(driverState.contextMap)
{
if(ctx != null)
{
if(ctx.getScenarioInstances().size() > 0)
{
}
else
{
driverState.contextMap.remove(folder);
}
}
}
}
}

View File

@@ -42,6 +42,11 @@ public interface RuleEvaluator
* @return Command the command to fulfil the operation
*/
public Command evaluate(EvaluatorContext context, Operation operation);
/**
* Tell the context of a rename
*/
public void notifyRename(EvaluatorContext context, Operation operation, Command c);
}

View File

@@ -204,5 +204,31 @@ public class RuleEvaluatorImpl implements RuleEvaluator
EvaluatorContextImpl impl = new EvaluatorContextImpl(sessionState);
return impl;
}
@Override
public void notifyRename(EvaluatorContext context, Operation operation,
Command command)
{
// currentScenarioInstances needs to be protected for concurrency.
synchronized (context.getScenarioInstances())
{
/**
* For each active scenario.
*/
Iterator<ScenarioInstance> i = context.getScenarioInstances().iterator();
while(i.hasNext())
{
ScenarioInstance scenario = i.next();
if(scenario instanceof ScenarioInstanceRenameAware)
{
ScenarioInstanceRenameAware awareScenario = (ScenarioInstanceRenameAware)scenario;
awareScenario.notifyRename(operation, command);
}
}
}
}
}

View File

@@ -23,12 +23,13 @@ import java.util.regex.Pattern;
import org.alfresco.filesys.repo.rules.ScenarioInstance.Ranking;
import org.alfresco.filesys.repo.rules.operations.CloseFileOperation;
import org.alfresco.filesys.repo.rules.operations.DeleteFileOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* The DeleteOnClose rename shuffle is a delete on close of a file resulting in a file being deleted followed by a rename of a file from
* somewhere else.
* The DeleteOnClose rename shuffle is a delete on close of a file resulting in a file being deleted followed by a
* rename or a create
*
* First case of this is Mac Mountain Lion Preview application.
* and then a new copy of the file put into place.
@@ -36,11 +37,23 @@ import org.apache.commons.logging.LogFactory;
* a) DeleteOnClose fileA
* b) Close fileA
* c) Rename whatever fileA
*
* Second case First case of this is Mac Drag and drop.
* and then a new copy of the file put into place.
*
* a) Delete fileA
* b) Close fileA
* c) Create fileA
*
* Third case Gedit.
*
* a) Delete fileA
* b) Rename .goutputstream fileA
*
*/
public class ScenarioDeleteOnCloseRename implements Scenario
public class ScenarioDeleteRenameOrCreate implements Scenario
{
private static Log logger = LogFactory.getLog(ScenarioDeleteOnCloseRename.class);
private static Log logger = LogFactory.getLog(ScenarioDeleteRenameOrCreate.class);
/**
* The regex pattern of a close that will trigger a new instance of
@@ -67,9 +80,27 @@ public class ScenarioDeleteOnCloseRename implements Scenario
{
if(logger.isDebugEnabled())
{
logger.debug("New Scenario ScenarioDeleteOnCloseRename strPattern:" + pattern);
logger.debug("New Scenario ScenarioDeleteRenameOrCreate strPattern:" + pattern);
}
ScenarioDeleteOnCloseRenameInstance instance = new ScenarioDeleteOnCloseRenameInstance();
ScenarioDeleteRenameOrCreateInstance instance = new ScenarioDeleteRenameOrCreateInstance();
instance.setTimeout(timeout);
instance.setRanking(ranking);
return instance;
}
}
if(operation instanceof DeleteFileOperation)
{
DeleteFileOperation c = (DeleteFileOperation)operation;
Matcher m = pattern.matcher(c.getName());
if(m.matches())
{
if(logger.isDebugEnabled())
{
logger.debug("New Scenario ScenarioDeleteRenameOrCreate strPattern:" + pattern);
}
ScenarioDeleteRenameOrCreateInstance instance = new ScenarioDeleteRenameOrCreateInstance();
instance.setTimeout(timeout);
instance.setRanking(ranking);
return instance;

View File

@@ -28,6 +28,8 @@ import org.alfresco.filesys.repo.rules.commands.CopyContentCommand;
import org.alfresco.filesys.repo.rules.commands.DeleteFileCommand;
import org.alfresco.filesys.repo.rules.commands.RestoreFileCommand;
import org.alfresco.filesys.repo.rules.operations.CloseFileOperation;
import org.alfresco.filesys.repo.rules.operations.CreateFileOperation;
import org.alfresco.filesys.repo.rules.operations.DeleteFileOperation;
import org.alfresco.filesys.repo.rules.operations.MoveFileOperation;
import org.alfresco.filesys.repo.rules.operations.RenameFileOperation;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
@@ -46,9 +48,9 @@ import org.apache.commons.logging.LogFactory;
* This rule will kick in and ...
*
*/
class ScenarioDeleteOnCloseRenameInstance implements ScenarioInstance
class ScenarioDeleteRenameOrCreateInstance implements ScenarioInstance
{
private static Log logger = LogFactory.getLog(ScenarioDeleteOnCloseRenameInstance.class);
private static Log logger = LogFactory.getLog(ScenarioDeleteRenameOrCreateInstance.class);
private Date startTime = new Date();
@@ -66,7 +68,7 @@ class ScenarioDeleteOnCloseRenameInstance implements ScenarioInstance
enum InternalState
{
NONE,
LOOK_FOR_RENAME
INITIALISED
} ;
InternalState state = InternalState.NONE;
@@ -101,7 +103,7 @@ class ScenarioDeleteOnCloseRenameInstance implements ScenarioInstance
CloseFileOperation c = (CloseFileOperation)operation;
this.name = c.getName();
logger.debug("New scenario initialised for file " + name);
state = InternalState.LOOK_FOR_RENAME;
state = InternalState.INITIALISED;
ArrayList<Command> commands = new ArrayList<Command>();
ArrayList<Command> postCommitCommands = new ArrayList<Command>();
@@ -110,15 +112,47 @@ class ScenarioDeleteOnCloseRenameInstance implements ScenarioInstance
postCommitCommands.add(newDeleteFileCallbackCommand());
return new CompoundCommand(commands, postCommitCommands, postErrorCommands);
}
if(operation instanceof DeleteFileOperation)
{
DeleteFileOperation c = (DeleteFileOperation)operation;
this.name = c.getName();
logger.debug("New scenario initialised for file " + name);
state = InternalState.INITIALISED;
ArrayList<Command> commands = new ArrayList<Command>();
ArrayList<Command> postCommitCommands = new ArrayList<Command>();
ArrayList<Command> postErrorCommands = new ArrayList<Command>();
commands.add(new DeleteFileCommand(c.getName(), c.getRootNodeRef(), c.getPath()));
postCommitCommands.add(newDeleteFileCallbackCommand());
return new CompoundCommand(commands, postCommitCommands, postErrorCommands);
}
break;
case LOOK_FOR_RENAME:
case INITIALISED:
if(operation instanceof CreateFileOperation)
{
CreateFileOperation c = (CreateFileOperation)operation;
if(c.getName().equalsIgnoreCase(name))
{
isComplete = true;
if(originalNodeRef != null)
{
logger.debug("Delete create shuffle fire!:" + this);
return new RestoreFileCommand(c.getName(), c.getRootNodeRef(), c.getPath(), c.getAllocationSize(), originalNodeRef);
}
return null;
}
}
if(operation instanceof RenameFileOperation)
{
RenameFileOperation r = (RenameFileOperation)operation;
if(name.equals(r.getTo()))
{
logger.debug("Delete on close Rename shuffle - fire!");
logger.debug("Delete Rename shuffle - fire!");
if(originalNodeRef != null)
{
@@ -155,7 +189,7 @@ class ScenarioDeleteOnCloseRenameInstance implements ScenarioInstance
MoveFileOperation r = (MoveFileOperation)operation;
if(name.equals(r.getTo()))
{
logger.debug("Delete on close Rename shuffle - fire!");
logger.debug("Delete Rename shuffle - fire!");
if(originalNodeRef != null)
{
@@ -198,7 +232,7 @@ class ScenarioDeleteOnCloseRenameInstance implements ScenarioInstance
public String toString()
{
return "ScenarioDeleteOnCloseRenameShuffleInstance name:" + name ;
return "ScenarioDeleteRenameOrCreate name:" + name ;
}
public void setTimeout(long timeout)

View File

@@ -0,0 +1,19 @@
package org.alfresco.filesys.repo.rules;
/**
* The scenario instance wants to be notified about rename.
*
* @author mrogers
*
*/
public interface ScenarioInstanceRenameAware
{
/**
* Notify the scenario of a successful rename operation.
*
* @param operation
* @param command
*/
public void notifyRename(Operation operation, Command command);
}

View File

@@ -74,7 +74,7 @@ import org.apache.commons.logging.LogFactory;
* 4) close
*
*/
class ScenarioOpenFileInstance implements ScenarioInstance, DependentInstance
class ScenarioOpenFileInstance implements ScenarioInstance, DependentInstance, ScenarioInstanceRenameAware
{
private static Log logger = LogFactory.getLog(ScenarioOpenFileInstance.class);
@@ -242,6 +242,20 @@ class ScenarioOpenFileInstance implements ScenarioInstance, DependentInstance
case OPEN:
if(operation instanceof RenameFileOperation)
{
RenameFileOperation r = (RenameFileOperation)operation;
if(r.getFrom() == null)
{
return null;
}
if(name.equalsIgnoreCase(r.getFrom()))
{
logger.warn("rename of an open file");
}
}
if(operation instanceof CloseFileOperation)
{
CloseFileOperation c = (CloseFileOperation)operation;
@@ -564,25 +578,70 @@ class ScenarioOpenFileInstance implements ScenarioInstance, DependentInstance
}
if(looser.scenario instanceof ScenarioDeleteOnCloseRenameInstance)
if(looser.scenario instanceof ScenarioDeleteRenameOrCreateInstance)
{
CompoundCommand l = (CompoundCommand)looser.command;
ArrayList<Command> commands = new ArrayList<Command>();
ArrayList<Command> postCommitCommands = new ArrayList<Command>();
ArrayList<Command> postErrorCommands = new ArrayList<Command>();
commands.addAll(c.getCommands());
postCommitCommands.addAll(c.getPostCommitCommands());
// Merge in the loosing post commit
postCommitCommands.addAll(l.getPostCommitCommands());
postErrorCommands.addAll(c.getPostErrorCommands());
logger.debug("returning merged high priority executor");
return new CompoundCommand(commands, postCommitCommands, postErrorCommands);
Command x = looser.command;
if(x instanceof CompoundCommand)
{
CompoundCommand l = (CompoundCommand)x;
ArrayList<Command> commands = new ArrayList<Command>();
ArrayList<Command> postCommitCommands = new ArrayList<Command>();
ArrayList<Command> postErrorCommands = new ArrayList<Command>();
commands.addAll(c.getCommands());
postCommitCommands.addAll(c.getPostCommitCommands());
// Merge in the loosing post commit
postCommitCommands.addAll(l.getPostCommitCommands());
postErrorCommands.addAll(c.getPostErrorCommands());
logger.debug("returning merged high priority executor");
return new CompoundCommand(commands, postCommitCommands, postErrorCommands);
}
else
{
return x;
}
}
}
}
// No change
return command;
}
@Override
public void notifyRename(Operation operation, Command command)
{
if(operation instanceof RenameFileOperation)
{
RenameFileOperation r = (RenameFileOperation)operation;
if(r.getFrom() == null)
{
return;
}
if(name.equalsIgnoreCase(r.getFrom()))
{
if(logger.isWarnEnabled())
{
logger.warn("rename of this scenario: to " + r.getTo());
}
name = r.getTo();
if (fileHandleReadWrite != null)
{
fileHandleReadWrite.setName(r.getTo());
fileHandleReadWrite.setFullName(r.getToPath());
}
if (fileHandleReadOnly != null)
{
fileHandleReadOnly.setName(r.getTo());
fileHandleReadOnly.setFullName(r.getToPath());
}
}
}
}
}