org.alfresco.service.namespace.NamespaceService Java Examples
The following examples show how to use
org.alfresco.service.namespace.NamespaceService.
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: TestCMIS.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
private NodeRef makeRenditionNode(NodeRef parent, String title, String name, String mimetype) { Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_NAME, name); props.put(ContentModel.PROP_TITLE, title); QName assocQName = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, name); ChildAssociationRef assoc = nodeService.createNode(parent, RenditionModel.ASSOC_RENDITION, assocQName, ContentModel.TYPE_THUMBNAIL, props); NodeRef childRef = assoc.getChildRef(); if (!nodeService.hasAspect(parent, RenditionModel.ASPECT_RENDITIONED)) { nodeService.addAspect(parent, RenditionModel.ASPECT_RENDITIONED, null); } ContentWriter writer = contentService.getWriter(childRef, ContentModel.PROP_CONTENT, true); writer.setMimetype(mimetype); writer.setEncoding("UTF-8"); writer.putContent("Dummy "+name+" content"); return childRef; }
Example #2
Source File: NodeChangeTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void setUp() throws Exception { namespaceService = mock(NamespaceService.class); Collection<String> cmAlways = new ArrayList<String>(); cmAlways.add("cm"); when(namespaceService.getPrefixes(anyString())).thenReturn(cmAlways); when(namespaceService.getNamespaceURI(anyString())).thenReturn("cm"); nodeService = mock(NodeService.class); Path rootPath = newPath(null, "/"); Path homeFolderPath = newPath(rootPath, "cm:homeFolder"); folderPath1 = newPath(homeFolderPath, "cm:folder1"); folderPath2 = newPath(homeFolderPath, "cm:folder2"); folder1 = newFolder(folderPath1); folder2 = newFolder(folderPath2); content1 = newContent(folderPath1, "cm:content1"); nodeInfoFactory = new NodeInfoFactory(nodeService, namespaceService); nodeChange = new NodeChange(nodeInfoFactory, namespaceService, content1); }
Example #3
Source File: DBConjunction.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void prepare(NamespaceService namespaceService, DictionaryService dictionaryService, QNameDAO qnameDAO, NodeDAO nodeDAO, TenantService tenantService, Set<String> selectors, Map<String, Argument> functionArgs, FunctionEvaluationContext functionContext, boolean supportBooleanFloatAndDouble) { for (Constraint constraint : getConstraints()) { if (constraint instanceof DBQueryBuilderComponent) { if(constraint.getOccur() == Occur.OPTIONAL) { throw new QueryModelException("Disjunctions are not suported"); } DBQueryBuilderComponent dbQueryBuilderComponent = (DBQueryBuilderComponent) constraint; dbQueryBuilderComponent.prepare(namespaceService, dictionaryService, qnameDAO, nodeDAO, tenantService, selectors, functionArgs, functionContext, supportBooleanFloatAndDouble); } else { throw new UnsupportedOperationException(); } } }
Example #4
Source File: ReplicationServiceIntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private NodeRef makeNode(NodeRef parent, QName nodeType, String name) { Map<QName, Serializable> props = new HashMap<QName, Serializable>(); QName newName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, name); NodeRef existing = nodeService.getChildByName(parent, ContentModel.ASSOC_CONTAINS, name); if(existing != null) { System.err.println("Zapped existing node " + existing + " for name " + name); try { lockService.unlock(existing, true); } catch(UnableToReleaseLockException e) {} nodeService.deleteNode(existing); } props.put(ContentModel.PROP_NAME, name); ChildAssociationRef assoc = nodeService.createNode(parent, ContentModel.ASSOC_CONTAINS, newName, nodeType, props); return assoc.getChildRef(); }
Example #5
Source File: OnCreateChildAssociationRuleTrigger.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @see org.alfresco.repo.rule.ruletrigger.RuleTrigger#registerRuleTrigger() */ public void registerRuleTrigger() { if (isClassBehaviour == true) { this.policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, POLICY_NAME), this, new JavaBehaviour(this, POLICY_NAME)); } else { this.policyComponent.bindAssociationBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, POLICY_NAME), this, new JavaBehaviour(this, POLICY_NAME)); } }
Example #6
Source File: DBDisjunction.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void prepare(NamespaceService namespaceService, DictionaryService dictionaryService, QNameDAO qnameDAO, NodeDAO nodeDAO, TenantService tenantService, Set<String> selectors, Map<String, Argument> functionArgs, FunctionEvaluationContext functionContext, boolean supportBooleanFloatAndDouble) { //throw new QueryModelException("Disjunctions are not suported"); for (Constraint constraint : getConstraints()) { if (constraint instanceof DBQueryBuilderComponent) { DBQueryBuilderComponent dbQueryBuilderComponent = (DBQueryBuilderComponent) constraint; dbQueryBuilderComponent.prepare(namespaceService, dictionaryService, qnameDAO, nodeDAO, tenantService, selectors, functionArgs, functionContext, supportBooleanFloatAndDouble); } else { throw new UnsupportedOperationException(); } } }
Example #7
Source File: WorkflowDefinitionType.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * The initialise method */ public void init() { // Register interest in the onContentUpdate policy for the workflow definition type policyComponent.bindClassBehaviour( ContentServicePolicies.OnContentUpdatePolicy.QNAME, WorkflowModel.TYPE_WORKFLOW_DEF, new JavaBehaviour(this, "onContentUpdate")); // Register interest in the onPropertyUpdate policy for the workflow definition type policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), WorkflowModel.TYPE_WORKFLOW_DEF, new JavaBehaviour(this, "onUpdateProperties")); // Register interest in the node delete policy policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"), WorkflowModel.TYPE_WORKFLOW_DEF, new JavaBehaviour(this, "beforeDeleteNode")); }
Example #8
Source File: ScriptNode.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @return The array of aspects applied to this node as short prefix qname strings */ public Scriptable getAspectsShort() { final NamespaceService ns = this.services.getNamespaceService(); final Map<String, String> cache = new HashMap<String, String>(); final Set<QName> aspects = getAspectsSet(); final Object[] result = new Object[aspects.size()]; int count = 0; for (final QName qname : aspects) { String prefix = cache.get(qname.getNamespaceURI()); if (prefix == null) { // first request for this namespace prefix, get and cache result Collection<String> prefixes = ns.getPrefixes(qname.getNamespaceURI()); prefix = prefixes.size() != 0 ? prefixes.iterator().next() : ""; cache.put(qname.getNamespaceURI(), prefix); } result[count++] = prefix + QName.NAMESPACE_PREFIX + qname.getLocalName(); } return Context.getCurrentContext().newArray(this.scope, result); }
Example #9
Source File: FieldUtils.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Generates a list of association fields with values. * * @param assocDefs List of association definitions to generate * @param values Map containing the values to use for each property * @param group The group the field belongs to * @param namespaceService NamespaceService instance * @return List of generated Field objects */ public static List<Field> makeAssociationFields( Collection<AssociationDefinition> assocDefs, Map<AssociationDefinition, Object> values, FieldGroup group, NamespaceService namespaceService, DictionaryService dictionaryService) { AssociationFieldProcessor processor = new AssociationFieldProcessor(namespaceService, dictionaryService); ArrayList<Field> fields = new ArrayList<Field>(assocDefs.size()); for (AssociationDefinition propDef : assocDefs) { Object value = values == null ? null : values.get(propDef); Field field = processor.makeField(propDef, value, group); fields.add(field); } return fields; }
Example #10
Source File: DiscussableAspect.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Initialise method */ public void init() { // All forum-related copy behaviour uses the same copy callback this.policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), ForumModel.ASPECT_DISCUSSABLE, new JavaBehaviour(this, "onAddAspect")); this.policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"), ForumModel.ASPECT_DISCUSSABLE, new JavaBehaviour(this, "getCopyCallback")); this.policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "onCopyComplete"), ForumModel.ASPECT_DISCUSSABLE, new JavaBehaviour(this, "onCopyComplete")); this.policyComponent.bindClassBehaviour( AfterVersionRevertPolicy.QNAME, ContentModel.ASPECT_VERSIONABLE, new JavaBehaviour(this, "afterVersionRevert")); }
Example #11
Source File: DefaultFieldBuilder.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public DefaultFieldBuilder(FormCreationData formData, FieldProcessorRegistry registry, NamespaceService namespaceService, List<String> ignoredFields, Log logger) { this.logger = logger; this.formData = formData; this.registry = registry; this.namespaceService = namespaceService; this.ignoredFields = getNonNullList(ignoredFields ); this.ItemData = (ContentModelItemData<?>) formData.getItemData(); }
Example #12
Source File: DBLower.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void prepare(NamespaceService namespaceService, DictionaryService dictionaryService, QNameDAO qnameDAO, NodeDAO nodeDAO, TenantService tenantService, Set<String> selectors, Map<String, Argument> functionArgs, FunctionEvaluationContext functionContext, boolean supportBooleanFloatAndDouble) { // TODO Auto-generated method stub }
Example #13
Source File: AccessAuditorTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private static NodeRef newContent(NodeRef parent, String name) { PropertyMap propertyMap0 = new PropertyMap(); propertyMap0.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-16", Locale.ENGLISH)); NodeRef content = nodeService.createNode( parent, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), ContentModel.TYPE_CONTENT, propertyMap0).getChildRef(); ContentWriter writer = serviceRegistry.getContentService().getWriter(content, ContentModel.TYPE_CONTENT, true); writer.putContent("The cat sat on the mat."); return content; }
Example #14
Source File: UsageQuotaProtector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * The initialise method */ public void init() { if (contentUsageService.getEnabled()) { // Register interest in the onUpdateProperties policy policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), ContentModel.TYPE_PERSON, new JavaBehaviour(this, "onUpdateProperties")); } }
Example #15
Source File: ScriptBehaviourTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void test3SpringConfiguredBehaviour() { this.nodeService.addAspect(this.folderNodeRef, ContentModel.ASPECT_COUNTABLE, null); assertTrue(this.nodeService.hasAspect(this.folderNodeRef, ContentModel.ASPECT_TITLED)); // Create a couple of nodes Map<QName, Serializable> props = new HashMap<QName, Serializable>(1); props.put(ContentModel.PROP_NAME, "myDoc.txt"); ChildAssociationRef childAssoc = this.nodeService.createNode( this.folderNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myDoc.txt"), ContentModel.TYPE_CONTENT, props); Map<QName, Serializable> props2 = new HashMap<QName, Serializable>(1); props2.put(ContentModel.PROP_NAME, "folder2"); ChildAssociationRef childAssoc2 = this.nodeService.createNode( this.folderNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "folder2"), ContentModel.TYPE_FOLDER, props2); this.nodeService.addChild(childAssoc2.getChildRef(), childAssoc.getChildRef(), ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "linked")); assertTrue(this.nodeService.hasAspect(childAssoc.getChildRef(), ContentModel.ASPECT_VERSIONABLE)); }
Example #16
Source File: TaskFormProcessorTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private TypeDefinition makeTypeDef() { TypeDefinition typeDef = mock(TypeDefinition.class); QName name = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, TASK_DEF_NAME); when(typeDef.getName()).thenReturn(name); // Set up task property definitions Map<QName, PropertyDefinition> propertyDefs = makeTaskPropertyDefs(); when(typeDef.getProperties()).thenReturn(propertyDefs); // Set up task association definitions. Map<QName, AssociationDefinition> associationDefs = makeTaskAssociationDefs(); when(typeDef.getAssociations()).thenReturn(associationDefs); return typeDef; }
Example #17
Source File: MultiTDemoTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private NodeRef createHomeSpaceFolderNode(NodeRef folderNodeRef, String spaceName, String userName) { if (spaceName != null) { Map<QName, Serializable> folderProps = new HashMap<QName, Serializable>(); folderProps.put(ContentModel.PROP_NAME, spaceName); NodeRef nodeRef = this.nodeService.createNode( folderNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, spaceName), ContentModel.TYPE_FOLDER, folderProps).getChildRef(); // apply the uifacets aspect - icon and title props Map<QName, Serializable> uiFacetsProps = new HashMap<QName, Serializable>(3); uiFacetsProps.put(ApplicationModel.PROP_ICON, "space-icon-default"); uiFacetsProps.put(ContentModel.PROP_TITLE, spaceName); this.nodeService.addAspect(nodeRef, ApplicationModel.ASPECT_UIFACETS, uiFacetsProps); setupHomeSpacePermissions(nodeRef, userName); return nodeRef; } return null; }
Example #18
Source File: CommentsPost.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * add the comment from json to given nodeRef * * @param nodeRef * @param json * @return */ private NodeRef addComment(NodeRef nodeRef, JSONObject json) { // fetch the parent to add the node to NodeRef commentsFolder = getOrCreateCommentsFolder(nodeRef); // get a unique name String name = getUniqueChildName("comment"); // create the comment NodeRef commentNodeRef = nodeService.createNode(commentsFolder, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(name)), ForumModel.TYPE_POST).getChildRef(); // fetch the title required to create a comment String title = getOrNull(json, JSON_KEY_TITLE); HashMap<QName, Serializable> props = new HashMap<QName, Serializable>(1, 1.0f); props.put(ContentModel.PROP_TITLE, title != null ? title : ""); nodeService.addProperties(commentNodeRef, props); ContentWriter writer = contentService.getWriter(commentNodeRef, ContentModel.PROP_CONTENT, true); // fetch the content of a comment String contentString = getOrNull(json, JSON_KEY_CONTENT); writer.setMimetype(MimetypeMap.MIMETYPE_HTML); writer.putContent(contentString); return commentNodeRef; }
Example #19
Source File: FieldUtils.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Generates an asssociation field. * * @param assocDef The definition of the association to generate * @param value The value of the field * @param group The group the field belongs to * @param namespaceService NamespaceService instance * @return The generated Field object */ public static Field makeAssociationField( AssociationDefinition assocDef, Object value, FieldGroup group, NamespaceService namespaceService, DictionaryService dictionaryService) { AssociationFieldProcessor processor = new AssociationFieldProcessor(namespaceService, dictionaryService); return processor.makeField(assocDef, value, group); }
Example #20
Source File: TaskFormProcessor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public TaskFormProcessor(WorkflowService workflowService, NamespaceService namespaceService, DictionaryService dictionaryService, AuthenticationService authenticationService, PersonService personService, FieldProcessorRegistry fieldProcessorRegistry) { this.workflowService = workflowService; this.namespaceService = namespaceService; this.dictionaryService = dictionaryService; this.authenticationService = authenticationService; this.personService = personService; this.fieldProcessorRegistry = fieldProcessorRegistry; }
Example #21
Source File: BeanPropertiesMapperRegistry.java From alfresco-mvc with Apache License 2.0 | 5 votes |
public BeanPropertiesMapperRegistry(final NamespaceService namespaceService, final DictionaryService dictionaryService) { Assert.notNull(namespaceService, "[Assertion failed] - the namespaceService argument must be null"); Assert.notNull(dictionaryService, "[Assertion failed] - the dictionaryService argument must be null"); this.namespaceService = namespaceService; this.dictionaryService = dictionaryService; }
Example #22
Source File: AlfrescoSolrDataModel.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
private PropertyDefinition getPropertyDefinition(String identifier) { return QueryParserUtils.matchPropertyDefinition(NamespaceService.CONTENT_MODEL_1_0_URI, getNamespaceDAO(), getDictionaryService(CMISStrictDictionaryService.DEFAULT), identifier); }
Example #23
Source File: ThumbnailServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * See REPO-2257, MNT-17661 */ @Test public void testLastThumbnailModificationDataContentCopy() throws Exception { final NodeRef pdfOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_PDF); QName qname = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "doclib"); ThumbnailDefinition details = thumbnailService.getThumbnailRegistry().getThumbnailDefinition(qname.getLocalName()); NodeRef thumbnail = this.thumbnailService.createThumbnail(pdfOrig, ContentModel.PROP_CONTENT, MimetypeMap.MIMETYPE_IMAGE_JPEG, details.getTransformationOptions(), "doclib"); assertNotNull(thumbnail); TestTransaction.flagForCommit(); TestTransaction.end(); Thread.sleep(1000); // Get initial value of property "Last thumbnail modification data" List<String>lastThumbnailData = (List<String>)this.secureNodeService.getProperty(pdfOrig, ContentModel.PROP_LAST_THUMBNAIL_MODIFICATION_DATA); assertNotNull(lastThumbnailData); assertEquals(1, lastThumbnailData.size()); assertTrue(lastThumbnailData.get(0).contains("doclib:")); final NodeRef pdfCopy = copyService.copy(pdfOrig, this.folder, ContentModel.ASSOC_CONTAINS, QName.createQName("copyOfOriginal")); List<String> lastThumbnailDataCopy = (List<String>)this.secureNodeService.getProperty(pdfCopy, ContentModel.PROP_LAST_THUMBNAIL_MODIFICATION_DATA); assertNull(lastThumbnailDataCopy); }
Example #24
Source File: CustomContentModelIT.java From alfresco-sdk with Apache License 2.0 | 5 votes |
/** * Create a new node, such as a file or a folder, with passed in type and properties * * @param name the name of the file or folder * @param type the content model type * @param properties the properties from the content model * @return the Node Reference for the newly created node */ private NodeRef createNode(String name, QName type, Map<QName, Serializable> properties) { NodeRef parentFolderNodeRef = getCompanyHomeNodeRef(); QName associationType = ContentModel.ASSOC_CONTAINS; QName associationQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(name)); properties.put(ContentModel.PROP_NAME, name); ChildAssociationRef parentChildAssocRef = getServiceRegistry().getNodeService().createNode( parentFolderNodeRef, associationType, associationQName, type, properties); return parentChildAssocRef.getChildRef(); }
Example #25
Source File: ImapServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void testContentRecovery() throws Exception { reauthenticate(USER_NAME, USER_PASSWORD); // create content NodeRef nodeRef = nodeService.createNode(testImapFolderNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "content_recover"), ContentModel.TYPE_CONTENT).getChildRef(); FileInfo fileInfo = fileFolderService.getFileInfo(nodeRef); // Outlook sets flags that indicates that a content was seen and deleted imapService.setFlag(fileInfo, Flags.Flag.DELETED, true); imapService.setFlag(fileInfo, Flags.Flag.SEEN, true); // delete a content fileFolderService.delete(nodeRef); // get archive node reference String storePath = "archive://SpacesStore"; StoreRef storeRef = new StoreRef(storePath); NodeRef archivedNodeRef = new NodeRef(storeRef, nodeRef.getId()); // restore a node and check flags Boolean value = false; if (nodeService.exists(archivedNodeRef)) { NodeRef restoredNode = nodeService.restoreNode(archivedNodeRef, testImapFolderNodeRef, null, null); Map<QName, Serializable> props = nodeService.getProperties(restoredNode); if (props.containsKey(ImapModel.PROP_FLAG_DELETED) && props.containsKey(ImapModel.PROP_FLAG_SEEN)) { value = !(Boolean) props.get(ImapModel.PROP_FLAG_DELETED) && !(Boolean) props.get(ImapModel.PROP_FLAG_SEEN); } } assertTrue("Can't set DELETED flag to false", value); }
Example #26
Source File: WorkflowModelBuilderTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); namespaceService = new NamespaceServiceMemoryImpl(); namespaceService.registerNamespace("test", URI); namespaceService.registerNamespace(NamespaceService.CONTENT_MODEL_PREFIX, NamespaceService.CONTENT_MODEL_1_0_URI); namespaceService.registerNamespace(NamespaceService.BPM_MODEL_PREFIX, NamespaceService.BPM_MODEL_1_0_URI); personService = mock(PersonService.class); when(personService.getPerson(userName)).thenReturn(person); when(personService.personExists(userName)).thenReturn(true); nodeService = mock(NodeService.class); Map<QName, Serializable> personProps = new HashMap<QName, Serializable>(); personProps.put(ContentModel.PROP_USERNAME, userName); personProps.put(ContentModel.PROP_FIRSTNAME, firstName); personProps.put(ContentModel.PROP_LASTNAME, lastName); when(nodeService.getProperties(person)).thenReturn(personProps); when(nodeService.getProperty(person, ContentModel.PROP_USERNAME)).thenReturn(userName); when(nodeService.getProperty(person, ContentModel.PROP_FIRSTNAME)).thenReturn(firstName); when(nodeService.getProperty(person, ContentModel.PROP_LASTNAME)).thenReturn(lastName); workflowService = mock(WorkflowService.class); dictionaryService = mock(DictionaryService.class); authenticationService = mock(AuthenticationService.class); builder = new WorkflowModelBuilder(namespaceService, nodeService, authenticationService, personService, workflowService, dictionaryService); }
Example #27
Source File: TransactionServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Test the write veto * @throws Exception */ @Test public void testReadOnlyVetoTxn() throws Exception { QName v1 = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "V1"); QName v2 = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "V2"); QName v3 = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "V2"); try { // start a read-only transaction transactionService.setAllowWrite(false, v1); transactionService.setAllowWrite(false, v2); assertFalse("v1 AND v2 veto not read only", transactionService.getAllowWrite()); transactionService.setAllowWrite(true, v2); assertFalse("v1 not read only", transactionService.getAllowWrite()); transactionService.setAllowWrite(true, v1); assertTrue("v1 still read only", transactionService.getAllowWrite()); /** * Remove non existent veto */ transactionService.setAllowWrite(true, v3); assertTrue("v3 veto", transactionService.getAllowWrite()); } finally { transactionService.setAllowWrite(true, v1); transactionService.setAllowWrite(true, v2); transactionService.setAllowWrite(true, v3); } }
Example #28
Source File: AbstractWorkflowServiceIntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
protected void checkTaskQueryStartTaskCompleted(String workflowInstanceId, WorkflowTask startTask) { List<String> expectedTasks = Arrays.asList(startTask.getId()); checkProcessIdQuery(workflowInstanceId, expectedTasks, WorkflowTaskState.COMPLETED); checkTaskIdQuery(startTask.getId(), WorkflowTaskState.COMPLETED); QName startTaskName = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "submitAdhocTask"); checkTaskNameQuery(startTaskName, expectedTasks, WorkflowTaskState.COMPLETED, null); checkActorIdQuery(USER1, expectedTasks, WorkflowTaskState.COMPLETED, null); checkIsActiveQuery(expectedTasks, WorkflowTaskState.COMPLETED, workflowInstanceId); checkTaskPropsQuery(expectedTasks, WorkflowTaskState.COMPLETED, null); }
Example #29
Source File: RepoTransferReceiverImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * @return */ private TransferManifestNormalNode createContentNode(/*String transferId*/) throws Exception { TransferManifestNormalNode node = new TransferManifestNormalNode(); String uuid = GUID.generate(); NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, uuid); node.setNodeRef(nodeRef); node.setUuid(uuid); byte[] dummyContent = "This is some dummy content.".getBytes("UTF-8"); node.setType(ContentModel.TYPE_CONTENT); /** * Get guest home */ NodeRef parentFolder = guestHome; String nodeName = uuid + ".testnode" + getNameSuffix(); List<ChildAssociationRef> parents = new ArrayList<ChildAssociationRef>(); ChildAssociationRef primaryAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, parentFolder, QName .createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeName), node.getNodeRef(), true, -1); parents.add(primaryAssoc); node.setParentAssocs(parents); node.setParentPath(nodeService.getPath(parentFolder)); node.setPrimaryParentAssoc(primaryAssoc); Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_NODE_UUID, uuid); props.put(ContentModel.PROP_NAME, nodeName); ContentData contentData = new ContentData("/" + uuid, "text/plain", dummyContent.length, "UTF-8"); props.put(ContentModel.PROP_CONTENT, contentData); node.setProperties(props); return node; }
Example #30
Source File: ContentModelFormPersister.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public ContentModelFormPersister(ContentModelItemData<?> itemData, NamespaceService namespaceService, DictionaryService dictionaryService, Log logger) { this.dictionaryService= dictionaryService; this.logger = logger==null ? LOGGER : logger; this.keyMatcher = new DataKeyMatcher(namespaceService); this.itemData = itemData; }