Java Code Examples for org.alfresco.model.ContentModel#TYPE_CONTENT
The following examples show how to use
org.alfresco.model.ContentModel#TYPE_CONTENT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DbOrIndexSwitchingQueryLanguageTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 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
Source File: TemplateFilingRule.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private FilingData createFilingData(Reference parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName, Map<QName, Serializable> properties) throws VirtualizationException { NodeRef fParentRef = null; QName fType = null; Set<QName> fAspects = null; Map<QName, Serializable> fProperties = null; NamespacePrefixResolver nsPrefixResolver = env.getNamespacePrefixResolver(); if (type == null || type.length() == 0) { fType = nodeTypeQName; } else { fType = QName.createQName(type, nsPrefixResolver); // CM-528 acceptance criteria 3 : // Given that the current user can upload new content into a // specific virtual folder (filing rule) // when a filing rule specifies a type or sub type of cm:folder // (which is a non supported configuration) // uploading content will create a document, not a folder if (env.isSubClass(fType, ContentModel.TYPE_FOLDER)) { if (logger.isDebugEnabled()) { logger.debug("CM-528 acceptance criteria 3 : we deny the creation of folders subtype " + fType + " and force cm:content instead."); } fType = ContentModel.TYPE_CONTENT; } // Explicit type matching follows. // It might cause non-transactional behavior. // To avoid it we rely on folder creation exclusion in // VirtualNodeServiceExtension#createNode // See CM-533 Suppress options to create folders in a virtual folder if (env.isSubClass(nodeTypeQName, fType)) { fType = nodeTypeQName; } } fParentRef = parentNodeRefFor(parentRef, true); fProperties = new HashMap<QName, Serializable>(properties); Set<Entry<String, String>> propertyEntries = stringProperties.entrySet(); for (Entry<String, String> propertyEntry : propertyEntries) { String name = propertyEntry.getKey(); QName qName = QName.createQName(name, nsPrefixResolver); if (!fProperties.containsKey(qName)) { fProperties.put(qName, stringProperties.get(name)); } } fAspects = new HashSet<>(); for (String aspect : aspects) { fAspects.add(QName.createQName(aspect, env.getNamespacePrefixResolver())); } return new FilingData(fParentRef, assocTypeQName, assocQName, fType, fAspects, fProperties); }
Example 3
Source File: AbstractRenderingEngineTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 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)); }