mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Change to mapping of AVM aspects.
This seems to make indexing a bit quicker, and at least doesn't make other things slower. Bulk import now just sucks; it used to be an order of magnitude suckier. 98% of that is due to Andy's recent changes. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6103 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -72,4 +73,10 @@ public interface AVMAspectNameDAO
|
||||
* @return Whether the aspect is there.
|
||||
*/
|
||||
public boolean exists(AVMNode node, QName name);
|
||||
|
||||
/**
|
||||
* Get an iterator over all aspect instances.
|
||||
* @return
|
||||
*/
|
||||
public Iterator<AVMAspectName> iterator();
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
@@ -226,7 +227,7 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.avm.AVMService#getAspects(int, java.lang.String)
|
||||
*/
|
||||
public List<QName> getAspects(int version, String path)
|
||||
public Set<QName> getAspects(int version, String path)
|
||||
{
|
||||
return fService.getAspects(version, path);
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
@@ -228,4 +229,10 @@ public interface AVMNode
|
||||
* @param guid
|
||||
*/
|
||||
public void setGuid(String guid);
|
||||
|
||||
/**
|
||||
* Get the Aspects that this node has.
|
||||
* @return A Set of Aspects names.
|
||||
*/
|
||||
public Set<QName> getAspects();
|
||||
}
|
||||
|
@@ -25,8 +25,10 @@ package org.alfresco.repo.avm;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.avm.util.RawServices;
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
@@ -83,11 +85,17 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
*/
|
||||
private String fGUID;
|
||||
|
||||
/**
|
||||
* The Aspects that belong to this node.
|
||||
*/
|
||||
private Set<QName> fAspects;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
protected AVMNodeImpl()
|
||||
{
|
||||
fAspects = new HashSet<QName>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,6 +106,7 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
protected AVMNodeImpl(long id,
|
||||
AVMStore store)
|
||||
{
|
||||
fAspects = new HashSet<QName>();
|
||||
fID = id;
|
||||
fVersionID = -1;
|
||||
fIsRoot = false;
|
||||
@@ -351,16 +360,7 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
*/
|
||||
protected void copyAspects(AVMNode other)
|
||||
{
|
||||
List<AVMAspectName> aspects =
|
||||
AVMDAOs.Instance().fAVMAspectNameDAO.get(other);
|
||||
for (AVMAspectName name : aspects)
|
||||
{
|
||||
AVMAspectName newName =
|
||||
new AVMAspectNameImpl();
|
||||
newName.setName(name.getName());
|
||||
newName.setNode(this);
|
||||
AVMDAOs.Instance().fAVMAspectNameDAO.save(newName);
|
||||
}
|
||||
fAspects = new HashSet<QName>(other.getAspects());
|
||||
}
|
||||
|
||||
protected void copyACLs(AVMNode other)
|
||||
@@ -538,4 +538,21 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
{
|
||||
fGUID = guid;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.AVMNode#getAspects()
|
||||
*/
|
||||
public Set<QName> getAspects()
|
||||
{
|
||||
return fAspects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the aspects on this node.
|
||||
* @param aspects
|
||||
*/
|
||||
public void setAspects(Set<QName> aspects)
|
||||
{
|
||||
fAspects = aspects;
|
||||
}
|
||||
}
|
||||
|
@@ -742,8 +742,7 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
}
|
||||
try
|
||||
{
|
||||
List<QName> aspects = fAVMService.getAspects(version, path);
|
||||
for (QName name : aspects)
|
||||
for (QName name : fAVMService.getAspects(version, path))
|
||||
{
|
||||
result.add(name);
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ import java.io.OutputStream;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
@@ -476,7 +477,7 @@ public class AVMRemoteLocal implements AVMRemote
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.remote.AVMRemote#getAspects(int, java.lang.String)
|
||||
*/
|
||||
public List<QName> getAspects(int version, String path)
|
||||
public Set<QName> getAspects(int version, String path)
|
||||
{
|
||||
return fService.getAspects(version, path);
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
@@ -1013,7 +1014,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.remote.AVMRemoteTransport#getAspects(java.lang.String, int, java.lang.String)
|
||||
*/
|
||||
public List<QName> getAspects(String ticket, int version, String path)
|
||||
public Set<QName> getAspects(String ticket, int version, String path)
|
||||
{
|
||||
fAuthService.validate(ticket);
|
||||
return fAVMService.getAspects(version, path);
|
||||
|
@@ -31,6 +31,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
@@ -2260,7 +2261,7 @@ public class AVMRepository
|
||||
* @param path The path to the node.
|
||||
* @return A List of the QNames of the Aspects.
|
||||
*/
|
||||
public List<QName> getAspects(int version, String path)
|
||||
public Set<QName> getAspects(int version, String path)
|
||||
{
|
||||
fLookupCount.set(1);
|
||||
try
|
||||
|
@@ -31,6 +31,7 @@ import java.io.OutputStream;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
@@ -1285,7 +1286,7 @@ public class AVMServiceImpl implements AVMService
|
||||
* @param path The path to the node.
|
||||
* @return A List of the QNames of the aspects.
|
||||
*/
|
||||
public List<QName> getAspects(int version, String path)
|
||||
public Set<QName> getAspects(int version, String path)
|
||||
{
|
||||
if (path == null)
|
||||
{
|
||||
@@ -1424,7 +1425,7 @@ public class AVMServiceImpl implements AVMService
|
||||
// In either case copy properties, aspects, and acls.
|
||||
Map<QName, PropertyValue> props = getNodeProperties(version, desc.getPath());
|
||||
setNodeProperties(newPath, props);
|
||||
List<QName> aspects = getAspects(version, desc.getPath());
|
||||
Set<QName> aspects = getAspects(version, desc.getPath());
|
||||
for (QName aspect : aspects)
|
||||
{
|
||||
addAspect(newPath, aspect);
|
||||
|
@@ -101,6 +101,105 @@ import org.alfresco.util.Pair;
|
||||
*/
|
||||
public class AVMServiceTest extends AVMServiceTestBase
|
||||
{
|
||||
/**
|
||||
* Test properties.
|
||||
*/
|
||||
public void testProperties()
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef("main");
|
||||
SearchService searchService = fIndexerAndSearcher.getSearcher(storeRef, true);
|
||||
ResultSet results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}SillyProperty")+":\"Silly\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
|
||||
QName name = QName.createQName("silly.uri", "SillyProperty");
|
||||
PropertyValue value = new PropertyValue(name, "Silly Property Value");
|
||||
fService.setNodeProperty("main:/a/b/c/foo", name, value);
|
||||
fService.createSnapshot("main", null, null);
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}SillyProperty")+":\"Silly\"");
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
PropertyValue returned = fService.getNodeProperty(-1, "main:/a/b/c/foo", name);
|
||||
assertEquals(value.toString(), returned.toString());
|
||||
Map<QName, PropertyValue> props = fService.getNodeProperties(-1, "main:/a/b/c/foo");
|
||||
assertEquals(1, props.size());
|
||||
assertEquals(value.toString(), props.get(name).toString());
|
||||
|
||||
|
||||
props = new HashMap<QName, PropertyValue>();
|
||||
QName n1 = QName.createQName("silly.uri", "Prop1");
|
||||
PropertyValue p1 = new PropertyValue(null, new Date(System.currentTimeMillis()));
|
||||
props.put(n1, p1);
|
||||
QName n2 = QName.createQName("silly.uri", "Prop2");
|
||||
PropertyValue p2 = new PropertyValue(null, "A String Property.");
|
||||
props.put(n2, p2);
|
||||
QName n3 = QName.createQName("silly.uri", "Prop3");
|
||||
PropertyValue p3 = new PropertyValue(null, 42);
|
||||
props.put(n3, p3);
|
||||
fService.setNodeProperties("main:/a/b/c/bar", props);
|
||||
fService.createSnapshot("main", null, null);
|
||||
props = fService.getNodeProperties(-1, "main:/a/b/c/bar");
|
||||
assertEquals(3, props.size());
|
||||
assertEquals(p1.toString(), props.get(n1).toString());
|
||||
assertEquals(p2.toString(), props.get(n2).toString());
|
||||
assertEquals(p3.toString(), props.get(n3).toString());
|
||||
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop1")+":\"" + props.get(n1).getStringValue() +"\"");
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop2")+":\"" + props.get(n2).getStringValue() +"\"");
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
fService.deleteNodeProperty("main:/a/b/c/bar", n1);
|
||||
fService.createSnapshot("main", null, null);
|
||||
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop1")+":\"" + props.get(n1).getStringValue() +"\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop2")+":\"" + props.get(n2).getStringValue() +"\"");
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
props = fService.getNodeProperties(-1, "main:/a/b/c/bar");
|
||||
assertEquals(2, props.size());
|
||||
assertEquals(p2.toString(), props.get(n2).toString());
|
||||
assertEquals(p3.toString(), props.get(n3).toString());
|
||||
fService.deleteNodeProperties("main:/a/b/c/bar");
|
||||
fService.createSnapshot("main", null, null);
|
||||
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop1")+":\"" + p1.getStringValue() +"\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop2")+":\"" + props.get(n2).getStringValue() +"\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
|
||||
props = fService.getNodeProperties(-1, "main:/a/b/c/bar");
|
||||
assertEquals(0, props.size());
|
||||
fService.removeNode("main:/a/b/c/foo");
|
||||
fService.setNodeProperty("main:/a/b/c/foo", QName.createQName("silly.uri", "Prop1"), new PropertyValue(
|
||||
null, 42));
|
||||
assertEquals(1, fService.getNodeProperties(-1, "main:/a/b/c/foo").size());
|
||||
fService.createSnapshot("main", null, null);
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop1")+":\"" + p1.getStringValue() +"\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop2")+":\"" + p2.getStringValue() +"\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getStoreVersionRootPaths().
|
||||
*/
|
||||
@@ -5029,103 +5128,6 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test properties.
|
||||
*/
|
||||
public void testProperties()
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef("main");
|
||||
SearchService searchService = fIndexerAndSearcher.getSearcher(storeRef, true);
|
||||
ResultSet results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}SillyProperty")+":\"Silly\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
|
||||
QName name = QName.createQName("silly.uri", "SillyProperty");
|
||||
PropertyValue value = new PropertyValue(name, "Silly Property Value");
|
||||
fService.setNodeProperty("main:/a/b/c/foo", name, value);
|
||||
fService.createSnapshot("main", null, null);
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}SillyProperty")+":\"Silly\"");
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
PropertyValue returned = fService.getNodeProperty(-1, "main:/a/b/c/foo", name);
|
||||
assertEquals(value.toString(), returned.toString());
|
||||
Map<QName, PropertyValue> props = fService.getNodeProperties(-1, "main:/a/b/c/foo");
|
||||
assertEquals(1, props.size());
|
||||
assertEquals(value.toString(), props.get(name).toString());
|
||||
|
||||
|
||||
props = new HashMap<QName, PropertyValue>();
|
||||
QName n1 = QName.createQName("silly.uri", "Prop1");
|
||||
PropertyValue p1 = new PropertyValue(null, new Date(System.currentTimeMillis()));
|
||||
props.put(n1, p1);
|
||||
QName n2 = QName.createQName("silly.uri", "Prop2");
|
||||
PropertyValue p2 = new PropertyValue(null, "A String Property.");
|
||||
props.put(n2, p2);
|
||||
QName n3 = QName.createQName("silly.uri", "Prop3");
|
||||
PropertyValue p3 = new PropertyValue(null, 42);
|
||||
props.put(n3, p3);
|
||||
fService.setNodeProperties("main:/a/b/c/bar", props);
|
||||
fService.createSnapshot("main", null, null);
|
||||
props = fService.getNodeProperties(-1, "main:/a/b/c/bar");
|
||||
assertEquals(3, props.size());
|
||||
assertEquals(p1.toString(), props.get(n1).toString());
|
||||
assertEquals(p2.toString(), props.get(n2).toString());
|
||||
assertEquals(p3.toString(), props.get(n3).toString());
|
||||
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop1")+":\"" + props.get(n1).getStringValue() +"\"");
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop2")+":\"" + props.get(n2).getStringValue() +"\"");
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
fService.deleteNodeProperty("main:/a/b/c/bar", n1);
|
||||
fService.createSnapshot("main", null, null);
|
||||
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop1")+":\"" + props.get(n1).getStringValue() +"\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop2")+":\"" + props.get(n2).getStringValue() +"\"");
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
props = fService.getNodeProperties(-1, "main:/a/b/c/bar");
|
||||
assertEquals(2, props.size());
|
||||
assertEquals(p2.toString(), props.get(n2).toString());
|
||||
assertEquals(p3.toString(), props.get(n3).toString());
|
||||
fService.deleteNodeProperties("main:/a/b/c/bar");
|
||||
fService.createSnapshot("main", null, null);
|
||||
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop1")+":\"" + props.get(n1).getStringValue() +"\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop2")+":\"" + props.get(n2).getStringValue() +"\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
|
||||
props = fService.getNodeProperties(-1, "main:/a/b/c/bar");
|
||||
assertEquals(0, props.size());
|
||||
fService.removeNode("main:/a/b/c/foo");
|
||||
fService.setNodeProperty("main:/a/b/c/foo", QName.createQName("silly.uri", "Prop1"), new PropertyValue(
|
||||
null, 42));
|
||||
assertEquals(1, fService.getNodeProperties(-1, "main:/a/b/c/foo").size());
|
||||
fService.createSnapshot("main", null, null);
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop1")+":\"" + props.get(n1).getStringValue() +"\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
results = searchService.query(storeRef, "lucene", LuceneQueryParser.escape("@{silly.uri}Prop2")+":\"" + props.get(n2).getStringValue() +"\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test properties on stores.
|
||||
@@ -5197,7 +5199,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
|
||||
fService.removeNode("main:/a/b/c/bar");
|
||||
fService.addAspect("main:/a/b/c/bar", ContentModel.ASPECT_TITLED);
|
||||
List<QName> names = fService.getAspects(-1, "main:/a/b/c/foo");
|
||||
Set<QName> names = fService.getAspects(-1, "main:/a/b/c/foo");
|
||||
assertEquals(2, names.size());
|
||||
assertTrue(fService.hasAspect(-1, "main:/a/b/c/foo", ContentModel.ASPECT_TITLED));
|
||||
assertFalse(fService.hasAspect(-1, "main:/a/b/c/foo", ContentModel.ASPECT_AUTHOR));
|
||||
|
@@ -28,6 +28,7 @@ import java.io.OutputStream;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
@@ -422,7 +423,7 @@ public interface AVMStore
|
||||
* @param path The path to the node.
|
||||
* @return A List of the QNames of the aspects.
|
||||
*/
|
||||
public List<QName> getAspects(int version, String path);
|
||||
public Set<QName> getAspects(int version, String path);
|
||||
|
||||
/**
|
||||
* Remove an aspect and all its properties from a node.
|
||||
|
@@ -32,12 +32,12 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.WCMModel;
|
||||
import org.alfresco.repo.avm.AVMAspectName;
|
||||
import org.alfresco.repo.avm.util.RawServices;
|
||||
import org.alfresco.repo.avm.util.SimplePath;
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
@@ -1289,16 +1289,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMNotFoundException("Path " + path + " not found.");
|
||||
}
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
if (AVMDAOs.Instance().fAVMAspectNameDAO.exists(node, aspectName))
|
||||
{
|
||||
throw new AVMExistsException("Aspect exists.");
|
||||
}
|
||||
AVMAspectName newName =
|
||||
new AVMAspectNameImpl();
|
||||
newName.setNode(node);
|
||||
newName.setName(aspectName);
|
||||
node.getAspects().add(aspectName);
|
||||
node.setGuid(GUID.generate());
|
||||
AVMDAOs.Instance().fAVMAspectNameDAO.save(newName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1307,7 +1299,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
* @param path The path to the node.
|
||||
* @return A List of the QNames of the aspects.
|
||||
*/
|
||||
public List<QName> getAspects(int version, String path)
|
||||
public Set<QName> getAspects(int version, String path)
|
||||
{
|
||||
Lookup lPath = lookup(version, path, false, true);
|
||||
if (lPath == null)
|
||||
@@ -1315,14 +1307,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMNotFoundException("Path " + path + " not found.");
|
||||
}
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
List<AVMAspectName> names =
|
||||
AVMDAOs.Instance().fAVMAspectNameDAO.get(node);
|
||||
ArrayList<QName> result = new ArrayList<QName>();
|
||||
for (AVMAspectName name : names)
|
||||
{
|
||||
result.add(name.getName());
|
||||
}
|
||||
return result;
|
||||
return node.getAspects();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1338,7 +1323,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMNotFoundException("Path " + path + " not found.");
|
||||
}
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
AVMDAOs.Instance().fAVMAspectNameDAO.delete(node, aspectName);
|
||||
node.getAspects().remove(aspectName);
|
||||
AspectDefinition def = RawServices.Instance().getDictionaryService().getAspect(aspectName);
|
||||
Map<QName, PropertyDefinition> properties =
|
||||
def.getProperties();
|
||||
@@ -1364,7 +1349,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMNotFoundException("Path " + path + " not found.");
|
||||
}
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
return AVMDAOs.Instance().fAVMAspectNameDAO.exists(node, aspectName);
|
||||
return node.getAspects().contains(aspectName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1447,14 +1432,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
dir.putChild(name, toLink);
|
||||
toLink.changeAncestor(child);
|
||||
toLink.setVersionID(child.getVersionID() + 1);
|
||||
if (AVMDAOs.Instance().fAVMAspectNameDAO.exists(toLink, WCMModel.ASPECT_REVERTED))
|
||||
{
|
||||
AVMDAOs.Instance().fAVMAspectNameDAO.delete(toLink, WCMModel.ASPECT_REVERTED);
|
||||
}
|
||||
AVMAspectName aspect = new AVMAspectNameImpl();
|
||||
aspect.setNode(toLink);
|
||||
aspect.setName(WCMModel.ASPECT_REVERTED);
|
||||
AVMDAOs.Instance().fAVMAspectNameDAO.save(aspect);
|
||||
// TODO This really shouldn't be here. Leaking layers.
|
||||
toLink.getAspects().add(WCMModel.ASPECT_REVERTED);
|
||||
PropertyValue value = new PropertyValue(null, toRevertTo.getId());
|
||||
toLink.setProperty(WCMModel.PROP_REVERTED_ID, value);
|
||||
}
|
||||
|
@@ -109,7 +109,7 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
|
||||
getBasicAttributes(),
|
||||
getContentData(lPath),
|
||||
indirect.getProperties(),
|
||||
AVMDAOs.Instance().fAVMAspectNameDAO.get(indirect),
|
||||
indirect.getAspects(),
|
||||
indirect.getAcl(),
|
||||
getVersionID());
|
||||
newMe.setAncestor(this);
|
||||
|
@@ -308,7 +308,7 @@ public class OrphanReaper
|
||||
// Get rid of all properties belonging to this node.
|
||||
AVMDAOs.Instance().fAVMNodePropertyDAO.deleteAll(node);
|
||||
// Get rid of all aspects belonging to this node.
|
||||
AVMDAOs.Instance().fAVMAspectNameDAO.delete(node);
|
||||
// AVMDAOs.Instance().fAVMAspectNameDAO.delete(node);
|
||||
// Get rid of ACL.
|
||||
DbAccessControlList acl = node.getAcl();
|
||||
node.setAcl(null);
|
||||
|
@@ -23,8 +23,10 @@
|
||||
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.avm.util.RawServices;
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
@@ -117,7 +119,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
|
||||
BasicAttributes attrs,
|
||||
ContentData content,
|
||||
Map<QName, PropertyValue> props,
|
||||
List<AVMAspectName> aspects,
|
||||
Set<QName> aspects,
|
||||
DbAccessControlList acl,
|
||||
int versionID)
|
||||
{
|
||||
@@ -128,14 +130,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
|
||||
AVMDAOs.Instance().fAVMNodeDAO.save(this);
|
||||
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
||||
setProperties(props);
|
||||
for (AVMAspectName name : aspects)
|
||||
{
|
||||
AVMAspectName newName =
|
||||
new AVMAspectNameImpl();
|
||||
newName.setName(name.getName());
|
||||
newName.setNode(this);
|
||||
AVMDAOs.Instance().fAVMAspectNameDAO.save(newName);
|
||||
}
|
||||
setAspects(new HashSet<QName>(aspects));
|
||||
if (acl != null)
|
||||
{
|
||||
setAcl(acl.getCopy());
|
||||
|
@@ -46,6 +46,11 @@
|
||||
<!-- ACL -->
|
||||
<many-to-one name="acl" column="acl_id" foreign-key="fk_avm_n_acl"
|
||||
class="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl"/>
|
||||
<set name="aspects" fetch="join" lazy="false" table="avm_aspects_new" cascade="all" optimistic-lock="true">
|
||||
<cache usage="read-write"/>
|
||||
<key column="id"/>
|
||||
<element type="QName" not-null="true" column="name" length="200"/>
|
||||
</set>
|
||||
<!-- Deleted nodes -->
|
||||
<subclass name="DeletedNodeImpl"
|
||||
proxy="DeletedNode"
|
||||
|
@@ -23,6 +23,7 @@
|
||||
|
||||
package org.alfresco.repo.avm.hibernate;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.avm.AVMAspectName;
|
||||
@@ -113,4 +114,15 @@ public class AVMAspectNameDAOHibernate extends HibernateDaoSupport
|
||||
query.setParameter("name", name);
|
||||
return query.uniqueResult() != null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.AVMAspectNameDAO#iterator()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Iterator<AVMAspectName> iterator()
|
||||
{
|
||||
Query query =
|
||||
getSession().createQuery("from AVMAspectNameImpl aa");
|
||||
return (Iterator<AVMAspectName>)query.iterate();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user