Java Code Examples for org.alfresco.service.namespace.NamespaceService

The following examples show how to use org.alfresco.service.namespace.NamespaceService. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
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 2
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 3
@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 4
@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 5
/**
 * @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
@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
/**
 * 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
/**
 * 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 9
/**
 * 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 10
/**
 * @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 11
@Override
public void addObjectToFolder(
        String repositoryId, String objectId, String folderId, Boolean allVersions,
        ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    if (!allVersions)
    {
        throw new CmisInvalidArgumentException("Only allVersions=true supported!");
    }

    // get node ref
    CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");

    if (!info.isDocument())
    {
        throw new CmisInvalidArgumentException("Object is not a document!");
    }

    final NodeRef nodeRef = info.getNodeRef();

    // get the folder node ref
    final CMISNodeInfo folderInfo = getOrCreateFolderInfo(folderId, "Folder");

    connector.checkChildObjectType(folderInfo, info.getType().getTypeId());

    final QName name = QName.createQName(
            NamespaceService.CONTENT_MODEL_1_0_URI,
            QName.createValidLocalName((String) connector.getNodeService().getProperty(nodeRef,
                    ContentModel.PROP_NAME)));

    connector.getNodeService().addChild(
            folderInfo.getNodeRef(), nodeRef, ContentModel.ASSOC_CONTAINS, name);
}
 
Example 12
/**
 * @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 13
public NodeRef createCmObject(final NodeRef parentNodeRef, final String name)
{
    QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(name));
    NodeRef nodeRef = nodeService.createNode(parentNodeRef, ContentModel.ASSOC_CONTAINS, assocQName, ContentModel.TYPE_CMOBJECT).getChildRef();

    return nodeRef;
}
 
Example 14
public void end()
{
    try
    {
        contentHandler.endElement(NamespaceService.REPOSITORY_VIEW_PREFIX, VIEW_LOCALNAME, VIEW_QNAME.toPrefixString());
        contentHandler.endPrefixMapping(NamespaceService.REPOSITORY_VIEW_PREFIX);
        contentHandler.endDocument();
    }
    catch (SAXException e)
    {
        throw new ExporterException("Failed to process end export event", e);
    }
}
 
Example 15
@Test
   public void test1EnableDisableBehaviour()
{
	// Register the onCreateNode behaviour script
	ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/jscript/test_onCreateNode_cmContent.js");
	ScriptBehaviour behaviour = new ScriptBehaviour(this.serviceRegistry, location);
	
	this.policyComponent.bindClassBehaviour(
			QName.createQName(NodeServicePolicies.OnCreateNodePolicy.NAMESPACE, "onCreateNode"),
			ContentModel.TYPE_CONTENT,
			behaviour);
	
	behaviour.disable();
	
	// Create a content node
	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);
	assertFalse(this.nodeService.hasAspect(childAssoc.getChildRef(), ContentModel.ASPECT_TITLED));
	
	behaviour.enable();
	
	Map<QName, Serializable> props2 = new HashMap<QName, Serializable>(1);
	props2.put(ContentModel.PROP_NAME, "myDoc1.txt");
	ChildAssociationRef childAssoc2 = this.nodeService.createNode(
			this.folderNodeRef,
			ContentModel.ASSOC_CONTAINS,
			QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myDoc1.txt"),
			ContentModel.TYPE_CONTENT,
			props2);
	assertTrue(this.nodeService.hasAspect(childAssoc2.getChildRef(), ContentModel.ASPECT_TITLED));		
}
 
Example 16
/**
 * Check for special case: additional node validation (pending common lower-level service support)
 * for blacklist of system nodes that should not be deleted or locked, eg. Company Home, Sites, Data Dictionary
 *
 * @param nodeRef
 * @param type
 * @return
 */
protected boolean isSpecialNode(NodeRef nodeRef, QName type)
{
    // Check for Company Home, Sites and Data Dictionary (note: must be tenant-aware)

    if (nodeRef.equals(repositoryHelper.getCompanyHome()))
    {
        return true;
    }
    else if (type.equals(SiteModel.TYPE_SITES) || type.equals(SiteModel.TYPE_SITE))
    {
        // note: alternatively, we could inject SiteServiceInternal and use getSitesRoot (or indirectly via node locator)
        return true;
    }
    else
    {
        String tenantDomain = TenantUtil.getCurrentDomain();
        NodeRef ddNodeRef = ddCache.get(tenantDomain);
        if (ddNodeRef == null)
        {
            List<ChildAssociationRef> ddAssocs = nodeService.getChildAssocs(
                    repositoryHelper.getCompanyHome(),
                    ContentModel.ASSOC_CONTAINS,
                    QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "dictionary"));
            if (ddAssocs.size() == 1)
            {
                ddNodeRef = ddAssocs.get(0).getChildRef();
                ddCache.put(tenantDomain, ddNodeRef);
            }
        }

        if (nodeRef.equals(ddNodeRef))
        {
            return true;
        }
    }

    return false;
}
 
