Merged 5.1-MNT1 (5.1.0) to HEAD (5.1)

115460 adavis: Merged 5.1.N (5.1.1) to 5.1-MNT1 (5.1.0)
      113727 amorarasu: Merged 5.0.N (5.0.3) to 5.1.N (5.1.1)
         113684 adavis: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.3) (PARTIAL MERGE)
            113603 cturlica: Merged DEV to V4.2-BUG-FIX (4.2.6)
               113602 cturlica: MNT-14504: Cloud pull process not working after large delete


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@115670 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-10-30 00:10:30 +00:00
parent 9f4fdeb0e4
commit 4165e47032
10 changed files with 327 additions and 8 deletions

View File

@@ -3003,6 +3003,67 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
return results;
}
@Override
public Collection<Pair<Long, AssociationRef>> getTargetAssocsByPropertyValue(Long sourceNodeId, QName typeQName, QName propertyQName, Serializable propertyValue)
{
Long typeQNameId = null;
if (typeQName != null)
{
Pair<Long, QName> typeQNamePair = qnameDAO.getQName(typeQName);
if (typeQNamePair == null)
{
// No such QName
return Collections.emptyList();
}
typeQNameId = typeQNamePair.getFirst();
}
Long propertyQNameId = null;
NodePropertyValue nodeValue = null;
if (propertyQName != null)
{
Pair<Long, QName> propQNamePair = qnameDAO.getQName(propertyQName);
if (propQNamePair == null)
{
// No such QName
return Collections.emptyList();
}
propertyQNameId = propQNamePair.getFirst();
PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName);
nodeValue = nodePropertyHelper.makeNodePropertyValue(propertyDef, propertyValue);
if (nodeValue != null)
{
switch (nodeValue.getPersistedType())
{
case 1: // Boolean
case 3: // long
case 5: // double
case 6: // string
// no floats due to the range errors testing equality on a float.
break;
default:
throw new IllegalArgumentException("method not supported for persisted value type " + nodeValue.getPersistedType());
}
}
}
List<NodeAssocEntity> nodeAssocEntities = selectNodeAssocsBySourceAndPropertyValue(sourceNodeId, typeQNameId, propertyQNameId, nodeValue);
// Create custom result
List<Pair<Long, AssociationRef>> results = new ArrayList<Pair<Long, AssociationRef>>(nodeAssocEntities.size());
for (NodeAssocEntity nodeAssocEntity : nodeAssocEntities)
{
Long assocId = nodeAssocEntity.getId();
AssociationRef assocRef = nodeAssocEntity.getAssociationRef(qnameDAO);
results.add(new Pair<Long, AssociationRef>(assocId, assocRef));
}
return results;
}
@Override
public Pair<Long, AssociationRef> getNodeAssocOrNull(Long assocId)
{
@@ -4871,6 +4932,7 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
protected abstract int deleteNodeAssocs(List<Long> ids);
protected abstract List<NodeAssocEntity> selectNodeAssocs(Long nodeId);
protected abstract List<NodeAssocEntity> selectNodeAssocsBySource(Long sourceNodeId, Long typeQNameId);
protected abstract List<NodeAssocEntity> selectNodeAssocsBySourceAndPropertyValue(Long sourceNodeId, Long typeQNameId, Long propertyQNameId, NodePropertyValue nodeValue);
protected abstract List<NodeAssocEntity> selectNodeAssocsByTarget(Long targetNodeId, Long typeQNameId);
protected abstract NodeAssocEntity selectNodeAssocById(Long assocId);
protected abstract int selectNodeAssocMaxIndex(Long sourceNodeId, Long assocTypeQNameId);

View File

@@ -39,7 +39,11 @@ public class NodeAssocEntity
private Long typeQNameId;
private int assocIndex;
private List<Long> typeQNameIds;
// Supplemental query-related parameters
private Long propertyQNameId;
private NodePropertyValue propertyValue;
/**
* Required default constructor
*/
@@ -145,4 +149,25 @@ public class NodeAssocEntity
{
this.typeQNameIds = typeQNameIds;
}
public Long getPropertyQNameId()
{
return propertyQNameId;
}
public void setPropertyQNameId(Long propertyQNameId)
{
this.propertyQNameId = propertyQNameId;
}
public NodePropertyValue getPropertyValue()
{
return propertyValue;
}
public void setPropertyValue(NodePropertyValue propertyValue)
{
this.propertyValue = propertyValue;
}
}

