Merged V2.9 to HEAD

10586: Merged V2.2 to V2.9
      9883: Fix for https://issues.alfresco.com/jira/browse/ETWOTWO-561
      9893: Gave some more time to wait for the threads to finish (QNameDAOTest)
      9955: Added trace logging of calls that possibly cause failures during session flushing
      9956: Part fix ETWOTWO570: RetryingTransactionAdvice needs to use RetryingTransactionHelper
      9958: Fixed ETWOTWO-570: AVM transaction interceptors fail if methods are incorrectly declared
      9973: More missing transaction declarations for AttributeService
      9977: Fixed unit test to rollback properly after expected txn failure
      9978: Fix for ETWOTWO-440: Error : 500: Failed to execute method NodeInfoBean.sendNodeInfo
      9986: LinkValidationService missing txn declaration for onBootstrap
   10588: Merged V2.2 to V2.9
      9898: Fixed handling of cm:name on root nodes
      9900: Empty property sets are allowed
   10589: Merged V2.2 to V2.9
      9965: Fixed unit test to inject 'nodeService' and not 'NodeService'.
      10311: getWebProjectUserRole - change log level from info to debug
      10329: Fix missing and mis-spelt transaction declarations
      10343: Fix for ETWOTWO-32
      10346: Build Fix
      10358: Fix for ETWOTWO-621
      10362: Fix for ETWOTWO-518
      10371: QNameDAO cache doesn't blow up if cache entry is invalid
      10538: Fix for minor XSS issue identified in ETWOTWO-657 item 3
   10678: Merged V2.2 to V2.9
      10205: Fix for ETWOTWO-48: Cancelled import of war into a Web project and Web Project became unusable
      10206: Fix for ETWOTWO-181: Deletion of checked out document


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10710 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2008-09-04 01:19:51 +00:00
parent 3227355279
commit 76abcf04d9
23 changed files with 592 additions and 239 deletions

View File

@@ -32,6 +32,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -45,6 +46,7 @@ import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.avm.AVMNodeService;
import org.alfresco.repo.search.IndexerException;
import org.alfresco.repo.search.MLAnalysisMode;
import org.alfresco.repo.search.QueryRegisterComponent;
@@ -67,6 +69,7 @@ import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.InitializingBean;
/**
* This class is resource manager LuceneIndexers and LuceneSearchers. It supports two phase commit inside XA
@@ -932,7 +935,7 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory implements LuceneI
*
* @author Derek Hulley
*/
public static class LuceneIndexBackupComponent
public static class LuceneIndexBackupComponent implements InitializingBean
{
private static String BACKUP_TEMP_NAME = ".indexbackup_temp";
@@ -946,6 +949,8 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory implements LuceneI
private String targetLocation;
private boolean checkConfiguration = true;
/**
* Default constructor
*/
@@ -953,6 +958,16 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory implements LuceneI
{
}
/**
* If false do not check the index configuration.
*
* @param checkConfiguration
*/
public void setCheckConfiguration(boolean checkConfiguration)
{
this.checkConfiguration = checkConfiguration;
}
/**
* Provides transactions in which to perform the work
*
@@ -1294,6 +1309,86 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory implements LuceneI
}
}
public void afterPropertiesSet() throws Exception
{
RetryingTransactionCallback<Object> backupWork = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
File targetDir = new File(targetLocation).getCanonicalFile();
List<StoreRef> stores;
try
{
stores = nodeService.getStores();
}
catch (Exception e)
{
return null;
}
Set<String> protocols = new HashSet<String>();
protocols.add(StoreRef.PROTOCOL_AVM);
protocols.add(StoreRef.PROTOCOL_ARCHIVE);
protocols.add(StoreRef.PROTOCOL_WORKSPACE);
protocols.add("locks");
for (StoreRef store : stores)
{
protocols.add(store.getProtocol());
}
for (LuceneIndexerAndSearcher factory : factories)
{
File indexRootDir = new File(factory.getIndexRootLocation()).getCanonicalFile();
if (indexRootDir.getCanonicalPath().startsWith(targetDir.getCanonicalPath()))
{
throw new IllegalArgumentException("Backup directory can not contain or be an index directory");
}
if (targetDir.getCanonicalPath().startsWith(indexRootDir.getCanonicalPath()))
{
for (String name : protocols)
{
File test = new File(indexRootDir, name);
if (targetDir.getCanonicalPath().startsWith(test.getCanonicalPath()))
{
throw new IllegalArgumentException("Backup directory can not be in index directory and match a store protocol name " + targetDir);
}
}
}
// if the back up directory exists make sure it only contains directories that are store
// protocols
if (targetDir.exists())
{
for (File file : targetDir.listFiles())
{
if (file.isFile())
{
throw new IllegalArgumentException("Existing index backup does not look like the expected structure. It constains a file "
+ file.getCanonicalPath());
}
if (!protocols.contains(file.getName()))
{
throw new IllegalArgumentException(
"Existing index backup does not look like the expected structure. It constains a directory with a name that does not match a store protocol "
+ file.getCanonicalPath());
}
}
}
}
return null;
}
};
if (checkConfiguration)
{
transactionService.getRetryingTransactionHelper().doInTransaction(backupWork);
}
}
}
/**