mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
In certain circumstances update was not capturing aspects, properties, and
ACLs. This fixes that. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3979 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -197,4 +197,10 @@ public interface AVMNode
|
||||
* @return The store that we're new in.
|
||||
*/
|
||||
public AVMStore getStoreNew();
|
||||
|
||||
/**
|
||||
* Copy metadata from another node.
|
||||
* @param other The other node.
|
||||
*/
|
||||
public void copyMetaDataFrom(AVMNode other);
|
||||
}
|
@@ -337,6 +337,17 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy out metadata from another node.
|
||||
* @param other The other node.
|
||||
*/
|
||||
public void copyMetaDataFrom(AVMNode other)
|
||||
{
|
||||
copyAspects(other);
|
||||
copyACLs(other);
|
||||
copyProperties(other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a property on a node. Overwrite it if it exists.
|
||||
* @param name The name of the property.
|
||||
|
@@ -181,7 +181,7 @@ public class AVMRepository
|
||||
DirectoryNode child = null;
|
||||
if (dir instanceof LayeredDirectoryNode)
|
||||
{
|
||||
child = new LayeredDirectoryNodeImpl((String)null, store);
|
||||
child = new LayeredDirectoryNodeImpl((String)null, store, null);
|
||||
((LayeredDirectoryNode)child).setPrimaryIndirection(false);
|
||||
((LayeredDirectoryNode)child).setLayerID(parent.getLayerID());
|
||||
}
|
||||
@@ -1581,6 +1581,23 @@ public class AVMRepository
|
||||
return fgInstance;
|
||||
}
|
||||
|
||||
public void setMetaDataFrom(String path, AVMNodeDescriptor from)
|
||||
{
|
||||
fLookupCount.set(1);
|
||||
String [] pathParts = SplitPath(path);
|
||||
AVMStore store = getAVMStoreByName(pathParts[0]);
|
||||
if (store == null)
|
||||
{
|
||||
throw new AVMNotFoundException("Store not found: " + pathParts[0]);
|
||||
}
|
||||
AVMNode fromNode = AVMContext.fgInstance.fAVMNodeDAO.getByID(from.getId());
|
||||
if (fromNode == null)
|
||||
{
|
||||
throw new AVMNotFoundException("Node not found: " + from.getPath());
|
||||
}
|
||||
store.setMetaDataFrom(pathParts[1], fromNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an aspect to an AVM Node.
|
||||
* @param path The path to the node.
|
||||
|
@@ -1056,6 +1056,20 @@ public class AVMServiceImpl implements AVMService
|
||||
fAVMRepository.setContentData(path, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all metadata on a node from another node. Aspects, properties, ACLs.
|
||||
* @param path The path to the node to set.
|
||||
* @param from The descriptor for the node to get metadata from.
|
||||
*/
|
||||
public void setMetaDataFrom(String path, AVMNodeDescriptor from)
|
||||
{
|
||||
if (path == null || from == null)
|
||||
{
|
||||
throw new AVMBadArgumentException("Illegal null argument.");
|
||||
}
|
||||
fAVMRepository.setMetaDataFrom(path, from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an aspect to an AVM node.
|
||||
* @param path The path to the node.
|
||||
|
@@ -359,6 +359,13 @@ public interface AVMStore
|
||||
*/
|
||||
public void setContentData(String path, ContentData data);
|
||||
|
||||
/**
|
||||
* Set meta data, aspects, properties, acls, from another node.
|
||||
* @param path The path to the node to set metadata on.
|
||||
* @param from The node to get the metadata from.
|
||||
*/
|
||||
public void setMetaDataFrom(String path, AVMNode from);
|
||||
|
||||
/**
|
||||
* Add an aspect to a node.
|
||||
* @param path The path to the node.
|
||||
|
@@ -194,7 +194,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
// a LayeredDirectoryNode that gets its indirection from
|
||||
// its parent.
|
||||
{
|
||||
newDir = new LayeredDirectoryNodeImpl((String)null, this);
|
||||
newDir = new LayeredDirectoryNodeImpl((String)null, this, null);
|
||||
((LayeredDirectoryNodeImpl)newDir).setPrimaryIndirection(false);
|
||||
((LayeredDirectoryNodeImpl)newDir).setLayerID(lPath.getTopLayer().getLayerID());
|
||||
}
|
||||
@@ -227,7 +227,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMExistsException("Child exists: " + name);
|
||||
}
|
||||
LayeredDirectoryNode newDir =
|
||||
new LayeredDirectoryNodeImpl(srcPath, this);
|
||||
new LayeredDirectoryNodeImpl(srcPath, this, null);
|
||||
if (lPath.isLayered())
|
||||
{
|
||||
// When a layered directory is made inside of a layered context,
|
||||
@@ -1142,7 +1142,23 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
}
|
||||
((FileNode)node).setContentData(data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set meta data, aspects, properties, acls, from another node.
|
||||
* @param path The path to the node to set metadata on.
|
||||
* @param from The node to get the metadata from.
|
||||
*/
|
||||
public void setMetaDataFrom(String path, AVMNode from)
|
||||
{
|
||||
Lookup lPath = lookup(-1, path, true, false);
|
||||
if (lPath == null)
|
||||
{
|
||||
throw new AVMNotFoundException("Path not found: " + path);
|
||||
}
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
node.copyMetaDataFrom(from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an aspect to a node.
|
||||
* @param path The path to the node.
|
||||
|
@@ -24,6 +24,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
||||
@@ -32,6 +33,7 @@ import org.alfresco.service.cmr.avm.AVMWrongTypeException;
|
||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncException;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
@@ -412,7 +414,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
||||
*/
|
||||
private void linkIn(String parentPath, String name, AVMNodeDescriptor toLink, boolean removeFirst)
|
||||
{
|
||||
mkdirs(parentPath);
|
||||
mkdirs(parentPath, AVMNodeConverter.SplitBase(toLink.getPath())[0]);
|
||||
if (removeFirst)
|
||||
{
|
||||
fAVMService.removeNode(parentPath, name);
|
||||
@@ -435,6 +437,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
||||
{
|
||||
fAVMService.createDirectory(parentPath, name);
|
||||
String newParentPath = AVMNodeConverter.ExtendAVMPath(parentPath, name);
|
||||
fAVMService.setMetaDataFrom(newParentPath, toCopy);
|
||||
AVMNodeDescriptor parentDesc = fAVMService.lookup(-1, newParentPath, true);
|
||||
Map<String, AVMNodeDescriptor> children =
|
||||
fAVMService.getDirectoryListing(toCopy, true);
|
||||
@@ -461,6 +464,7 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
||||
// Otherwise make a directory in the target parent, and recursiveCopy all the source
|
||||
// children into it.
|
||||
AVMNodeDescriptor newParentDesc = fAVMRepository.createDirectory(parent, name);
|
||||
fAVMService.setMetaDataFrom(newParentDesc.getPath(), toCopy);
|
||||
Map<String, AVMNodeDescriptor> children =
|
||||
fAVMService.getDirectoryListing(toCopy, true);
|
||||
for (Map.Entry<String, AVMNodeDescriptor> entry : children.entrySet())
|
||||
@@ -692,8 +696,9 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
||||
/**
|
||||
* Make sure this entire directory path exists.
|
||||
* @param path
|
||||
* @param sourcePath
|
||||
*/
|
||||
private void mkdirs(String path)
|
||||
private void mkdirs(String path, String sourcePath)
|
||||
{
|
||||
if (fAVMService.lookup(-1, path) != null)
|
||||
{
|
||||
@@ -706,7 +711,8 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
||||
// Something else is going on.
|
||||
throw new AVMSyncException("No corresponding destination path: " + path);
|
||||
}
|
||||
mkdirs(pathParts[0]);
|
||||
mkdirs(pathParts[0], AVMNodeConverter.SplitBase(sourcePath)[0]);
|
||||
fAVMService.createDirectory(pathParts[0], pathParts[1]);
|
||||
fAVMService.setMetaDataFrom(path, fAVMService.lookup(-1, sourcePath));
|
||||
}
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
* @param indirection The indirection path to set.
|
||||
* @param store The store that owns this node.
|
||||
*/
|
||||
public LayeredDirectoryNodeImpl(String indirection, AVMStore store)
|
||||
public LayeredDirectoryNodeImpl(String indirection, AVMStore store, AVMNode toCopy)
|
||||
{
|
||||
super(store.getAVMRepository().issueID(), store);
|
||||
fLayerID = -1;
|
||||
@@ -83,6 +83,12 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
fOpacity = false;
|
||||
AVMContext.fgInstance.fAVMNodeDAO.save(this);
|
||||
AVMContext.fgInstance.fAVMNodeDAO.flush();
|
||||
if (toCopy != null)
|
||||
{
|
||||
copyProperties(toCopy);
|
||||
copyACLs(toCopy);
|
||||
copyAspects(toCopy);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,7 +259,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
// layer. The following creates a node that will inherit its
|
||||
// indirection from its parent.
|
||||
newMe = new LayeredDirectoryNodeImpl((String)null,
|
||||
store);
|
||||
store, this);
|
||||
newMe.setPrimaryIndirection(false);
|
||||
newMe.setLayerID(lPath.getTopLayer().getLayerID());
|
||||
}
|
||||
|
@@ -674,6 +674,13 @@ public interface AVMService
|
||||
*/
|
||||
public void setContentData(String path, ContentData data);
|
||||
|
||||
/**
|
||||
* Set all metadata on a node from another node. Aspects, properties, ACLs.
|
||||
* @param path The path to the node to set.
|
||||
* @param from The descriptor for the node to get metadata from.
|
||||
*/
|
||||
public void setMetaDataFrom(String path, AVMNodeDescriptor from);
|
||||
|
||||
/**
|
||||
* Add an aspect to an AVM node.
|
||||
* @param path The path to the node.
|
||||
|
Reference in New Issue
Block a user