mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
ACS-4857: Lookup for root tag in DB and NOT using search engine (#1810)
* ACS-4857: Lookup for root tag in DB and NOT using search engine Also: - removing commons-collections exclusion within test scope due to: "Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.CollectionUtils"
This commit is contained in:
committed by
GitHub
parent
8e1d4782b4
commit
a26ac1f778
@@ -121,12 +121,6 @@
|
|||||||
<version>${dependency.webscripts.version}</version>
|
<version>${dependency.webscripts.version}</version>
|
||||||
<classifier>tests</classifier>
|
<classifier>tests</classifier>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>commons-collections</groupId>
|
|
||||||
<artifactId>commons-collections</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
|
@@ -353,28 +353,15 @@ public abstract class AbstractCategoryServiceImpl implements CategoryService
|
|||||||
return assocs;
|
return assocs;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Set<NodeRef> getClassificationNodes(StoreRef storeRef, QName qname)
|
protected Set<NodeRef> getClassificationNodes(StoreRef storeRef, QName aspectQName)
|
||||||
{
|
{
|
||||||
ResultSet resultSet = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
resultSet = indexerAndSearcher.getSearcher(storeRef, false).query(storeRef, "lucene",
|
return getRootCategoryNodeRef(storeRef, aspectQName).stream().collect(Collectors.toSet());
|
||||||
"PATH:\"/" + getPrefix(qname.getNamespaceURI()) + ISO9075.encode(qname.getLocalName()) + "\"", null);
|
|
||||||
|
|
||||||
Set<NodeRef> nodeRefs = new HashSet<NodeRef>(resultSet.length());
|
|
||||||
for (ResultSetRow row : resultSet)
|
|
||||||
{
|
|
||||||
nodeRefs.add(row.getNodeRef());
|
|
||||||
}
|
|
||||||
|
|
||||||
return nodeRefs;
|
|
||||||
}
|
}
|
||||||
finally
|
catch (CategoryServiceException ignore)
|
||||||
{
|
{
|
||||||
if (resultSet != null)
|
return Collections.emptySet();
|
||||||
{
|
|
||||||
resultSet.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,19 +617,24 @@ public abstract class AbstractCategoryServiceImpl implements CategoryService
|
|||||||
@Override
|
@Override
|
||||||
@Experimental
|
@Experimental
|
||||||
public Optional<NodeRef> getRootCategoryNodeRef(final StoreRef storeRef)
|
public Optional<NodeRef> getRootCategoryNodeRef(final StoreRef storeRef)
|
||||||
|
{
|
||||||
|
return getRootCategoryNodeRef(storeRef, ContentModel.ASPECT_GEN_CLASSIFIABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Optional<NodeRef> getRootCategoryNodeRef(final StoreRef storeRef, final QName childNodeType)
|
||||||
{
|
{
|
||||||
final NodeRef rootNode = nodeService.getRootNode(storeRef);
|
final NodeRef rootNode = nodeService.getRootNode(storeRef);
|
||||||
final ChildAssociationRef categoryRoot = nodeService.getChildAssocs(rootNode, Set.of(ContentModel.TYPE_CATEGORYROOT)).stream()
|
final ChildAssociationRef categoryRoot = nodeService.getChildAssocs(rootNode, Set.of(ContentModel.TYPE_CATEGORYROOT)).stream()
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow(() -> new CategoryServiceException(NODE_WITH_CATEGORY_ROOT_TYPE_NOT_FOUND));
|
.orElseThrow(() -> new CategoryServiceException(NODE_WITH_CATEGORY_ROOT_TYPE_NOT_FOUND));
|
||||||
final List<ChildAssociationRef> categoryRootAssocs = nodeService.getChildAssocs(categoryRoot.getChildRef());
|
final List<ChildAssociationRef> categoryRootAssocs = nodeService.getChildAssocs(categoryRoot.getChildRef());
|
||||||
if (CollectionUtils.isEmpty(categoryRootAssocs))
|
if (CollectionUtils.isEmpty(categoryRootAssocs))
|
||||||
{
|
{
|
||||||
throw new CategoryServiceException(CATEGORY_ROOT_NODE_NOT_FOUND);
|
throw new CategoryServiceException(CATEGORY_ROOT_NODE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
return categoryRootAssocs.stream()
|
return categoryRootAssocs.stream()
|
||||||
.filter(ca -> ca.getQName().equals(ContentModel.ASPECT_GEN_CLASSIFIABLE))
|
.filter(ca -> ca.getQName().equals(childNodeType))
|
||||||
.map(ChildAssociationRef::getChildRef)
|
.map(ChildAssociationRef::getChildRef)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user