Skip to content

Commit

Permalink
Merge pull request #131 from xenit-eu/master
Browse files Browse the repository at this point in the history
Release <- Master
  • Loading branch information
WimCrols authored Sep 29, 2021
2 parents d68daec + dc1010e commit 46053a0
Show file tree
Hide file tree
Showing 53 changed files with 560 additions and 588 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Alfred API - Changelog


## 3.0.1 (2021-09-29)

### Changed
* [XENOPS-891](https://xenitsupport.jira.com/browse/XENOPS-891): Update docker images and wars to latest hotfix for 52, 62 & 70
* [ALFREDAPI-378](https://xenitsupport.jira.com/browse/ALFREDAPI-378): Replace deprecated calls to serviceregistry

### Fixed
* [ALFREDAPI-469](https://xenitsupport.jira.com/browse/ALFREDAPI-469): Add swagger-doc-extractor subproject for http://docs.xenit.eu/alfred-api
* [ALFREDAPI-489](https://xenitsupport.jira.com/browse/ALFREDAPI-489): Implemented check on content indexing in solrtesthelper
* [ALFREDAPI-490](https://xenitsupport.jira.com/browse/ALFREDAPI-490): Improve performance of retrieving categories


## 3.0.0 (2021-07-29)
This release adds support for Alfresco 7.0 and drops support for Alfresco 5.0, 5.1 and 6.0.

Expand Down
5 changes: 3 additions & 2 deletions apix-docker/52/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
dependencies {
baseAlfrescoWar "org.alfresco:alfresco-enterprise:5.2.5@war"
baseAlfrescoWar platform('org.alfresco:alfresco-platform-enterprise:5.2.7.12')
baseAlfrescoWar "org.alfresco:alfresco-platform-enterprise@war"
if (!ci.isCi()) {
alfrescoAmp(group: 'eu.xenit.care4alf', name: 'care4alf-5x', version: "${care4alfVersion}", ext: 'amp')
}
}

dockerAlfresco {
baseImage = "hub.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:5.2.5"
baseImage = "hub.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:5.2.7.12"
}
1 change: 1 addition & 0 deletions apix-docker/52/debug-extension.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ services:
environment:
- DEBUG=true
- ALFRESCO_HOST=alfresco-core
- ALFRESCO_INTERNAL_HOST=alfresco-core
7 changes: 4 additions & 3 deletions apix-docker/61/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dependencies {
baseAlfrescoWar 'org.alfresco:content-services:6.1.1@war'
baseAlfrescoWar platform("org.alfresco:content-services:6.1.1.3")
baseAlfrescoWar 'org.alfresco:content-services@war'
// Fix for https://github.com/xenit-eu/dynamic-extensions-for-alfresco#alfresco-61---wrong-version-of-commons-annotations-used
alfrescoAmp(group: 'eu.xenit.alfresco', name: 'alfresco-hotfix-MNT-20557', version: '1.0.1', ext: 'amp')
if (!ci.isCi()) {
Expand All @@ -8,5 +9,5 @@ dependencies {
}

dockerAlfresco {
baseImage = 'hub.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:6.1'
}
baseImage = 'hub.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:6.1.1.3'
}
1 change: 1 addition & 0 deletions apix-docker/61/debug-extension.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ services:
environment:
- DEBUG=true
- ALFRESCO_HOST=alfresco-core
- ALFRESCO_INTERNAL_HOST=alfresco-core
5 changes: 3 additions & 2 deletions apix-docker/62/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
dependencies {
baseAlfrescoWar 'org.alfresco:content-services:6.2.1@war'
baseAlfrescoWar platform("org.alfresco:acs-packaging:6.2.2.19")
baseAlfrescoWar 'org.alfresco:content-services:6.2.2.19@war'
// Fix for https://github.com/xenit-eu/dynamic-extensions-for-alfresco#alfresco-61---wrong-version-of-commons-annotations-used
alfrescoAmp(group: 'eu.xenit.alfresco', name: 'alfresco-hotfix-MNT-20557', version: '1.0.2', ext: 'amp')
}

dockerAlfresco {
baseImage = 'hub.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:6.2.1'
baseImage = 'hub.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:6.2.2.19'
}
1 change: 1 addition & 0 deletions apix-docker/62/debug-extension.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ services:
environment:
- DEBUG=true
- ALFRESCO_HOST=alfresco-core
- ALFRESCO_INTERNAL_HOST=alfresco-core
6 changes: 3 additions & 3 deletions apix-docker/70/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dependencies {
baseAlfrescoWar platform("org.alfresco:acs-packaging:7.0.0")
baseAlfrescoWar platform("org.alfresco:acs-packaging:7.0.1.3")
baseAlfrescoWar 'org.alfresco:content-services@war'
}

dockerAlfresco {
baseImage = 'hub.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:7.0.0'
}
baseImage = 'hub.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:7.0.1.3'
}
1 change: 1 addition & 0 deletions apix-docker/70/debug-extension.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ services:
environment:
- DEBUG=true
- ALFRESCO_HOST=alfresco-core
- ALFRESCO_INTERNAL_HOST=alfresco-core
4 changes: 2 additions & 2 deletions apix-docker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'eu.xenit.docker-alfresco' version '5.0.0' apply false
id 'eu.xenit.docker-compose' version '5.0.0' apply false
id 'eu.xenit.docker-alfresco' version '5.0.6' apply false
id 'eu.xenit.docker-compose' version '5.0.6' apply false
id 'be.vbgn.ci-detect' version '0.1.0' apply false
}

Expand Down
18 changes: 9 additions & 9 deletions apix-impl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ subprojects {
apply from: "${rootProject.projectDir}/publish.gradle"
apply plugin: 'eu.xenit.amp'

configurations {
ampArtifact
dynamicExtensionsBundles
}

dependencies {
compile(project(":apix-impl"))
dynamicExtensionsBundles(group: 'eu.xenit.swagger.ui', name: 'swagger-ui_5x', version: '1.1.0') {
transitive = false
} // Works for 6x too
}

publishing {
Expand All @@ -32,10 +40,6 @@ subprojects {
}
}

configurations {
ampArtifact
}

artifacts {
ampArtifact amp
}
Expand All @@ -58,15 +62,11 @@ subprojects {
}
}


// Extend amp plugin task:
// We want to add 'alfresco-global.properties' etc to the module-specific folder in the AMP
// (e.g. 'config/module/alfresco/module/apix-impl-51/') without hard-coding project name for each Alfresco version.
amp {
deBundles = files(
jar,
"${rootDir}/lib/swagger-ui_5x-1.1.0.jar", // Works for 6x too
)
deBundles = configurations.dynamicExtensionsBundles + files(jar)
into("config/alfresco/module/${project.name}") {
from("${project.parent.projectDir}/config/alfresco-global.properties")
from("${project.parent.projectDir}/config/log4j.properties")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package eu.xenit.apix.alfresco.categories;

import com.github.dynamicextensionsalfresco.osgi.OsgiService;
import com.google.common.collect.Iterables;
import eu.xenit.apix.alfresco.ApixToAlfrescoConversion;
import eu.xenit.apix.categories.Category;
import eu.xenit.apix.categories.ICategoryService;
import eu.xenit.apix.utils.java8.Optional;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -21,37 +21,27 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
* Created by Michiel Huygen on 30/11/2015. https://wiki.alfresco.com/wiki/Classification_And_Categories Example:
* https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/repository/config/alfresco/bootstrap/categories.xml
*/

@OsgiService
@Component("eu.xenit.apix.categories.ICategoryService")
public class CategoryService implements ICategoryService {

@Autowired
private ApixToAlfrescoConversion c;

@Autowired
private NodeService nodeService;
@Autowired
private org.alfresco.service.cmr.search.CategoryService categoryService;
@Autowired
private NamespaceService namespaceService;


public CategoryService() {
}


public CategoryService(ServiceRegistry registry, ApixToAlfrescoConversion apixToAlfrescoConversion) {
nodeService = registry.getNodeService();
categoryService = registry.getCategoryService();
namespaceService = registry.getNamespaceService();

this.c = apixToAlfrescoConversion;

c = apixToAlfrescoConversion;
}

/**
Expand All @@ -70,70 +60,65 @@ public void classifyNode(eu.xenit.apix.data.NodeRef targetNodeA, eu.xenit.apix.d
} else {
nodeService.setProperty(targetNode, ContentModel.PROP_CATEGORIES, categories);
}

}


/**
* Retuns all categories for given classifiable aspect. This consists of a list of category roots WARNING: can be
* slow for many categories
* Returns all categories for given classifiable aspect. This consists of a list of category roots.
*
* WARNING: Can be slow for many categories.
*
* @param classifiableAspectNameA Should be aspect of type cm:classifiable //TODO: getCategoryTrees
* @param classifiableAspectNameA Should be aspect of type cm:classifiable
*/
public List<Category> getCategoryTree(eu.xenit.apix.data.QName classifiableAspectNameA) {
QName classifiableAspectName = c.alfresco(classifiableAspectNameA);
java.util.Collection<org.alfresco.service.cmr.repository.ChildAssociationRef> refs = categoryService
.getCategories(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, classifiableAspectName,
org.alfresco.service.cmr.search.CategoryService.Depth.ANY);

Collection<ChildAssociationRef> categories = categoryService
.getClassifications(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
Optional<ChildAssociationRef> classifierRootNodeMaybe = Optional.empty();
for (ChildAssociationRef child : categories) {
if (!child.getQName().equals(classifiableAspectName)) {
continue;
}
NodeRef classifierRootNode = getClassificationRootNode(classifiableAspectName);

classifierRootNodeMaybe = Optional.of(child);
break;
}

// Optional<ChildAssociationRef> classifierRootNodeMaybe = categoryService.getClassifications(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE)
// .stream().filter(c -> c.getQName().equals(classifiableAspectName)).findFirst();

if (!classifierRootNodeMaybe.isPresent()) {
throw new RuntimeException("Aspect name does not match a classifiable");
}
NodeRef classifierRootNode = classifierRootNodeMaybe.get().getChildRef();

HashMap<NodeRef, Category> map = new HashMap<>();
List<Category> ret = new ArrayList<Category>();
HashMap<NodeRef, Category> categoryLookup = new HashMap<>();
List<Category> result = new ArrayList<>();

for (org.alfresco.service.cmr.repository.ChildAssociationRef r : refs) {
// Walk through categories and build up category tree
for (org.alfresco.service.cmr.repository.ChildAssociationRef r : categoryService.getCategories(
StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
classifiableAspectName,
org.alfresco.service.cmr.search.CategoryService.Depth.ANY)) {
NodeRef parentRef = r.getParentRef();
NodeRef nodeRef = r.getChildRef();
Category cat = map.get(nodeRef);
if (cat == null) {
cat = new Category();
map.put(r.getChildRef(), cat);
Category category = categoryLookup.get(nodeRef);
if (category == null) {
category = new Category();
categoryLookup.put(r.getChildRef(), category);
}
cat.setNoderef(nodeRef.toString());
cat.setName((String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME));
cat.setQnamePath(nodeService.getPath(nodeRef).toPrefixString(namespaceService));
category.setNoderef(nodeRef.toString());
category.setName((String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME));
category.setQnamePath(nodeService.getPath(nodeRef).toPrefixString(namespaceService));

if (r.getParentRef().equals(classifierRootNode)) {
// Is root node
ret.add(cat);
result.add(category);
} else {
if (!map.containsKey(parentRef)) {
map.put(parentRef, new Category()); //Warn: not setting ref to this cat
if (!categoryLookup.containsKey(parentRef)) {
categoryLookup.put(parentRef,
new Category()); // Only empty category, which is filled in a later iteration
}
Category parent = map.get(parentRef);
parent.getSubcategories().add(cat);
Category parent = categoryLookup.get(parentRef);
parent.getSubcategories().add(category);
}
}
return result;
}

return ret;

private NodeRef getClassificationRootNode(QName classifiableAspectName) {
// We use this unintuitive way of getting the category root, since categoryService.getClassifications() can
// take minutes at customers having a large SOLR.
Collection<ChildAssociationRef> categories = categoryService.getRootCategories(
StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
classifiableAspectName);
if (categories.isEmpty()) {
throw new RuntimeException("Aspect name does not match a classifiable");
}
// What we actually get back is the first level categories UNDER the category root
// Thus, we return one of their parents.
return Iterables.get(categories, 0).getParentRef();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,20 @@
public class SearchFacetsServiceImpl implements SearchFacetsService {

private static final Logger logger = LoggerFactory.getLogger(SearchFacetsServiceImpl.class);
private final FacetLabelDisplayHandlerRegistry facetLabelDisplayHandlerRegistry;
private FacetLabelDisplayHandlerRegistry facetLabelDisplayHandlerRegistry;
private SolrFacetHelper solrFacetHelper;
private DictionaryService dictionaryService;
private NodeService nodeService;
@Autowired
private SolrFacetService facetService;
@Autowired
private ITranslationService translationService;

// This file might give inspection error due to being 5.x specific.
// Intellij can't handle this file being reused in different libs.
@Autowired
public SearchFacetsServiceImpl(ServiceRegistry serviceRegistry) {
public SearchFacetsServiceImpl(ServiceRegistry serviceRegistry, SolrFacetService solrFacetsService,
ITranslationService translationService) {
facetService = solrFacetsService;
this.translationService = translationService;
facetLabelDisplayHandlerRegistry = serviceRegistry.getFacetLabelDisplayHandlerRegistry();
solrFacetHelper = serviceRegistry.getSolrFacetHelper();
dictionaryService = serviceRegistry.getDictionaryService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.AdditionalAnswers.returnsFirstArg;

import eu.xenit.apix.alfresco.search.SearchFacetsService;
import eu.xenit.apix.alfresco.search.SearchFacetsServiceImpl;
import eu.xenit.apix.search.FacetSearchResult;
import eu.xenit.apix.search.FacetSearchResult.FacetValue;
import eu.xenit.apix.search.SearchQuery.FacetOptions;
import eu.xenit.apix.translation.ITranslationService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import eu.xenit.apix.translation.ITranslationService;
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
import org.alfresco.repo.search.impl.solr.facet.SolrFacetHelper;
import org.alfresco.repo.search.impl.solr.facet.SolrFacetService;
Expand Down Expand Up @@ -48,12 +47,9 @@ public void initMocks() {
ServiceRegistry serviceRegistryMock = mock(ServiceRegistry.class);

SolrFacetHelper solrFacetHelperMock = mock(SolrFacetHelper.class);
when(serviceRegistryMock.getSolrFacetHelper()).thenReturn(solrFacetHelperMock);

FacetLabelDisplayHandlerRegistry facetLabelDisplayHandlerRegistryStub =
new FacetLabelDisplayHandlerRegistry();
when(serviceRegistryMock.getFacetLabelDisplayHandlerRegistry())
.thenReturn(facetLabelDisplayHandlerRegistryStub);

DataTypeDefinition textDataTypeDef = mock(DataTypeDefinition.class);
when(textDataTypeDef.getName()).thenReturn(DataTypeDefinition.TEXT);
Expand Down Expand Up @@ -95,8 +91,10 @@ public void initMocks() {
when(dictionaryServiceMock.getProperty(documentStatusQName)).thenReturn(documentStatusPropDefMock);

when(serviceRegistryMock.getDictionaryService()).thenReturn(dictionaryServiceMock);

searchFacetsService = new SearchFacetsServiceImpl(serviceRegistryMock);
when(serviceRegistryMock.getSolrFacetHelper()).thenReturn(solrFacetHelperMock);
when(serviceRegistryMock.getFacetLabelDisplayHandlerRegistry()).thenReturn(facetLabelDisplayHandlerRegistryStub);
searchFacetsService = new SearchFacetsServiceImpl(serviceRegistryMock, mock(SolrFacetService.class), mock(
ITranslationService.class));

facetOptionsMock = mock(FacetOptions.class);
when(facetOptionsMock.isEnabled()).thenReturn(true);
Expand Down
Loading

0 comments on commit 46053a0

Please sign in to comment.