Example 17
/**
 * Register version label policy for the specified type
 * 
 * @param typeQName QName
 * @param policy CalculateVersionLabelPolicy
 */
@Extend(extensionAPI=VersionServiceExtension.class,traitAPI=VersionServiceTrait.class)
public void registerVersionLabelPolicy(QName typeQName, CalculateVersionLabelPolicy policy)
{
    // Register the serial version label behaviour
    this.policyComponent.bindClassBehaviour(
            QName.createQName(NamespaceService.ALFRESCO_URI, "calculateVersionLabel"),
            typeQName,
            new JavaBehaviour(policy, "calculateVersionLabel"));
}
 
Example 18
/**
 * Function to check if a module is installed
 * 
 * @param moduleName	module name (e.g. "org.alfresco.module.foo")
 * @return boolean      true if the module is currently installed
 */
public boolean moduleInstalled(String moduleName)
{
    ModuleService moduleService = (ModuleService)this.services.getService(QName.createQName(NamespaceService.ALFRESCO_URI, "ModuleService"));
    if (moduleService != null)
    {
        ModuleDetails moduleDetail = (ModuleDetails)moduleService.getModule(moduleName);
        return (moduleDetail != null);
    }
    return false;
}
 
Example 19
/**
 * This method copies properties from the temporary rendition node onto the targetNode. It also sets the node type.
 * {@link #unchangedProperties Some properties} are not copied.
 * @param finalRenditionAssoc ChildAssociationRef
 */
private void transferNodeProperties(ChildAssociationRef finalRenditionAssoc)
{
    NodeRef targetNode = finalRenditionAssoc.getChildRef();
    if (logger.isDebugEnabled())
    {
        StringBuilder msg = new StringBuilder();
        msg.append("Transferring some properties from ").append(tempRenditionNode).append(" to ").append(targetNode);
        logger.debug(msg.toString());
    }

    // Copy the type from the temporary rendition to the real rendition, if required
    QName type = nodeService.getType(tempRenditionNode);
    if ((null != type) && !type.equals(nodeService.getType(targetNode)))
    {
        nodeService.setType(targetNode, type);
    }
    
    // Copy over all regular properties from the temporary rendition
    Map<QName, Serializable> newProps = nodeService.getProperties(targetNode);
    for(Entry<QName,Serializable> entry : nodeService.getProperties(tempRenditionNode).entrySet())
    {
        QName propKey = entry.getKey();
        if(unchangedProperties.contains(propKey) ||
           NamespaceService.SYSTEM_MODEL_1_0_URI.equals(propKey.getNamespaceURI()))
        {
            // These shouldn't be copied over
            continue;
        }
        newProps.put(propKey, entry.getValue());
    }
    nodeService.setProperties(targetNode, newProps);
}
 
Example 20
public void testSubscriptionsRemovalOnArchivingNodesForAlf12358() throws Exception
{
    NodeRef companyHome = repositoryHelper.getCompanyHome();

    ChildAssociationRef followed = null;

    int initialCount = subscriptionService.getSubscriptionCount(USER_TOM, SubscriptionItemTypeEnum.USER);

    try
    {
        followed = nodeService.createNode(companyHome, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName
                .createValidLocalName(FOLLOWED_NODE_NAME)), ContentModel.TYPE_USER);
        nodeService.addAspect(followed.getChildRef(), ASPECT_ARCHIVE, null);
        assertTrue("Fake User node MUST BE archival!", nodeService.hasAspect(followed.getChildRef(), ASPECT_ARCHIVE));

        subscriptionService.subscribe(USER_TOM, followed.getChildRef());
        assertEquals("Initial subscriptions count MUST BE lesser by 1 after adding new subscription!", 1, (subscriptionService.getSubscriptionCount(USER_TOM,
                SubscriptionItemTypeEnum.USER) - initialCount));

        nodeService.deleteNode(followed.getChildRef());
        assertEquals("Archiving of node MUST cause removal all the subscriptions created against it!", initialCount, subscriptionService.getSubscriptionCount(USER_TOM,
                SubscriptionItemTypeEnum.USER));
    }
    finally
    {
        if ((null != followed) && nodeService.exists(followed.getChildRef()))
        {
            try
            {
                nodeService.deleteNode(followed.getChildRef());
            }
            catch (Exception e)
            {
                // Doing nothing
            }
        }
    }
}
 
Example 21
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 22
/**
 * 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 23
@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 24
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 25
private PropertyDefinition getPropertyDefinition(String identifier)
{
    return QueryParserUtils.matchPropertyDefinition(NamespaceService.CONTENT_MODEL_1_0_URI,
            getNamespaceDAO(),
            getDictionaryService(CMISStrictDictionaryService.DEFAULT),
            identifier);
}
 
Example 26
@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 27
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; 
}
 
Example 28
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 29
/**
 * 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 30
public DefaultFieldBuilder(FormCreationData data,
        FieldProcessorRegistry registry,
        NamespaceService namespaceService,
        List<String> ignoredFields)
{
    this(data, registry, namespaceService, ignoredFields, MY_LOGGER);
}