use of org.alfresco.repo.virtual.ref.ProtocolMethodException in project alfresco-repository by Alfresco.
the class GetPathMethod method execute.
@Override
public Path execute(VirtualProtocol virtualProtocol, Reference reference) throws ProtocolMethodException {
try {
NodeRef actualNodeRef = reference.execute(new GetActualNodeRefMethod(environment));
Path path = null;
if (actualNodeRef == null) {
// Although not a feature yet, pure-virtual-references should
// use an empty path as root since pure-virtual-references have
// no actual peer to use.
path = new Path();
} else {
path = environment.getPath(actualNodeRef);
}
Path virtualPath = smartStore.getPath(reference);
return path.append(virtualPath);
} catch (ReferenceEncodingException e) {
throw new ProtocolMethodException(e);
}
}
use of org.alfresco.repo.virtual.ref.ProtocolMethodException in project alfresco-repository by Alfresco.
the class ApplyTemplateMethod method execute.
@Override
public VirtualFolderDefinition execute(VanillaProtocol vanillaProtocol, Reference reference) throws ProtocolMethodException {
InputStream vanillaIS = reference.execute(new GetVanillaScriptInputStreamMethod(environment));
try {
String vanillaJSON = IOUtils.toString(vanillaIS, StandardCharsets.UTF_8);
VirtualContext context = createVirtualContext(reference);
context.setParameter(VANILLA_JSON_PARAM_NAME, vanillaJSON);
return execute(vanillaProtocol, reference, context);
} catch (IOException e) {
throw new ProtocolMethodException(e);
} finally {
try {
if (vanillaIS != null)
vanillaIS.close();
} catch (IOException ioe) {
logger.warn("Failed to close input stream : " + ioe);
}
}
}
use of org.alfresco.repo.virtual.ref.ProtocolMethodException in project alfresco-repository by Alfresco.
the class ApplyTemplateMethod method execute.
public VirtualFolderDefinition execute(VirtualProtocol virtualProtocol, Reference reference, VirtualContext context) throws ProtocolMethodException {
Resource resource = reference.getResource();
try {
VirtualFolderDefinition theStructure = resource.processWith(new TemplateResourceProcessor(context));
String path = reference.execute(new GetTemplatePathMethod());
if (!path.isEmpty()) {
String[] pathElements = path.split(PATH_SEPARATOR);
int startIndex = path.startsWith(PATH_SEPARATOR) ? 1 : 0;
for (int i = startIndex; i < pathElements.length; i++) {
theStructure = theStructure.findChildById(pathElements[i]);
if (theStructure == null) {
throw new ProtocolMethodException("Invalid template path in " + reference.toString());
}
}
}
return theStructure;
} catch (ResourceProcessingError e) {
throw new ProtocolMethodException(e);
}
}
Aggregations