use of org.alfresco.repo.virtual.VirtualContext in project alfresco-repository by Alfresco.
the class TemplateResourceProcessorTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
VirtualContext context = new VirtualContext(environment, virtualFolder1NodeRef);
nodeService.setProperty(virtualFolder1NodeRef, ContentModel.PROP_DESCRIPTION, "AContextDescription");
InputStream vanillaIS = getClass().getResourceAsStream(TEST_TEMPLATE_2_JSON_CLASSPATH);
String vanillaJSON = IOUtils.toString(vanillaIS, StandardCharsets.UTF_8);
context.setParameter(ApplyTemplateMethod.VANILLA_JSON_PARAM_NAME, vanillaJSON);
TemplateResourceProcessor processor = new TemplateResourceProcessor(context);
testTemplate2Definition = processor.process(new ClasspathResource(VANILLA_PROCESSOR_JS_CLASSPATH));
}
use of org.alfresco.repo.virtual.VirtualContext 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);
}
}
}
Aggregations