View File

@@ -457,6 +457,17 @@ public interface NodeDAO extends NodeBulkLoader
*/
public Collection<Pair<Long, AssociationRef>> getTargetNodeAssocs(Long sourceNodeId, QName typeQName);
/**
* Get target associations by type of the association, property name and value.
*
* @param sourceNodeId the source of the association
* @param typeQName the type of the association (<tt>null</tt> allowed)
* @param propertyQName property QName (<tt>null</tt> allowed)
* @param propertyValue property value (<tt>null</tt> allowed only if the <b>propertyQName</b> is <tt>null</tt>)
* @return Returns all the node associations where the node is the <b>source</b>.
*/
public Collection<Pair<Long, AssociationRef>> getTargetAssocsByPropertyValue(Long sourceNodeId, QName typeQName, QName propertyQName, Serializable propertyValue);
/**
* @return Returns a specific node association with the given ID
* or <tt>null</tt> if it doesn't exist

View File

@@ -109,7 +109,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
private static final String DELETE_NODE_ASSOC = "alfresco.node.delete_NodeAssoc";
private static final String DELETE_NODE_ASSOCS = "alfresco.node.delete_NodeAssocs";
private static final String SELECT_NODE_ASSOCS = "alfresco.node.select_NodeAssocs";
private static final String SELECT_NODE_ASSOCS_BY_SOURCE = "alfresco.node.select_NodeAssocsBySource";
private static final String SELECT_NODE_ASSOCS_BY_SOURCE_AND_PROPERTY_VALUE = "alfresco.node.select_NodeAssocsBySourceAndPropertyValue";
private static final String SELECT_NODE_ASSOCS_BY_TARGET = "alfresco.node.select_NodeAssocsByTarget";
private static final String SELECT_NODE_ASSOC_BY_ID = "alfresco.node.select_NodeAssocById";
private static final String SELECT_NODE_ASSOCS_MAX_INDEX = "alfresco.node.select_NodeAssocsMaxId";
@@ -754,9 +754,15 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
return template.selectList(SELECT_NODE_ASSOCS, node);
}
@SuppressWarnings("unchecked")
@Override
protected List<NodeAssocEntity> selectNodeAssocsBySource(Long sourceNodeId, Long typeQNameId)
{
return selectNodeAssocsBySourceAndPropertyValue(sourceNodeId, typeQNameId, null, null);
}
@SuppressWarnings("unchecked")
@Override
protected List<NodeAssocEntity> selectNodeAssocsBySourceAndPropertyValue(Long sourceNodeId, Long typeQNameId, Long propertyQNameId, NodePropertyValue nodeValue)
{
NodeAssocEntity assoc = new NodeAssocEntity();
// Source
@@ -765,8 +771,12 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
assoc.setSourceNode(sourceNode);
// Type
assoc.setTypeQNameId(typeQNameId);
return template.selectList(SELECT_NODE_ASSOCS_BY_SOURCE, assoc);
// Property
assoc.setPropertyQNameId(propertyQNameId);
assoc.setPropertyValue(nodeValue);
return (List<NodeAssocEntity>) template.selectList(SELECT_NODE_ASSOCS_BY_SOURCE_AND_PROPERTY_VALUE, assoc);
}
@SuppressWarnings("unchecked")

View File

@@ -2238,6 +2238,41 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
return nodeAssocRefs;
}
@Override
public List<AssociationRef> getTargetAssocsByPropertyValue(NodeRef sourceRef, QNamePattern qnamePattern, QName propertyQName, Serializable propertyValue)
{
Pair<Long, NodeRef> sourceNodePair = getNodePairNotNull(sourceRef);
Long sourceNodeId = sourceNodePair.getFirst();
QName qnameFilter = null;
if (qnamePattern instanceof QName)
{
qnameFilter = (QName) qnamePattern;
}
// Check the QName is not one of the "special" system maintained ones.
if (getChildAssocsByPropertyValueBannedProps.contains(propertyQName))
{
throw new IllegalArgumentException(
"getTargetAssocsByPropertyValue does not allow search of system maintained properties: " + propertyQName);
}
Collection<Pair<Long, AssociationRef>> assocPairs = nodeDAO.getTargetAssocsByPropertyValue(sourceNodeId, qnameFilter, propertyQName, propertyValue);
List<AssociationRef> nodeAssocRefs = new ArrayList<AssociationRef>(assocPairs.size());
for (Pair<Long, AssociationRef> assocPair : assocPairs)
{
AssociationRef assocRef = assocPair.getSecond();
// check qname pattern, if not already filtered
if (qnameFilter == null && !qnamePattern.isMatch(assocRef.getTypeQName()))
{
continue; // the assoc name doesn't match the pattern given
}
nodeAssocRefs.add(assocRef);
}
// done
return nodeAssocRefs;
}
public List<AssociationRef> getSourceAssocs(NodeRef targetRef, QNamePattern qnamePattern)
{
Pair<Long, NodeRef> targetNodePair = getNodePairNotNull(targetRef);

View File

@@ -238,4 +238,57 @@ public class Node2ServiceImpl extends NodeServiceImpl implements NodeService, Ve
return result;
}
/**
* {@inheritDoc}
* <p>
*
* Implementation for version store v2
*/
@Override
public List<AssociationRef> getTargetAssocsByPropertyValue(NodeRef sourceRef, QNamePattern qnamePattern, QName propertyQName, Serializable propertyValue)
{
// If lightWeightVersionStore call default version store implementation.
if (sourceRef.getStoreRef().getIdentifier().equals(VersionModel.STORE_ID))
{
return super.getTargetAssocsByPropertyValue(sourceRef, qnamePattern, propertyQName, propertyValue);
}
// Get the assoc references from the version store.
List<ChildAssociationRef> childAssocRefs = this.dbNodeService.getChildAssocs(VersionUtil.convertNodeRef(sourceRef),
Version2Model.CHILD_QNAME_VERSIONED_ASSOCS, qnamePattern);
List<AssociationRef> result = new ArrayList<AssociationRef>(childAssocRefs.size());
for (ChildAssociationRef childAssocRef : childAssocRefs)
{
// Get the assoc reference.
NodeRef childRef = childAssocRef.getChildRef();
NodeRef referencedNode = (NodeRef) this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE);
if (this.dbNodeService.exists(referencedNode))
{
Long assocDbId = (Long) this.dbNodeService.getProperty(childRef, Version2Model.PROP_QNAME_ASSOC_DBID);
// Check if property type validation has to be done.
if (propertyQName != null)
{
Serializable propertyValueRetrieved = this.dbNodeService.getProperty(referencedNode, propertyQName);
// Check if property value has been retrieved (property
// exists) and is equal to the requested value.
if (propertyValueRetrieved == null || !propertyValueRetrieved.equals(propertyValue))
{
continue;
}
}
// Build an assoc ref to add to the returned list.
AssociationRef newAssocRef = new AssociationRef(assocDbId, sourceRef, childAssocRef.getQName(), referencedNode);
result.add(newAssocRef);
}
}
return result;
}
}

View File

@@ -69,6 +69,8 @@ public class NodeServiceImpl implements NodeService, VersionModel
*/
protected final static String MSG_UNSUPPORTED =
"This operation is not supported by a version store implementation of the node service.";
private final static String MSG_UNSUPPORTED_V1 = "Versioning V1 is not implemented or supported. Patches exist to upgrade your data to use Versioning V2. Please contact support.";
/**
* The name of the spoofed root association
@@ -691,6 +693,16 @@ public class NodeServiceImpl implements NodeService, VersionModel
return result;
}
/**
* @throws UnsupportedOperationException always
*/
@Override
public List<AssociationRef> getTargetAssocsByPropertyValue(NodeRef sourceRef, QNamePattern qnamePattern, QName propertyQName, Serializable propertyValue)
{
// This operation is not supported for versioning V1
throw new UnsupportedOperationException(MSG_UNSUPPORTED_V1);
}
/**
* @throws UnsupportedOperationException always
*/