mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-23 18:05:32 +00:00
Fixed createBranch() so that layered node lookups behave properly.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5579 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
7567867be1
commit
f91cedfd69
@ -214,6 +214,24 @@
|
|||||||
<property name="purgeVersionTxnListener">
|
<property name="purgeVersionTxnListener">
|
||||||
<ref bean="purgeVersionTxnListener"/>
|
<ref bean="purgeVersionTxnListener"/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="avmStoreDAO">
|
||||||
|
<ref bean="avmStoreDAO"/>
|
||||||
|
</property>
|
||||||
|
<property name="avmNodeDAO">
|
||||||
|
<ref bean="avmNodeDAO"/>
|
||||||
|
</property>
|
||||||
|
<property name="versionRootDAO">
|
||||||
|
<ref bean="versionRootDAO"/>
|
||||||
|
</property>
|
||||||
|
<property name="versionLayeredNodeEntryDAO">
|
||||||
|
<ref bean="versionLayeredNodeEntryDAO"/>
|
||||||
|
</property>
|
||||||
|
<property name="avmStorePropertyDAO">
|
||||||
|
<ref bean="avmStorePropertyDAO"/>
|
||||||
|
</property>
|
||||||
|
<property name="childEntryDAO">
|
||||||
|
<ref bean="childEntryDAO"/>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- A Local implementation of the Remote AVM interface. -->
|
<!-- A Local implementation of the Remote AVM interface. -->
|
||||||
|
@ -141,4 +141,16 @@ public class AVMNodeConverter
|
|||||||
decomposed[1] = path.substring(off + 1);
|
decomposed[1] = path.substring(off + 1);
|
||||||
return decomposed;
|
return decomposed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize an AVM path.
|
||||||
|
* @param path The incoming path.
|
||||||
|
* @return The normalized path.
|
||||||
|
*/
|
||||||
|
public static String NormalizePath(String path)
|
||||||
|
{
|
||||||
|
path = path.replaceAll("/+", "/");
|
||||||
|
path = path.replaceAll("/$", "");
|
||||||
|
return path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,18 @@ public class AVMRepository
|
|||||||
*/
|
*/
|
||||||
private LookupCache fLookupCache;
|
private LookupCache fLookupCache;
|
||||||
|
|
||||||
|
private AVMStoreDAO fAVMStoreDAO;
|
||||||
|
|
||||||
|
private AVMNodeDAO fAVMNodeDAO;
|
||||||
|
|
||||||
|
private VersionRootDAO fVersionRootDAO;
|
||||||
|
|
||||||
|
private VersionLayeredNodeEntryDAO fVersionLayeredNodeEntryDAO;
|
||||||
|
|
||||||
|
private AVMStorePropertyDAO fAVMStorePropertyDAO;
|
||||||
|
|
||||||
|
private ChildEntryDAO fChildEntryDAO;
|
||||||
|
|
||||||
// A bunch of TransactionListeners that do work for this.
|
// A bunch of TransactionListeners that do work for this.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -180,6 +192,36 @@ public class AVMRepository
|
|||||||
fPurgeVersionTxnListener = listener;
|
fPurgeVersionTxnListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAvmStoreDAO(AVMStoreDAO dao)
|
||||||
|
{
|
||||||
|
fAVMStoreDAO = dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvmNodeDAO(AVMNodeDAO dao)
|
||||||
|
{
|
||||||
|
fAVMNodeDAO = dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersionRootDAO(VersionRootDAO dao)
|
||||||
|
{
|
||||||
|
fVersionRootDAO = dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersionLayeredNodeEntryDAO(VersionLayeredNodeEntryDAO dao)
|
||||||
|
{
|
||||||
|
fVersionLayeredNodeEntryDAO = dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvmStorePropertyDAO(AVMStorePropertyDAO dao)
|
||||||
|
{
|
||||||
|
fAVMStorePropertyDAO = dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildEntryDAO(ChildEntryDAO dao)
|
||||||
|
{
|
||||||
|
fChildEntryDAO = dao;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a file.
|
* Create a file.
|
||||||
* @param path The path to the containing directory.
|
* @param path The path to the containing directory.
|
||||||
@ -265,7 +307,7 @@ public class AVMRepository
|
|||||||
*/
|
*/
|
||||||
public AVMNodeDescriptor createDirectory(AVMNodeDescriptor parent, String name)
|
public AVMNodeDescriptor createDirectory(AVMNodeDescriptor parent, String name)
|
||||||
{
|
{
|
||||||
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(parent.getId());
|
AVMNode node = fAVMNodeDAO.getByID(parent.getId());
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
throw new AVMNotFoundException(parent.getId() + " not found.");
|
throw new AVMNotFoundException(parent.getId() + " not found.");
|
||||||
@ -391,6 +433,7 @@ public class AVMRepository
|
|||||||
fLookupCount.set(1);
|
fLookupCount.set(1);
|
||||||
String [] pathParts;
|
String [] pathParts;
|
||||||
Lookup sPath;
|
Lookup sPath;
|
||||||
|
List<VersionLayeredNodeEntry> layeredEntries = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pathParts = SplitPath(srcPath);
|
pathParts = SplitPath(srcPath);
|
||||||
@ -409,6 +452,8 @@ public class AVMRepository
|
|||||||
{
|
{
|
||||||
throw new AVMNotFoundException("Path not found.");
|
throw new AVMNotFoundException("Path not found.");
|
||||||
}
|
}
|
||||||
|
VersionRoot lastVersion = fVersionRootDAO.getByVersionID(srcRepo, version);
|
||||||
|
layeredEntries = fVersionLayeredNodeEntryDAO.get(lastVersion);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -458,6 +503,22 @@ public class AVMRepository
|
|||||||
dstNode.setAncestor(srcNode);
|
dstNode.setAncestor(srcNode);
|
||||||
dirNode.putChild(name, dstNode);
|
dirNode.putChild(name, dstNode);
|
||||||
dirNode.updateModTime();
|
dirNode.updateModTime();
|
||||||
|
String beginingPath = AVMNodeConverter.NormalizePath(srcPath);
|
||||||
|
String finalPath = AVMNodeConverter.ExtendAVMPath(dstPath, name);
|
||||||
|
finalPath = AVMNodeConverter.NormalizePath(finalPath);
|
||||||
|
VersionRoot latestVersion = fVersionRootDAO.getMaxVersion(dstRepo);
|
||||||
|
for (VersionLayeredNodeEntry entry : layeredEntries)
|
||||||
|
{
|
||||||
|
String path = entry.getPath();
|
||||||
|
if (!path.startsWith(srcPath))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String newPath = finalPath + path.substring(beginingPath.length());
|
||||||
|
VersionLayeredNodeEntry newEntry =
|
||||||
|
new VersionLayeredNodeEntryImpl(latestVersion, newPath);
|
||||||
|
fVersionLayeredNodeEntryDAO.save(newEntry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -639,8 +700,6 @@ public class AVMRepository
|
|||||||
}
|
}
|
||||||
else if (srcNode.getType() == AVMNodeType.LAYERED_DIRECTORY)
|
else if (srcNode.getType() == AVMNodeType.LAYERED_DIRECTORY)
|
||||||
{
|
{
|
||||||
// TODO I think I need to subdivide this logic again.
|
|
||||||
// based on whether the destination is a layer or not.
|
|
||||||
if (!sPath.isLayered() || (sPath.isInThisLayer() &&
|
if (!sPath.isLayered() || (sPath.isInThisLayer() &&
|
||||||
srcDir.getType() == AVMNodeType.LAYERED_DIRECTORY &&
|
srcDir.getType() == AVMNodeType.LAYERED_DIRECTORY &&
|
||||||
((LayeredDirectoryNode)srcDir).directlyContains(srcNode)))
|
((LayeredDirectoryNode)srcDir).directlyContains(srcNode)))
|
||||||
@ -795,23 +854,22 @@ public class AVMRepository
|
|||||||
fLookupCache.onDelete(name);
|
fLookupCache.onDelete(name);
|
||||||
AVMNode root = store.getRoot();
|
AVMNode root = store.getRoot();
|
||||||
root.setIsRoot(false);
|
root.setIsRoot(false);
|
||||||
VersionRootDAO vrDAO = AVMDAOs.Instance().fVersionRootDAO;
|
List<VersionRoot> vRoots = fVersionRootDAO.getAllInAVMStore(store);
|
||||||
List<VersionRoot> vRoots = vrDAO.getAllInAVMStore(store);
|
|
||||||
for (VersionRoot vr : vRoots)
|
for (VersionRoot vr : vRoots)
|
||||||
{
|
{
|
||||||
AVMNode node = vr.getRoot();
|
AVMNode node = vr.getRoot();
|
||||||
node.setIsRoot(false);
|
node.setIsRoot(false);
|
||||||
AVMDAOs.Instance().fVersionLayeredNodeEntryDAO.delete(vr);
|
fVersionLayeredNodeEntryDAO.delete(vr);
|
||||||
vrDAO.delete(vr);
|
fVersionRootDAO.delete(vr);
|
||||||
}
|
}
|
||||||
List<AVMNode> newGuys = AVMDAOs.Instance().fAVMNodeDAO.getNewInStore(store);
|
List<AVMNode> newGuys = fAVMNodeDAO.getNewInStore(store);
|
||||||
for (AVMNode newGuy : newGuys)
|
for (AVMNode newGuy : newGuys)
|
||||||
{
|
{
|
||||||
newGuy.setStoreNew(null);
|
newGuy.setStoreNew(null);
|
||||||
}
|
}
|
||||||
AVMDAOs.Instance().fAVMStorePropertyDAO.delete(store);
|
fAVMStorePropertyDAO.delete(store);
|
||||||
AVMDAOs.Instance().fAVMStoreDAO.delete(store);
|
fAVMStoreDAO.delete(store);
|
||||||
AVMDAOs.Instance().fAVMStoreDAO.invalidateCache();
|
fAVMStoreDAO.invalidateCache();
|
||||||
fPurgeStoreTxnListener.storePurged(name);
|
fPurgeStoreTxnListener.storePurged(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -860,7 +918,7 @@ public class AVMRepository
|
|||||||
|
|
||||||
public InputStream getInputStream(AVMNodeDescriptor desc)
|
public InputStream getInputStream(AVMNodeDescriptor desc)
|
||||||
{
|
{
|
||||||
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(desc.getId());
|
AVMNode node = fAVMNodeDAO.getByID(desc.getId());
|
||||||
if (!(node instanceof FileNode))
|
if (!(node instanceof FileNode))
|
||||||
{
|
{
|
||||||
throw new AVMWrongTypeException(desc + " is not a File.");
|
throw new AVMWrongTypeException(desc + " is not a File.");
|
||||||
@ -937,7 +995,7 @@ public class AVMRepository
|
|||||||
public SortedMap<String, AVMNodeDescriptor>
|
public SortedMap<String, AVMNodeDescriptor>
|
||||||
getListingDirect(AVMNodeDescriptor dir, boolean includeDeleted)
|
getListingDirect(AVMNodeDescriptor dir, boolean includeDeleted)
|
||||||
{
|
{
|
||||||
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(dir.getId());
|
AVMNode node = fAVMNodeDAO.getByID(dir.getId());
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
throw new AVMBadArgumentException("Invalid Node.");
|
throw new AVMBadArgumentException("Invalid Node.");
|
||||||
@ -964,7 +1022,7 @@ public class AVMRepository
|
|||||||
fLookupCount.set(1);
|
fLookupCount.set(1);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(dir.getId());
|
AVMNode node = fAVMNodeDAO.getByID(dir.getId());
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
throw new AVMBadArgumentException("Invalid Node.");
|
throw new AVMBadArgumentException("Invalid Node.");
|
||||||
@ -1015,7 +1073,7 @@ public class AVMRepository
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public List<AVMStoreDescriptor> getAVMStores()
|
public List<AVMStoreDescriptor> getAVMStores()
|
||||||
{
|
{
|
||||||
List<AVMStore> l = AVMDAOs.Instance().fAVMStoreDAO.getAll();
|
List<AVMStore> l = fAVMStoreDAO.getAll();
|
||||||
List<AVMStoreDescriptor> result = new ArrayList<AVMStoreDescriptor>();
|
List<AVMStoreDescriptor> result = new ArrayList<AVMStoreDescriptor>();
|
||||||
for (AVMStore store : l)
|
for (AVMStore store : l)
|
||||||
{
|
{
|
||||||
@ -1151,7 +1209,7 @@ public class AVMRepository
|
|||||||
*/
|
*/
|
||||||
private AVMStore getAVMStoreByName(String name)
|
private AVMStore getAVMStoreByName(String name)
|
||||||
{
|
{
|
||||||
AVMStore store = AVMDAOs.Instance().fAVMStoreDAO.getByName(name);
|
AVMStore store = fAVMStoreDAO.getByName(name);
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1213,7 +1271,6 @@ public class AVMRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO This should really return null for not found.
|
|
||||||
/**
|
/**
|
||||||
* Lookup a descriptor from a directory descriptor.
|
* Lookup a descriptor from a directory descriptor.
|
||||||
* @param dir The directory descriptor.
|
* @param dir The directory descriptor.
|
||||||
@ -1225,7 +1282,7 @@ public class AVMRepository
|
|||||||
fLookupCount.set(1);
|
fLookupCount.set(1);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(dir.getId());
|
AVMNode node = fAVMNodeDAO.getByID(dir.getId());
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
throw new AVMNotFoundException("Not found: " + dir.getId());
|
throw new AVMNotFoundException("Not found: " + dir.getId());
|
||||||
@ -1251,7 +1308,7 @@ public class AVMRepository
|
|||||||
*/
|
*/
|
||||||
public List<Pair<Integer, String>> getPaths(AVMNodeDescriptor desc)
|
public List<Pair<Integer, String>> getPaths(AVMNodeDescriptor desc)
|
||||||
{
|
{
|
||||||
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(desc.getId());
|
AVMNode node = fAVMNodeDAO.getByID(desc.getId());
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
throw new AVMNotFoundException("Not found: " + desc.getPath());
|
throw new AVMNotFoundException("Not found: " + desc.getPath());
|
||||||
@ -1269,7 +1326,7 @@ public class AVMRepository
|
|||||||
*/
|
*/
|
||||||
public Pair<Integer, String> getAPath(AVMNodeDescriptor desc)
|
public Pair<Integer, String> getAPath(AVMNodeDescriptor desc)
|
||||||
{
|
{
|
||||||
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(desc.getId());
|
AVMNode node = fAVMNodeDAO.getByID(desc.getId());
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
throw new AVMNotFoundException("Could not find node: " + desc);
|
throw new AVMNotFoundException("Could not find node: " + desc);
|
||||||
@ -1285,7 +1342,7 @@ public class AVMRepository
|
|||||||
*/
|
*/
|
||||||
public List<Pair<Integer, String>> getHeadPaths(AVMNodeDescriptor desc)
|
public List<Pair<Integer, String>> getHeadPaths(AVMNodeDescriptor desc)
|
||||||
{
|
{
|
||||||
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(desc.getId());
|
AVMNode node = fAVMNodeDAO.getByID(desc.getId());
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
throw new AVMNotFoundException("Not found: " + desc.getPath());
|
throw new AVMNotFoundException("Not found: " + desc.getPath());
|
||||||
@ -1325,7 +1382,7 @@ public class AVMRepository
|
|||||||
paths.add(this.makePath(components, storeName));
|
paths.add(this.makePath(components, storeName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<ChildEntry> entries = AVMDAOs.Instance().fChildEntryDAO.getByChild(node);
|
List<ChildEntry> entries = fChildEntryDAO.getByChild(node);
|
||||||
for (ChildEntry entry : entries)
|
for (ChildEntry entry : entries)
|
||||||
{
|
{
|
||||||
String name = entry.getKey().getName();
|
String name = entry.getKey().getName();
|
||||||
@ -1350,7 +1407,7 @@ public class AVMRepository
|
|||||||
{
|
{
|
||||||
throw new AVMNotFoundException("Store not found: " + store);
|
throw new AVMNotFoundException("Store not found: " + store);
|
||||||
}
|
}
|
||||||
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(desc.getId());
|
AVMNode node = fAVMNodeDAO.getByID(desc.getId());
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
throw new AVMNotFoundException("Not found: " + desc.getPath());
|
throw new AVMNotFoundException("Not found: " + desc.getPath());
|
||||||
@ -1372,20 +1429,20 @@ public class AVMRepository
|
|||||||
{
|
{
|
||||||
if (node.getIsRoot())
|
if (node.getIsRoot())
|
||||||
{
|
{
|
||||||
AVMStore store = AVMDAOs.Instance().fAVMStoreDAO.getByRoot(node);
|
AVMStore store = fAVMStoreDAO.getByRoot(node);
|
||||||
if (store != null)
|
if (store != null)
|
||||||
{
|
{
|
||||||
addPath(components, -1, store.getName(), paths);
|
addPath(components, -1, store.getName(), paths);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
VersionRoot vr = AVMDAOs.Instance().fVersionRootDAO.getByRoot(node);
|
VersionRoot vr = fVersionRootDAO.getByRoot(node);
|
||||||
if (vr != null)
|
if (vr != null)
|
||||||
{
|
{
|
||||||
addPath(components, vr.getVersionID(), vr.getAvmStore().getName(), paths);
|
addPath(components, vr.getVersionID(), vr.getAvmStore().getName(), paths);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<ChildEntry> entries = AVMDAOs.Instance().fChildEntryDAO.getByChild(node);
|
List<ChildEntry> entries = fChildEntryDAO.getByChild(node);
|
||||||
for (ChildEntry entry : entries)
|
for (ChildEntry entry : entries)
|
||||||
{
|
{
|
||||||
String name = entry.getKey().getName();
|
String name = entry.getKey().getName();
|
||||||
@ -1406,19 +1463,19 @@ public class AVMRepository
|
|||||||
{
|
{
|
||||||
if (node.getIsRoot())
|
if (node.getIsRoot())
|
||||||
{
|
{
|
||||||
AVMStore store = AVMDAOs.Instance().fAVMStoreDAO.getByRoot(node);
|
AVMStore store = fAVMStoreDAO.getByRoot(node);
|
||||||
if (store != null)
|
if (store != null)
|
||||||
{
|
{
|
||||||
return new Pair<Integer, String>(-1, makePath(components, store.getName()));
|
return new Pair<Integer, String>(-1, makePath(components, store.getName()));
|
||||||
}
|
}
|
||||||
VersionRoot vr = AVMDAOs.Instance().fVersionRootDAO.getByRoot(node);
|
VersionRoot vr = fVersionRootDAO.getByRoot(node);
|
||||||
if (vr != null)
|
if (vr != null)
|
||||||
{
|
{
|
||||||
return new Pair<Integer, String>(vr.getVersionID(), makePath(components, vr.getAvmStore().getName()));
|
return new Pair<Integer, String>(vr.getVersionID(), makePath(components, vr.getAvmStore().getName()));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<ChildEntry> entries = AVMDAOs.Instance().fChildEntryDAO.getByChild(node);
|
List<ChildEntry> entries = fChildEntryDAO.getByChild(node);
|
||||||
for (ChildEntry entry : entries)
|
for (ChildEntry entry : entries)
|
||||||
{
|
{
|
||||||
String name = entry.getKey().getName();
|
String name = entry.getKey().getName();
|
||||||
@ -1444,7 +1501,7 @@ public class AVMRepository
|
|||||||
{
|
{
|
||||||
if (node.getIsRoot())
|
if (node.getIsRoot())
|
||||||
{
|
{
|
||||||
AVMStore store = AVMDAOs.Instance().fAVMStoreDAO.getByRoot(node);
|
AVMStore store = fAVMStoreDAO.getByRoot(node);
|
||||||
if (store != null)
|
if (store != null)
|
||||||
{
|
{
|
||||||
addPath(components, -1, store.getName(), paths);
|
addPath(components, -1, store.getName(), paths);
|
||||||
@ -1452,7 +1509,7 @@ public class AVMRepository
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<ChildEntry> entries = AVMDAOs.Instance().fChildEntryDAO.getByChild(node);
|
List<ChildEntry> entries = fChildEntryDAO.getByChild(node);
|
||||||
for (ChildEntry entry : entries)
|
for (ChildEntry entry : entries)
|
||||||
{
|
{
|
||||||
String name = entry.getKey().getName();
|
String name = entry.getKey().getName();
|
||||||
@ -1478,7 +1535,7 @@ public class AVMRepository
|
|||||||
addPath(components, -1, storeName, paths);
|
addPath(components, -1, storeName, paths);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<ChildEntry> entries = AVMDAOs.Instance().fChildEntryDAO.getByChild(node);
|
List<ChildEntry> entries = fChildEntryDAO.getByChild(node);
|
||||||
for (ChildEntry entry : entries)
|
for (ChildEntry entry : entries)
|
||||||
{
|
{
|
||||||
String name = entry.getKey().getName();
|
String name = entry.getKey().getName();
|
||||||
@ -1652,7 +1709,7 @@ public class AVMRepository
|
|||||||
*/
|
*/
|
||||||
public List<AVMNodeDescriptor> getHistory(AVMNodeDescriptor desc, int count)
|
public List<AVMNodeDescriptor> getHistory(AVMNodeDescriptor desc, int count)
|
||||||
{
|
{
|
||||||
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(desc.getId());
|
AVMNode node = fAVMNodeDAO.getByID(desc.getId());
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
throw new AVMNotFoundException("Not found.");
|
throw new AVMNotFoundException("Not found.");
|
||||||
@ -1916,7 +1973,7 @@ public class AVMRepository
|
|||||||
throw new AVMNotFoundException("Store not found.");
|
throw new AVMNotFoundException("Store not found.");
|
||||||
}
|
}
|
||||||
List<AVMStoreProperty> matches =
|
List<AVMStoreProperty> matches =
|
||||||
AVMDAOs.Instance().fAVMStorePropertyDAO.queryByKeyPattern(st,
|
fAVMStorePropertyDAO.queryByKeyPattern(st,
|
||||||
keyPattern);
|
keyPattern);
|
||||||
Map<QName, PropertyValue> results = new HashMap<QName, PropertyValue>();
|
Map<QName, PropertyValue> results = new HashMap<QName, PropertyValue>();
|
||||||
for (AVMStoreProperty prop : matches)
|
for (AVMStoreProperty prop : matches)
|
||||||
@ -1935,7 +1992,7 @@ public class AVMRepository
|
|||||||
queryStoresPropertyKeys(QName keyPattern)
|
queryStoresPropertyKeys(QName keyPattern)
|
||||||
{
|
{
|
||||||
List<AVMStoreProperty> matches =
|
List<AVMStoreProperty> matches =
|
||||||
AVMDAOs.Instance().fAVMStorePropertyDAO.queryByKeyPattern(keyPattern);
|
fAVMStorePropertyDAO.queryByKeyPattern(keyPattern);
|
||||||
Map<String, Map<QName, PropertyValue>> results =
|
Map<String, Map<QName, PropertyValue>> results =
|
||||||
new HashMap<String, Map<QName, PropertyValue>>();
|
new HashMap<String, Map<QName, PropertyValue>>();
|
||||||
for (AVMStoreProperty prop : matches)
|
for (AVMStoreProperty prop : matches)
|
||||||
@ -2001,8 +2058,8 @@ public class AVMRepository
|
|||||||
public AVMNodeDescriptor getCommonAncestor(AVMNodeDescriptor left,
|
public AVMNodeDescriptor getCommonAncestor(AVMNodeDescriptor left,
|
||||||
AVMNodeDescriptor right)
|
AVMNodeDescriptor right)
|
||||||
{
|
{
|
||||||
AVMNode lNode = AVMDAOs.Instance().fAVMNodeDAO.getByID(left.getId());
|
AVMNode lNode = fAVMNodeDAO.getByID(left.getId());
|
||||||
AVMNode rNode = AVMDAOs.Instance().fAVMNodeDAO.getByID(right.getId());
|
AVMNode rNode = fAVMNodeDAO.getByID(right.getId());
|
||||||
if (lNode == null || rNode == null)
|
if (lNode == null || rNode == null)
|
||||||
{
|
{
|
||||||
throw new AVMNotFoundException("Node not found.");
|
throw new AVMNotFoundException("Node not found.");
|
||||||
@ -2143,7 +2200,7 @@ public class AVMRepository
|
|||||||
{
|
{
|
||||||
throw new AVMNotFoundException("Store not found: " + pathParts[0]);
|
throw new AVMNotFoundException("Store not found: " + pathParts[0]);
|
||||||
}
|
}
|
||||||
AVMNode fromNode = AVMDAOs.Instance().fAVMNodeDAO.getByID(from.getId());
|
AVMNode fromNode = fAVMNodeDAO.getByID(from.getId());
|
||||||
if (fromNode == null)
|
if (fromNode == null)
|
||||||
{
|
{
|
||||||
throw new AVMNotFoundException("Node not found: " + from.getPath());
|
throw new AVMNotFoundException("Node not found: " + from.getPath());
|
||||||
@ -2344,7 +2401,7 @@ public class AVMRepository
|
|||||||
*/
|
*/
|
||||||
public void link(AVMNodeDescriptor parent, String name, AVMNodeDescriptor child)
|
public void link(AVMNodeDescriptor parent, String name, AVMNodeDescriptor child)
|
||||||
{
|
{
|
||||||
AVMNode node = AVMDAOs.Instance().fAVMNodeDAO.getByID(parent.getId());
|
AVMNode node = fAVMNodeDAO.getByID(parent.getId());
|
||||||
if (!(node instanceof DirectoryNode))
|
if (!(node instanceof DirectoryNode))
|
||||||
{
|
{
|
||||||
throw new AVMWrongTypeException("Not a Directory.");
|
throw new AVMWrongTypeException("Not a Directory.");
|
||||||
@ -2387,7 +2444,7 @@ public class AVMRepository
|
|||||||
}
|
}
|
||||||
LayeredDirectoryNode dir = (LayeredDirectoryNode)node;
|
LayeredDirectoryNode dir = (LayeredDirectoryNode)node;
|
||||||
dir.flatten(name);
|
dir.flatten(name);
|
||||||
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
fAVMNodeDAO.flush();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -2452,7 +2509,7 @@ public class AVMRepository
|
|||||||
}
|
}
|
||||||
store.setName(destName);
|
store.setName(destName);
|
||||||
fLookupCache.onDelete(sourceName);
|
fLookupCache.onDelete(sourceName);
|
||||||
AVMDAOs.Instance().fAVMStoreDAO.invalidateCache();
|
fAVMStoreDAO.invalidateCache();
|
||||||
fPurgeStoreTxnListener.storePurged(sourceName);
|
fPurgeStoreTxnListener.storePurged(sourceName);
|
||||||
fCreateStoreTxnListener.storeCreated(destName);
|
fCreateStoreTxnListener.storeCreated(destName);
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,34 @@ import org.alfresco.util.Pair;
|
|||||||
*/
|
*/
|
||||||
public class AVMServiceTest extends AVMServiceTestBase
|
public class AVMServiceTest extends AVMServiceTestBase
|
||||||
{
|
{
|
||||||
|
public void testBranchLayerSnapshot()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
setupBasicTree();
|
||||||
|
fService.createStore("layer");
|
||||||
|
fService.createDirectory("layer:/", "root");
|
||||||
|
fService.createLayeredDirectory("main:/a", "layer:/root", "layer");
|
||||||
|
fService.createSnapshot("layer", null, null);
|
||||||
|
fService.createFile("main:/a", "dummy").close();
|
||||||
|
fService.createFile("layer:/root/layer", "pygmy");
|
||||||
|
fService.createSnapshot("layer", null, null);
|
||||||
|
fService.createStore("branch");
|
||||||
|
fService.createBranch(1, "layer:/root", "branch:/", "branch");
|
||||||
|
fService.createSnapshot("branch", null, null);
|
||||||
|
fService.getFileOutputStream("main:/a/b/c/foo").close();
|
||||||
|
assertEquals(fService.lookup(1, "main:/a/b/c/foo").getId(),
|
||||||
|
fService.lookup(1, "branch:/branch/layer/b/c/foo").getId());
|
||||||
|
assertEquals(fService.lookup(-1, "main:/a/b/c/foo").getId(),
|
||||||
|
fService.lookup(-1, "branch:/branch/layer/b/c/foo").getId());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Deployment.
|
* Test Deployment.
|
||||||
*/
|
*/
|
||||||
|
@ -235,7 +235,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
|||||||
}
|
}
|
||||||
parent.putChild(parentName[1], newChild);
|
parent.putChild(parentName[1], newChild);
|
||||||
}
|
}
|
||||||
AVMDAOs.Instance().fVersionLayeredNodeEntryDAO.delete(lastVersion);
|
// AVMDAOs.Instance().fVersionLayeredNodeEntryDAO.delete(lastVersion);
|
||||||
// Clear out the new nodes.
|
// Clear out the new nodes.
|
||||||
List<AVMNode> newInRep = AVMDAOs.Instance().fAVMNodeDAO.getNewInStore(this);
|
List<AVMNode> newInRep = AVMDAOs.Instance().fAVMNodeDAO.getNewInStore(this);
|
||||||
List<AVMNode> layeredNodes = new ArrayList<AVMNode>();
|
List<AVMNode> layeredNodes = new ArrayList<AVMNode>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user