From 86270157439bca083db2e16ad246451d4e17a671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Lo=CC=88fgren?= Date: Mon, 9 May 2022 18:03:54 +0200 Subject: [PATCH] Feature: filter by aspect --- pom.xml | 14 +++++++++- repo/pom.xml | 8 +++++- .../component/NumberingComponentImpl.java | 28 ++++++++++++++++++- .../numbering/decorator/BasicDecorator.java | 2 +- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 9fadf14..56ceada 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ org.redpill-linpro.alfresco.numbering alfresco-numbering - 1.3.0 + 1.3.1-SNAPSHOT Alfresco Numbering pom @@ -52,6 +52,18 @@ https://github.com/Redpill-Linpro/alfresco-numbering/issues + + alfresco-public + https://artifacts.alfresco.com/nexus/content/groups/public + + + alfresco-public-snapshots + https://artifacts.alfresco.com/nexus/content/groups/public-snapshots + + true + daily + + redpill-public https://maven.redpill-linpro.com/nexus/content/groups/public diff --git a/repo/pom.xml b/repo/pom.xml index 6117f33..048674c 100644 --- a/repo/pom.xml +++ b/repo/pom.xml @@ -3,7 +3,7 @@ org.redpill-linpro.alfresco.numbering alfresco-numbering - 1.3.0 + 1.3.1-SNAPSHOT alfresco-numbering-repo jar @@ -55,6 +55,12 @@ 1.0.16 test + + org.apache.commons + commons-lang3 + 3.12.0 + provided + diff --git a/repo/src/main/java/org/redpill/alfresco/numbering/component/NumberingComponentImpl.java b/repo/src/main/java/org/redpill/alfresco/numbering/component/NumberingComponentImpl.java index a230dc3..f399d8a 100644 --- a/repo/src/main/java/org/redpill/alfresco/numbering/component/NumberingComponentImpl.java +++ b/repo/src/main/java/org/redpill/alfresco/numbering/component/NumberingComponentImpl.java @@ -35,11 +35,13 @@ public class NumberingComponentImpl implements NumberingComponent, InitializingB protected long startValue = 1; protected List bindTypes = new ArrayList<>(); + protected List bindAspects = new ArrayList<>(); protected List ignoreTypes = new ArrayList<>(); protected List ignoreAspects = new ArrayList<>(); protected List bindTypeQNames = new ArrayList<>(); protected List ignoreTypeQNames = new ArrayList<>(); protected List ignoreAspectQNames = new ArrayList<>(); + protected ListbindAspectQNames = new ArrayList<>(); protected Decorator decorator; protected NamespaceService namespaceService; @@ -74,6 +76,21 @@ public boolean allowGetNextNumber(final NodeRef nodeRef) { return false; } + // If list bindAspectQNames is not empty, check that the node is of allowed aspect + if (!bindAspectQNames.isEmpty()) { + boolean aspectMatch = false; + for (QName bindAspect : bindAspectQNames) { + if(nodeService.hasAspect(nodeRef, bindAspect)) { + aspectMatch = true; + } + } + if (!aspectMatch) { + if(LOG.isTraceEnabled()) { + LOG.trace("Node " + nodeRef + " is not in the list of allowed aspects "); + } + return false; + } + } //Check if the node type is on the type ignore list for (QName ignoreType : ignoreTypeQNames) { if (type.equals(ignoreType)) { @@ -117,7 +134,6 @@ public long getNextNumber(final NodeRef nodeRef,String subOptionValue) { return numberingStorage.getNextNumber(startValue, id,subOptionValue); } - @Override public String getDecoratedNextNumber(final NodeRef nodeRef) { return decorator.decorate(getNextNumber(nodeRef), nodeRef); @@ -179,6 +195,16 @@ public void setBindTypes(List bindTypes) { } } + public void setBindAspects(List bindAspects) { + this.bindAspects = bindAspects; + if (bindAspects != null) { + if (LOG.isTraceEnabled()) { + LOG.trace("Registering bind aspects: " + bindAspects.toString()); + } + checkForDictionaryExistance(bindAspects, bindAspectQNames); + } + } + public void setIgnoreAspects(List ignoreAspects) { this.ignoreAspects = ignoreAspects; if (ignoreAspects != null) { diff --git a/repo/src/main/java/org/redpill/alfresco/numbering/decorator/BasicDecorator.java b/repo/src/main/java/org/redpill/alfresco/numbering/decorator/BasicDecorator.java index d2ea78a..5713609 100644 --- a/repo/src/main/java/org/redpill/alfresco/numbering/decorator/BasicDecorator.java +++ b/repo/src/main/java/org/redpill/alfresco/numbering/decorator/BasicDecorator.java @@ -1,7 +1,7 @@ package org.redpill.alfresco.numbering.decorator; import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; /** * A regular number series