use of org.alfresco.repo.virtual.template.VirtualFolderDefinition in project alfresco-repository by Alfresco.
the class VirtualStoreImpl method getPath.
@Override
public Path getPath(Reference reference) throws VirtualizationException {
Reference virtualPathElement = reference;
Reference virtualPathParent = reference.execute(new GetParentReferenceMethod());
Path virtualPath = new Path();
while (virtualPathElement != null && virtualPathParent != null) {
NodeRef parentNodeRef;
parentNodeRef = virtualPathParent.toNodeRef();
NodeRef parent = parentNodeRef;
NodeRef virtualPathNodeRef = virtualPathElement.toNodeRef();
// TODO: extract node reference name into protocol method in order
// to enforce path processing code reuse and consistency
String templatePath = virtualPathElement.execute(new GetTemplatePathMethod()).trim();
final String pathSeparator = "/";
if (pathSeparator.equals(templatePath)) {
// found root
break;
} else if (templatePath.endsWith(pathSeparator)) {
templatePath = templatePath.substring(0, templatePath.length() - 1);
}
int lastSeparator = templatePath.lastIndexOf(pathSeparator);
String childId = templatePath.substring(lastSeparator + 1);
VirtualFolderDefinition structure = resolveVirtualFolderDefinition(virtualPathParent);
VirtualFolderDefinition child = structure.findChildById(childId);
if (child == null) {
throw new VirtualizationException("Invalid reference: " + reference.encode());
}
String childName = child.getName();
QName childQName = QName.createQName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI, childName);
ChildAssociationRef assocRef = new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, parent, childQName, virtualPathNodeRef, true, -1);
ChildAssocElement assocRefElement = new ChildAssocElement(assocRef);
virtualPath.prepend(assocRefElement);
virtualPathElement = virtualPathParent;
virtualPathParent = virtualPathParent.execute(new GetParentReferenceMethod());
}
return virtualPath;
}
use of org.alfresco.repo.virtual.template.VirtualFolderDefinition in project alfresco-repository by Alfresco.
the class GetSetPermissionsMethod method execute.
@Override
public NodePermissionEntry execute(VirtualProtocol virtualProtocol, Reference reference) throws ProtocolMethodException {
Set<String> toAllow = userPermissions.getAllowSmartNodes();
Set<String> toDeny = userPermissions.getDenySmartNodes();
VirtualFolderDefinition definition = resolver.resolveVirtualFolderDefinition(reference);
FilingRule filingRule = definition.getFilingRule();
boolean readonly = filingRule.isNullFilingRule() || filingRule.filingNodeRefFor(new FilingParameters(reference)) == null;
if (readonly) {
Set<String> deniedPermissions = userPermissions.getDenyReadonlySmartNodes();
toDeny = new HashSet<>(toDeny);
toDeny.addAll(deniedPermissions);
toAllow.add(PermissionService.READ);
}
return execute(reference, toAllow, toDeny);
}
Aggregations