mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
* fix random failing erors while calling aspect api (#313)
This commit is contained in:
@@ -88,28 +88,29 @@ public class AspectsImpl extends AbstractClassImpl<Aspect> implements Aspects
|
||||
{
|
||||
Paging paging = params.getPaging();
|
||||
ModelApiFilter query = getQuery(params.getQuery());
|
||||
Stream<QName> aspectList = null;
|
||||
Stream<QName> aspectStream = null;
|
||||
|
||||
if (query != null && query.getModelIds() != null)
|
||||
{
|
||||
validateListParam(query.getModelIds(), PARAM_MODEL_IDS);
|
||||
Set<Pair<QName, Boolean>> modelsFilter = parseModelIds(query.getModelIds(), PARAM_INCLUDE_SUBASPECTS);
|
||||
aspectList = modelsFilter.parallelStream().map(this::getModelAspects).flatMap(Collection::parallelStream);
|
||||
aspectStream = modelsFilter.stream().map(this::getModelAspects).flatMap(Collection::stream);
|
||||
}
|
||||
else if (query != null && query.getParentIds() != null)
|
||||
{
|
||||
validateListParam(query.getParentIds(), PARAM_PARENT_IDS);
|
||||
aspectList = query.getParentIds().parallelStream().map(this::getChildAspects).flatMap(Collection::parallelStream);
|
||||
aspectStream = query.getParentIds().stream().map(this::getChildAspects).flatMap(Collection::stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
aspectList = this.dictionaryService.getAllAspects().parallelStream();
|
||||
aspectStream = this.dictionaryService.getAllAspects().stream();
|
||||
}
|
||||
|
||||
List<Aspect> allAspects = aspectList.filter((qName) -> filterByNamespace(query, qName))
|
||||
List<Aspect> allAspects = aspectStream.filter((qName) -> filterByNamespace(query, qName))
|
||||
.filter(distinctByKey(QName::getPrefixString))
|
||||
.map((qName) -> this.convertToAspect(dictionaryService.getAspect(qName), params.getInclude()))
|
||||
.filter(distinctByKey(Aspect::getId))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return createPagedResult(allAspects, paging);
|
||||
}
|
||||
|
||||
@@ -168,14 +169,15 @@ public class AspectsImpl extends AbstractClassImpl<Aspect> implements Aspects
|
||||
|
||||
Collection<QName> aspects = this.dictionaryService.getAspects(modelDefinition.getName());
|
||||
|
||||
if (!model.getSecond())
|
||||
if (!model.getSecond()) // look for model aspects alone
|
||||
return aspects;
|
||||
|
||||
Stream<QName> children = aspects.stream()
|
||||
Stream<QName> aspectStream = aspects.stream();
|
||||
Stream<QName> childrenStream = aspects.stream()
|
||||
.map(aspect -> this.dictionaryService.getSubAspects(aspect, false))
|
||||
.flatMap(Collection::parallelStream);
|
||||
.flatMap(Collection::stream);
|
||||
|
||||
return Stream.concat(aspects.parallelStream(), children).collect(Collectors.toList());
|
||||
return Stream.concat(aspectStream, childrenStream).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Collection<QName> getChildAspects(String aspectId)
|
||||
|
@@ -88,28 +88,30 @@ public class TypesImpl extends AbstractClassImpl<Type> implements Types
|
||||
{
|
||||
Paging paging = params.getPaging();
|
||||
ModelApiFilter query = getQuery(params.getQuery());
|
||||
Stream<QName> typeList = null;
|
||||
Stream<QName> typeStream = null;
|
||||
|
||||
if (query != null && query.getModelIds() != null)
|
||||
{
|
||||
validateListParam(query.getModelIds(), PARAM_MODEL_IDS);
|
||||
Set<Pair<QName, Boolean>> modelsFilter = parseModelIds(query.getModelIds(), PARAM_INCLUDE_SUBTYPES);
|
||||
typeList = modelsFilter.parallelStream().map(this::getModelTypes).flatMap(Collection::parallelStream);
|
||||
typeStream = modelsFilter.stream().map(this::getModelTypes).flatMap(Collection::stream);
|
||||
}
|
||||
else if (query != null && query.getParentIds() != null)
|
||||
{
|
||||
validateListParam(query.getParentIds(), PARAM_PARENT_IDS);
|
||||
typeList = query.getParentIds().parallelStream().map(this::getChildTypes).flatMap(Collection::parallelStream);
|
||||
typeStream = query.getParentIds().stream().map(this::getChildTypes).flatMap(Collection::stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
typeList = this.dictionaryService.getAllTypes().parallelStream();
|
||||
typeStream = this.dictionaryService.getAllTypes().stream();
|
||||
}
|
||||
|
||||
List<Type> allTypes = typeList.filter((qName) -> filterByNamespace(query, qName))
|
||||
List<Type> allTypes = typeStream
|
||||
.filter((qName) -> filterByNamespace(query, qName))
|
||||
.filter(distinctByKey(QName::getPrefixString))
|
||||
.map((qName) -> this.convertToType(dictionaryService.getType(qName), params.getInclude()))
|
||||
.filter(distinctByKey(Type::getId))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return createPagedResult(allTypes, paging);
|
||||
}
|
||||
|
||||
@@ -168,14 +170,15 @@ public class TypesImpl extends AbstractClassImpl<Type> implements Types
|
||||
|
||||
Collection<QName> aspects = this.dictionaryService.getTypes(modelDefinition.getName());
|
||||
|
||||
if (!model.getSecond())
|
||||
if (!model.getSecond()) //look for model types alone
|
||||
return aspects;
|
||||
|
||||
Stream<QName> children = aspects.parallelStream()
|
||||
Stream<QName> aspectStream = aspects.stream();
|
||||
Stream<QName> childrenStream = aspects.stream()
|
||||
.map(aspect -> this.dictionaryService.getSubTypes(aspect, false))
|
||||
.flatMap(Collection::parallelStream);
|
||||
.flatMap(Collection::stream);
|
||||
|
||||
return Stream.concat(aspects.parallelStream(), children).collect(Collectors.toList());
|
||||
return Stream.concat(aspectStream, childrenStream).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Collection<QName> getChildTypes(String typeId)
|
||||
|
Reference in New Issue
Block a user