use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualFileFolderServiceExtension method asFileInfoResults.
public PagingResults<FileInfo> asFileInfoResults(ActualEnvironment environment, final PagingResults<Reference> results, VirtualStore store) throws ReferenceEncodingException, VirtualizationException {
List<Reference> virtualPage = results.getPage();
final LinkedList<FileInfo> page = new LinkedList<FileInfo>();
for (Reference ref : virtualPage) {
FileInfo fileInfo = asFileInfo(store, environment, ref);
page.add(fileInfo);
}
final boolean hasMoreItems = results.hasMoreItems();
final Pair<Integer, Integer> totalResultCount = results.getTotalResultCount();
final String queryExecutionId = results.getQueryExecutionId();
return new PagingResults<FileInfo>() {
@Override
public List<FileInfo> getPage() {
return page;
}
@Override
public String getQueryExecutionId() {
return queryExecutionId;
}
@Override
public Pair<Integer, Integer> getTotalResultCount() {
return totalResultCount;
}
@Override
public boolean hasMoreItems() {
return hasMoreItems;
}
};
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualPermissionServiceExtension method getSetPermissions.
@Override
public NodePermissionEntry getSetPermissions(NodeRef nodeRef) {
PermissionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
return theTrait.getSetPermissions(nodeRef);
} else {
NodePermissionEntry virtualSetPermissions = smartStore.getSetPermissions(reference);
NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
List<? extends PermissionEntry> actualPermissionEntries;
boolean inheritPermissions = false;
if (nodeToAdhereTo != null) {
NodePermissionEntry actualSetPermissions = theTrait.getSetPermissions(nodeToAdhereTo);
actualPermissionEntries = actualSetPermissions.getPermissionEntries();
inheritPermissions = actualSetPermissions.inheritPermissions();
} else {
actualPermissionEntries = Collections.emptyList();
inheritPermissions = false;
}
List<PermissionEntry> mergedEntries = new LinkedList<>();
List<? extends PermissionEntry> virtualPermissionEntries = virtualSetPermissions.getPermissionEntries();
Set<QName> overridenPermissions = new HashSet<>();
for (PermissionEntry permissionEntry : virtualPermissionEntries) {
overridenPermissions.add(permissionEntry.getPermissionReference().getQName());
mergedEntries.add(permissionEntry);
}
for (PermissionEntry permissionEntry : actualPermissionEntries) {
if (!overridenPermissions.contains(permissionEntry.getPermissionReference().getQName())) {
mergedEntries.add(permissionEntry);
}
}
return new SimpleNodePermissionEntry(nodeRef, inheritPermissions, mergedEntries);
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualPermissionServiceExtension method getPermissions.
@Override
public Set<AccessPermission> getPermissions(NodeRef nodeRef) {
PermissionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
return theTrait.getPermissions(nodeRef);
} else {
Set<AccessPermission> virtualSetPermissions = smartStore.getAllSetPermissions(reference);
NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
Set<AccessPermission> mergedEntries = new HashSet<>(virtualSetPermissions);
if (nodeToAdhereTo != null) {
Set<AccessPermission> actualSetPermissions = theTrait.getPermissions(nodeToAdhereTo);
mergedEntries.addAll(actualSetPermissions);
}
return mergedEntries;
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualPermissionServiceExtension method getAllSetPermissions.
@Override
public Set<AccessPermission> getAllSetPermissions(NodeRef nodeRef) {
PermissionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
return theTrait.getAllSetPermissions(nodeRef);
} else {
Set<AccessPermission> virtualSetPermissions = smartStore.getAllSetPermissions(reference);
NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
Set<AccessPermission> actualSetPermissions;
if (nodeToAdhereTo != null) {
actualSetPermissions = theTrait.getAllSetPermissions(nodeToAdhereTo);
} else {
actualSetPermissions = Collections.emptySet();
}
Set<String> overridenPermissions = new HashSet<>();
Set<AccessPermission> mergedEntries = new HashSet<>();
for (AccessPermission permission : virtualSetPermissions) {
overridenPermissions.add(permission.getPermission());
mergedEntries.add(permission);
}
for (AccessPermission permission : actualSetPermissions) {
if (!overridenPermissions.contains(permission.getPermission())) {
mergedEntries.add(permission);
}
}
return mergedEntries;
}
}
use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualVersionServiceExtension method ensureVersioningEnabled.
@Override
public void ensureVersioningEnabled(NodeRef nodeRef, Map<QName, Serializable> versionProperties) {
VersionServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(nodeRef);
if (reference == null) {
theTrait.ensureVersioningEnabled(nodeRef, versionProperties);
} else {
NodeRef materialNode = smartStore.materialize(reference);
theTrait.ensureVersioningEnabled(materialNode, versionProperties);
}
}
Aggregations