mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added aspect cm:mounted, and dispatchers in DbNodeServiceImpl to allow
cross repository type browsing. The Node Browser seems to work happily with this. The UI can traverse a mounpoint but errors out when trying to browse further down into an AVM store, because its being naughty and peeking into NodeRefs. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3649 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -185,6 +185,10 @@ public interface ContentModel
|
||||
public static final QName PROP_ADDRESSEES = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "addressees");
|
||||
public static final QName PROP_SUBJECT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "subjectline");
|
||||
|
||||
// mounted aspect
|
||||
public static final QName ASPECT_MOUNTED = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "mounted");
|
||||
public static final QName PROP_MOUNTPOINT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "mountpoint");
|
||||
|
||||
//
|
||||
// Application Model Definitions
|
||||
//
|
||||
|
@@ -7,6 +7,8 @@ import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
@@ -111,6 +113,13 @@ public class AVMContext implements ApplicationContextAware
|
||||
* The DictionaryService
|
||||
*/
|
||||
private DictionaryService fDictionaryService;
|
||||
|
||||
/**
|
||||
* The Node Service.
|
||||
*/
|
||||
private NodeService fNodeService;
|
||||
|
||||
private AuthenticationService fAuthenticationService;
|
||||
|
||||
/**
|
||||
* The application context.
|
||||
@@ -274,4 +283,26 @@ public class AVMContext implements ApplicationContextAware
|
||||
}
|
||||
return fDictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the NodeService
|
||||
* @return The Node service.
|
||||
*/
|
||||
public NodeService getNodeService()
|
||||
{
|
||||
if (fNodeService == null)
|
||||
{
|
||||
fNodeService = (NodeService)fAppContext.getBean("NodeService");
|
||||
}
|
||||
return fNodeService;
|
||||
}
|
||||
|
||||
public AuthenticationService getAuthenticationService()
|
||||
{
|
||||
if (fAuthenticationService == null)
|
||||
{
|
||||
fAuthenticationService = (AuthenticationService)fAppContext.getBean("AuthenticationService");
|
||||
}
|
||||
return fAuthenticationService;
|
||||
}
|
||||
}
|
||||
|
@@ -24,11 +24,21 @@ import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.avm.util.BulkLoader;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
|
||||
/**
|
||||
@@ -37,11 +47,18 @@ import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
*/
|
||||
public class AVMInterpreter
|
||||
{
|
||||
private static Logger fgLogger = Logger.getLogger(AVMInterpreter.class);
|
||||
|
||||
/**
|
||||
* The service interface.
|
||||
*/
|
||||
private AVMService fService;
|
||||
|
||||
|
||||
/**
|
||||
* The Node service.
|
||||
*/
|
||||
private NodeService fNodeService;
|
||||
|
||||
/**
|
||||
* The reader for interaction.
|
||||
*/
|
||||
@@ -91,6 +108,11 @@ public class AVMInterpreter
|
||||
fLoader = loader;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService service)
|
||||
{
|
||||
fNodeService = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Read-Eval-Print loop.
|
||||
*/
|
||||
@@ -124,7 +146,7 @@ public class AVMInterpreter
|
||||
*/
|
||||
public String interpretCommand(String line, BufferedReader in)
|
||||
{
|
||||
String[] command = line.split("\\s+");
|
||||
String[] command = line.split(",\\s+");
|
||||
if (command.length == 0)
|
||||
{
|
||||
command = new String[1];
|
||||
@@ -411,6 +433,48 @@ public class AVMInterpreter
|
||||
AVMNodeDescriptor ca = fService.getCommonAncestor(left, right);
|
||||
out.println(ca);
|
||||
}
|
||||
else if (command[0].equals("mount"))
|
||||
{
|
||||
if (command.length != 5)
|
||||
{
|
||||
return "Syntax Error.";
|
||||
}
|
||||
int version = Integer.parseInt(command[1]);
|
||||
String avmPath = command[2];
|
||||
String alfPath = command[3];
|
||||
String mountName = command[4];
|
||||
String [] components = alfPath.split("/");
|
||||
NodeRef nodeRef = fNodeService.getRootNode(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"));
|
||||
for (String name : components)
|
||||
{
|
||||
fgLogger.error(name);
|
||||
List<ChildAssociationRef> children =
|
||||
fNodeService.getChildAssocs(nodeRef);
|
||||
for (ChildAssociationRef child : children)
|
||||
{
|
||||
fgLogger.error(" " + child.getQName());
|
||||
if (child.getQName().getLocalName().equals(name))
|
||||
{
|
||||
nodeRef = child.getChildRef();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<QName, Serializable> properties =
|
||||
new HashMap<QName, Serializable>();
|
||||
properties.put(ContentModel.PROP_NAME, mountName);
|
||||
ChildAssociationRef childRef =
|
||||
fNodeService.createNode(nodeRef, ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.APP_MODEL_1_0_URI, mountName),
|
||||
ContentModel.TYPE_FOLDER,
|
||||
properties);
|
||||
properties.clear();
|
||||
properties.put(ContentModel.PROP_MOUNTPOINT,
|
||||
AVMNodeConverter.ToNodeRef(version, avmPath));
|
||||
fNodeService.addAspect(childRef.getChildRef(),
|
||||
ContentModel.ASPECT_MOUNTED,
|
||||
properties);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Syntax Error.";
|
||||
|
@@ -31,6 +31,7 @@ import java.util.Stack;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.avm.AVMContext;
|
||||
import org.alfresco.repo.domain.ChildAssoc;
|
||||
import org.alfresco.repo.domain.Node;
|
||||
import org.alfresco.repo.domain.NodeAssoc;
|
||||
@@ -252,6 +253,20 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
Assert.notNull(assocTypeQName);
|
||||
Assert.notNull(assocQName);
|
||||
|
||||
// get the parent node
|
||||
Node parentNode = getNodeNotNull(parentRef);
|
||||
|
||||
if (parentNode.getAspects().contains(ContentModel.ASPECT_MOUNTED))
|
||||
{
|
||||
NodeRef mounted = (NodeRef)parentNode.getProperties().get(ContentModel.PROP_MOUNTPOINT).
|
||||
getValue(DataTypeDefinition.NODE_REF);
|
||||
return AVMContext.fgInstance.getNodeService().createNode(mounted,
|
||||
assocTypeQName,
|
||||
assocQName,
|
||||
nodeTypeQName,
|
||||
properties);
|
||||
}
|
||||
|
||||
// null property map is allowed
|
||||
if (properties == null)
|
||||
{
|
||||
@@ -288,9 +303,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
// create the node instance
|
||||
Node childNode = nodeDaoService.newNode(store, newId, nodeTypeQName);
|
||||
|
||||
// get the parent node
|
||||
Node parentNode = getNodeNotNull(parentRef);
|
||||
|
||||
// Set the default property values
|
||||
addDefaultPropertyValues(nodeTypeDef, properties);
|
||||
|
||||
@@ -711,6 +723,16 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
public void removeChild(NodeRef parentRef, NodeRef childRef) throws InvalidNodeRefException
|
||||
{
|
||||
Node parentNode = getNodeNotNull(parentRef);
|
||||
|
||||
if (parentNode.getAspects().contains(ContentModel.ASPECT_MOUNTED))
|
||||
{
|
||||
NodeRef mounted =
|
||||
(NodeRef)parentNode.getProperties().get(ContentModel.PROP_MOUNTPOINT).
|
||||
getValue(DataTypeDefinition.NODE_REF);
|
||||
AVMContext.fgInstance.getNodeService().removeChild(mounted, childRef);
|
||||
return;
|
||||
}
|
||||
|
||||
Node childNode = getNodeNotNull(childRef);
|
||||
Long childNodeId = childNode.getId();
|
||||
|
||||
@@ -995,6 +1017,14 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern)
|
||||
{
|
||||
Node node = getNodeNotNull(nodeRef);
|
||||
if (node.getAspects().contains(ContentModel.ASPECT_MOUNTED))
|
||||
{
|
||||
NodeRef mounted = (NodeRef)node.getProperties().get(ContentModel.PROP_MOUNTPOINT).
|
||||
getValue(DataTypeDefinition.NODE_REF);
|
||||
return AVMContext.fgInstance.getNodeService().getChildAssocs(mounted,
|
||||
typeQNamePattern,
|
||||
qnamePattern);
|
||||
}
|
||||
// get the assocs pointing from it
|
||||
Collection<ChildAssociationRef> childAssocRefs = nodeDaoService.getChildAssocRefs(node);
|
||||
// shortcut if there are no assocs
|
||||
@@ -1031,6 +1061,14 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
public NodeRef getChildByName(NodeRef nodeRef, QName assocTypeQName, String childName)
|
||||
{
|
||||
Node node = getNodeNotNull(nodeRef);
|
||||
if (node.getAspects().contains(ContentModel.ASPECT_MOUNTED))
|
||||
{
|
||||
NodeRef mounted = (NodeRef)node.getProperties().get(ContentModel.PROP_MOUNTPOINT).
|
||||
getValue(DataTypeDefinition.NODE_REF);
|
||||
return AVMContext.fgInstance.getNodeService().getChildByName(mounted,
|
||||
assocTypeQName,
|
||||
childName);
|
||||
}
|
||||
ChildAssoc childAssoc = nodeDaoService.getChildAssoc(node, assocTypeQName, childName);
|
||||
if (childAssoc != null)
|
||||
{
|
||||
|
Reference in New Issue
Block a user