Search in sources :

Example 1 with Parameter

use of org.alfresco.repo.virtual.ref.Parameter 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);
}
Also used : QName(org.alfresco.service.namespace.QName) Reference(org.alfresco.repo.virtual.ref.Reference) Resource(org.alfresco.repo.virtual.ref.Resource) ClasspathResource(org.alfresco.repo.virtual.ref.ClasspathResource) RepositoryResource(org.alfresco.repo.virtual.ref.RepositoryResource) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) RepositoryLocation(org.alfresco.repo.virtual.ref.RepositoryLocation) NodeRef(org.alfresco.service.cmr.repository.NodeRef) ResourceProcessingError(org.alfresco.repo.virtual.ref.ResourceProcessingError) ClasspathResource(org.alfresco.repo.virtual.ref.ClasspathResource) ResourceParameter(org.alfresco.repo.virtual.ref.ResourceParameter) RepositoryResource(org.alfresco.repo.virtual.ref.RepositoryResource) ResourceParameter(org.alfresco.repo.virtual.ref.ResourceParameter) Parameter(org.alfresco.repo.virtual.ref.Parameter)

Aggregations

ClasspathResource (org.alfresco.repo.virtual.ref.ClasspathResource)1 Parameter (org.alfresco.repo.virtual.ref.Parameter)1 Reference (org.alfresco.repo.virtual.ref.Reference)1 RepositoryLocation (org.alfresco.repo.virtual.ref.RepositoryLocation)1 RepositoryResource (org.alfresco.repo.virtual.ref.RepositoryResource)1 Resource (org.alfresco.repo.virtual.ref.Resource)1 ResourceParameter (org.alfresco.repo.virtual.ref.ResourceParameter)1 ResourceProcessingError (org.alfresco.repo.virtual.ref.ResourceProcessingError)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 QName (org.alfresco.service.namespace.QName)1