mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Expose database unique node ID as a spoofed property. This can be used as an alternative to the UUID for local uniqueness.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3115 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -115,6 +115,10 @@
|
|||||||
<type>d:text</type>
|
<type>d:text</type>
|
||||||
<mandatory enforced="true">true</mandatory>
|
<mandatory enforced="true">true</mandatory>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sys:node-dbid">
|
||||||
|
<type>d:long</type>
|
||||||
|
<mandatory enforced="true">true</mandatory>
|
||||||
|
</property>
|
||||||
</properties>
|
</properties>
|
||||||
</aspect>
|
</aspect>
|
||||||
|
|
||||||
|
@@ -35,6 +35,7 @@ public interface ContentModel
|
|||||||
static final QName PROP_STORE_PROTOCOL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store-protocol");
|
static final QName PROP_STORE_PROTOCOL = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store-protocol");
|
||||||
static final QName PROP_STORE_IDENTIFIER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store-identifier");
|
static final QName PROP_STORE_IDENTIFIER = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store-identifier");
|
||||||
static final QName PROP_NODE_UUID = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-uuid");
|
static final QName PROP_NODE_UUID = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-uuid");
|
||||||
|
static final QName PROP_NODE_DBID = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-dbid");
|
||||||
|
|
||||||
// tag for incomplete nodes
|
// tag for incomplete nodes
|
||||||
static final QName ASPECT_INCOMPLETE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "incomplete");
|
static final QName ASPECT_INCOMPLETE = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "incomplete");
|
||||||
|
@@ -530,13 +530,15 @@ public abstract class AbstractNodeServiceImpl implements NodeService
|
|||||||
* is always present as a property on a node.
|
* is always present as a property on a node.
|
||||||
*
|
*
|
||||||
* @param nodeRef the node reference containing the values required
|
* @param nodeRef the node reference containing the values required
|
||||||
|
* @param nodeDbId the database-assigned ID
|
||||||
* @param properties the node properties
|
* @param properties the node properties
|
||||||
*/
|
*/
|
||||||
protected void addReferencableProperties(NodeRef nodeRef, Map<QName, Serializable> properties)
|
protected void addReferencableProperties(NodeRef nodeRef, Long nodeDbId, Map<QName, Serializable> properties)
|
||||||
{
|
{
|
||||||
properties.put(ContentModel.PROP_STORE_PROTOCOL, nodeRef.getStoreRef().getProtocol());
|
properties.put(ContentModel.PROP_STORE_PROTOCOL, nodeRef.getStoreRef().getProtocol());
|
||||||
properties.put(ContentModel.PROP_STORE_IDENTIFIER, nodeRef.getStoreRef().getIdentifier());
|
properties.put(ContentModel.PROP_STORE_IDENTIFIER, nodeRef.getStoreRef().getIdentifier());
|
||||||
properties.put(ContentModel.PROP_NODE_UUID, nodeRef.getId());
|
properties.put(ContentModel.PROP_NODE_UUID, nodeRef.getId());
|
||||||
|
properties.put(ContentModel.PROP_NODE_DBID, nodeDbId);
|
||||||
// add the ID as the name, if required
|
// add the ID as the name, if required
|
||||||
if (properties.get(ContentModel.PROP_NAME) == null)
|
if (properties.get(ContentModel.PROP_NAME) == null)
|
||||||
{
|
{
|
||||||
|
@@ -1028,10 +1028,12 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
|||||||
Serializable wsProtocol = nodeService.getProperty(rootNodeRef, ContentModel.PROP_STORE_PROTOCOL);
|
Serializable wsProtocol = nodeService.getProperty(rootNodeRef, ContentModel.PROP_STORE_PROTOCOL);
|
||||||
Serializable wsIdentifier = nodeService.getProperty(rootNodeRef, ContentModel.PROP_STORE_IDENTIFIER);
|
Serializable wsIdentifier = nodeService.getProperty(rootNodeRef, ContentModel.PROP_STORE_IDENTIFIER);
|
||||||
Serializable nodeUuid = nodeService.getProperty(rootNodeRef, ContentModel.PROP_NODE_UUID);
|
Serializable nodeUuid = nodeService.getProperty(rootNodeRef, ContentModel.PROP_NODE_UUID);
|
||||||
|
Serializable nodeDbId = nodeService.getProperty(rootNodeRef, ContentModel.PROP_NODE_DBID);
|
||||||
|
|
||||||
assertNotNull("Workspace Protocol property not present", wsProtocol);
|
assertNotNull("Workspace Protocol property not present", wsProtocol);
|
||||||
assertNotNull("Workspace Identifier property not present", wsIdentifier);
|
assertNotNull("Workspace Identifier property not present", wsIdentifier);
|
||||||
assertNotNull("Node UUID property not present", nodeUuid);
|
assertNotNull("Node UUID property not present", nodeUuid);
|
||||||
|
assertNotNull("Node DB ID property not present", nodeDbId);
|
||||||
|
|
||||||
assertEquals("Workspace Protocol property incorrect", rootNodeRef.getStoreRef().getProtocol(), wsProtocol);
|
assertEquals("Workspace Protocol property incorrect", rootNodeRef.getStoreRef().getProtocol(), wsProtocol);
|
||||||
assertEquals("Workspace Identifier property incorrect", rootNodeRef.getStoreRef().getIdentifier(), wsIdentifier);
|
assertEquals("Workspace Identifier property incorrect", rootNodeRef.getStoreRef().getIdentifier(), wsIdentifier);
|
||||||
@@ -1042,6 +1044,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
|||||||
assertTrue("Workspace Protocol property not present in map", properties.containsKey(ContentModel.PROP_STORE_PROTOCOL));
|
assertTrue("Workspace Protocol property not present in map", properties.containsKey(ContentModel.PROP_STORE_PROTOCOL));
|
||||||
assertTrue("Workspace Identifier property not present in map", properties.containsKey(ContentModel.PROP_STORE_IDENTIFIER));
|
assertTrue("Workspace Identifier property not present in map", properties.containsKey(ContentModel.PROP_STORE_IDENTIFIER));
|
||||||
assertTrue("Node UUID property not present in map", properties.containsKey(ContentModel.PROP_NODE_UUID));
|
assertTrue("Node UUID property not present in map", properties.containsKey(ContentModel.PROP_NODE_UUID));
|
||||||
|
assertTrue("Node DB ID property not present in map", properties.containsKey(ContentModel.PROP_NODE_DBID));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetParentAssocs() throws Exception
|
public void testGetParentAssocs() throws Exception
|
||||||
|
@@ -770,7 +770,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
|||||||
ret.put(propertyQName, value);
|
ret.put(propertyQName, value);
|
||||||
}
|
}
|
||||||
// spoof referencable properties
|
// spoof referencable properties
|
||||||
addReferencableProperties(nodeRef, ret);
|
addReferencableProperties(nodeRef, node.getId(), ret);
|
||||||
// done
|
// done
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -793,6 +793,12 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
|||||||
|
|
||||||
// get the property from the node
|
// get the property from the node
|
||||||
Node node = getNodeNotNull(nodeRef);
|
Node node = getNodeNotNull(nodeRef);
|
||||||
|
|
||||||
|
if (qname.equals(ContentModel.PROP_NODE_DBID))
|
||||||
|
{
|
||||||
|
return node.getId();
|
||||||
|
}
|
||||||
|
|
||||||
Map<QName, PropertyValue> properties = node.getProperties();
|
Map<QName, PropertyValue> properties = node.getProperties();
|
||||||
PropertyValue propertyValue = properties.get(qname);
|
PropertyValue propertyValue = properties.get(qname);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user