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:
Britt Park
2006-08-31 22:12:36 +00:00
parent 368f01a338
commit 8a8511c605
6 changed files with 165 additions and 5 deletions

View File

@@ -97,6 +97,19 @@
<cm:title>${spaces.guest_home.name}</cm:title> <cm:title>${spaces.guest_home.name}</cm:title>
<cm:description>${spaces.guest_home.description}</cm:description> <cm:description>${spaces.guest_home.description}</cm:description>
</cm:folder> </cm:folder>
<cm:folder view:childName="app:WCM">
<view:acl view:inherit="false">
<view:ace view:access="ALLOWED">
<view:authority>GROUP_EVERYONE</view:authority>
<view:permission>Consumer</view:permission>
</view:ace>
</view:acl>
<app:uifacets/>
<cm:name>WCM</cm:name>
<app:icon>space-icon-default</app:icon>
<cm:title>WCM</cm:title>
<cm:description>Web Content Management Spaces</cm:description>
</cm:folder>
</cm:contains> </cm:contains>
</cm:folder> </cm:folder>

View File

@@ -683,6 +683,16 @@
</properties> </properties>
</aspect> </aspect>
<aspect name="cm:mounted">
<title>Mounted</title>
<properties>
<property name="cm:mountpoint">
<title>Mountpoint</title>
<type>d:noderef</type>
</property>
</properties>
</aspect>
</aspects> </aspects>
</model> </model>

View File

@@ -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_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"); 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 // Application Model Definitions
// //

View File

@@ -7,6 +7,8 @@ import org.alfresco.repo.content.ContentStore;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.MimetypeService; 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.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
@@ -111,6 +113,13 @@ public class AVMContext implements ApplicationContextAware
* The DictionaryService * The DictionaryService
*/ */
private DictionaryService fDictionaryService; private DictionaryService fDictionaryService;
/**
* The Node Service.
*/
private NodeService fNodeService;
private AuthenticationService fAuthenticationService;
/** /**
* The application context. * The application context.
@@ -274,4 +283,26 @@ public class AVMContext implements ApplicationContextAware
} }
return fDictionaryService; 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;
}
} }

View File

@@ -24,11 +24,21 @@ import java.io.InputStreamReader;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.util.BulkLoader; 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; import org.springframework.context.support.FileSystemXmlApplicationContext;
/** /**
@@ -37,11 +47,18 @@ import org.springframework.context.support.FileSystemXmlApplicationContext;
*/ */
public class AVMInterpreter public class AVMInterpreter
{ {
private static Logger fgLogger = Logger.getLogger(AVMInterpreter.class);
/** /**
* The service interface. * The service interface.
*/ */
private AVMService fService; private AVMService fService;
/**
* The Node service.
*/
private NodeService fNodeService;
/** /**
* The reader for interaction. * The reader for interaction.
*/ */
@@ -91,6 +108,11 @@ public class AVMInterpreter
fLoader = loader; fLoader = loader;
} }
public void setNodeService(NodeService service)
{
fNodeService = service;
}
/** /**
* A Read-Eval-Print loop. * A Read-Eval-Print loop.
*/ */
@@ -124,7 +146,7 @@ public class AVMInterpreter
*/ */
public String interpretCommand(String line, BufferedReader in) public String interpretCommand(String line, BufferedReader in)
{ {
String[] command = line.split("\\s+"); String[] command = line.split(",\\s+");
if (command.length == 0) if (command.length == 0)
{ {
command = new String[1]; command = new String[1];
@@ -411,6 +433,48 @@ public class AVMInterpreter
AVMNodeDescriptor ca = fService.getCommonAncestor(left, right); AVMNodeDescriptor ca = fService.getCommonAncestor(left, right);
out.println(ca); 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 else
{ {
return "Syntax Error."; return "Syntax Error.";

View File

@@ -31,6 +31,7 @@ import java.util.Stack;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMContext;
import org.alfresco.repo.domain.ChildAssoc; import org.alfresco.repo.domain.ChildAssoc;
import org.alfresco.repo.domain.Node; import org.alfresco.repo.domain.Node;
import org.alfresco.repo.domain.NodeAssoc; import org.alfresco.repo.domain.NodeAssoc;
@@ -252,6 +253,20 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
Assert.notNull(assocTypeQName); Assert.notNull(assocTypeQName);
Assert.notNull(assocQName); 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 // null property map is allowed
if (properties == null) if (properties == null)
{ {
@@ -288,9 +303,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
// create the node instance // create the node instance
Node childNode = nodeDaoService.newNode(store, newId, nodeTypeQName); Node childNode = nodeDaoService.newNode(store, newId, nodeTypeQName);
// get the parent node
Node parentNode = getNodeNotNull(parentRef);
// Set the default property values // Set the default property values
addDefaultPropertyValues(nodeTypeDef, properties); addDefaultPropertyValues(nodeTypeDef, properties);
@@ -711,6 +723,16 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
public void removeChild(NodeRef parentRef, NodeRef childRef) throws InvalidNodeRefException public void removeChild(NodeRef parentRef, NodeRef childRef) throws InvalidNodeRefException
{ {
Node parentNode = getNodeNotNull(parentRef); 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); Node childNode = getNodeNotNull(childRef);
Long childNodeId = childNode.getId(); Long childNodeId = childNode.getId();
@@ -995,6 +1017,14 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern)
{ {
Node node = getNodeNotNull(nodeRef); 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 // get the assocs pointing from it
Collection<ChildAssociationRef> childAssocRefs = nodeDaoService.getChildAssocRefs(node); Collection<ChildAssociationRef> childAssocRefs = nodeDaoService.getChildAssocRefs(node);
// shortcut if there are no assocs // shortcut if there are no assocs
@@ -1031,6 +1061,14 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
public NodeRef getChildByName(NodeRef nodeRef, QName assocTypeQName, String childName) public NodeRef getChildByName(NodeRef nodeRef, QName assocTypeQName, String childName)
{ {
Node node = getNodeNotNull(nodeRef); 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); ChildAssoc childAssoc = nodeDaoService.getChildAssoc(node, assocTypeQName, childName);
if (childAssoc != null) if (childAssoc != null)
{ {