Provided a getLatestSnapshotID() for AVMService. It returns the latest extant version of

a store.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4364 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park 2006-11-15 15:30:50 +00:00
parent 95c8647031
commit 2cab072bc1
6 changed files with 57 additions and 1 deletions

View File

@ -965,6 +965,20 @@ public class AVMRepository
return store.getNextVersionID(); return store.getNextVersionID();
} }
/**
* Get the latest extant snapshotted version id.
* @param name The store name.
*/
public int getLatestSnapshotID(String name)
{
AVMStore store = getAVMStoreByName(name);
if (store == null)
{
throw new AVMNotFoundException("Store not found.");
}
return store.getLastVersionID();
}
/** /**
* Get an AVMStore by name. * Get an AVMStore by name.
* @param name The name of the AVMStore. * @param name The name of the AVMStore.

View File

@ -453,6 +453,21 @@ public class AVMServiceImpl implements AVMService
return fAVMRepository.getLatestVersionID(repName); return fAVMRepository.getLatestVersionID(repName);
} }
/**
* Get the latest snapshot id of a store.
* @param storeName The store name.
* @return The id of the latest extant version of the store.
* @throws AVMNotFoundException If <code>storeName</code> does not exist.
*/
public int getLatestSnapshotID(String storeName)
{
if (storeName == null)
{
throw new AVMBadArgumentException("Illegal null argument.");
}
return fAVMRepository.getLatestSnapshotID(storeName);
}
/** /**
* Create snapshots of a group of AVMStores. * Create snapshots of a group of AVMStores.
* @param stores A List of AVMStore names. * @param stores A List of AVMStore names.

View File

@ -254,7 +254,7 @@ public class AVMServiceTest extends AVMServiceTestBase
VersionPathStuffer stuffer = new VersionPathStuffer(); VersionPathStuffer stuffer = new VersionPathStuffer();
stuffer.add(-1, "area:/a/b"); stuffer.add(-1, "area:/a/b");
String nodeList = stuffer.toString(); String nodeList = stuffer.toString();
action.setParameterValue(AVMRevertListAction.PARAM_VERSION, 1); action.setParameterValue(AVMRevertListAction.PARAM_VERSION, fService.getLatestSnapshotID("area"));
action.setParameterValue(AVMRevertListAction.PARAM_NODE_LIST, nodeList); action.setParameterValue(AVMRevertListAction.PARAM_NODE_LIST, nodeList);
action.setParameterValue(AVMRevertListAction.PARAM_FLATTEN, true); action.setParameterValue(AVMRevertListAction.PARAM_FLATTEN, true);
action.setParameterValue(AVMRevertListAction.PARAM_STORE, "area"); action.setParameterValue(AVMRevertListAction.PARAM_STORE, "area");
@ -273,6 +273,8 @@ public class AVMServiceTest extends AVMServiceTestBase
new TxnWork()); new TxnWork());
diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a"); diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a");
assertEquals(0, diffs.size()); assertEquals(0, diffs.size());
System.out.println(recursiveList("area", -1, true));
System.out.println(recursiveList("main", -1, true));
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -44,6 +44,11 @@ public interface AVMStore
* @return The next version to be snapshotted. * @return The next version to be snapshotted.
*/ */
public int getNextVersionID(); public int getNextVersionID();
/**
* This gets the last extant version id.
*/
public int getLastVersionID();
/** /**
* Set a new root for this store. * Set a new root for this store.

View File

@ -609,6 +609,10 @@ public class AVMStoreImpl implements AVMStore, Serializable
{ {
dir = AVMDAOs.Instance().fAVMNodeDAO.getAVMStoreRoot(this, version); dir = AVMDAOs.Instance().fAVMNodeDAO.getAVMStoreRoot(this, version);
} }
if (dir == null)
{
return null;
}
// Add an entry for the root. // Add an entry for the root.
result.add(dir, "", write); result.add(dir, "", write);
dir = (DirectoryNode)result.getCurrentNode(); dir = (DirectoryNode)result.getCurrentNode();
@ -796,6 +800,14 @@ public class AVMStoreImpl implements AVMStore, Serializable
return fNextVersionID; return fNextVersionID;
} }
/**
* This gets the last extant version id.
*/
public int getLastVersionID()
{
return AVMDAOs.Instance().fVersionRootDAO.getMaxVersionID(this);
}
/** /**
* Set the root directory. Hibernate. * Set the root directory. Hibernate.
* @param root * @param root

View File

@ -303,6 +303,14 @@ public interface AVMService
*/ */
public int getLatestVersionID(String storeName); public int getLatestVersionID(String storeName);
/**
* Get the latest snapshot id of a store.
* @param storeName The store name.
* @return The id of the latest extant version of the store.
* @throws AVMNotFoundException If <code>storeName</code> does not exist.
*/
public int getLatestSnapshotID(String storeName);
/** /**
* Snapshot the given AVMStores. When this is called everything that has been added, * Snapshot the given AVMStores. When this is called everything that has been added,
* deleted, or modified since the last time this function was called, is marked * deleted, or modified since the last time this function was called, is marked