通过OpenCMIS或Java API在露天创建用户 [英] create User in alfresco by OpenCMIS or java API

查看:73
本文介绍了通过OpenCMIS或Java API在露天创建用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用alfresco-community-4.0.e,OpenCMIS和primefaces作为用户界面来构建Web应用程序。

I build web applications using alfresco-community-4.0.e, OpenCMIS, and primefaces as user interface.

我需要以编程方式在alfresco中创建用户。我尝试使用以下代码创建用户:

I need to create users in alfresco programmatically. I tried to create a user using the following code:

Blockquote 
if (!personService.personExists("tuser1")) {
        personService.createPerson(createDefaultProperties("tuser1", "Test", "User1", "tuser1@localhost", "password"));
        if (logger.isDebugEnabled()) logger.debug("Created tuser1 person");
    }

    if (!personService.personExists("tuser1")) {
        personService.createPerson(createDefaultProperties("tuser1", "Test", "User1", "tuser1@localhost", "password"));
        if (logger.isDebugEnabled()) logger.debug("Created tuser1 person");
    } 

Blockquote

但是我面临着问题

我制作了一个露天认证类,该类抛出了openCMIS,它可以很好地创建我的自定义内容和其他一些自定义操作。

I made a class for alfresco authentication that throws the openCMIS and it works fine for creating my custom content and some other custom actions.

现在知道为什么它现在可以用来创建用户或任何其他代码来以编程方式构建用户吗?

Any idea why it is now working with creating user or any other code to build the user programmatically?

推荐答案

您的代码几乎在那里,但是缺少关键的一行。除了创建人员外,还需要为其创建关联的身份验证

Your code is almost there, but missing one crucial line. As well as creating the person, you also need to create the associated Authentication for them

您可能想要类似

if (this.authenticationService.authenticationExists(userName) == false)
{
   this.authenticationService.createAuthentication(userName, password.toCharArray());

   PropertyMap ppOne = new PropertyMap(4);
   ppOne.put(ContentModel.PROP_USERNAME, userName);
   ppOne.put(ContentModel.PROP_FIRSTNAME, "firstName");
   ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
   ppOne.put(ContentModel.PROP_EMAIL, userName+"@example.com");
   ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");

   this.personService.createPerson(ppOne);
}        

这篇关于通过OpenCMIS或Java API在露天创建用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