use of org.alfresco.repo.virtual.ref.ClasspathResource 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.ref.ClasspathResource in project alfresco-repository by Alfresco.
the class TypeVirtualizationMethodIntegrationTest method virtualize.
private void virtualize(NodeRef expectedTemplateNodeRef, QName fodlerType, QName... aspects) throws Exception {
ChildAssociationRef typedNodeAssocRef = createTypedNode(testRootFolder.getNodeRef(), "TypeVirtualized", fodlerType);
NodeRef typeNode = typedNodeAssocRef.getChildRef();
for (QName aspect : aspects) {
nodeService.addAspect(typeNode, aspect, Collections.<QName, Serializable>emptyMap());
}
assertTrue(typeVirtualizationMethod.canVirtualize(environment, typeNode));
Reference theVirtualizedNode = typeVirtualizationMethod.virtualize(environment, typeNode);
assertEquals(Protocols.VANILLA.protocol, theVirtualizedNode.getProtocol());
List<Parameter> parameters = theVirtualizedNode.getParameters();
ResourceParameter vanillaResourceParameter = (ResourceParameter) parameters.get(VanillaProtocol.VANILLA_TEMPLATE_PARAM_INDEX);
Resource vanillaResource = vanillaResourceParameter.getValue();
NodeRef resourceNodeRef = vanillaResource.processWith(new ResourceProcessor<NodeRef>() {
@Override
public NodeRef process(Resource resource) throws ResourceProcessingError {
fail("Inavlid resource type");
return null;
}
@Override
public NodeRef process(ClasspathResource classpath) throws ResourceProcessingError {
fail("Inavlid resource type");
return null;
}
@Override
public NodeRef process(RepositoryResource repository) throws ResourceProcessingError {
RepositoryLocation location = repository.getLocation();
return location.asNodeRef(environment);
}
});
assertEquals(expectedTemplateNodeRef, resourceNodeRef);
}
Aggregations