mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +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>
|
||||
<classifier>tests</classifier>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
@@ -353,28 +353,15 @@ public abstract class AbstractCategoryServiceImpl implements CategoryService
|
||||
return assocs;
|
||||
}
|
||||
|
||||
protected Set<NodeRef> getClassificationNodes(StoreRef storeRef, QName qname)
|
||||
protected Set<NodeRef> getClassificationNodes(StoreRef storeRef, QName aspectQName)
|
||||
{
|
||||
ResultSet resultSet = null;
|
||||
try
|
||||
{
|
||||
resultSet = indexerAndSearcher.getSearcher(storeRef, false).query(storeRef, "lucene",
|
||||
"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;
|
||||
return getRootCategoryNodeRef(storeRef, aspectQName).stream().collect(Collectors.toSet());
|
||||
}
|
||||
finally
|
||||
catch (CategoryServiceException ignore)
|
||||
{
|
||||
if (resultSet != null)
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,19 +617,24 @@ public abstract class AbstractCategoryServiceImpl implements CategoryService
|
||||
@Override
|
||||
@Experimental
|
||||
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 ChildAssociationRef categoryRoot = nodeService.getChildAssocs(rootNode, Set.of(ContentModel.TYPE_CATEGORYROOT)).stream()
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new CategoryServiceException(NODE_WITH_CATEGORY_ROOT_TYPE_NOT_FOUND));
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new CategoryServiceException(NODE_WITH_CATEGORY_ROOT_TYPE_NOT_FOUND));
|
||||
final List<ChildAssociationRef> categoryRootAssocs = nodeService.getChildAssocs(categoryRoot.getChildRef());
|
||||
if (CollectionUtils.isEmpty(categoryRootAssocs))
|
||||
{
|
||||
throw new CategoryServiceException(CATEGORY_ROOT_NODE_NOT_FOUND);
|
||||
}
|
||||
return categoryRootAssocs.stream()
|
||||
.filter(ca -> ca.getQName().equals(ContentModel.ASPECT_GEN_CLASSIFIABLE))
|
||||
.map(ChildAssociationRef::getChildRef)
|
||||
.findFirst();
|
||||
.filter(ca -> ca.getQName().equals(childNodeType))
|
||||
.map(ChildAssociationRef::getChildRef)
|
||||
.findFirst();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user