mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Extended the content model to include relevant avm specific types.
cm:avmcontent and cm:avmfolder are 'abstract'. cm:avmplaincontent is derived from cm:avmcontent and is just a plain file. cm:avmlayeredcontent is derived from cm:avmcontent and is (surprise) a layered file and has a d:noderef mandatory property, cm:avmfileindirection, that is the (possibly non-existent) file that the layered file is transparent to. cm:avmplainfolder is derived from cm:avmfolder and is just a plain directory. cm:avmlayeredfolder is a layered directory and has a property, cm:avmdirinderection, that is the (possibly non-existent) directory that the layered directory is transparent to. The ContentModel QName constants are. TYPE_AVM_PLAIN_FOLDER TYPE_AVM_LAYERED_FOLDER TYPE_AVM_PLAIN_CONTENT TYPE_AVM_LAYERED_CONTENT PROP_AVM_DIR_INDIRECTION PROP_AVM_FILE_INDIRECTION One can now create all four flavors of avm nodes through AVMNodeService.createNode(). The advantage of using these over the corresponding AVMService methods is that since (for now) AVMService, is permission and indexing unaware. Backed out cm:mounted aspect and dispatching code in DbNodeServiceImpl. (Dave and Derek, you may now relax) as we are implementing the UI with AVM dedicated screens. Finally, beginning interface for AVM node tree synchronization and comparison. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3764 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -437,48 +437,6 @@ 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.";
|
||||
|
@@ -268,16 +268,36 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
// Do the creates for supported types, or error out.
|
||||
try
|
||||
{
|
||||
if (nodeTypeQName.equals(ContentModel.TYPE_AVM_FOLDER) ||
|
||||
if (nodeTypeQName.equals(ContentModel.TYPE_AVM_PLAIN_FOLDER) ||
|
||||
nodeTypeQName.equals(ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
fAVMService.createDirectory(avmPath, nodeName);
|
||||
}
|
||||
else if (nodeTypeQName.equals(ContentModel.TYPE_AVM_CONTENT)
|
||||
else if (nodeTypeQName.equals(ContentModel.TYPE_AVM_PLAIN_CONTENT)
|
||||
||nodeTypeQName.equals(ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
fAVMService.createFile(avmPath, nodeName);
|
||||
}
|
||||
else if (nodeTypeQName.equals(ContentModel.TYPE_AVM_LAYERED_CONTENT))
|
||||
{
|
||||
NodeRef indirection = (NodeRef)properties.get(ContentModel.PROP_AVM_FILE_INDIRECTION);
|
||||
if (indirection == null)
|
||||
{
|
||||
throw new InvalidTypeException("No Indirection Property", nodeTypeQName);
|
||||
}
|
||||
Object [] indVersionPath = AVMNodeConverter.ToAVMVersionPath(indirection);
|
||||
fAVMService.createLayeredFile((String)indVersionPath[1], avmPath, nodeName);
|
||||
}
|
||||
else if (nodeTypeQName.equals(ContentModel.TYPE_AVM_LAYERED_FOLDER))
|
||||
{
|
||||
NodeRef indirection = (NodeRef)properties.get(ContentModel.PROP_AVM_DIR_INDIRECTION);
|
||||
if (indirection == null)
|
||||
{
|
||||
throw new InvalidTypeException("No Indirection Property.", nodeTypeQName);
|
||||
}
|
||||
Object [] indVersionPath = AVMNodeConverter.ToAVMVersionPath(indirection);
|
||||
fAVMService.createLayeredDirectory((String)indVersionPath[1], avmPath, nodeName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidTypeException("Invalid node type for AVM.", nodeTypeQName);
|
||||
@@ -450,14 +470,23 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
{
|
||||
AVMNodeDescriptor desc = fAVMService.lookup((Integer)avmVersionPath[0],
|
||||
(String)avmVersionPath[1]);
|
||||
if (desc.isDirectory())
|
||||
if (desc.isPlainDirectory())
|
||||
{
|
||||
return ContentModel.TYPE_AVM_FOLDER;
|
||||
return ContentModel.TYPE_AVM_PLAIN_FOLDER;
|
||||
}
|
||||
else if (desc.isPlainFile())
|
||||
{
|
||||
return ContentModel.TYPE_AVM_PLAIN_CONTENT;
|
||||
}
|
||||
else if (desc.isLayeredDirectory())
|
||||
{
|
||||
return ContentModel.TYPE_AVM_LAYERED_FOLDER;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ContentModel.TYPE_AVM_CONTENT;
|
||||
return ContentModel.TYPE_AVM_LAYERED_CONTENT;
|
||||
}
|
||||
|
||||
}
|
||||
catch (AVMNotFoundException e)
|
||||
{
|
||||
@@ -845,6 +874,16 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
result.put(ContentModel.PROP_NODE_DBID, new Long(desc.getId()));
|
||||
result.put(ContentModel.PROP_STORE_PROTOCOL, "avm");
|
||||
result.put(ContentModel.PROP_STORE_IDENTIFIER, nodeRef.getStoreRef().getIdentifier());
|
||||
if (desc.isLayeredDirectory())
|
||||
{
|
||||
result.put(ContentModel.PROP_AVM_DIR_INDIRECTION,
|
||||
AVMNodeConverter.ToNodeRef(-1, desc.getIndirection()));
|
||||
}
|
||||
if (desc.isLayeredFile())
|
||||
{
|
||||
result.put(ContentModel.PROP_AVM_FILE_INDIRECTION,
|
||||
AVMNodeConverter.ToNodeRef(-1, desc.getIndirection()));
|
||||
}
|
||||
if (desc.isFile())
|
||||
{
|
||||
try
|
||||
@@ -969,6 +1008,22 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
{
|
||||
return nodeRef.getStoreRef().getIdentifier();
|
||||
}
|
||||
else if (qName.equals(ContentModel.PROP_AVM_DIR_INDIRECTION))
|
||||
{
|
||||
if (desc.isLayeredDirectory())
|
||||
{
|
||||
return AVMNodeConverter.ToNodeRef(-1, desc.getIndirection());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else if (qName.equals(ContentModel.PROP_AVM_FILE_INDIRECTION))
|
||||
{
|
||||
if (desc.isLayeredFile())
|
||||
{
|
||||
return AVMNodeConverter.ToNodeRef(-1, desc.getIndirection());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
fgLogger.error("Invalid Built In Property: " + qName);
|
||||
@@ -1002,14 +1057,17 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
Map<QName, PropertyValue> values = new HashMap<QName, PropertyValue>();
|
||||
for (QName qName : properties.keySet())
|
||||
{
|
||||
// TODO This is until modification of built-in properties
|
||||
// For AVM nodes is in place.
|
||||
if (isBuiltInProperty(qName))
|
||||
{
|
||||
if (qName.equals(ContentModel.PROP_CONTENT))
|
||||
{
|
||||
fAVMService.setContentData((String)avmVersionPath[1],
|
||||
(ContentData)properties.get(qName));
|
||||
AVMNodeDescriptor desc = fAVMService.lookup(-1, (String)avmVersionPath[1]);
|
||||
if (desc.isPlainFile())
|
||||
{
|
||||
fAVMService.setContentData((String)avmVersionPath[1],
|
||||
(ContentData)properties.get(qName));
|
||||
}
|
||||
}
|
||||
}
|
||||
values.put(qName, new PropertyValue(null, properties.get(qName)));
|
||||
@@ -1036,7 +1094,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
ContentModel.PROP_NODE_UUID,
|
||||
ContentModel.PROP_NODE_DBID,
|
||||
ContentModel.PROP_STORE_PROTOCOL,
|
||||
ContentModel.PROP_STORE_IDENTIFIER
|
||||
ContentModel.PROP_STORE_IDENTIFIER,
|
||||
ContentModel.PROP_AVM_FILE_INDIRECTION,
|
||||
ContentModel.PROP_AVM_DIR_INDIRECTION
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -21,6 +21,7 @@ import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -41,8 +42,10 @@ import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
|
||||
import org.alfresco.service.cmr.avm.LayeringDescriptor;
|
||||
import org.alfresco.service.cmr.avm.VersionDescriptor;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
|
||||
@@ -2304,7 +2307,30 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
setupBasicTree();
|
||||
FileFolderService ffs = (FileFolderService)fContext.getBean("FileFolderService");
|
||||
assertTrue(ffs.create(AVMNodeConverter.ToNodeRef(-1, "main:/a/b/c"),
|
||||
"banana", ContentModel.TYPE_AVM_CONTENT) != null);
|
||||
"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");
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
properties.put(ContentModel.PROP_AVM_DIR_INDIRECTION,
|
||||
AVMNodeConverter.ToNodeRef(-1, "main:/a"));
|
||||
assertTrue(ns.createNode(AVMNodeConverter.ToNodeRef(-1, "main:/"),
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "layer"),
|
||||
ContentModel.TYPE_AVM_LAYERED_FOLDER,
|
||||
properties) != null);
|
||||
assertTrue(ns.getProperty(AVMNodeConverter.ToNodeRef(-1, "main:/layer"),
|
||||
ContentModel.PROP_AVM_DIR_INDIRECTION) != null);
|
||||
properties.clear();
|
||||
properties.put(ContentModel.PROP_AVM_FILE_INDIRECTION,
|
||||
AVMNodeConverter.ToNodeRef(-1, "main:/a/b/c/foo"));
|
||||
assertTrue(ns.createNode(AVMNodeConverter.ToNodeRef(-1, "main:/"),
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "foo"),
|
||||
ContentModel.TYPE_AVM_LAYERED_CONTENT,
|
||||
properties) != null);
|
||||
assertTrue(ns.getProperty(AVMNodeConverter.ToNodeRef(-1, "main:/foo"),
|
||||
ContentModel.PROP_AVM_FILE_INDIRECTION) != null);
|
||||
fService.createSnapshot("main");
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
}
|
||||
|
@@ -31,7 +31,6 @@ 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;
|
||||
@@ -253,20 +252,6 @@ 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)
|
||||
{
|
||||
@@ -317,6 +302,9 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
propertiesAfter = setPropertiesImpl(childNode, properties);
|
||||
}
|
||||
|
||||
// get the parent node
|
||||
Node parentNode = getNodeNotNull(parentRef);
|
||||
|
||||
// create the association
|
||||
ChildAssoc childAssoc = nodeDaoService.newChildAssoc(
|
||||
parentNode,
|
||||
@@ -724,15 +712,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
{
|
||||
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();
|
||||
|
||||
@@ -1017,14 +996,6 @@ 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
|
||||
@@ -1061,14 +1032,6 @@ 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