Java Code Examples for org.alfresco.model.ContentModel.TYPE_CONTENT

The following are Jave code examples for showing how to use TYPE_CONTENT of the org.alfresco.model.ContentModel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: alfresco-repository   File: DbOrIndexSwitchingQueryLanguageTest.java   View Source Code Vote up 5 votes
private ChildAssociationRef childAssoc(String id)
{
    return new ChildAssociationRef(
        ContentModel.ASSOC_CONTAINS,
        new NodeRef("test://store/parentRef"),
        ContentModel.TYPE_CONTENT,
        new NodeRef("test://store/" + id)
    );
}
 
Example 2
Project: alfresco-repository   File: AbstractRenderingEngineTest.java   View Source Code Vote up 4 votes
@SuppressWarnings({"unchecked" , "rawtypes"})
public void testCreateRenditionNodeAssoc() throws Exception
{
    QName assocType = RenditionModel.ASSOC_RENDITION;
    when(nodeService.exists(source)).thenReturn(true);
    QName nodeType = ContentModel.TYPE_CONTENT;
    ChildAssociationRef renditionAssoc = makeRenditionAssoc();
    RenditionDefinition definition = makeRenditionDefinition(renditionAssoc);

    // Stub the createNode() method to return renditionAssoc.
    when(nodeService.createNode(eq(source), eq(assocType), any(QName.class), any(QName.class), anyMap()))
        .thenReturn(renditionAssoc);
    engine.execute(definition, source);

    // Check the createNode method was called with the correct parameters.
    // Check the nodeType defaults to cm:content.
    ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class);
    verify(nodeService).createNode(eq(source), eq(assocType), any(QName.class), eq(nodeType), captor.capture());
    Map<String, Serializable> props = captor.getValue();

    // Check the node name is set to match teh rendition name local name.
    assertEquals(renditionAssoc.getQName().getLocalName(), props.get(ContentModel.PROP_NAME));

    // Check content property name defaults to cm:content
    assertEquals(ContentModel.PROP_CONTENT, props.get(ContentModel.PROP_CONTENT_PROPERTY_NAME));

    // Check the returned result is the association created by the call to
    // nodeServcie.createNode().
    Serializable result = definition.getParameterValue(ActionExecuter.PARAM_RESULT);
    assertEquals("The returned rendition association is not the one created by the node service!", renditionAssoc,
                result);

    // Check that setting the default content property and default node type
    // on the rendition engine works.
    nodeType = QName.createQName("url", "someNodeType");
    QName contentPropName = QName.createQName("url", "someContentProp");
    engine.setDefaultRenditionContentProp(contentPropName.toString());
    engine.setDefaultRenditionNodeType(nodeType.toString());
    engine.execute(definition, source);
    verify(nodeService).createNode(eq(source), eq(assocType), any(QName.class), eq(nodeType), captor.capture());
    props = captor.getValue();
    assertEquals(contentPropName, props.get(ContentModel.PROP_CONTENT_PROPERTY_NAME));

    // Check that setting the rendition node type param works.
    nodeType = ContentModel.TYPE_THUMBNAIL;
    contentPropName = ContentModel.PROP_CONTENT;
    definition.setParameterValue(RenditionService.PARAM_RENDITION_NODETYPE, nodeType);
    definition.setParameterValue(AbstractRenderingEngine.PARAM_TARGET_CONTENT_PROPERTY, contentPropName);
    engine.execute(definition, source);
    verify(nodeService).createNode(eq(source), eq(assocType), any(QName.class), eq(nodeType), captor.capture());
    props = captor.getValue();
    assertEquals(contentPropName, props.get(ContentModel.PROP_CONTENT_PROPERTY_NAME));
}