Changed AVMNodeConverter.ToAVMVersionPath() to return a

Pair<Integer, String>.  
Fixed avm.jsp which got busted by last checkin.
Added implementation of AddChild to AVMNodeService.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3983 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-09-30 17:51:15 +00:00
parent 0db9ace91f
commit c2e407165e
8 changed files with 136 additions and 107 deletions

View File

@@ -20,6 +20,7 @@ package org.alfresco.repo.avm;
import org.alfresco.service.cmr.avm.AVMException; import org.alfresco.service.cmr.avm.AVMException;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.util.Pair;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@@ -69,7 +70,7 @@ public class AVMNodeConverter
* @param nodeRef The NodeRef to convert. * @param nodeRef The NodeRef to convert.
* @return An Integer, String array. * @return An Integer, String array.
*/ */
public static Object[] ToAVMVersionPath(NodeRef nodeRef) public static Pair<Integer, String> ToAVMVersionPath(NodeRef nodeRef)
{ {
StoreRef store = nodeRef.getStoreRef(); StoreRef store = nodeRef.getStoreRef();
String translated = nodeRef.getId(); String translated = nodeRef.getId();
@@ -82,10 +83,7 @@ public class AVMNodeConverter
} }
int version = Integer.parseInt(translated.substring(0, off)); int version = Integer.parseInt(translated.substring(0, off));
String path = translated.substring(off); String path = translated.substring(off);
Object [] result = new Object[2]; return new Pair<Integer, String>(version, store.getIdentifier() + ":" + path);
result[0] = new Integer(version);
result[1] = store.getIdentifier() + ":" + path;
return result;
} }
/** /**

View File

@@ -18,6 +18,7 @@
package org.alfresco.repo.avm; package org.alfresco.repo.avm;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.Pair;
import junit.framework.TestCase; import junit.framework.TestCase;
@@ -36,15 +37,15 @@ public class AVMNodeConverterTest extends TestCase
int version = 2; int version = 2;
NodeRef nodeRef = AVMNodeConverter.ToNodeRef(version, avmPath); NodeRef nodeRef = AVMNodeConverter.ToNodeRef(version, avmPath);
System.out.println(nodeRef); System.out.println(nodeRef);
Object [] backOut = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> backOut = AVMNodeConverter.ToAVMVersionPath(nodeRef);
assertEquals(2, ((Integer)backOut[0]).intValue()); assertEquals(2, backOut.getFirst().intValue());
assertEquals(avmPath, (String)backOut[1]); assertEquals(avmPath, backOut.getSecond());
avmPath = "main:/fista/mista/wisticuff"; avmPath = "main:/fista/mista/wisticuff";
version = -1; version = -1;
nodeRef = AVMNodeConverter.ToNodeRef(version, avmPath); nodeRef = AVMNodeConverter.ToNodeRef(version, avmPath);
System.out.println(nodeRef); System.out.println(nodeRef);
backOut = AVMNodeConverter.ToAVMVersionPath(nodeRef); backOut = AVMNodeConverter.ToAVMVersionPath(nodeRef);
assertEquals(-1, ((Integer)backOut[0]).intValue()); assertEquals(-1, backOut.getFirst().intValue());
assertEquals(avmPath, (String)backOut[1]); assertEquals(avmPath, backOut.getSecond());
} }
} }

View File

@@ -59,6 +59,7 @@ import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.QNamePattern; import org.alfresco.service.namespace.QNamePattern;
import org.alfresco.util.Pair;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@@ -150,9 +151,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
*/ */
public boolean exists(NodeRef nodeRef) public boolean exists(NodeRef nodeRef)
{ {
Object [] avmInfo = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmInfo = AVMNodeConverter.ToAVMVersionPath(nodeRef);
int version = (Integer)avmInfo[0]; int version = avmInfo.getFirst();
String avmPath = (String)avmInfo[1]; String avmPath = avmInfo.getSecond();
return fAVMService.lookup(version, avmPath) != null; return fAVMService.lookup(version, avmPath) != null;
} }
@@ -235,13 +236,13 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
throw new InvalidTypeException(assocTypeQName); throw new InvalidTypeException(assocTypeQName);
} }
String nodeName = assocQName.getLocalName(); String nodeName = assocQName.getLocalName();
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef);
int version = ((Integer)avmVersionPath[0]); int version = avmVersionPath.getFirst();
if (version >= 0) if (version >= 0)
{ {
throw new InvalidNodeRefException("Read only store.", parentRef); throw new InvalidNodeRefException("Read only store.", parentRef);
} }
String avmPath = (String)avmVersionPath[1]; String avmPath = avmVersionPath.getSecond();
// Invoke policy behavior. // Invoke policy behavior.
// invokeBeforeUpdateNode(parentRef); // invokeBeforeUpdateNode(parentRef);
// invokeBeforeCreateNode(parentRef, assocTypeQName, assocQName, nodeTypeQName); // invokeBeforeCreateNode(parentRef, assocTypeQName, assocQName, nodeTypeQName);
@@ -267,8 +268,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
{ {
throw new InvalidTypeException("No Indirection Property", nodeTypeQName); throw new InvalidTypeException("No Indirection Property", nodeTypeQName);
} }
Object [] indVersionPath = AVMNodeConverter.ToAVMVersionPath(indirection); Pair<Integer, String> indVersionPath = AVMNodeConverter.ToAVMVersionPath(indirection);
fAVMService.createLayeredFile((String)indVersionPath[1], avmPath, nodeName); fAVMService.createLayeredFile(indVersionPath.getSecond(), avmPath, nodeName);
} }
else if (nodeTypeQName.equals(ContentModel.TYPE_AVM_LAYERED_FOLDER)) else if (nodeTypeQName.equals(ContentModel.TYPE_AVM_LAYERED_FOLDER))
{ {
@@ -277,8 +278,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
{ {
throw new InvalidTypeException("No Indirection Property.", nodeTypeQName); throw new InvalidTypeException("No Indirection Property.", nodeTypeQName);
} }
Object [] indVersionPath = AVMNodeConverter.ToAVMVersionPath(indirection); Pair<Integer, String> indVersionPath = AVMNodeConverter.ToAVMVersionPath(indirection);
fAVMService.createLayeredDirectory((String)indVersionPath[1], avmPath, nodeName); fAVMService.createLayeredDirectory(indVersionPath.getSecond(), avmPath, nodeName);
} }
else else
{ {
@@ -359,13 +360,13 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
throw new InvalidTypeException(assocTypeQName); throw new InvalidTypeException(assocTypeQName);
} }
// Extract the parts from the source. // Extract the parts from the source.
Object [] src = AVMNodeConverter.ToAVMVersionPath(nodeToMoveRef); Pair<Integer, String> src = AVMNodeConverter.ToAVMVersionPath(nodeToMoveRef);
int srcVersion = (Integer)src[0]; int srcVersion = src.getFirst();
if (srcVersion >= 0) if (srcVersion >= 0)
{ {
throw new InvalidNodeRefException("Read Only Store.", nodeToMoveRef); throw new InvalidNodeRefException("Read Only Store.", nodeToMoveRef);
} }
String srcPath = (String)src[0]; String srcPath = src.getSecond();
String [] splitSrc = null; String [] splitSrc = null;
try try
{ {
@@ -382,12 +383,12 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
} }
String srcName = splitSrc[1]; String srcName = splitSrc[1];
// Extract and setup the parts of the destination. // Extract and setup the parts of the destination.
Object[] dst = AVMNodeConverter.ToAVMVersionPath(newParentRef); Pair<Integer, String> dst = AVMNodeConverter.ToAVMVersionPath(newParentRef);
if ((Integer)dst[0] >= 0) if (dst.getFirst() >= 0)
{ {
throw new InvalidNodeRefException("Read Only Store.", newParentRef); throw new InvalidNodeRefException("Read Only Store.", newParentRef);
} }
String dstParent = (String)dst[1]; String dstParent = dst.getSecond();
String dstName = assocQName.getLocalName(); String dstName = assocQName.getLocalName();
// TODO Invoke policy behavior. Not quite sure how to translate this. // TODO Invoke policy behavior. Not quite sure how to translate this.
// NodeRef oldParentRef = AVMNodeConverter.ToNodeRef(-1, srcParent); // NodeRef oldParentRef = AVMNodeConverter.ToNodeRef(-1, srcParent);
@@ -467,9 +468,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
*/ */
public QName getType(NodeRef nodeRef) throws InvalidNodeRefException public QName getType(NodeRef nodeRef) throws InvalidNodeRefException
{ {
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
AVMNodeDescriptor desc = fAVMService.lookup((Integer)avmVersionPath[0], AVMNodeDescriptor desc = fAVMService.lookup(avmVersionPath.getFirst(),
(String)avmVersionPath[1]); avmVersionPath.getSecond());
if (desc == null) if (desc == null)
{ {
throw new InvalidNodeRefException("Not Found.", nodeRef); throw new InvalidNodeRefException("Not Found.", nodeRef);
@@ -540,13 +541,13 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
// invokeBeforeUpdateNode(nodeRef); // invokeBeforeUpdateNode(nodeRef);
// invokeBeforeAddAspect(nodeRef, aspectTypeQName); // invokeBeforeAddAspect(nodeRef, aspectTypeQName);
// Crack the nodeRef. // Crack the nodeRef.
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
int version = (Integer)avmVersionPath[0]; int version = avmVersionPath.getFirst();
if (version >= 0) if (version >= 0)
{ {
throw new InvalidNodeRefException("Read Only node.", nodeRef); throw new InvalidNodeRefException("Read Only node.", nodeRef);
} }
String avmPath = (String)avmVersionPath[1]; String avmPath = avmVersionPath.getSecond();
// Get the current node properties. // Get the current node properties.
Map<QName, Serializable> properties = getProperties(nodeRef); Map<QName, Serializable> properties = getProperties(nodeRef);
// Add the supplied properties. // Add the supplied properties.
@@ -627,13 +628,13 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
// TODO shouldn't we be throwing some kind of exception here. // TODO shouldn't we be throwing some kind of exception here.
return; return;
} }
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
int version = (Integer)avmVersionPath[0]; int version = avmVersionPath.getFirst();
if (version >= 0) if (version >= 0)
{ {
throw new InvalidNodeRefException("Read Only Node.", nodeRef); throw new InvalidNodeRefException("Read Only Node.", nodeRef);
} }
String path = (String)avmVersionPath[1]; String path = avmVersionPath.getSecond();
try try
{ {
if (fAVMService.hasAspect(-1, path, aspectTypeQName)) if (fAVMService.hasAspect(-1, path, aspectTypeQName))
@@ -669,9 +670,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
public boolean hasAspect(NodeRef nodeRef, QName aspectTypeQName) public boolean hasAspect(NodeRef nodeRef, QName aspectTypeQName)
throws InvalidNodeRefException, InvalidAspectException throws InvalidNodeRefException, InvalidAspectException
{ {
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
int version = (Integer)avmVersionPath[0]; int version = avmVersionPath.getFirst();
String path = (String)avmVersionPath[1]; String path = avmVersionPath.getSecond();
if (isBuiltinAspect(aspectTypeQName)) if (isBuiltinAspect(aspectTypeQName))
{ {
return true; return true;
@@ -709,9 +710,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
*/ */
public Set<QName> getAspects(NodeRef nodeRef) throws InvalidNodeRefException public Set<QName> getAspects(NodeRef nodeRef) throws InvalidNodeRefException
{ {
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
int version = (Integer)avmVersionPath[0]; int version = avmVersionPath.getFirst();
String path = (String)avmVersionPath[1]; String path = avmVersionPath.getSecond();
Set<QName> result = new HashSet<QName>(); Set<QName> result = new HashSet<QName>();
// Add the builtin ones. // Add the builtin ones.
for (QName name : fgBuiltinAspects) for (QName name : fgBuiltinAspects)
@@ -747,12 +748,12 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
{ {
// Invoke policy behaviors. // Invoke policy behaviors.
// invokeBeforeDeleteNode(nodeRef); // invokeBeforeDeleteNode(nodeRef);
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
if ((Integer)avmVersionPath[0] != -1) if (avmVersionPath.getFirst() != -1)
{ {
throw new InvalidNodeRefException("Read only store.", nodeRef); throw new InvalidNodeRefException("Read only store.", nodeRef);
} }
String [] avmPathBase = AVMNodeConverter.SplitBase((String)avmVersionPath[1]); String [] avmPathBase = AVMNodeConverter.SplitBase(avmVersionPath.getSecond());
if (avmPathBase[0] == null) if (avmPathBase[0] == null)
{ {
throw new InvalidNodeRefException("Cannot delete root node.", nodeRef); throw new InvalidNodeRefException("Cannot delete root node.", nodeRef);
@@ -794,9 +795,31 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
QName assocTypeQName, QName assocTypeQName,
QName qname) throws InvalidNodeRefException QName qname) throws InvalidNodeRefException
{ {
// TODO This can be supported theoretically. I'm not sure if Pair<Integer, String> childVersionPath = AVMNodeConverter.ToAVMVersionPath(childRef);
// the link operation is semantically equivalent. AVMNodeDescriptor child = fAVMService.lookup(childVersionPath.getFirst(),
throw new UnsupportedOperationException("addChild: unsupported"); childVersionPath.getSecond());
if (child == null)
{
throw new InvalidNodeRefException("Not Found.", childRef);
}
Pair<Integer, String> parentVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef);
if (parentVersionPath.getFirst() >= 0)
{
throw new InvalidNodeRefException("Read Only.", parentRef);
}
try
{
fAVMService.link(parentVersionPath.getSecond(), qname.getLocalName(), child);
ChildAssociationRef newChild =
new ChildAssociationRef(assocTypeQName, parentRef, qname,
AVMNodeConverter.ToNodeRef(-1,
AVMNodeConverter.ExtendAVMPath(parentVersionPath.getSecond(), qname.getLocalName())));
return newChild;
}
catch (AVMException e)
{
throw new InvalidNodeRefException("Could not link.", childRef);
}
} }
/** /**
@@ -811,20 +834,18 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
*/ */
public void removeChild(NodeRef parentRef, NodeRef childRef) throws InvalidNodeRefException public void removeChild(NodeRef parentRef, NodeRef childRef) throws InvalidNodeRefException
{ {
// Invoke policy behaviors. Pair<Integer, String> parentVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef);
// TODO Have to fake up ChildAssocRef. if (parentVersionPath.getFirst() >= 0)
Object [] parentVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef);
if ((Integer)parentVersionPath[0] >= 0)
{ {
throw new InvalidNodeRefException("Read only store.", parentRef); throw new InvalidNodeRefException("Read only store.", parentRef);
} }
Object [] childVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef); Pair<Integer, String> childVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef);
if ((Integer)childVersionPath[0] >= 0) if (childVersionPath.getFirst() >= 0)
{ {
throw new InvalidNodeRefException("Read only store.", childRef); throw new InvalidNodeRefException("Read only store.", childRef);
} }
String parentPath = (String)parentVersionPath[1]; String parentPath = parentVersionPath.getSecond();
String childPath = (String)childVersionPath[1]; String childPath = childVersionPath.getSecond();
String [] childPathBase = AVMNodeConverter.SplitBase(childPath); String [] childPathBase = AVMNodeConverter.SplitBase(childPath);
if (childPathBase[0] == null || !childPathBase[0].equals(parentPath)) if (childPathBase[0] == null || !childPathBase[0].equals(parentPath))
{ {
@@ -856,14 +877,14 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
*/ */
public Map<QName, Serializable> getProperties(NodeRef nodeRef) throws InvalidNodeRefException public Map<QName, Serializable> getProperties(NodeRef nodeRef) throws InvalidNodeRefException
{ {
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
Map<QName, PropertyValue> props = null; Map<QName, PropertyValue> props = null;
AVMNodeDescriptor desc = fAVMService.lookup((Integer)avmVersionPath[0], AVMNodeDescriptor desc = fAVMService.lookup(avmVersionPath.getFirst(),
(String)avmVersionPath[1]); avmVersionPath.getSecond());
try try
{ {
props = fAVMService.getNodeProperties((Integer)avmVersionPath[0], props = fAVMService.getNodeProperties(avmVersionPath.getFirst(),
(String)avmVersionPath[1]); avmVersionPath.getSecond());
} }
catch (AVMNotFoundException e) catch (AVMNotFoundException e)
{ {
@@ -901,8 +922,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
{ {
try try
{ {
ContentData contentData = fAVMService.getContentDataForRead((Integer)avmVersionPath[0], ContentData contentData = fAVMService.getContentDataForRead(avmVersionPath.getFirst(),
(String)avmVersionPath[1]); avmVersionPath.getSecond());
result.put(ContentModel.PROP_CONTENT, contentData); result.put(ContentModel.PROP_CONTENT, contentData);
} }
catch (AVMException e) catch (AVMException e)
@@ -921,15 +942,15 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
*/ */
public Serializable getProperty(NodeRef nodeRef, QName qname) throws InvalidNodeRefException public Serializable getProperty(NodeRef nodeRef, QName qname) throws InvalidNodeRefException
{ {
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
if (isBuiltInProperty(qname)) if (isBuiltInProperty(qname))
{ {
return getBuiltInProperty(avmVersionPath, qname, nodeRef); return getBuiltInProperty(avmVersionPath, qname, nodeRef);
} }
try try
{ {
PropertyValue value = fAVMService.getNodeProperty((Integer)avmVersionPath[0], PropertyValue value = fAVMService.getNodeProperty(avmVersionPath.getFirst(),
(String)avmVersionPath[1], avmVersionPath.getSecond(),
qname); qname);
if (value == null) if (value == null)
{ {
@@ -951,7 +972,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
* @param nodeRef The original NodeRef (for error reporting). * @param nodeRef The original NodeRef (for error reporting).
* @return The property value. * @return The property value.
*/ */
private Serializable getBuiltInProperty(Object [] avmVersionPath, private Serializable getBuiltInProperty(Pair<Integer, String> avmVersionPath,
QName qName, QName qName,
NodeRef nodeRef) NodeRef nodeRef)
{ {
@@ -960,8 +981,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
try try
{ {
ContentData contentData = ContentData contentData =
fAVMService.getContentDataForRead((Integer)avmVersionPath[0], fAVMService.getContentDataForRead(avmVersionPath.getFirst(),
(String)avmVersionPath[1]); avmVersionPath.getSecond());
return contentData; return contentData;
} }
catch (AVMException e) catch (AVMException e)
@@ -971,8 +992,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
return null; return null;
} }
} }
AVMNodeDescriptor desc = fAVMService.lookup((Integer)avmVersionPath[0], AVMNodeDescriptor desc = fAVMService.lookup(avmVersionPath.getFirst(),
(String)avmVersionPath[1]); avmVersionPath.getSecond());
if (desc == null) if (desc == null)
{ {
throw new InvalidNodeRefException("Not Found.", nodeRef); throw new InvalidNodeRefException("Not Found.", nodeRef);
@@ -1053,8 +1074,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
*/ */
public void setProperties(NodeRef nodeRef, Map<QName, Serializable> properties) throws InvalidNodeRefException public void setProperties(NodeRef nodeRef, Map<QName, Serializable> properties) throws InvalidNodeRefException
{ {
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
if ((Integer)avmVersionPath[0] >= 0) if (avmVersionPath.getFirst() >= 0)
{ {
throw new InvalidNodeRefException("Read only store.", nodeRef); throw new InvalidNodeRefException("Read only store.", nodeRef);
} }
@@ -1064,7 +1085,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
// Invoke policy behaviors. // Invoke policy behaviors.
// invokeBeforeUpdateNode(nodeRef); // invokeBeforeUpdateNode(nodeRef);
// Map<QName, Serializable> oldProps = getProperties(nodeRef); // Map<QName, Serializable> oldProps = getProperties(nodeRef);
fAVMService.deleteNodeProperties((String)avmVersionPath[1]); fAVMService.deleteNodeProperties(avmVersionPath.getSecond());
Map<QName, PropertyValue> values = new HashMap<QName, PropertyValue>(); Map<QName, PropertyValue> values = new HashMap<QName, PropertyValue>();
for (QName qName : properties.keySet()) for (QName qName : properties.keySet())
{ {
@@ -1073,21 +1094,21 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
{ {
if (qName.equals(ContentModel.PROP_CONTENT)) if (qName.equals(ContentModel.PROP_CONTENT))
{ {
AVMNodeDescriptor desc = fAVMService.lookup(-1, (String)avmVersionPath[1]); AVMNodeDescriptor desc = fAVMService.lookup(-1, avmVersionPath.getSecond());
if (desc == null) if (desc == null)
{ {
throw new InvalidNodeRefException("Not Found.", nodeRef); throw new InvalidNodeRefException("Not Found.", nodeRef);
} }
if (desc.isPlainFile()) if (desc.isPlainFile())
{ {
fAVMService.setContentData((String)avmVersionPath[1], fAVMService.setContentData(avmVersionPath.getSecond(),
(ContentData)properties.get(qName)); (ContentData)properties.get(qName));
} }
} }
} }
values.put(qName, new PropertyValue(null, properties.get(qName))); values.put(qName, new PropertyValue(null, properties.get(qName)));
} }
fAVMService.setNodeProperties((String)avmVersionPath[1], values); fAVMService.setNodeProperties(avmVersionPath.getSecond(), values);
// Invoke policy behaviors. // Invoke policy behaviors.
// invokeOnUpdateNode(nodeRef); // invokeOnUpdateNode(nodeRef);
// invokeOnUpdateProperties(nodeRef, oldProps, properties); // invokeOnUpdateProperties(nodeRef, oldProps, properties);
@@ -1148,8 +1169,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
{ {
// Invoke policy behaviors. // Invoke policy behaviors.
// invokeBeforeUpdateNode(nodeRef); // invokeBeforeUpdateNode(nodeRef);
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
if ((Integer)avmVersionPath[0] >= 0) if (avmVersionPath.getFirst() >= 0)
{ {
throw new InvalidNodeRefException("Read only store.", nodeRef); throw new InvalidNodeRefException("Read only store.", nodeRef);
} }
@@ -1159,7 +1180,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
{ {
try try
{ {
fAVMService.setContentData((String)avmVersionPath[1], (ContentData)value); fAVMService.setContentData(avmVersionPath.getSecond(), (ContentData)value);
} }
catch (ClassCastException e) catch (ClassCastException e)
{ {
@@ -1171,7 +1192,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
try try
{ {
// Map<QName, Serializable> propsBefore = getProperties(nodeRef); // Map<QName, Serializable> propsBefore = getProperties(nodeRef);
fAVMService.setNodeProperty((String)avmVersionPath[1], qname, new PropertyValue(null, value)); fAVMService.setNodeProperty(avmVersionPath.getSecond(), qname, new PropertyValue(null, value));
// Map<QName, Serializable> propsAfter = getProperties(nodeRef); // Map<QName, Serializable> propsAfter = getProperties(nodeRef);
// Invoke policy behaviors. // Invoke policy behaviors.
// invokeOnUpdateNode(nodeRef); // invokeOnUpdateNode(nodeRef);
@@ -1195,8 +1216,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
{ {
// TODO OK, for now we'll simply return the single parent that corresponds // TODO OK, for now we'll simply return the single parent that corresponds
// to the path stuffed in the NodeRef. // to the path stuffed in the NodeRef.
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
String path = (String)avmVersionPath[1]; String path = avmVersionPath.getSecond();
List<ChildAssociationRef> result = new ArrayList<ChildAssociationRef>(); List<ChildAssociationRef> result = new ArrayList<ChildAssociationRef>();
String [] splitPath = AVMNodeConverter.SplitBase(path); String [] splitPath = AVMNodeConverter.SplitBase(path);
if (splitPath[0] == null) if (splitPath[0] == null)
@@ -1204,7 +1225,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
return result; return result;
} }
result.add(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, result.add(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS,
AVMNodeConverter.ToNodeRef((Integer)avmVersionPath[0], AVMNodeConverter.ToNodeRef(avmVersionPath.getFirst(),
splitPath[0]), splitPath[0]),
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
splitPath[1]), splitPath[1]),
@@ -1268,9 +1289,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef) throws InvalidNodeRefException public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef) throws InvalidNodeRefException
{ {
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
int version = (Integer)avmVersionPath[0]; int version = avmVersionPath.getFirst();
String path = (String)avmVersionPath[1]; String path = avmVersionPath.getSecond();
List<ChildAssociationRef> result = new ArrayList<ChildAssociationRef>(); List<ChildAssociationRef> result = new ArrayList<ChildAssociationRef>();
SortedMap<String, AVMNodeDescriptor> children = null; SortedMap<String, AVMNodeDescriptor> children = null;
try try
@@ -1347,16 +1368,16 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
{ {
return null; return null;
} }
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
try try
{ {
AVMNodeDescriptor child = fAVMService.lookup((Integer)avmVersionPath[0], AVMNodeDescriptor child = fAVMService.lookup(avmVersionPath.getFirst(),
(String)avmVersionPath[1]); avmVersionPath.getSecond());
if (child == null) if (child == null)
{ {
return null; return null;
} }
return AVMNodeConverter.ToNodeRef((Integer)avmVersionPath[0], return AVMNodeConverter.ToNodeRef(avmVersionPath.getFirst(),
child.getPath()); child.getPath());
} }
catch (AVMException e) catch (AVMException e)
@@ -1465,9 +1486,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
{ {
// TODO Review later. This may be wrong. // TODO Review later. This may be wrong.
Path path = new Path(); Path path = new Path();
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
int version = (Integer)avmVersionPath[0]; int version = avmVersionPath.getFirst();
String currPath = (String)avmVersionPath[1]; String currPath = avmVersionPath.getSecond();
while (!currPath.endsWith("/")) while (!currPath.endsWith("/"))
{ {
String [] splitPath = AVMNodeConverter.SplitBase(currPath); String [] splitPath = AVMNodeConverter.SplitBase(currPath);

View File

@@ -29,6 +29,7 @@ import org.alfresco.service.cmr.avmsync.AVMSyncException;
import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.Pair;
/** /**
* An ActionExecuter that promotes content from one store to another. * An ActionExecuter that promotes content from one store to another.
@@ -75,9 +76,9 @@ public class SimpleAVMPromoteAction extends ActionExecuterAbstractBase
{ {
String targetStoreName = (String)action.getParameterValue(PARAM_TARGET_STORE); String targetStoreName = (String)action.getParameterValue(PARAM_TARGET_STORE);
// Crack the NodeRef. // Crack the NodeRef.
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef);
int version = (Integer)avmVersionPath[0]; int version = avmVersionPath.getFirst();
String path = (String)avmVersionPath[1]; String path = avmVersionPath.getSecond();
// Get store name and path parts. // Get store name and path parts.
String [] storePath = path.split(":"); String [] storePath = path.split(":");
if (storePath.length != 2) if (storePath.length != 2)

View File

@@ -31,6 +31,7 @@ import org.alfresco.service.cmr.avmsync.AVMSyncException;
import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@@ -89,9 +90,9 @@ public class SimpleAVMSubmitAction extends ActionExecuterAbstractBase
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{ {
// Crack the NodeRef. // Crack the NodeRef.
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef);
int version = (Integer)avmVersionPath[0]; int version = avmVersionPath.getFirst();
String path = (String)avmVersionPath[1]; String path = avmVersionPath.getSecond();
// Get store name and path parts. // Get store name and path parts.
String [] storePath = path.split(":"); String [] storePath = path.split(":");
if (storePath.length != 2) if (storePath.length != 2)

View File

@@ -119,4 +119,9 @@ public class RawServices implements ApplicationContextAware
} }
return fContentStore; return fContentStore;
} }
public ApplicationContext getContext()
{
return fContext;
}
} }

View File

@@ -53,6 +53,7 @@ import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.EqualsHelper; import org.alfresco.util.EqualsHelper;
import org.alfresco.util.Pair;
import org.alfresco.util.TempFileProvider; import org.alfresco.util.TempFileProvider;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -336,8 +337,8 @@ public class RoutingContentService implements ContentService
Serializable contentValue = null; Serializable contentValue = null;
if (nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) if (nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
{ {
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
contentValue = avmService.getContentDataForWrite((String)avmVersionPath[1]); contentValue = avmService.getContentDataForWrite(avmVersionPath.getSecond());
} }
else else
{ {

View File

@@ -24,6 +24,7 @@ import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.service.cmr.avm.AVMException; import org.alfresco.service.cmr.avm.AVMException;
import org.alfresco.service.cmr.repository.InvalidNodeRefException; import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.Pair;
/** /**
* The AVM implementation for getting and setting ACLs. * The AVM implementation for getting and setting ACLs.
@@ -56,9 +57,9 @@ public class AVMAccessControlListDAO implements AccessControlListDAO
*/ */
public DbAccessControlList getAccessControlList(NodeRef nodeRef) public DbAccessControlList getAccessControlList(NodeRef nodeRef)
{ {
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
int version = (Integer)avmVersionPath[0]; int version = avmVersionPath.getFirst();
String path = (String)avmVersionPath[1]; String path = avmVersionPath.getSecond();
try try
{ {
return fAVMRepository.getACL(version, path); return fAVMRepository.getACL(version, path);
@@ -77,13 +78,13 @@ public class AVMAccessControlListDAO implements AccessControlListDAO
*/ */
public void setAccessControlList(NodeRef nodeRef, DbAccessControlList acl) public void setAccessControlList(NodeRef nodeRef, DbAccessControlList acl)
{ {
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
int version = (Integer)avmVersionPath[0]; int version = avmVersionPath.getFirst();
if (version >= 0) if (version >= 0)
{ {
throw new InvalidNodeRefException("Read Only Node.", nodeRef); throw new InvalidNodeRefException("Read Only Node.", nodeRef);
} }
String path = (String)avmVersionPath[1]; String path = avmVersionPath.getSecond();
try try
{ {
fAVMRepository.setACL(path, acl); fAVMRepository.setACL(path, acl);