From c2e407165e01e93f1e35da6465fc4fa273a0d11e Mon Sep 17 00:00:00 2001 From: Britt Park Date: Sat, 30 Sep 2006 17:51:15 +0000 Subject: [PATCH] Changed AVMNodeConverter.ToAVMVersionPath() to return a Pair. 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 --- .../alfresco/repo/avm/AVMNodeConverter.java | 8 +- .../repo/avm/AVMNodeConverterTest.java | 11 +- .../org/alfresco/repo/avm/AVMNodeService.java | 187 ++++++++++-------- .../avm/actions/SimpleAVMPromoteAction.java | 7 +- .../avm/actions/SimpleAVMSubmitAction.java | 7 +- .../alfresco/repo/avm/util/RawServices.java | 5 + .../repo/content/RoutingContentService.java | 5 +- .../hibernate/AVMAccessControlListDAO.java | 13 +- 8 files changed, 136 insertions(+), 107 deletions(-) diff --git a/source/java/org/alfresco/repo/avm/AVMNodeConverter.java b/source/java/org/alfresco/repo/avm/AVMNodeConverter.java index 9c51275627..0a273e6113 100644 --- a/source/java/org/alfresco/repo/avm/AVMNodeConverter.java +++ b/source/java/org/alfresco/repo/avm/AVMNodeConverter.java @@ -20,6 +20,7 @@ package org.alfresco.repo.avm; import org.alfresco.service.cmr.avm.AVMException; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.util.Pair; import org.apache.log4j.Logger; /** @@ -69,7 +70,7 @@ public class AVMNodeConverter * @param nodeRef The NodeRef to convert. * @return An Integer, String array. */ - public static Object[] ToAVMVersionPath(NodeRef nodeRef) + public static Pair ToAVMVersionPath(NodeRef nodeRef) { StoreRef store = nodeRef.getStoreRef(); String translated = nodeRef.getId(); @@ -82,10 +83,7 @@ public class AVMNodeConverter } int version = Integer.parseInt(translated.substring(0, off)); String path = translated.substring(off); - Object [] result = new Object[2]; - result[0] = new Integer(version); - result[1] = store.getIdentifier() + ":" + path; - return result; + return new Pair(version, store.getIdentifier() + ":" + path); } /** diff --git a/source/java/org/alfresco/repo/avm/AVMNodeConverterTest.java b/source/java/org/alfresco/repo/avm/AVMNodeConverterTest.java index 449c21fbc6..e39f275df6 100644 --- a/source/java/org/alfresco/repo/avm/AVMNodeConverterTest.java +++ b/source/java/org/alfresco/repo/avm/AVMNodeConverterTest.java @@ -18,6 +18,7 @@ package org.alfresco.repo.avm; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.Pair; import junit.framework.TestCase; @@ -36,15 +37,15 @@ public class AVMNodeConverterTest extends TestCase int version = 2; NodeRef nodeRef = AVMNodeConverter.ToNodeRef(version, avmPath); System.out.println(nodeRef); - Object [] backOut = AVMNodeConverter.ToAVMVersionPath(nodeRef); - assertEquals(2, ((Integer)backOut[0]).intValue()); - assertEquals(avmPath, (String)backOut[1]); + Pair backOut = AVMNodeConverter.ToAVMVersionPath(nodeRef); + assertEquals(2, backOut.getFirst().intValue()); + assertEquals(avmPath, backOut.getSecond()); avmPath = "main:/fista/mista/wisticuff"; version = -1; nodeRef = AVMNodeConverter.ToNodeRef(version, avmPath); System.out.println(nodeRef); backOut = AVMNodeConverter.ToAVMVersionPath(nodeRef); - assertEquals(-1, ((Integer)backOut[0]).intValue()); - assertEquals(avmPath, (String)backOut[1]); + assertEquals(-1, backOut.getFirst().intValue()); + assertEquals(avmPath, backOut.getSecond()); } } diff --git a/source/java/org/alfresco/repo/avm/AVMNodeService.java b/source/java/org/alfresco/repo/avm/AVMNodeService.java index e2db74d1ae..99dbda883f 100644 --- a/source/java/org/alfresco/repo/avm/AVMNodeService.java +++ b/source/java/org/alfresco/repo/avm/AVMNodeService.java @@ -59,6 +59,7 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QNamePattern; +import org.alfresco.util.Pair; import org.apache.log4j.Logger; /** @@ -150,9 +151,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi */ public boolean exists(NodeRef nodeRef) { - Object [] avmInfo = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = (Integer)avmInfo[0]; - String avmPath = (String)avmInfo[1]; + Pair avmInfo = AVMNodeConverter.ToAVMVersionPath(nodeRef); + int version = avmInfo.getFirst(); + String avmPath = avmInfo.getSecond(); return fAVMService.lookup(version, avmPath) != null; } @@ -235,13 +236,13 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi throw new InvalidTypeException(assocTypeQName); } String nodeName = assocQName.getLocalName(); - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef); - int version = ((Integer)avmVersionPath[0]); + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef); + int version = avmVersionPath.getFirst(); if (version >= 0) { throw new InvalidNodeRefException("Read only store.", parentRef); } - String avmPath = (String)avmVersionPath[1]; + String avmPath = avmVersionPath.getSecond(); // Invoke policy behavior. // invokeBeforeUpdateNode(parentRef); // invokeBeforeCreateNode(parentRef, assocTypeQName, assocQName, nodeTypeQName); @@ -267,8 +268,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi { throw new InvalidTypeException("No Indirection Property", nodeTypeQName); } - Object [] indVersionPath = AVMNodeConverter.ToAVMVersionPath(indirection); - fAVMService.createLayeredFile((String)indVersionPath[1], avmPath, nodeName); + Pair indVersionPath = AVMNodeConverter.ToAVMVersionPath(indirection); + fAVMService.createLayeredFile(indVersionPath.getSecond(), avmPath, nodeName); } 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); } - Object [] indVersionPath = AVMNodeConverter.ToAVMVersionPath(indirection); - fAVMService.createLayeredDirectory((String)indVersionPath[1], avmPath, nodeName); + Pair indVersionPath = AVMNodeConverter.ToAVMVersionPath(indirection); + fAVMService.createLayeredDirectory(indVersionPath.getSecond(), avmPath, nodeName); } else { @@ -359,13 +360,13 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi throw new InvalidTypeException(assocTypeQName); } // Extract the parts from the source. - Object [] src = AVMNodeConverter.ToAVMVersionPath(nodeToMoveRef); - int srcVersion = (Integer)src[0]; + Pair src = AVMNodeConverter.ToAVMVersionPath(nodeToMoveRef); + int srcVersion = src.getFirst(); if (srcVersion >= 0) { throw new InvalidNodeRefException("Read Only Store.", nodeToMoveRef); } - String srcPath = (String)src[0]; + String srcPath = src.getSecond(); String [] splitSrc = null; try { @@ -382,12 +383,12 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi } String srcName = splitSrc[1]; // Extract and setup the parts of the destination. - Object[] dst = AVMNodeConverter.ToAVMVersionPath(newParentRef); - if ((Integer)dst[0] >= 0) + Pair dst = AVMNodeConverter.ToAVMVersionPath(newParentRef); + if (dst.getFirst() >= 0) { throw new InvalidNodeRefException("Read Only Store.", newParentRef); } - String dstParent = (String)dst[1]; + String dstParent = dst.getSecond(); String dstName = assocQName.getLocalName(); // TODO Invoke policy behavior. Not quite sure how to translate this. // NodeRef oldParentRef = AVMNodeConverter.ToNodeRef(-1, srcParent); @@ -467,9 +468,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi */ public QName getType(NodeRef nodeRef) throws InvalidNodeRefException { - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - AVMNodeDescriptor desc = fAVMService.lookup((Integer)avmVersionPath[0], - (String)avmVersionPath[1]); + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + AVMNodeDescriptor desc = fAVMService.lookup(avmVersionPath.getFirst(), + avmVersionPath.getSecond()); if (desc == null) { throw new InvalidNodeRefException("Not Found.", nodeRef); @@ -540,13 +541,13 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi // invokeBeforeUpdateNode(nodeRef); // invokeBeforeAddAspect(nodeRef, aspectTypeQName); // Crack the nodeRef. - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = (Integer)avmVersionPath[0]; + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + int version = avmVersionPath.getFirst(); if (version >= 0) { throw new InvalidNodeRefException("Read Only node.", nodeRef); } - String avmPath = (String)avmVersionPath[1]; + String avmPath = avmVersionPath.getSecond(); // Get the current node properties. Map properties = getProperties(nodeRef); // 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. return; } - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = (Integer)avmVersionPath[0]; + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + int version = avmVersionPath.getFirst(); if (version >= 0) { throw new InvalidNodeRefException("Read Only Node.", nodeRef); } - String path = (String)avmVersionPath[1]; + String path = avmVersionPath.getSecond(); try { if (fAVMService.hasAspect(-1, path, aspectTypeQName)) @@ -669,9 +670,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi public boolean hasAspect(NodeRef nodeRef, QName aspectTypeQName) throws InvalidNodeRefException, InvalidAspectException { - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = (Integer)avmVersionPath[0]; - String path = (String)avmVersionPath[1]; + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + int version = avmVersionPath.getFirst(); + String path = avmVersionPath.getSecond(); if (isBuiltinAspect(aspectTypeQName)) { return true; @@ -709,9 +710,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi */ public Set getAspects(NodeRef nodeRef) throws InvalidNodeRefException { - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = (Integer)avmVersionPath[0]; - String path = (String)avmVersionPath[1]; + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + int version = avmVersionPath.getFirst(); + String path = avmVersionPath.getSecond(); Set result = new HashSet(); // Add the builtin ones. for (QName name : fgBuiltinAspects) @@ -747,12 +748,12 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi { // Invoke policy behaviors. // invokeBeforeDeleteNode(nodeRef); - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - if ((Integer)avmVersionPath[0] != -1) + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + if (avmVersionPath.getFirst() != -1) { throw new InvalidNodeRefException("Read only store.", nodeRef); } - String [] avmPathBase = AVMNodeConverter.SplitBase((String)avmVersionPath[1]); + String [] avmPathBase = AVMNodeConverter.SplitBase(avmVersionPath.getSecond()); if (avmPathBase[0] == null) { throw new InvalidNodeRefException("Cannot delete root node.", nodeRef); @@ -794,9 +795,31 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi QName assocTypeQName, QName qname) throws InvalidNodeRefException { - // TODO This can be supported theoretically. I'm not sure if - // the link operation is semantically equivalent. - throw new UnsupportedOperationException("addChild: unsupported"); + Pair childVersionPath = AVMNodeConverter.ToAVMVersionPath(childRef); + AVMNodeDescriptor child = fAVMService.lookup(childVersionPath.getFirst(), + childVersionPath.getSecond()); + if (child == null) + { + throw new InvalidNodeRefException("Not Found.", childRef); + } + Pair 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 { - // Invoke policy behaviors. - // TODO Have to fake up ChildAssocRef. - Object [] parentVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef); - if ((Integer)parentVersionPath[0] >= 0) + Pair parentVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef); + if (parentVersionPath.getFirst() >= 0) { throw new InvalidNodeRefException("Read only store.", parentRef); } - Object [] childVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef); - if ((Integer)childVersionPath[0] >= 0) + Pair childVersionPath = AVMNodeConverter.ToAVMVersionPath(parentRef); + if (childVersionPath.getFirst() >= 0) { throw new InvalidNodeRefException("Read only store.", childRef); } - String parentPath = (String)parentVersionPath[1]; - String childPath = (String)childVersionPath[1]; + String parentPath = parentVersionPath.getSecond(); + String childPath = childVersionPath.getSecond(); String [] childPathBase = AVMNodeConverter.SplitBase(childPath); if (childPathBase[0] == null || !childPathBase[0].equals(parentPath)) { @@ -856,14 +877,14 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi */ public Map getProperties(NodeRef nodeRef) throws InvalidNodeRefException { - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); Map props = null; - AVMNodeDescriptor desc = fAVMService.lookup((Integer)avmVersionPath[0], - (String)avmVersionPath[1]); + AVMNodeDescriptor desc = fAVMService.lookup(avmVersionPath.getFirst(), + avmVersionPath.getSecond()); try { - props = fAVMService.getNodeProperties((Integer)avmVersionPath[0], - (String)avmVersionPath[1]); + props = fAVMService.getNodeProperties(avmVersionPath.getFirst(), + avmVersionPath.getSecond()); } catch (AVMNotFoundException e) { @@ -901,8 +922,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi { try { - ContentData contentData = fAVMService.getContentDataForRead((Integer)avmVersionPath[0], - (String)avmVersionPath[1]); + ContentData contentData = fAVMService.getContentDataForRead(avmVersionPath.getFirst(), + avmVersionPath.getSecond()); result.put(ContentModel.PROP_CONTENT, contentData); } catch (AVMException e) @@ -921,15 +942,15 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi */ public Serializable getProperty(NodeRef nodeRef, QName qname) throws InvalidNodeRefException { - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); if (isBuiltInProperty(qname)) { return getBuiltInProperty(avmVersionPath, qname, nodeRef); } try { - PropertyValue value = fAVMService.getNodeProperty((Integer)avmVersionPath[0], - (String)avmVersionPath[1], + PropertyValue value = fAVMService.getNodeProperty(avmVersionPath.getFirst(), + avmVersionPath.getSecond(), qname); if (value == null) { @@ -951,7 +972,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi * @param nodeRef The original NodeRef (for error reporting). * @return The property value. */ - private Serializable getBuiltInProperty(Object [] avmVersionPath, + private Serializable getBuiltInProperty(Pair avmVersionPath, QName qName, NodeRef nodeRef) { @@ -960,8 +981,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi try { ContentData contentData = - fAVMService.getContentDataForRead((Integer)avmVersionPath[0], - (String)avmVersionPath[1]); + fAVMService.getContentDataForRead(avmVersionPath.getFirst(), + avmVersionPath.getSecond()); return contentData; } catch (AVMException e) @@ -971,8 +992,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi return null; } } - AVMNodeDescriptor desc = fAVMService.lookup((Integer)avmVersionPath[0], - (String)avmVersionPath[1]); + AVMNodeDescriptor desc = fAVMService.lookup(avmVersionPath.getFirst(), + avmVersionPath.getSecond()); if (desc == null) { throw new InvalidNodeRefException("Not Found.", nodeRef); @@ -1053,8 +1074,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi */ public void setProperties(NodeRef nodeRef, Map properties) throws InvalidNodeRefException { - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - if ((Integer)avmVersionPath[0] >= 0) + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + if (avmVersionPath.getFirst() >= 0) { throw new InvalidNodeRefException("Read only store.", nodeRef); } @@ -1064,7 +1085,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi // Invoke policy behaviors. // invokeBeforeUpdateNode(nodeRef); // Map oldProps = getProperties(nodeRef); - fAVMService.deleteNodeProperties((String)avmVersionPath[1]); + fAVMService.deleteNodeProperties(avmVersionPath.getSecond()); Map values = new HashMap(); for (QName qName : properties.keySet()) { @@ -1073,21 +1094,21 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi { if (qName.equals(ContentModel.PROP_CONTENT)) { - AVMNodeDescriptor desc = fAVMService.lookup(-1, (String)avmVersionPath[1]); + AVMNodeDescriptor desc = fAVMService.lookup(-1, avmVersionPath.getSecond()); if (desc == null) { throw new InvalidNodeRefException("Not Found.", nodeRef); } if (desc.isPlainFile()) { - fAVMService.setContentData((String)avmVersionPath[1], + fAVMService.setContentData(avmVersionPath.getSecond(), (ContentData)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. // invokeOnUpdateNode(nodeRef); // invokeOnUpdateProperties(nodeRef, oldProps, properties); @@ -1148,8 +1169,8 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi { // Invoke policy behaviors. // invokeBeforeUpdateNode(nodeRef); - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - if ((Integer)avmVersionPath[0] >= 0) + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + if (avmVersionPath.getFirst() >= 0) { throw new InvalidNodeRefException("Read only store.", nodeRef); } @@ -1159,7 +1180,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi { try { - fAVMService.setContentData((String)avmVersionPath[1], (ContentData)value); + fAVMService.setContentData(avmVersionPath.getSecond(), (ContentData)value); } catch (ClassCastException e) { @@ -1171,7 +1192,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi try { // Map propsBefore = getProperties(nodeRef); - fAVMService.setNodeProperty((String)avmVersionPath[1], qname, new PropertyValue(null, value)); + fAVMService.setNodeProperty(avmVersionPath.getSecond(), qname, new PropertyValue(null, value)); // Map propsAfter = getProperties(nodeRef); // Invoke policy behaviors. // 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 // to the path stuffed in the NodeRef. - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - String path = (String)avmVersionPath[1]; + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + String path = avmVersionPath.getSecond(); List result = new ArrayList(); String [] splitPath = AVMNodeConverter.SplitBase(path); if (splitPath[0] == null) @@ -1204,7 +1225,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi return result; } result.add(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, - AVMNodeConverter.ToNodeRef((Integer)avmVersionPath[0], + AVMNodeConverter.ToNodeRef(avmVersionPath.getFirst(), splitPath[0]), QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, splitPath[1]), @@ -1268,9 +1289,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi public List getChildAssocs(NodeRef nodeRef) throws InvalidNodeRefException { - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = (Integer)avmVersionPath[0]; - String path = (String)avmVersionPath[1]; + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + int version = avmVersionPath.getFirst(); + String path = avmVersionPath.getSecond(); List result = new ArrayList(); SortedMap children = null; try @@ -1347,16 +1368,16 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi { return null; } - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); try { - AVMNodeDescriptor child = fAVMService.lookup((Integer)avmVersionPath[0], - (String)avmVersionPath[1]); + AVMNodeDescriptor child = fAVMService.lookup(avmVersionPath.getFirst(), + avmVersionPath.getSecond()); if (child == null) { return null; } - return AVMNodeConverter.ToNodeRef((Integer)avmVersionPath[0], + return AVMNodeConverter.ToNodeRef(avmVersionPath.getFirst(), child.getPath()); } catch (AVMException e) @@ -1465,9 +1486,9 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi { // TODO Review later. This may be wrong. Path path = new Path(); - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = (Integer)avmVersionPath[0]; - String currPath = (String)avmVersionPath[1]; + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + int version = avmVersionPath.getFirst(); + String currPath = avmVersionPath.getSecond(); while (!currPath.endsWith("/")) { String [] splitPath = AVMNodeConverter.SplitBase(currPath); diff --git a/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java b/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java index 6561cb2686..81e843fea1 100644 --- a/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java +++ b/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java @@ -29,6 +29,7 @@ import org.alfresco.service.cmr.avmsync.AVMSyncException; import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.Pair; /** * 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); // Crack the NodeRef. - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef); - int version = (Integer)avmVersionPath[0]; - String path = (String)avmVersionPath[1]; + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef); + int version = avmVersionPath.getFirst(); + String path = avmVersionPath.getSecond(); // Get store name and path parts. String [] storePath = path.split(":"); if (storePath.length != 2) diff --git a/source/java/org/alfresco/repo/avm/actions/SimpleAVMSubmitAction.java b/source/java/org/alfresco/repo/avm/actions/SimpleAVMSubmitAction.java index 8a99c6fdf0..784e835707 100644 --- a/source/java/org/alfresco/repo/avm/actions/SimpleAVMSubmitAction.java +++ b/source/java/org/alfresco/repo/avm/actions/SimpleAVMSubmitAction.java @@ -31,6 +31,7 @@ import org.alfresco.service.cmr.avmsync.AVMSyncException; import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; +import org.alfresco.util.Pair; import org.apache.log4j.Logger; /** @@ -89,9 +90,9 @@ public class SimpleAVMSubmitAction extends ActionExecuterAbstractBase protected void executeImpl(Action action, NodeRef actionedUponNodeRef) { // Crack the NodeRef. - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef); - int version = (Integer)avmVersionPath[0]; - String path = (String)avmVersionPath[1]; + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef); + int version = avmVersionPath.getFirst(); + String path = avmVersionPath.getSecond(); // Get store name and path parts. String [] storePath = path.split(":"); if (storePath.length != 2) diff --git a/source/java/org/alfresco/repo/avm/util/RawServices.java b/source/java/org/alfresco/repo/avm/util/RawServices.java index 4fb9b79780..3174b6fb4d 100644 --- a/source/java/org/alfresco/repo/avm/util/RawServices.java +++ b/source/java/org/alfresco/repo/avm/util/RawServices.java @@ -119,4 +119,9 @@ public class RawServices implements ApplicationContextAware } return fContentStore; } + + public ApplicationContext getContext() + { + return fContext; + } } diff --git a/source/java/org/alfresco/repo/content/RoutingContentService.java b/source/java/org/alfresco/repo/content/RoutingContentService.java index 5b169b6d0d..61f9eefd2c 100644 --- a/source/java/org/alfresco/repo/content/RoutingContentService.java +++ b/source/java/org/alfresco/repo/content/RoutingContentService.java @@ -53,6 +53,7 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.EqualsHelper; +import org.alfresco.util.Pair; import org.alfresco.util.TempFileProvider; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -336,8 +337,8 @@ public class RoutingContentService implements ContentService Serializable contentValue = null; if (nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) { - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - contentValue = avmService.getContentDataForWrite((String)avmVersionPath[1]); + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + contentValue = avmService.getContentDataForWrite(avmVersionPath.getSecond()); } else { diff --git a/source/java/org/alfresco/repo/domain/hibernate/AVMAccessControlListDAO.java b/source/java/org/alfresco/repo/domain/hibernate/AVMAccessControlListDAO.java index 7291d9ce99..1525eb232f 100644 --- a/source/java/org/alfresco/repo/domain/hibernate/AVMAccessControlListDAO.java +++ b/source/java/org/alfresco/repo/domain/hibernate/AVMAccessControlListDAO.java @@ -24,6 +24,7 @@ import org.alfresco.repo.domain.DbAccessControlList; import org.alfresco.service.cmr.avm.AVMException; import org.alfresco.service.cmr.repository.InvalidNodeRefException; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.Pair; /** * The AVM implementation for getting and setting ACLs. @@ -56,9 +57,9 @@ public class AVMAccessControlListDAO implements AccessControlListDAO */ public DbAccessControlList getAccessControlList(NodeRef nodeRef) { - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = (Integer)avmVersionPath[0]; - String path = (String)avmVersionPath[1]; + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + int version = avmVersionPath.getFirst(); + String path = avmVersionPath.getSecond(); try { return fAVMRepository.getACL(version, path); @@ -77,13 +78,13 @@ public class AVMAccessControlListDAO implements AccessControlListDAO */ public void setAccessControlList(NodeRef nodeRef, DbAccessControlList acl) { - Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); - int version = (Integer)avmVersionPath[0]; + Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); + int version = avmVersionPath.getFirst(); if (version >= 0) { throw new InvalidNodeRefException("Read Only Node.", nodeRef); } - String path = (String)avmVersionPath[1]; + String path = avmVersionPath.getSecond(); try { fAVMRepository.setACL(path, acl);