Checkpoint of AVMSyncService support changes. Fix of AVMNodeConverter not liking

trailing '/'s.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3803 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-09-15 14:03:22 +00:00
parent 83b4cdb76d
commit fc2bfb0315
8 changed files with 111 additions and 2 deletions

View File

@@ -44,6 +44,10 @@ public class AVMNodeConverter
{
throw new AVMException("Malformed AVM Path.");
}
while (pathParts[1].endsWith("/") && pathParts[1].length() > 1)
{
pathParts[1] = pathParts[1].substring(0, pathParts[1].length() - 1);
}
StoreRef storeRef = ToStoreRef(pathParts[0]);
String translated = version + pathParts[1];
translated = translated.replaceAll("/+", ";");

View File

@@ -29,6 +29,7 @@ import java.util.SortedMap;
import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMCycleException;
import org.alfresco.service.cmr.avm.AVMException;
import org.alfresco.service.cmr.avm.AVMExistsException;
@@ -515,6 +516,32 @@ public class AVMRepository
return store.getListingDirect(version, pathParts[1], includeDeleted);
}
/**
* Get the list of nodes directly contained in a directory.
* @param dir The descriptor to the directory node.
* @param includeDeleted Whether to include deleted children.
* @return A Map of names to descriptors.
*/
public SortedMap<String, AVMNodeDescriptor>
getListingDirect(AVMNodeDescriptor dir, boolean includeDeleted)
{
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(dir.getId());
if (node == null)
{
throw new AVMBadArgumentException("Invalid Node.");
}
if (node.getType() == AVMNodeType.PLAIN_DIRECTORY)
{
return getListing(dir, includeDeleted);
}
if (node.getType() != AVMNodeType.LAYERED_DIRECTORY)
{
throw new AVMWrongTypeException("Not a directory.");
}
LayeredDirectoryNode dirNode = (LayeredDirectoryNode)node;
return dirNode.getListingDirect(dir, includeDeleted);
}
/**
* Get a directory listing from a directory node descriptor.
* @param dir The directory node descriptor.
@@ -524,6 +551,10 @@ public class AVMRepository
{
fLookupCount.set(1);
AVMNode node = AVMContext.fgInstance.fAVMNodeDAO.getByID(dir.getId());
if (node == null)
{
throw new AVMBadArgumentException("Invalid Node.");
}
if (node.getType() != AVMNodeType.LAYERED_DIRECTORY &&
node.getType() != AVMNodeType.PLAIN_DIRECTORY)
{

View File

@@ -133,6 +133,22 @@ public class AVMServiceImpl implements AVMService
return fAVMRepository.getListing(version, path, includeDeleted);
}
/**
* Get a listing of all the directly contained children of a directory.
* @param dir The directory descriptor.
* @param includeDeleted Whether to include deleted children.
* @return A Map of Strings to descriptors.
*/
public SortedMap<String, AVMNodeDescriptor>
getDirectoryListingDirect(AVMNodeDescriptor dir, boolean includeDeleted)
{
if (dir == null)
{
throw new AVMBadArgumentException("Illegal null descriptor.");
}
return fAVMRepository.getListingDirect(dir, includeDeleted);
}
/**
* Get the listing of nodes contained directly in a directory. This is the
* same as getDirectoryListing for PlainDirectories, but returns only those that
@@ -172,6 +188,7 @@ public class AVMServiceImpl implements AVMService
}
return fAVMRepository.getListingDirect(version, path, includeDeleted);
}
/**
* Get a directory listing from a node descriptor.
* @param dir The directory node descriptor.

View File

@@ -2639,8 +2639,10 @@ public class AVMServiceTest extends AVMServiceTestBase
FileFolderService ffs = (FileFolderService)fContext.getBean("FileFolderService");
AuthenticationComponent ac = (AuthenticationComponent)fContext.getBean("authenticationComponent");
ac.authenticate("admin", "admin".toCharArray());
assertTrue(ffs.create(AVMNodeConverter.ToNodeRef(-1, "main:/a/b/c"),
"banana", ContentModel.TYPE_AVM_PLAIN_CONTENT) != null);
assertTrue(ffs.create(AVMNodeConverter.ToNodeRef(-1, "main:/a/b/c/"),
"banana", ContentModel.TYPE_AVM_PLAIN_CONTENT) != null);
assertTrue(ffs.create(AVMNodeConverter.ToNodeRef(-1, "main://"),
"banana", ContentModel.TYPE_AVM_PLAIN_CONTENT) != null);
assertTrue(ffs.create(AVMNodeConverter.ToNodeRef(-1, "main:/a/b/c"),
"apples", ContentModel.TYPE_AVM_PLAIN_FOLDER) != null);
NodeService ns = (NodeService)fContext.getBean("NodeService");

View File

@@ -81,6 +81,15 @@ public interface DirectoryNode extends AVMNode
*/
public Map<String, AVMNode> getListingDirect(Lookup lPath, boolean includeDeleted);
/**
* Get a listing of nodes directly contained by a directory.
* @param dir The descriptor for the directory.
* @param includeDeleted Whether to include deleted nodes.
* @return A Map of Strings to descriptors.
*/
public SortedMap<String, AVMNodeDescriptor> getListingDirect(AVMNodeDescriptor dir,
boolean includeDeleted);
/**
* Get a listing from a directory specified by an AVMNodeDescriptor.
* @param dir The directory to list.

View File

@@ -364,6 +364,31 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
return listing;
}
/**
* Get the direct contents of this directory.
* @param dir The descriptor that describes us.
* @param includeDeleted Whether to inlude deleted nodes.
* @return A Map of Strings to descriptors.
*/
public SortedMap<String, AVMNodeDescriptor> getListingDirect(AVMNodeDescriptor dir,
boolean includeDeleted)
{
List<ChildEntry> children = AVMContext.fgInstance.fChildEntryDAO.getByParent(this);
SortedMap<String, AVMNodeDescriptor> listing = new TreeMap<String, AVMNodeDescriptor>();
for (ChildEntry child : children)
{
AVMNode childNode = child.getChild();
if (!includeDeleted && childNode.getType() == AVMNodeType.DELETED_NODE)
{
continue;
}
AVMNodeDescriptor childDesc =
childNode.getDescriptor(dir.getPath(), child.getName(), dir.getIndirection());
listing.put(child.getName(), childDesc);
}
return listing;
}
/**
* Get a listing from a directory node descriptor.
* @param dir The directory node descriptor.

View File

@@ -119,6 +119,18 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
{
return getListing(lPath, includeDeleted);
}
/**
* Get a listing of the nodes directly contained by a directory.
* @param dir The node's descriptor.
* @param includeDeleted Whether to include deleted nodes.
* @return A Map of Strings to descriptors.
*/
public SortedMap<String, AVMNodeDescriptor> getListingDirect(AVMNodeDescriptor dir,
boolean includeDeleted)
{
return getListing(dir, includeDeleted);
}
/**
* Get a listing of from a directory node descriptor.