mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Slightly less broken RepoLs. Checkpoint. Also gave Pair a reasonable toString method.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4508 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -7,6 +7,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List the contents of a directory in a repo.
|
* List the contents of a directory in a repo.
|
||||||
@@ -45,10 +47,10 @@ public class RepoLs extends CltBase
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<String, NodeRef> listing = fRepoRemote.getListing(dir);
|
Map<String, Pair<NodeRef, QName>> listing = fRepoRemote.getListing(dir);
|
||||||
for (String name : listing.keySet())
|
for (String name : listing.keySet())
|
||||||
{
|
{
|
||||||
System.out.println(name);
|
System.out.println(name + "\t" + listing.get(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,8 @@ import java.util.Map;
|
|||||||
import org.alfresco.service.cmr.remote.RepoRemote;
|
import org.alfresco.service.cmr.remote.RepoRemote;
|
||||||
import org.alfresco.service.cmr.remote.RepoRemoteTransport;
|
import org.alfresco.service.cmr.remote.RepoRemoteTransport;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client side implementation of RepoRemote interface.
|
* Client side implementation of RepoRemote interface.
|
||||||
@@ -57,7 +59,7 @@ public class RepoRemoteImpl implements RepoRemote
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.remote.RepoRemote#getListing(org.alfresco.service.cmr.repository.NodeRef)
|
* @see org.alfresco.service.cmr.remote.RepoRemote#getListing(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
*/
|
*/
|
||||||
public Map<String, NodeRef> getListing(NodeRef dir)
|
public Map<String, Pair<NodeRef, QName>> getListing(NodeRef dir)
|
||||||
{
|
{
|
||||||
return fTransport.getListing(ClientTicketHolder.GetTicket(), dir);
|
return fTransport.getListing(ClientTicketHolder.GetTicket(), dir);
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||||
@@ -22,6 +23,7 @@ import org.alfresco.service.cmr.repository.ContentWriter;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
@@ -124,13 +126,22 @@ public class RepoRemoteService implements RepoRemote
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.remote.RepoRemote#getListing(org.alfresco.service.cmr.repository.NodeRef)
|
* @see org.alfresco.service.cmr.remote.RepoRemote#getListing(org.alfresco.service.cmr.repository.NodeRef)
|
||||||
*/
|
*/
|
||||||
public Map<String, NodeRef> getListing(NodeRef dir)
|
public Map<String, Pair<NodeRef, QName>> getListing(NodeRef dir)
|
||||||
{
|
{
|
||||||
List<FileInfo> list = fFileFolderService.listFiles(dir);
|
List<ChildAssociationRef> listing = fNodeService.getChildAssocs(dir);
|
||||||
Map<String, NodeRef> result = new TreeMap<String, NodeRef>();
|
Map<String, Pair<NodeRef, QName>> result = new TreeMap<String, Pair<NodeRef, QName>>();
|
||||||
for (FileInfo info : list)
|
for (ChildAssociationRef child : listing)
|
||||||
{
|
{
|
||||||
result.put(info.getName(), info.getNodeRef());
|
fgLogger.error(child.getQName());
|
||||||
|
NodeRef childRef = child.getChildRef();
|
||||||
|
QName type = fNodeService.getType(childRef);
|
||||||
|
if (type.equals(ContentModel.TYPE_CONTENT) ||
|
||||||
|
type.equals(ContentModel.TYPE_FOLDER))
|
||||||
|
{
|
||||||
|
result.put(child.getQName().getLocalName(),
|
||||||
|
new Pair<NodeRef, QName>(child.getChildRef(),
|
||||||
|
type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -159,19 +170,23 @@ public class RepoRemoteService implements RepoRemote
|
|||||||
public NodeRef lookup(NodeRef base, String path)
|
public NodeRef lookup(NodeRef base, String path)
|
||||||
{
|
{
|
||||||
List<String> pathList = splitPath(path);
|
List<String> pathList = splitPath(path);
|
||||||
if (pathList.size() == 1)
|
NodeRef curr = base;
|
||||||
|
for (String name : pathList)
|
||||||
{
|
{
|
||||||
return fNodeService.getChildByName(base, ContentModel.ASSOC_CONTAINS, pathList.get(0));
|
fgLogger.error(name);
|
||||||
}
|
NodeRef next = fNodeService.getChildByName(curr, ContentModel.ASSOC_CONTAINS, name);
|
||||||
try
|
if (next == null)
|
||||||
{
|
{
|
||||||
FileInfo info = fFileFolderService.resolveNamePath(base, pathList);
|
fgLogger.error("Wasn't a contains.");
|
||||||
return info.getNodeRef();
|
next = fNodeService.getChildByName(curr, ContentModel.ASSOC_CHILDREN, name);
|
||||||
}
|
if (next == null)
|
||||||
catch (FileNotFoundException e)
|
{
|
||||||
{
|
return null;
|
||||||
return null;
|
}
|
||||||
|
}
|
||||||
|
curr = next;
|
||||||
}
|
}
|
||||||
|
return curr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@@ -16,7 +16,9 @@ import org.alfresco.service.cmr.remote.RepoRemote;
|
|||||||
import org.alfresco.service.cmr.remote.RepoRemoteTransport;
|
import org.alfresco.service.cmr.remote.RepoRemoteTransport;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The server side implementation of RepoRemoteTransport. It
|
* The server side implementation of RepoRemoteTransport. It
|
||||||
@@ -291,7 +293,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport,
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.remote.RepoRemoteTransport#getListing(java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
|
* @see org.alfresco.service.cmr.remote.RepoRemoteTransport#getListing(java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
|
||||||
*/
|
*/
|
||||||
public Map<String, NodeRef> getListing(String ticket, NodeRef dir)
|
public Map<String, Pair<NodeRef, QName>> getListing(String ticket, NodeRef dir)
|
||||||
{
|
{
|
||||||
fAuthService.validate(ticket);
|
fAuthService.validate(ticket);
|
||||||
return fRepoRemote.getListing(dir);
|
return fRepoRemote.getListing(dir);
|
||||||
|
@@ -8,6 +8,8 @@ import java.io.OutputStream;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A highly simplified remote interface for the repo.
|
* A highly simplified remote interface for the repo.
|
||||||
@@ -26,7 +28,7 @@ public interface RepoRemote
|
|||||||
* @param dir The node ref of the directory.
|
* @param dir The node ref of the directory.
|
||||||
* @return A Map of names to node refs.
|
* @return A Map of names to node refs.
|
||||||
*/
|
*/
|
||||||
public Map<String, NodeRef> getListing(NodeRef dir);
|
public Map<String, Pair<NodeRef, QName>> getListing(NodeRef dir);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lookup a node by path relative to a node.
|
* Lookup a node by path relative to a node.
|
||||||
|
@@ -3,11 +3,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.service.cmr.remote;
|
package org.alfresco.service.cmr.remote;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Over the wire, and authentication safe flavor of
|
* Over the wire, and authentication safe flavor of
|
||||||
@@ -27,7 +27,7 @@ public interface RepoRemoteTransport
|
|||||||
* @param dir The node ref of the directory.
|
* @param dir The node ref of the directory.
|
||||||
* @return A Map of names to node refs.
|
* @return A Map of names to node refs.
|
||||||
*/
|
*/
|
||||||
public Map<String, NodeRef> getListing(String ticket, NodeRef dir);
|
public Map<String, Pair<NodeRef, QName>> getListing(String ticket, NodeRef dir);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lookup a node by path relative to a node.
|
* Lookup a node by path relative to a node.
|
||||||
|
Reference in New Issue
Block a user