The outside hooks for AVMSyncService are in place and the implementation

of the simplest method, resetLayer is done.
Also fixed goofy merge induced bug in DbNodeServiceImpl.
Can we make merging a punishment for naughty Alfrescans?


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3778 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-09-13 05:45:24 +00:00
parent d5294a4879
commit a06fc74aef
10 changed files with 329 additions and 27 deletions

View File

@@ -34,9 +34,7 @@ import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.apache.log4j.Logger;
import org.springframework.context.support.FileSystemXmlApplicationContext;
/**
@@ -45,8 +43,6 @@ import org.springframework.context.support.FileSystemXmlApplicationContext;
*/
public class AVMInterpreter
{
private static Logger fgLogger = Logger.getLogger(AVMInterpreter.class);
/**
* The service interface.
*/

View File

@@ -2516,4 +2516,29 @@ public class AVMServiceTest extends AVMServiceTestBase
fail();
}
}
/**
* Test AVMSyncService resetLayer.
*/
public void testResetLayer()
{
try
{
setupBasicTree();
fService.createLayeredDirectory("main:/a", "main:/", "layer");
fService.createFile("main:/layer", "figs").close();
assertFalse(recursiveContents("main:/a", -1, true).equals(
recursiveContents("main:/layer", -1, true)));
System.out.println(recursiveList("main", -1, true));
fSyncService.resetLayer("main:/layer");
assertEquals(recursiveContents("main:/a", -1, true),
recursiveContents("main:/layer", -1, true));
System.out.println(recursiveList("main", -1, true));
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
}

View File

@@ -27,6 +27,7 @@ import java.util.TreeMap;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import junit.framework.TestCase;
@@ -47,6 +48,10 @@ public class AVMServiceTestBase extends TestCase
*/
protected static OrphanReaper fReaper;
/**
* The AVMSyncService.
*/
protected static AVMSyncService fSyncService;
/**
* The application context.
*/
@@ -70,6 +75,7 @@ public class AVMServiceTestBase extends TestCase
fContext = new FileSystemXmlApplicationContext("config/alfresco/avm-test-context.xml");
fService = (AVMService)fContext.getBean("AVMService");
fReaper = (OrphanReaper)fContext.getBean("orphanReaper");
fSyncService = (AVMSyncService)fContext.getBean("AVMSyncService");
}
fService.createAVMStore("main");
fStartTime = System.currentTimeMillis();

View File

@@ -0,0 +1,121 @@
/*
* Copyright (C) 2006 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.avm;
import java.util.List;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
/**
* This implements APIs that allow comparison and synchronization
* of node trees as well as cumulative operations on layers to
* support various content production models.
* @author britt
*/
public class AVMSyncServiceImpl implements AVMSyncService
{
/**
* The AVMService.
*/
private AVMService fAVMService;
/**
* Do nothing constructor.
*/
public AVMSyncServiceImpl()
{
}
/**
* Set the AVM Service. For Spring. For now, at least,
* it's important to wire this using the unintercepted AVMServiceImpl,
* as AVMServiceImpl uses Runtime Exceptions for handling valid states
* that should not cause rollbacks.
* @param avmService The AVMService reference.
*/
public void setAvmService(AVMService avmService)
{
fAVMService = avmService;
}
/**
* Get a difference list between two corresponding node trees.
* @param srcVersion The version id for the source tree.
* @param srcPath The avm path to the source tree.
* @param dstVersion The version id for the destination tree.
* @param dstPath The avm path to the destination tree.
* @return A List of AVMDifference structs which can be used for
* the update operation.
*/
public List<AVMDifference> compare(int srcVersion, String srcPath,
int dstVersion, String dstPath)
{
// TODO Implement.
return null;
}
/**
* Updates the destination nodes in the AVMDifferences
* with the source nodes. Normally any conflicts or cases in
* which the source of an AVMDifference is older than the destination
* will cause the transaction to roll back.
* @param diffList A List of AVMDifference structs.
* @param ignoreConflicts If this is true the update will skip those
* AVMDifferences which are in conflict or for which the source is older than
* the destination.
* @param overrideConflicts If this is true the update will override conflicting
* AVMDifferences and replace the destination with the conflicting source.
* @param overrideOlder If this is true the update will override AVMDifferences
* in which the source is older than the destination and overwrite the destination.
*/
public void update(List<AVMDifference> diffList, boolean ignoreConflicts,
boolean overrideConflicts, boolean overrideOlder)
{
// TODO Implement.
}
/**
* Flattens a layer so that all all nodes under and including
* <code>layerPath</code> become translucent to any nodes in the
* corresponding location under and including <code>underlyingPath</code>
* that are the same version.
* @param layerPath The overlying layer path.
* @param underlyingPath The underlying path.
*/
public void flatten(String layerPath, String underlyingPath)
{
// TODO Implement.
}
/**
* Takes a layer, deletes it and recreates it pointing at the same underlying
* node. Any changes in the layer are lost (except to history if the layer has been
* snapshotted.)
* @param layerPath
*/
public void resetLayer(String layerPath)
{
AVMNodeDescriptor desc = fAVMService.lookup(-1, layerPath);
String [] parts = AVMNodeConverter.SplitBase(layerPath);
fAVMService.removeNode(parts[0], parts[1]);
fAVMService.createLayeredDirectory(desc.getIndirection(), parts[0], parts[1]);
}
}

View File

@@ -83,7 +83,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
private static Log logger = LogFactory.getLog(DbNodeServiceImpl.class);
private static Log loggerPaths = LogFactory.getLog(DbNodeServiceImpl.class.getName() + ".paths");
private DictionaryService dictionaryService;
private NodeDaoService nodeDaoService;
private StoreArchiveMap storeArchiveMap;
private NodeService avmNodeService;
@@ -93,11 +92,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
storeArchiveMap = new StoreArchiveMap(); // in case it is not set
}
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
public void setNodeDaoService(NodeDaoService nodeDaoService)
{
this.nodeDaoService = nodeDaoService;

View File

@@ -27,6 +27,7 @@ import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.audit.AuditService;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.lock.LockService;
@@ -341,4 +342,13 @@ public class ServiceDescriptorRegistry
{
return (AVMService)getService(AVM_SERVICE);
}
/**
* Get the AVM Sync Service.
* @return The AVM Sync Service.
*/
public AVMSyncService getAVMSyncService()
{
return (AVMSyncService)getService(AVM_SYNC_SERVICE);
}
}