use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualNodeServiceExtension method getChildAssocs.
@Override
public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern, int maxResults, boolean preload) {
NodeServiceTrait theTrait = getTrait();
boolean canVirtualize = canVirtualizeAssocNodeRef(nodeRef);
if (canVirtualize) {
Reference reference = smartStore.virtualize(nodeRef);
List<ChildAssociationRef> virtualAssociations = smartStore.getChildAssocs(reference, typeQNamePattern, qnamePattern, maxResults, preload);
List<ChildAssociationRef> associations = new LinkedList<>(virtualAssociations);
if (associations.size() < maxResults) {
if (smartStore.canMaterialize(reference)) {
NodeRef materialReference = smartStore.materialize(reference);
List<ChildAssociationRef> actualAssociations = theTrait.getChildAssocs(materialReference, typeQNamePattern, qnamePattern, maxResults - associations.size(), preload);
associations.addAll(actualAssociations);
}
}
return associations;
} else {
return theTrait.getChildAssocs(nodeRef, typeQNamePattern, qnamePattern, maxResults, preload);
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualNodeServiceExtension method getChildAssocs.
@Override
public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) {
NodeServiceTrait theTrait = getTrait();
boolean canVirtualize = canVirtualizeAssocNodeRef(nodeRef);
if (canVirtualize) {
Reference reference = smartStore.virtualize(nodeRef);
List<ChildAssociationRef> virtualAssociations = smartStore.getChildAssocs(reference, typeQNamePattern, qnamePattern, Integer.MAX_VALUE, false);
List<ChildAssociationRef> associations = new LinkedList<>(virtualAssociations);
if (smartStore.canMaterialize(reference)) {
NodeRef materialReference = smartStore.materialize(reference);
List<ChildAssociationRef> actualAssociations = theTrait.getChildAssocs(materialReference, typeQNamePattern, qnamePattern);
associations.addAll(actualAssociations);
}
return associations;
} else {
return theTrait.getChildAssocs(nodeRef, typeQNamePattern, qnamePattern);
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualStoreImpl method search.
@Override
public List<Reference> search(Reference reference, String namePattern, boolean fileSearch, boolean folderSearch, boolean includeSubFolders) throws VirtualizationException {
VirtualFolderDefinition structure = resolveVirtualFolderDefinition(reference);
List<Reference> result = new LinkedList<Reference>();
List<Reference> childReferences = createChildReferences(reference, structure);
if (folderSearch) {
result.addAll(childReferences);
}
if (includeSubFolders) {
for (Reference childRef : childReferences) {
List<Reference> childResults = search(childRef, namePattern, fileSearch, folderSearch, includeSubFolders);
result.addAll(childResults);
}
}
if (fileSearch) {
final VirtualQuery query = structure.getQuery();
if (query != null) {
VirtualQueryConstraint vqConstraint = null;
if (namePattern == null) {
vqConstraint = BasicConstraint.INSTANCE;
} else {
vqConstraint = new NamePatternPropertyValueConstraint(new FilesFoldersConstraint(BasicConstraint.INSTANCE, true, true), ContentModel.PROP_NAME, namePattern, environment.getNamespacePrefixResolver());
}
PagingResults<Reference> queryNodes = query.perform(environment, vqConstraint, null, reference);
result.addAll(queryNodes.getPage());
}
}
return result;
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualStoreImpl method canVirtualize.
@Override
public boolean canVirtualize(NodeRef nodeRef) throws VirtualizationException {
String runAsUser = AuthenticationUtil.getRunAsUser();
if (runAsUser == null) {
if (logger.isTraceEnabled()) {
RuntimeException stackTracingException = new RuntimeException("Stack trace.");
logger.trace("Virtualization check call in unauthenticated-context - stack trace follows:", stackTracingException);
}
return false;
}
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference != null) {
return true;
} else {
for (VirtualizationMethod vMethod : virtualizationMethods) {
if (vMethod.canVirtualize(environment, nodeRef)) {
return true;
}
}
return false;
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualStoreImpl method list.
@Override
public PagingResults<Reference> list(final Reference ref, boolean actual, boolean virtual, final boolean files, final boolean folders, final String pattern, final Set<QName> searchTypeQNames, final Set<QName> ignoreTypeQNames, final Set<QName> ignoreAspectQNames, final List<Pair<QName, Boolean>> sortProps, final PagingRequest pagingRequest) throws VirtualizationException {
VirtualFolderDefinition structure = resolveVirtualFolderDefinition(ref);
List<Reference> virtualRefs = null;
// constraints should handle folder & file filtering
if (virtual && folders) {
virtualRefs = createChildReferences(ref, structure);
} else {
virtualRefs = Collections.emptyList();
}
if (actual) {
final VirtualQuery query = structure.getQuery();
if (query != null) {
// we have a query we must collate results
PagingResultsSource<Reference> querySourc = new PagingResultsSource<Reference>() {
@Override
public PagingResults<Reference> retrieve(PagingRequest pr) throws PageCollationException {
try {
return query.perform(environment, files, folders, pattern, searchTypeQNames, ignoreTypeQNames, ignoreAspectQNames, sortProps, pr, ref);
} catch (VirtualizationException e) {
throw new PageCollationException(e);
}
}
};
PageCollator<Reference> collator = new PageCollator<>();
try {
return collator.collate(virtualRefs, querySourc, pagingRequest, new ReferenceComparator(this, sortProps));
} catch (PageCollationException e) {
throw new VirtualizationException(e);
}
}
}
return new ListBackedPagingResults<>(virtualRefs);
}
Aggregations