mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.2 to HEAD
16714: WCM/AVM fixes - ETHREEOH-2697 & ETHREEOH-1847 16802: Merged V3.1 to V3.2 16801: AVMTestSuite - add couple of missing unit tests 16810: WCM locking - minor improvement to include lock owner (when trying to "grabLock") git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16925 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -34,6 +34,8 @@ import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.importer.ImporterBootstrap;
|
||||
import org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode;
|
||||
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
|
||||
import org.alfresco.repo.search.IndexMode;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
@@ -92,6 +94,7 @@ public class ConfigurationChecker extends AbstractLifecycleBean
|
||||
private NodeService nodeService;
|
||||
private SearchService searchService;
|
||||
private ContentService contentService;
|
||||
private AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
|
||||
|
||||
public ConfigurationChecker()
|
||||
{
|
||||
@@ -167,7 +170,12 @@ public class ConfigurationChecker extends AbstractLifecycleBean
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
|
||||
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
|
||||
{
|
||||
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
@@ -208,12 +216,6 @@ public class ConfigurationChecker extends AbstractLifecycleBean
|
||||
List<StoreRef> missingIndexStoreRefs = new ArrayList<StoreRef>(0);
|
||||
for (StoreRef storeRef : storeRefs)
|
||||
{
|
||||
// TODO: For now, do not check existence of index for AVM stores
|
||||
//if (storeRef.getProtocol().equals(StoreRef.PROTOCOL_AVM))
|
||||
//{
|
||||
// continue;
|
||||
//}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
NodeRef rootNodeRef = null;
|
||||
try
|
||||
@@ -227,6 +229,19 @@ public class ConfigurationChecker extends AbstractLifecycleBean
|
||||
}
|
||||
if (indexRecoveryMode != RecoveryMode.FULL)
|
||||
{
|
||||
if (storeRef.getProtocol().equals(StoreRef.PROTOCOL_AVM))
|
||||
{
|
||||
IndexMode storeIndexMode = avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(storeRef.getIdentifier());
|
||||
if (storeIndexMode.equals(IndexMode.UNINDEXED))
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Skipping index for store: " + storeRef + " (unindexed AVM store)");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Checking index for store: " + storeRef);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -175,7 +175,15 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
|
||||
{
|
||||
fService.createStore(name);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.avm.AVMService#createStore(java.lang.String, java.util.Map)
|
||||
*/
|
||||
public void createStore(String name, Map<QName, PropertyValue> props)
|
||||
{
|
||||
fService.createStore(name, props);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.avm.AVMService#deleteNodeProperties(java.lang.String)
|
||||
*/
|
||||
@@ -915,15 +923,28 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
|
||||
if (webProject != null)
|
||||
{
|
||||
String userName = fAuthenticationService.getCurrentUserName();
|
||||
if (!fLockingService.hasAccess(webProject, path, userName))
|
||||
|
||||
boolean hasAccess = fLockingService.hasAccess(webProject, path, userName);
|
||||
AVMLock lock = fLockingService.getLock(webProject, storePath[1]);
|
||||
|
||||
if (!hasAccess)
|
||||
{
|
||||
throw new AVMLockingException("avmlockservice.locked", new Object[]{path});
|
||||
String owners = null;
|
||||
if (lock == null)
|
||||
{
|
||||
owners = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
owners = lock.getOwners().toString(); // eg. '[alice]' or '[alice, bob]'
|
||||
}
|
||||
throw new AVMLockingException("avmlockservice.locked", new Object[]{path, owners});
|
||||
}
|
||||
if (fLockingService.getLock(webProject, storePath[1]) == null)
|
||||
if (lock == null)
|
||||
{
|
||||
List<String> owners = new ArrayList<String>(1);
|
||||
owners.add(userName);
|
||||
AVMLock lock = new AVMLock(webProject, storePath[0], storePath[1], AVMLockingService.Type.DISCRETIONARY, owners);
|
||||
lock = new AVMLock(webProject, storePath[0], storePath[1], AVMLockingService.Type.DISCRETIONARY, owners);
|
||||
fLockingService.lockPath(lock);
|
||||
}
|
||||
}
|
||||
|
@@ -451,6 +451,11 @@ public class AVMRepository
|
||||
* The name to give the new AVMStore.
|
||||
*/
|
||||
public void createAVMStore(String name)
|
||||
{
|
||||
createAVMStore(name, null);
|
||||
}
|
||||
|
||||
public void createAVMStore(String name, Map<QName, PropertyValue> props)
|
||||
{
|
||||
AlfrescoTransactionSupport.bindListener(fCreateStoreTxnListener);
|
||||
if (getAVMStoreByName(name) != null)
|
||||
@@ -465,6 +470,12 @@ public class AVMRepository
|
||||
rootNode.setStoreNew(null);
|
||||
fAVMNodeDAO.update(rootNode);
|
||||
|
||||
|
||||
if (props != null)
|
||||
{
|
||||
setStoreProperties(name, props);
|
||||
}
|
||||
|
||||
fCreateStoreTxnListener.storeCreated(name);
|
||||
}
|
||||
|
||||
|
@@ -474,7 +474,7 @@ public class AVMServiceImpl implements AVMService
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an AVMStore with the given name. It must not exist.
|
||||
* Create an AVMStore with the given name (it must not exist).
|
||||
* @param name The name to give the AVMStore.
|
||||
*/
|
||||
public void createStore(String name)
|
||||
@@ -485,8 +485,22 @@ public class AVMServiceImpl implements AVMService
|
||||
}
|
||||
fAVMRepository.createAVMStore(name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an AVMStore with the given name (it must not exist) and set store properties.
|
||||
* @param name The name to give the AVMStore.
|
||||
* @param props A Map of the properties to set.
|
||||
*/
|
||||
public void createStore(String name, Map<QName, PropertyValue> props)
|
||||
{
|
||||
if (name == null || !FileNameValidator.isValid(name))
|
||||
{
|
||||
throw new AVMBadArgumentException("Bad Name.");
|
||||
}
|
||||
fAVMRepository.createAVMStore(name, props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a branch.
|
||||
* @param version The version to branch from.
|
||||
* @param srcPath The path to the thing to branch from.
|
||||
|
@@ -27,6 +27,8 @@ package org.alfresco.repo.avm;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.alfresco.repo.avm.locking.AVMLockingServiceTest;
|
||||
|
||||
/**
|
||||
* AVM test suite
|
||||
*/
|
||||
@@ -48,6 +50,7 @@ public class AVMTestSuite extends TestSuite
|
||||
suite.addTestSuite(AVMServiceTestBase.class);
|
||||
suite.addTestSuite(AVMServiceTest.class);
|
||||
suite.addTestSuite(AVMServiceLocalTest.class);
|
||||
suite.addTestSuite(AVMLockingServiceTest.class);
|
||||
suite.addTestSuite(AVMServicePermissionsTest.class);
|
||||
suite.addTestSuite(AVMServiceIndexTest.class);
|
||||
|
||||
|
@@ -152,7 +152,15 @@ public class MultiTAVMService implements AVMService
|
||||
{
|
||||
fService.createStore(getTenantStoreName(storeName));
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.avm.AVMService#createStore(java.lang.String, java.util.Map)
|
||||
*/
|
||||
public void createStore(String name, Map<QName, PropertyValue> props)
|
||||
{
|
||||
fService.createStore(name, props);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.avm.AVMService#deleteNodeProperties(java.lang.String)
|
||||
*/
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -31,6 +31,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
@@ -47,9 +49,8 @@ import org.alfresco.service.cmr.security.AuthorityType;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* Tests for AVM locking service.
|
||||
@@ -57,7 +58,7 @@ import junit.framework.TestCase;
|
||||
*/
|
||||
public class AVMLockingServiceTest extends TestCase
|
||||
{
|
||||
private static FileSystemXmlApplicationContext fContext = null;
|
||||
private static ApplicationContext fContext = null;
|
||||
|
||||
private static AVMLockingService fService;
|
||||
|
||||
@@ -77,6 +78,8 @@ public class AVMLockingServiceTest extends TestCase
|
||||
|
||||
private static NodeRef fWebProject;
|
||||
|
||||
private final static String WP = "alfresco-"+System.currentTimeMillis();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@@ -85,7 +88,7 @@ public class AVMLockingServiceTest extends TestCase
|
||||
{
|
||||
if (fContext == null)
|
||||
{
|
||||
fContext = new FileSystemXmlApplicationContext("config/alfresco/application-context.xml");
|
||||
fContext = ApplicationContextHelper.getApplicationContext();
|
||||
fService = (AVMLockingService)fContext.getBean("AVMLockingService");
|
||||
fAttributeService = (AttributeService)fContext.getBean("AttributeService");
|
||||
fPersonService = (PersonService)fContext.getBean("PersonService");
|
||||
@@ -99,9 +102,9 @@ public class AVMLockingServiceTest extends TestCase
|
||||
// Set up a fake web project.
|
||||
NodeRef root = fRepoRemote.getRoot();
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
properties.put(WCMAppModel.PROP_AVMSTORE, "alfresco");
|
||||
fWebProject = fNodeService.createNode(root, ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "alfresco"),
|
||||
properties.put(WCMAppModel.PROP_AVMSTORE, WP);
|
||||
fWebProject = fNodeService.createNode(root, ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, WP),
|
||||
WCMAppModel.TYPE_AVMWEBFOLDER, properties).getChildRef();
|
||||
// Set up sample users groups and roles.
|
||||
fAuthenticationService.createAuthentication("Buffy", "Buffy".toCharArray());
|
||||
@@ -134,7 +137,10 @@ public class AVMLockingServiceTest extends TestCase
|
||||
List<String> webProjects = fService.getWebProjects();
|
||||
for (String webProject : webProjects)
|
||||
{
|
||||
fService.removeWebProject(webProject);
|
||||
if (webProject.equals(WP))
|
||||
{
|
||||
fService.removeWebProject(WP);
|
||||
}
|
||||
}
|
||||
fAuthenticationService.deleteAuthentication("Buffy");
|
||||
fAuthenticationService.deleteAuthentication("Willow");
|
||||
@@ -156,25 +162,25 @@ public class AVMLockingServiceTest extends TestCase
|
||||
{
|
||||
try
|
||||
{
|
||||
fService.addWebProject("alfresco");
|
||||
fService.addWebProject(WP);
|
||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
||||
List<String> owners = new ArrayList<String>();
|
||||
owners.add("Buffy");
|
||||
owners.add("Spike");
|
||||
AVMLock lock = new AVMLock("alfresco",
|
||||
AVMLock lock = new AVMLock(WP,
|
||||
"Sunnydale",
|
||||
"Revello Drive/1630",
|
||||
AVMLockingService.Type.DISCRETIONARY,
|
||||
owners);
|
||||
fService.lockPath(lock);
|
||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
||||
assertNotNull(fService.getLock("alfresco", "Revello Drive/1630"));
|
||||
assertNotNull(fService.getLock(WP, "Revello Drive/1630"));
|
||||
// assertEquals(1, fService.getUsersLocks("Buffy").size());
|
||||
assertEquals(1, fService.getWebProjectLocks("alfresco").size());
|
||||
assertEquals(1, fService.getWebProjectLocks(WP).size());
|
||||
List<String> owners2 = new ArrayList<String>();
|
||||
owners2.add("Buffy");
|
||||
owners2.add("Willow");
|
||||
AVMLock lock2 = new AVMLock("alfresco",
|
||||
AVMLock lock2 = new AVMLock(WP,
|
||||
"Sunnydale",
|
||||
"UC Sunnydale/Stevenson Hall",
|
||||
AVMLockingService.Type.DISCRETIONARY,
|
||||
@@ -182,14 +188,14 @@ public class AVMLockingServiceTest extends TestCase
|
||||
fService.lockPath(lock2);
|
||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
||||
// assertEquals(2, fService.getUsersLocks("Buffy").size());
|
||||
assertEquals(2, fService.getWebProjectLocks("alfresco").size());
|
||||
assertEquals(2, fService.getWebProjectLocks(WP).size());
|
||||
System.out.println("Before----------------------------");
|
||||
fService.removeLock("alfresco", "Revello Drive/1630");
|
||||
fService.removeLock(WP, "Revello Drive/1630");
|
||||
System.out.println("After----------------------------");
|
||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
||||
// assertEquals(1, fService.getUsersLocks("Buffy").size());
|
||||
assertEquals(1, fService.getWebProjectLocks("alfresco").size());
|
||||
fService.removeWebProject("alfresco");
|
||||
assertEquals(1, fService.getWebProjectLocks(WP).size());
|
||||
fService.removeWebProject(WP);
|
||||
System.out.println(fAttributeService.getAttribute(".avm_lock_table"));
|
||||
// assertEquals(0, fService.getUsersLocks("Spike").size());
|
||||
// assertEquals(0, fService.getUsersLocks("Buffy").size());
|
||||
@@ -207,26 +213,26 @@ public class AVMLockingServiceTest extends TestCase
|
||||
{
|
||||
try
|
||||
{
|
||||
fService.addWebProject("alfresco");
|
||||
fService.addWebProject(WP);
|
||||
List<String> owners = new ArrayList<String>();
|
||||
owners.add("ROLE_SUPER_POWERED");
|
||||
owners.add("Tara");
|
||||
AVMLock lock = new AVMLock("alfresco",
|
||||
AVMLock lock = new AVMLock(WP,
|
||||
"Sunnydale",
|
||||
"TheInitiative/Adam/plans.txt",
|
||||
AVMLockingService.Type.DISCRETIONARY,
|
||||
owners);
|
||||
fService.lockPath(lock);
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Buffy"));
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Spike"));
|
||||
assertFalse(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Tara"));
|
||||
assertFalse(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Xander"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Spike"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Willow"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Tara"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Xander"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Buffy"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Spike"));
|
||||
assertFalse(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Tara"));
|
||||
assertFalse(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Xander"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Spike"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Willow"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Tara"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Xander"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -239,26 +245,26 @@ public class AVMLockingServiceTest extends TestCase
|
||||
{
|
||||
try
|
||||
{
|
||||
fService.addWebProject("alfresco");
|
||||
fService.addWebProject(WP);
|
||||
List<String> owners = new ArrayList<String>();
|
||||
owners.add("GROUP_Scoobies");
|
||||
owners.add("Tara");
|
||||
AVMLock lock = new AVMLock("alfresco",
|
||||
AVMLock lock = new AVMLock(WP,
|
||||
"Sunnydale",
|
||||
"TheInitiative/Adam/plans.txt",
|
||||
AVMLockingService.Type.DISCRETIONARY,
|
||||
owners);
|
||||
fService.lockPath(lock);
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Spike"));
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Tara"));
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Xander"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Spike"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Willow"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Tara"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Xander"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Spike"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Tara"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Xander"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Spike"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Willow"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Tara"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Xander"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -271,60 +277,60 @@ public class AVMLockingServiceTest extends TestCase
|
||||
{
|
||||
try
|
||||
{
|
||||
fService.addWebProject("alfresco");
|
||||
fService.addWebProject(WP);
|
||||
List<String> owners = new ArrayList<String>();
|
||||
owners.add("GROUP_Scoobies");
|
||||
owners.add("Tara");
|
||||
AVMLock lock = new AVMLock("alfresco",
|
||||
AVMLock lock = new AVMLock(WP,
|
||||
"Sunnydale",
|
||||
"TheInitiative/Adam/plans.txt",
|
||||
AVMLockingService.Type.DISCRETIONARY,
|
||||
owners);
|
||||
fService.lockPath(lock);
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Spike"));
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Tara"));
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/TheInitiative/Adam/plans.txt", "Xander"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Spike"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Willow"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Tara"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/TheInitiative/Adam/plans.txt", "Xander"));
|
||||
fService.modifyLock("alfresco", "TheInitiative/Adam/plans.txt", "ScrapHeap/Adam/plans.txt", null, null, null);
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/ScrapHeap/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess("alfresco", "Sunnydale:/ScrapHeap/Adam/plans.txt", "Spike"));
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/ScrapHeap/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/ScrapHeap/Adam/plans.txt", "Tara"));
|
||||
assertTrue(fService.hasAccess("alfresco", "Sunnydale:/ScrapHeap/Adam/plans.txt", "Xander"));
|
||||
fService.modifyLock("alfresco", "ScrapHeap/Adam/plans.txt", null, "LA", null, null);
|
||||
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Spike"));
|
||||
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Tara"));
|
||||
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Xander"));
|
||||
assertFalse(fService.hasAccess("alfresco", "Sunnydale:/ScrapHeap/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess("alfresco", "Sunnydale:/ScrapHeap/Adam/plans.txt", "Spike"));
|
||||
assertFalse(fService.hasAccess("alfresco", "Sunnydale:/ScrapHeap/Adam/plans.txt", "Willow"));
|
||||
assertFalse(fService.hasAccess("alfresco", "Sunnydale:/ScrapHeap/Adam/plans.txt", "Tara"));
|
||||
assertFalse(fService.hasAccess("alfresco", "Sunnydale:/ScrapHeap/Adam/plans.txt", "Xander"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Spike"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Tara"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/TheInitiative/Adam/plans.txt", "Xander"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Spike"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Willow"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Tara"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/TheInitiative/Adam/plans.txt", "Xander"));
|
||||
fService.modifyLock(WP, "TheInitiative/Adam/plans.txt", "ScrapHeap/Adam/plans.txt", null, null, null);
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/ScrapHeap/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess(WP, "Sunnydale:/ScrapHeap/Adam/plans.txt", "Spike"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/ScrapHeap/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/ScrapHeap/Adam/plans.txt", "Tara"));
|
||||
assertTrue(fService.hasAccess(WP, "Sunnydale:/ScrapHeap/Adam/plans.txt", "Xander"));
|
||||
fService.modifyLock(WP, "ScrapHeap/Adam/plans.txt", null, "LA", null, null);
|
||||
assertTrue(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Spike"));
|
||||
assertTrue(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Tara"));
|
||||
assertTrue(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Xander"));
|
||||
assertFalse(fService.hasAccess(WP, "Sunnydale:/ScrapHeap/Adam/plans.txt", "Buffy"));
|
||||
assertFalse(fService.hasAccess(WP, "Sunnydale:/ScrapHeap/Adam/plans.txt", "Spike"));
|
||||
assertFalse(fService.hasAccess(WP, "Sunnydale:/ScrapHeap/Adam/plans.txt", "Willow"));
|
||||
assertFalse(fService.hasAccess(WP, "Sunnydale:/ScrapHeap/Adam/plans.txt", "Tara"));
|
||||
assertFalse(fService.hasAccess(WP, "Sunnydale:/ScrapHeap/Adam/plans.txt", "Xander"));
|
||||
List<String> usersToAdd = new ArrayList<String>();
|
||||
usersToAdd.add("Spike");
|
||||
fService.modifyLock("alfresco", "ScrapHeap/Adam/plans.txt", null, null, null, usersToAdd);
|
||||
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Buffy"));
|
||||
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Spike"));
|
||||
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Tara"));
|
||||
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Xander"));
|
||||
fService.modifyLock(WP, "ScrapHeap/Adam/plans.txt", null, null, null, usersToAdd);
|
||||
assertTrue(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Buffy"));
|
||||
assertTrue(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Spike"));
|
||||
assertTrue(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Tara"));
|
||||
assertTrue(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Xander"));
|
||||
List<String> usersToRemove = new ArrayList<String>();
|
||||
usersToRemove.add("GROUP_Scoobies");
|
||||
fService.modifyLock("alfresco", "ScrapHeap/Adam/plans.txt", null, null, usersToRemove, null);
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Buffy"));
|
||||
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Spike"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Tara"));
|
||||
assertFalse(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", "Xander"));
|
||||
assertTrue(fService.hasAccess("alfresco", "LA:/ScrapHeap/Adam/plans.txt", AuthenticationUtil.getAdminUserName()));
|
||||
fService.modifyLock(WP, "ScrapHeap/Adam/plans.txt", null, null, usersToRemove, null);
|
||||
assertFalse(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Buffy"));
|
||||
assertTrue(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Spike"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Willow"));
|
||||
assertTrue(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Tara"));
|
||||
assertFalse(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", "Xander"));
|
||||
assertTrue(fService.hasAccess(WP, "LA:/ScrapHeap/Adam/plans.txt", AuthenticationUtil.getAdminUserName()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.node.index;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -199,16 +223,7 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
|
||||
// Nothing to do for unindexed stores
|
||||
if (avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(store) == IndexMode.UNINDEXED)
|
||||
{
|
||||
|
||||
if (!avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated(store))
|
||||
{
|
||||
logger.warn(" Index for avm store " + store + " is out of date");
|
||||
return recoveryMode;
|
||||
}
|
||||
else
|
||||
{
|
||||
return RecoveryMode.NONE;
|
||||
}
|
||||
return RecoveryMode.NONE;
|
||||
}
|
||||
|
||||
if (recoveryMode == RecoveryMode.FULL) // no validate required
|
||||
@@ -268,22 +283,23 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
|
||||
|
||||
private void recoverStore(final String store, final RecoveryMode mode)
|
||||
{
|
||||
if (mode == RecoveryMode.AUTO)
|
||||
{
|
||||
logger.info(" Auto recovering index for " + store);
|
||||
}
|
||||
else if (mode == RecoveryMode.FULL)
|
||||
{
|
||||
logger.info(" Rebuilding index for " + store);
|
||||
}
|
||||
|
||||
if (!avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated(store))
|
||||
{
|
||||
avmSnapShotTriggeredIndexingMethodInterceptor.createIndex(store);
|
||||
}
|
||||
|
||||
if (avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(store) != IndexMode.UNINDEXED)
|
||||
IndexMode storeIndexMode = avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(store);
|
||||
if (storeIndexMode != IndexMode.UNINDEXED)
|
||||
{
|
||||
if (mode == RecoveryMode.AUTO)
|
||||
{
|
||||
logger.info(" Auto recovering index for " + store);
|
||||
}
|
||||
else if (mode == RecoveryMode.FULL)
|
||||
{
|
||||
logger.info(" Rebuilding index for " + store);
|
||||
}
|
||||
|
||||
if (!avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated(store))
|
||||
{
|
||||
avmSnapShotTriggeredIndexingMethodInterceptor.createIndex(store);
|
||||
}
|
||||
|
||||
final int latest = avmService.getLatestSnapshotID(store);
|
||||
if (latest <= 0)
|
||||
{
|
||||
@@ -313,12 +329,18 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
|
||||
}
|
||||
};
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true, true);
|
||||
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" Index updated for " + store + "("+storeIndexMode.toString()+")");
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
else
|
||||
{
|
||||
logger.debug(" Index updated for " + store);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" Index skipped for " + store+ "("+storeIndexMode.toString()+")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -42,7 +42,7 @@ import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
/**
|
||||
* Method interceptor for atomic indexing of AVM entries The proeprties can defined how stores are indexed based on type
|
||||
* Method interceptor for atomic indexing of AVM entries The properties can defined how stores are indexed based on type
|
||||
* (as set by Alfresco the Web site management UI) or based on the name of the store. Creates and deletes are indexed
|
||||
* synchronously. Updates may be asynchronous, synchronous or ignored by the index.
|
||||
*
|
||||
@@ -106,12 +106,14 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
|
||||
{
|
||||
String store = (String) mi.getArguments()[0];
|
||||
Object returnValue = mi.proceed();
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef(store);
|
||||
Indexer indexer = indexerAndSearcher.getIndexer(storeRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
|
||||
if (getIndexMode(store) != IndexMode.UNINDEXED)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
avmIndexer.deleteIndex(store, IndexMode.SYNCHRONOUS);
|
||||
AVMLuceneIndexer avmIndexer = getIndexer(store);
|
||||
if (avmIndexer != null)
|
||||
{
|
||||
avmIndexer.deleteIndex(store, IndexMode.SYNCHRONOUS);
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
@@ -119,7 +121,10 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
|
||||
{
|
||||
String store = (String) mi.getArguments()[0];
|
||||
Object returnValue = mi.proceed();
|
||||
createIndex(store);
|
||||
if (getIndexMode(store) != IndexMode.UNINDEXED)
|
||||
{
|
||||
createIndex(store);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
else if (mi.getMethod().getName().equals("renameStore"))
|
||||
@@ -128,25 +133,25 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
|
||||
String to = (String) mi.getArguments()[1];
|
||||
Object returnValue = mi.proceed();
|
||||
int after = avmService.getLatestSnapshotID(to);
|
||||
|
||||
StoreRef fromRef = AVMNodeConverter.ToStoreRef(from);
|
||||
StoreRef toRef = AVMNodeConverter.ToStoreRef(to);
|
||||
|
||||
Indexer indexer = indexerAndSearcher.getIndexer(fromRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
|
||||
if (getIndexMode(from) != IndexMode.UNINDEXED)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
avmIndexer.deleteIndex(from, IndexMode.SYNCHRONOUS);
|
||||
AVMLuceneIndexer avmIndexer = getIndexer(from);
|
||||
if (avmIndexer != null)
|
||||
{
|
||||
avmIndexer.deleteIndex(from, IndexMode.SYNCHRONOUS);
|
||||
}
|
||||
}
|
||||
|
||||
indexer = indexerAndSearcher.getIndexer(toRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
|
||||
if (getIndexMode(to) != IndexMode.UNINDEXED)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
avmIndexer.createIndex(to, IndexMode.SYNCHRONOUS);
|
||||
avmIndexer.index(to, 0, after, getIndexMode(to));
|
||||
AVMLuceneIndexer avmIndexer = getIndexer(to);
|
||||
if (avmIndexer != null)
|
||||
{
|
||||
avmIndexer.createIndex(to, IndexMode.SYNCHRONOUS);
|
||||
avmIndexer.index(to, 0, after, getIndexMode(to));
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
else
|
||||
@@ -222,43 +227,56 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
|
||||
*/
|
||||
public void indexSnapshot(String store, int before, int after)
|
||||
{
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef(store);
|
||||
Indexer indexer = indexerAndSearcher.getIndexer(storeRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
avmIndexer.index(store, before, after, getIndexMode(store));
|
||||
}
|
||||
indexSnapshotImpl(store, before, after);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param store
|
||||
* @param after
|
||||
*/
|
||||
public void indexSnapshot(String store, int after)
|
||||
{
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef(store);
|
||||
Indexer indexer = indexerAndSearcher.getIndexer(storeRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
indexSnapshotImpl(store, -1, after);
|
||||
}
|
||||
|
||||
private void indexSnapshotImpl(String store, int before, int after)
|
||||
{
|
||||
if (getIndexMode(store) != IndexMode.UNINDEXED)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
int before = avmIndexer.getLastIndexedSnapshot(store);
|
||||
avmIndexer.index(store, before, after, getIndexMode(store));
|
||||
AVMLuceneIndexer avmIndexer = getIndexer(store);
|
||||
if (avmIndexer != null)
|
||||
{
|
||||
int last = getLastIndexedSnapshot(avmIndexer, store);
|
||||
|
||||
if ((last == -1) && (! hasIndexBeenCreated(store)))
|
||||
{
|
||||
createIndex(store);
|
||||
}
|
||||
|
||||
avmIndexer.index(store, (before != -1 ? before : last), after, getIndexMode(store));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param store
|
||||
* @return - the last indexed snapshot
|
||||
*/
|
||||
public int getLastIndexedSnapshot(String store)
|
||||
{
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef(store);
|
||||
Indexer indexer = indexerAndSearcher.getIndexer(storeRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
AVMLuceneIndexer avmIndexer = getIndexer(store);
|
||||
if (avmIndexer != null)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
return avmIndexer.getLastIndexedSnapshot(store);
|
||||
return getLastIndexedSnapshot(avmIndexer, store);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
private int getLastIndexedSnapshot(AVMLuceneIndexer avmIndexer, String store)
|
||||
{
|
||||
return avmIndexer.getLastIndexedSnapshot(store);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the snapshot applied to the index? Is there an entry for any node that was added OR have all the nodes in the
|
||||
* transaction been deleted as expected?
|
||||
@@ -269,11 +287,9 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
|
||||
*/
|
||||
public boolean isSnapshotIndexed(String store, int id)
|
||||
{
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef(store);
|
||||
Indexer indexer = indexerAndSearcher.getIndexer(storeRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
AVMLuceneIndexer avmIndexer = getIndexer(store);
|
||||
if (avmIndexer != null)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
return avmIndexer.isSnapshotIndexed(store, id);
|
||||
}
|
||||
return false;
|
||||
@@ -295,11 +311,9 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
|
||||
case SYNCHRONOUS:
|
||||
case ASYNCHRONOUS:
|
||||
int last = avmService.getLatestSnapshotID(store);
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef(store);
|
||||
Indexer indexer = indexerAndSearcher.getIndexer(storeRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
AVMLuceneIndexer avmIndexer = getIndexer(store);
|
||||
if (avmIndexer != null)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
avmIndexer.flushPending();
|
||||
return avmIndexer.isSnapshotSearchable(store, last);
|
||||
}
|
||||
@@ -318,7 +332,6 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
|
||||
*/
|
||||
public boolean isIndexUpToDate(String store)
|
||||
{
|
||||
|
||||
switch (getIndexMode(store))
|
||||
{
|
||||
case UNINDEXED:
|
||||
@@ -326,13 +339,11 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
|
||||
case SYNCHRONOUS:
|
||||
case ASYNCHRONOUS:
|
||||
int last = avmService.getLatestSnapshotID(store);
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef(store);
|
||||
Indexer indexer = indexerAndSearcher.getIndexer(storeRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
AVMLuceneIndexer avmIndexer = getIndexer(store);
|
||||
if (avmIndexer != null)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
avmIndexer.flushPending();
|
||||
return avmIndexer.getLastIndexedSnapshot(store) == last;
|
||||
return getLastIndexedSnapshot(avmIndexer, store) == last;
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
@@ -472,11 +483,9 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
|
||||
|
||||
public boolean hasIndexBeenCreated(String store)
|
||||
{
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef(store);
|
||||
Indexer indexer = indexerAndSearcher.getIndexer(storeRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
AVMLuceneIndexer avmIndexer = getIndexer(store);
|
||||
if (avmIndexer != null)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
avmIndexer.flushPending();
|
||||
return avmIndexer.hasIndexBeenCreated(store);
|
||||
}
|
||||
@@ -485,11 +494,9 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
|
||||
|
||||
public void createIndex(String store)
|
||||
{
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef(store);
|
||||
Indexer indexer = indexerAndSearcher.getIndexer(storeRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
AVMLuceneIndexer avmIndexer = getIndexer(store);
|
||||
if (avmIndexer != null)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
avmIndexer.createIndex(store, IndexMode.SYNCHRONOUS);
|
||||
}
|
||||
}
|
||||
|
@@ -1,26 +1,27 @@
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Copyright 2005-2007 Alfresco Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special
|
||||
* exception to the terms and conditions of version 2.0 of the GPL, you may
|
||||
* redistribute this Program in connection with Free/Libre and Open Source
|
||||
* Software ("FLOSS") applications as described in Alfresco's FLOSS exception.
|
||||
* You should have received a copy of the text describing the FLOSS exception,
|
||||
* and it is also available here: http://www.alfresco.com/legal/licensing
|
||||
*
|
||||
*----------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing
|
||||
*/
|
||||
|
||||
package org.alfresco.service.cmr.avm;
|
||||
|
||||
@@ -302,6 +303,16 @@ public interface AVMService
|
||||
*/
|
||||
public void createStore(String name);
|
||||
|
||||
/**
|
||||
* Create a new AVMStore with store properties (equivalent to createStore + setProperties)
|
||||
*
|
||||
* @param name The name of the new AVMStore.
|
||||
* @param props A Map of the properties to set.
|
||||
* @throws AVMExistsException
|
||||
* @since 3.2
|
||||
*/
|
||||
public void createStore(String name, Map<QName, PropertyValue> props);
|
||||
|
||||
|
||||
/**
|
||||
* Create a branch from a given version and path. As a side effect,
|
||||
|
@@ -27,6 +27,7 @@ package org.alfresco.wcm.sandbox;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -153,7 +154,16 @@ public final class SandboxFactory extends WCMUtil
|
||||
{
|
||||
// create the 'staging' store for the website
|
||||
String stagingStoreName = WCMUtil.buildStagingStoreName(storeId);
|
||||
avmService.createStore(stagingStoreName);
|
||||
|
||||
// tag store with properties
|
||||
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>(3);
|
||||
// tag the store with the store type
|
||||
props.put(SandboxConstants.PROP_SANDBOX_STAGING_MAIN, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
props.put(SandboxConstants.PROP_WEB_PROJECT_NODE_REF, new PropertyValue(DataTypeDefinition.NODE_REF, webProjectNodeRef));
|
||||
// tag the store with the DNS name property
|
||||
addStoreDNSPath(stagingStoreName, props, storeId);
|
||||
|
||||
avmService.createStore(stagingStoreName, props);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
@@ -182,24 +192,23 @@ public final class SandboxFactory extends WCMUtil
|
||||
|
||||
// Add permissions for layers
|
||||
|
||||
// tag the store with the store type
|
||||
avmService.setStoreProperty(stagingStoreName,
|
||||
SandboxConstants.PROP_SANDBOX_STAGING_MAIN,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
avmService.setStoreProperty(stagingStoreName,
|
||||
SandboxConstants.PROP_WEB_PROJECT_NODE_REF,
|
||||
new PropertyValue(DataTypeDefinition.NODE_REF, webProjectNodeRef));
|
||||
|
||||
// tag the store with the DNS name property
|
||||
tagStoreDNSPath(avmService, stagingStoreName, storeId);
|
||||
|
||||
// snapshot the store
|
||||
avmService.createSnapshot(stagingStoreName, null, null);
|
||||
|
||||
|
||||
// create the 'preview' store for the website
|
||||
String previewStoreName = WCMUtil.buildStagingPreviewStoreName(storeId);
|
||||
avmService.createStore(previewStoreName);
|
||||
|
||||
// tag store with properties - store type, web project DM nodeRef, DNS name
|
||||
props = new HashMap<QName, PropertyValue>(3);
|
||||
// tag the store with the store type
|
||||
props.put(SandboxConstants.PROP_SANDBOX_STAGING_PREVIEW, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with the DNS name property
|
||||
addStoreDNSPath(previewStoreName, props, storeId, "preview");
|
||||
// The preview store depends on the main staging store (dist=1)
|
||||
addStoreBackgroundLayer(props, stagingStoreName, 1);
|
||||
|
||||
avmService.createStore(previewStoreName, props);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
@@ -212,22 +221,11 @@ public final class SandboxFactory extends WCMUtil
|
||||
previewStoreName + ":/",
|
||||
JNDIConstants.DIR_DEFAULT_WWW);
|
||||
|
||||
|
||||
|
||||
// apply READ permissions for all users
|
||||
//dirRef = AVMNodeConverter.ToNodeRef(-1, WCMUtil.buildStoreRootPath(previewStoreName));
|
||||
//permissionService.setPermission(dirRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true);
|
||||
|
||||
// tag the store with the store type
|
||||
avmService.setStoreProperty(previewStoreName,
|
||||
SandboxConstants.PROP_SANDBOX_STAGING_PREVIEW,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with the DNS name property
|
||||
tagStoreDNSPath(avmService, previewStoreName, storeId, "preview");
|
||||
|
||||
// The preview store depends on the main staging store (dist=1)
|
||||
tagStoreBackgroundLayer(avmService,previewStoreName,stagingStoreName,1);
|
||||
|
||||
// snapshot the store
|
||||
avmService.createSnapshot(previewStoreName, null, null);
|
||||
|
||||
@@ -580,9 +578,27 @@ public final class SandboxFactory extends WCMUtil
|
||||
return userSandboxInfo;
|
||||
}
|
||||
|
||||
avmService.createStore(userStoreName);
|
||||
QName sandboxIdProp = QName.createQName(null, SandboxConstants.PROP_SANDBOXID + GUID.generate());
|
||||
|
||||
String stagingStoreName = WCMUtil.buildStagingStoreName(storeId);
|
||||
|
||||
// tag store with properties
|
||||
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>(6);
|
||||
// tag the store with the store type
|
||||
props.put(SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with the base name of the website so that corresponding staging areas can be found.
|
||||
props.put(SandboxConstants.PROP_WEBSITE_NAME, new PropertyValue(DataTypeDefinition.TEXT, storeId));
|
||||
// tag the store, oddly enough, with its own store name for querying.
|
||||
props.put(QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + userStoreName), new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag all related stores to indicate that they are part of a single sandbox
|
||||
props.put(sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with the DNS name property
|
||||
addStoreDNSPath(userStoreName, props, storeId, username);
|
||||
// The user store depends on the main staging store (dist=1)
|
||||
addStoreBackgroundLayer(props, stagingStoreName, 1);
|
||||
|
||||
avmService.createStore(userStoreName, props);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Created user sandbox: " + userStoreName + " above staging store " + stagingStoreName);
|
||||
@@ -611,33 +627,26 @@ public final class SandboxFactory extends WCMUtil
|
||||
// permissionService.setPermission(dirRef.getStoreRef(), manager, AVMUtil.ROLE_CONTENT_MANAGER, true);
|
||||
// }
|
||||
|
||||
// tag the store with the store type
|
||||
avmService.setStoreProperty(userStoreName,
|
||||
SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with the base name of the website so that corresponding
|
||||
// staging areas can be found.
|
||||
avmService.setStoreProperty(userStoreName,
|
||||
SandboxConstants.PROP_WEBSITE_NAME,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, storeId));
|
||||
|
||||
// tag the store, oddly enough, with its own store name for querying.
|
||||
avmService.setStoreProperty(userStoreName,
|
||||
QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + userStoreName),
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with the DNS name property
|
||||
tagStoreDNSPath(avmService, userStoreName, storeId, username);
|
||||
|
||||
// The user store depends on the main staging store (dist=1)
|
||||
tagStoreBackgroundLayer(avmService,userStoreName,stagingStoreName,1);
|
||||
|
||||
// snapshot the store
|
||||
avmService.createSnapshot(userStoreName, null, null);
|
||||
|
||||
// tag store with properties
|
||||
props = new HashMap<QName, PropertyValue>(6);
|
||||
// tag the store with the store type
|
||||
props.put(SandboxConstants.PROP_SANDBOX_AUTHOR_PREVIEW, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with its own store name for querying.
|
||||
props.put(QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName), new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag all related stores to indicate that they are part of a single sandbox
|
||||
props.put(sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with the DNS name property
|
||||
addStoreDNSPath(previewStoreName, props, storeId, username, "preview");
|
||||
// The preview user store depends on the main user store (dist=1)
|
||||
addStoreBackgroundLayer(props, userStoreName, 1);
|
||||
// The preview user store depends on the main staging store (dist=2)
|
||||
addStoreBackgroundLayer(props, stagingStoreName, 2);
|
||||
|
||||
// create the user 'preview' store
|
||||
avmService.createStore(previewStoreName);
|
||||
avmService.createStore(previewStoreName, props);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
@@ -663,39 +672,9 @@ public final class SandboxFactory extends WCMUtil
|
||||
permissionService.setPermission(dirRef.getStoreRef(), manager, WCMUtil.ROLE_CONTENT_MANAGER, true);
|
||||
}
|
||||
|
||||
// tag the store with the store type
|
||||
avmService.setStoreProperty(previewStoreName,
|
||||
SandboxConstants.PROP_SANDBOX_AUTHOR_PREVIEW,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with its own store name for querying.
|
||||
avmService.setStoreProperty(previewStoreName,
|
||||
QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName),
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with the DNS name property
|
||||
tagStoreDNSPath(avmService, previewStoreName, storeId, username, "preview");
|
||||
|
||||
// The preview user store depends on the main user store (dist=1)
|
||||
tagStoreBackgroundLayer(avmService,previewStoreName, userStoreName,1);
|
||||
|
||||
// The preview user store depends on the main staging store (dist=2)
|
||||
tagStoreBackgroundLayer(avmService,previewStoreName, stagingStoreName,2);
|
||||
|
||||
|
||||
// snapshot the store
|
||||
avmService.createSnapshot(previewStoreName, null, null);
|
||||
|
||||
|
||||
// tag all related stores to indicate that they are part of a single sandbox
|
||||
QName sandboxIdProp = QName.createQName(null, SandboxConstants.PROP_SANDBOXID + GUID.generate());
|
||||
avmService.setStoreProperty(userStoreName,
|
||||
sandboxIdProp,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
avmService.setStoreProperty(previewStoreName,
|
||||
sandboxIdProp,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
dumpStoreProperties(avmService, userStoreName);
|
||||
@@ -720,53 +699,62 @@ public final class SandboxFactory extends WCMUtil
|
||||
public SandboxInfo createWorkflowSandbox(final String storeId)
|
||||
{
|
||||
String stagingStoreName = WCMUtil.buildStagingStoreName(storeId);
|
||||
|
||||
|
||||
// create the workflow 'main' store
|
||||
String packageName = WCMUtil.STORE_WORKFLOW + "-" + GUID.generate();
|
||||
String mainStoreName = WCMUtil.buildWorkflowMainStoreName(storeId, packageName);
|
||||
|
||||
avmService.createStore(mainStoreName);
|
||||
final QName sandboxIdProp = QName.createQName(SandboxConstants.PROP_SANDBOXID + GUID.generate());
|
||||
|
||||
// tag store with properties
|
||||
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>(6);
|
||||
// tag the store with the store type
|
||||
props.put(SandboxConstants.PROP_SANDBOX_WORKFLOW_MAIN, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with the base name of the website so that corresponding staging areas can be found.
|
||||
props.put(SandboxConstants.PROP_WEBSITE_NAME, new PropertyValue(DataTypeDefinition.TEXT, storeId));
|
||||
// tag the store, oddly enough, with its own store name for querying.
|
||||
props.put(QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + mainStoreName), new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag all related stores to indicate that they are part of a single sandbox
|
||||
props.put(sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with the DNS name property
|
||||
addStoreDNSPath(mainStoreName, props, storeId, packageName);
|
||||
// The main workflow store depends on the main staging store (dist=1)
|
||||
addStoreBackgroundLayer(props, stagingStoreName, 1);
|
||||
|
||||
avmService.createStore(mainStoreName, props);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Created workflow sandbox store: " + mainStoreName);
|
||||
}
|
||||
|
||||
|
||||
// create a layered directory pointing to 'www' in the staging area
|
||||
avmService.createLayeredDirectory(WCMUtil.buildStoreRootPath(stagingStoreName),
|
||||
mainStoreName + ":/",
|
||||
JNDIConstants.DIR_DEFAULT_WWW);
|
||||
|
||||
// tag the store with the store type
|
||||
avmService.setStoreProperty(mainStoreName,
|
||||
SandboxConstants.PROP_SANDBOX_WORKFLOW_MAIN,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with the base name of the website so that corresponding
|
||||
// staging areas can be found.
|
||||
avmService.setStoreProperty(mainStoreName,
|
||||
SandboxConstants.PROP_WEBSITE_NAME,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, storeId));
|
||||
|
||||
// tag the store, oddly enough, with its own store name for querying.
|
||||
avmService.setStoreProperty(mainStoreName,
|
||||
QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + mainStoreName),
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with the DNS name property
|
||||
tagStoreDNSPath(avmService, mainStoreName, storeId, packageName);
|
||||
|
||||
|
||||
// The main workflow store depends on the main staging store (dist=1)
|
||||
tagStoreBackgroundLayer(avmService,mainStoreName, stagingStoreName ,1);
|
||||
|
||||
|
||||
// snapshot the store
|
||||
avmService.createSnapshot(mainStoreName, null, null);
|
||||
|
||||
|
||||
// create the workflow 'preview' store
|
||||
final String previewStoreName = WCMUtil.buildWorkflowPreviewStoreName(storeId, packageName);
|
||||
|
||||
avmService.createStore(previewStoreName);
|
||||
// tag store with properties
|
||||
props = new HashMap<QName, PropertyValue>(6);
|
||||
// tag the store with the store type
|
||||
props.put(SandboxConstants.PROP_SANDBOX_WORKFLOW_PREVIEW, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with its own store name for querying.
|
||||
props.put(QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName), new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag all related stores to indicate that they are part of a single sandbox
|
||||
props.put(sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with the DNS name property
|
||||
addStoreDNSPath(previewStoreName, props, storeId, packageName, "preview");
|
||||
// The preview workflow store depends on the main workflow store (dist=1)
|
||||
addStoreBackgroundLayer(props, mainStoreName, 1);
|
||||
// The preview workflow store depends on the main staging store (dist=2)
|
||||
addStoreBackgroundLayer(props, stagingStoreName, 2);
|
||||
|
||||
avmService.createStore(previewStoreName, props);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
@@ -777,41 +765,9 @@ public final class SandboxFactory extends WCMUtil
|
||||
avmService.createLayeredDirectory(WCMUtil.buildStoreRootPath(mainStoreName),
|
||||
previewStoreName + ":/",
|
||||
JNDIConstants.DIR_DEFAULT_WWW);
|
||||
|
||||
// tag the store with the store type
|
||||
avmService.setStoreProperty(previewStoreName,
|
||||
SandboxConstants.PROP_SANDBOX_WORKFLOW_PREVIEW,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with its own store name for querying.
|
||||
avmService.setStoreProperty(previewStoreName,
|
||||
QName.createQName(null,
|
||||
SandboxConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName),
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with the DNS name property
|
||||
tagStoreDNSPath(avmService, previewStoreName, storeId, packageName, "preview");
|
||||
|
||||
|
||||
// The preview worfkflow store depends on the main workflow store (dist=1)
|
||||
tagStoreBackgroundLayer(avmService,previewStoreName, mainStoreName,1);
|
||||
|
||||
// The preview workflow store depends on the main staging store (dist=2)
|
||||
tagStoreBackgroundLayer(avmService,previewStoreName, stagingStoreName,2);
|
||||
|
||||
|
||||
// snapshot the store
|
||||
avmService.createSnapshot(previewStoreName, null, null);
|
||||
|
||||
|
||||
// tag all related stores to indicate that they are part of a single sandbox
|
||||
final QName sandboxIdProp = QName.createQName(SandboxConstants.PROP_SANDBOXID + GUID.generate());
|
||||
avmService.setStoreProperty(mainStoreName,
|
||||
sandboxIdProp,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
avmService.setStoreProperty(previewStoreName,
|
||||
sandboxIdProp,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
@@ -845,12 +801,29 @@ public final class SandboxFactory extends WCMUtil
|
||||
{
|
||||
String wpStoreId = WCMUtil.getWebProjectStoreId(storeId);
|
||||
String stagingStoreName = WCMUtil.buildStagingStoreName(storeId);
|
||||
|
||||
|
||||
// create the workflow 'main' store
|
||||
String packageName = WCMUtil.STORE_WORKFLOW + "-" + GUID.generate();
|
||||
String mainStoreName = WCMUtil.buildWorkflowMainStoreName(storeId, packageName);
|
||||
|
||||
avmService.createStore(mainStoreName);
|
||||
final QName sandboxIdProp = QName.createQName(SandboxConstants.PROP_SANDBOXID + GUID.generate());
|
||||
|
||||
// tag store with properties
|
||||
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>(6);
|
||||
// tag the store with the store type
|
||||
props.put(SandboxConstants.PROP_SANDBOX_WORKFLOW_MAIN, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with the base name of the website so that corresponding staging areas can be found.
|
||||
props.put(SandboxConstants.PROP_WEBSITE_NAME, new PropertyValue(DataTypeDefinition.TEXT, storeId));
|
||||
// tag the store, oddly enough, with its own store name for querying.
|
||||
props.put(QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + mainStoreName), new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with the DNS name property
|
||||
addStoreDNSPath(mainStoreName, props, storeId, packageName);
|
||||
// The main workflow store depends on the main staging store (dist=1)
|
||||
addStoreBackgroundLayer(props, stagingStoreName, 1);
|
||||
// tag all related stores to indicate that they are part of a single sandbox
|
||||
props.put(sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
avmService.createStore(mainStoreName, props);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
@@ -861,35 +834,6 @@ public final class SandboxFactory extends WCMUtil
|
||||
avmService.createLayeredDirectory(WCMUtil.buildStoreRootPath(stagingStoreName),
|
||||
mainStoreName + ":/",
|
||||
JNDIConstants.DIR_DEFAULT_WWW);
|
||||
|
||||
// tag the store with the store type
|
||||
avmService.setStoreProperty(mainStoreName,
|
||||
SandboxConstants.PROP_SANDBOX_WORKFLOW_MAIN,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with the base name of the website so that corresponding
|
||||
// staging areas can be found.
|
||||
avmService.setStoreProperty(mainStoreName,
|
||||
SandboxConstants.PROP_WEBSITE_NAME,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, storeId));
|
||||
|
||||
// tag the store, oddly enough, with its own store name for querying.
|
||||
avmService.setStoreProperty(mainStoreName,
|
||||
QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + mainStoreName),
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with the DNS name property
|
||||
tagStoreDNSPath(avmService, mainStoreName, storeId, packageName);
|
||||
|
||||
|
||||
// The main workflow store depends on the main staging store (dist=1)
|
||||
tagStoreBackgroundLayer(avmService,mainStoreName, stagingStoreName ,1);
|
||||
|
||||
// tag all related stores to indicate that they are part of a single sandbox
|
||||
final QName sandboxIdProp = QName.createQName(SandboxConstants.PROP_SANDBOXID + GUID.generate());
|
||||
avmService.setStoreProperty(mainStoreName,
|
||||
sandboxIdProp,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
@@ -914,8 +858,27 @@ public final class SandboxFactory extends WCMUtil
|
||||
// create the workflow 'main' store
|
||||
String packageName = "workflow-" + GUID.generate();
|
||||
String workflowStoreName = userStore + STORE_SEPARATOR + packageName;
|
||||
|
||||
avmService.createStore(workflowStoreName);
|
||||
|
||||
final QName sandboxIdProp = QName.createQName(SandboxConstants.PROP_SANDBOXID + GUID.generate());
|
||||
|
||||
// tag store with properties
|
||||
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>(7);
|
||||
// tag the store with the store type
|
||||
props.put(SandboxConstants.PROP_SANDBOX_AUTHOR_WORKFLOW_MAIN, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with the name of the author's store this one is layered over
|
||||
props.put(SandboxConstants.PROP_AUTHOR_NAME, new PropertyValue(DataTypeDefinition.TEXT, userStore));
|
||||
// tag the store, oddly enough, with its own store name for querying.
|
||||
props.put(QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + workflowStoreName), new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with the DNS name property
|
||||
addStoreDNSPath(workflowStoreName, props, stagingStore, packageName);
|
||||
// the main workflow store depends on the main user store (dist=1)
|
||||
addStoreBackgroundLayer(props, userStore, 1);
|
||||
// The main workflow store depends on the main staging store (dist=2)
|
||||
addStoreBackgroundLayer(props, stagingStore, 2);
|
||||
// tag all related stores to indicate that they are part of a single sandbox
|
||||
props.put(sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
avmService.createStore(workflowStoreName, props);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
@@ -927,52 +890,32 @@ public final class SandboxFactory extends WCMUtil
|
||||
userStore + ":/" + JNDIConstants.DIR_DEFAULT_WWW,
|
||||
workflowStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW);
|
||||
|
||||
// tag the store with the store type
|
||||
avmService.setStoreProperty(workflowStoreName,
|
||||
SandboxConstants.PROP_SANDBOX_AUTHOR_WORKFLOW_MAIN,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with the name of the author's store this one is layered over
|
||||
avmService.setStoreProperty(workflowStoreName,
|
||||
SandboxConstants.PROP_AUTHOR_NAME,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, userStore));
|
||||
|
||||
// tag the store, oddly enough, with its own store name for querying.
|
||||
avmService.setStoreProperty(workflowStoreName,
|
||||
QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + workflowStoreName),
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with the DNS name property
|
||||
String path = workflowStoreName + ":/" + JNDIConstants.DIR_DEFAULT_WWW +
|
||||
"/" + JNDIConstants.DIR_DEFAULT_APPBASE;
|
||||
// DNS name mangle the property name - can only contain value DNS characters!
|
||||
String dnsProp = SandboxConstants.PROP_DNS + DNSNameMangler.MakeDNSName(stagingStore, packageName);
|
||||
avmService.setStoreProperty(workflowStoreName, QName.createQName(null, dnsProp),
|
||||
new PropertyValue(DataTypeDefinition.TEXT, path));
|
||||
|
||||
// TODO review above and replace with common call to ...
|
||||
/*
|
||||
// tag the store with the DNS name property
|
||||
tagStoreDNSPath(avmService, workflowStoreName, storeId, packageName);
|
||||
*/
|
||||
|
||||
// the main workflow store depends on the main user store (dist=1)
|
||||
String prop_key = SandboxConstants.PROP_BACKGROUND_LAYER + userStore;
|
||||
avmService.setStoreProperty(workflowStoreName, QName.createQName(null, prop_key),
|
||||
new PropertyValue(DataTypeDefinition.INT, 1));
|
||||
|
||||
// The main workflow store depends on the main staging store (dist=2)
|
||||
prop_key = SandboxConstants.PROP_BACKGROUND_LAYER + stagingStore;
|
||||
avmService.setStoreProperty(workflowStoreName, QName.createQName(null, prop_key),
|
||||
new PropertyValue(DataTypeDefinition.INT, 2));
|
||||
|
||||
// snapshot the store
|
||||
avmService.createSnapshot(workflowStoreName, null, null);
|
||||
|
||||
// create the workflow 'preview' store
|
||||
String previewStoreName = workflowStoreName + STORE_SEPARATOR + "preview";
|
||||
avmService.createStore(previewStoreName);
|
||||
|
||||
|
||||
// tag store with properties
|
||||
props = new HashMap<QName, PropertyValue>(7);
|
||||
// tag the store with the store type
|
||||
props.put(SandboxConstants.PROP_SANDBOX_AUTHOR_WORKFLOW_PREVIEW, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with its own store name for querying.
|
||||
props.put(QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName), new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
// tag the store with the DNS name property
|
||||
addStoreDNSPath(previewStoreName, props, userStore, packageName, "preview");
|
||||
// The preview worfkflow store depends on the main workflow store (dist=1)
|
||||
addStoreBackgroundLayer(props, workflowStoreName, 1);
|
||||
// The preview workflow store depends on the main user store (dist=2)
|
||||
addStoreBackgroundLayer(props, userStore, 2);
|
||||
// The preview workflow store depends on the main staging store (dist=3)
|
||||
addStoreBackgroundLayer(props, stagingStore, 3);
|
||||
|
||||
// tag all related stores to indicate that they are part of a single sandbox
|
||||
props.put(sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
avmService.createStore(previewStoreName, props);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Created user workflow sandbox preview store: " + previewStoreName);
|
||||
@@ -982,55 +925,10 @@ public final class SandboxFactory extends WCMUtil
|
||||
avmService.createLayeredDirectory(
|
||||
workflowStoreName + ":/" + JNDIConstants.DIR_DEFAULT_WWW,
|
||||
previewStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW);
|
||||
|
||||
// tag the store with the store type
|
||||
avmService.setStoreProperty(previewStoreName, SandboxConstants.PROP_SANDBOX_WORKFLOW_PREVIEW,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with its own store name for querying.
|
||||
avmService.setStoreProperty(previewStoreName,
|
||||
QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName),
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
// tag the store with the DNS name property
|
||||
path = previewStoreName + ":/" + JNDIConstants.DIR_DEFAULT_WWW +
|
||||
"/" + JNDIConstants.DIR_DEFAULT_APPBASE;
|
||||
// DNS name mangle the property name - can only contain value DNS characters!
|
||||
dnsProp = SandboxConstants.PROP_DNS + DNSNameMangler.MakeDNSName(userStore, packageName, "preview");
|
||||
avmService.setStoreProperty(previewStoreName, QName.createQName(null, dnsProp),
|
||||
new PropertyValue(DataTypeDefinition.TEXT, path));
|
||||
|
||||
// TODO review above and replace with common call to ...
|
||||
/*
|
||||
// tag the store with the DNS name property
|
||||
tagStoreDNSPath(avmService, previewStoreName, storeId, packageName, "preview");
|
||||
*/
|
||||
|
||||
// The preview worfkflow store depends on the main workflow store (dist=1)
|
||||
prop_key = SandboxConstants.PROP_BACKGROUND_LAYER + workflowStoreName;
|
||||
avmService.setStoreProperty(previewStoreName, QName.createQName(null, prop_key),
|
||||
new PropertyValue(DataTypeDefinition.INT, 1));
|
||||
|
||||
// The preview workflow store depends on the main user store (dist=2)
|
||||
prop_key = SandboxConstants.PROP_BACKGROUND_LAYER + userStore;
|
||||
avmService.setStoreProperty(previewStoreName, QName.createQName(null, prop_key),
|
||||
new PropertyValue(DataTypeDefinition.INT, 2));
|
||||
|
||||
// The preview workflow store depends on the main staging store (dist=3)
|
||||
prop_key = SandboxConstants.PROP_BACKGROUND_LAYER + stagingStore;
|
||||
avmService.setStoreProperty(previewStoreName, QName.createQName(null, prop_key),
|
||||
new PropertyValue(DataTypeDefinition.INT, 3));
|
||||
|
||||
// snapshot the store
|
||||
avmService.createSnapshot(previewStoreName, null, null);
|
||||
|
||||
// tag all related stores to indicate that they are part of a single sandbox
|
||||
QName sandboxIdProp = QName.createQName(SandboxConstants.PROP_SANDBOXID + GUID.generate());
|
||||
avmService.setStoreProperty(workflowStoreName, sandboxIdProp,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
avmService.setStoreProperty(previewStoreName, sandboxIdProp,
|
||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||
|
||||
|
||||
// return the main workflow store name
|
||||
return workflowStoreName;
|
||||
}
|
||||
@@ -1270,13 +1168,12 @@ public final class SandboxFactory extends WCMUtil
|
||||
*
|
||||
* @param store Name of the store to tag
|
||||
*/
|
||||
private static void tagStoreDNSPath(AVMService avmService, String store, String... components)
|
||||
private static void addStoreDNSPath(String store, Map<QName, PropertyValue> props, String... components)
|
||||
{
|
||||
String path = WCMUtil.buildSandboxRootPath(store);
|
||||
// DNS name mangle the property name - can only contain value DNS characters!
|
||||
String dnsProp = SandboxConstants.PROP_DNS + DNSNameMangler.MakeDNSName(components);
|
||||
avmService.setStoreProperty(store, QName.createQName(null, dnsProp),
|
||||
new PropertyValue(DataTypeDefinition.TEXT, path));
|
||||
props.put(QName.createQName(null, dnsProp), new PropertyValue(DataTypeDefinition.TEXT, path));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1304,14 +1201,12 @@ public final class SandboxFactory extends WCMUtil
|
||||
* The backgroundStore 'mysite' is 1 away from the store 'mysite--alice'
|
||||
* but 2 away from the store 'mysite--alice--preview'.
|
||||
*/
|
||||
private static void tagStoreBackgroundLayer(AVMService avmService,
|
||||
String store,
|
||||
private static void addStoreBackgroundLayer(Map<QName, PropertyValue> props,
|
||||
String backgroundStore,
|
||||
int distance)
|
||||
{
|
||||
String prop_key = SandboxConstants.PROP_BACKGROUND_LAYER + backgroundStore;
|
||||
avmService.setStoreProperty(store, QName.createQName(null, prop_key),
|
||||
new PropertyValue(DataTypeDefinition.INT, distance));
|
||||
props.put(QName.createQName(null, prop_key), new PropertyValue(DataTypeDefinition.INT, distance));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user