Search in sources :

Example 1 with GetVanillaScriptInputStreamMethod

use of org.alfresco.repo.virtual.ref.GetVanillaScriptInputStreamMethod 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);
        }
    }
}
Also used : ProtocolMethodException(org.alfresco.repo.virtual.ref.ProtocolMethodException) InputStream(java.io.InputStream) GetVanillaScriptInputStreamMethod(org.alfresco.repo.virtual.ref.GetVanillaScriptInputStreamMethod) IOException(java.io.IOException) VirtualContext(org.alfresco.repo.virtual.VirtualContext)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 VirtualContext (org.alfresco.repo.virtual.VirtualContext)1 GetVanillaScriptInputStreamMethod (org.alfresco.repo.virtual.ref.GetVanillaScriptInputStreamMethod)1 ProtocolMethodException (org.alfresco.repo.virtual.ref.ProtocolMethodException)1