如何使用 Alfresco Javascript API 检索每个用户的组列表

发布于 2024-11-18 10:42:32 字数 1008 浏览 1 评论 0原文

我对 Alfresco 及其 Javascript API 完全陌生,所以请记住这一点...

我希望能够查看 Alfresco 存储库中每个用户的组列表。

这是我目前的代码:

  var gens = search.luceneSearch("TYPE:\"{http://www.alfresco.org/model/content/1.0}person\"");
  var logFile = space.childByNamePath("log_user_groups.csv");
  if (logFile == null) {
      logFile = space.createFile("log_user_groups.csv");
   }
   logFile.content = "";



   for (var i=0; i<gens.length;i++) {
     logFile.content += gens[i].properties["cm:userName"]+"\n";

     var groupes= people.getContainerGroups(gens[i]);

     for (var j=0; j<groupes.length;j++) {
       logFile.content += "\t"+groupes[j].properties.shortName +"\t";
       logFile.content += "\t"+groupes[j].properties.fullName +"\t";
       logFile.content += "\t"+groupes[j].properties.displayName +"\n";
     }
  }

该文件是使用正确显示的用户名创建的。但是,组属性“shortName”、“fullName”和“displayName”均为空。事实上,我打印出了“groupes”对象的所有属性,并且该对象的每个字段都是“未定义”的。

有人知道我做错了什么吗?

任何帮助将不胜感激。

规范。

I'm totally new to Alfresco and their Javascript API so please bear that in mind...

I want to be able to view a list of groups for every user in Alfresco repository.

This is the code I have at the moment:

  var gens = search.luceneSearch("TYPE:\"{http://www.alfresco.org/model/content/1.0}person\"");
  var logFile = space.childByNamePath("log_user_groups.csv");
  if (logFile == null) {
      logFile = space.createFile("log_user_groups.csv");
   }
   logFile.content = "";



   for (var i=0; i<gens.length;i++) {
     logFile.content += gens[i].properties["cm:userName"]+"\n";

     var groupes= people.getContainerGroups(gens[i]);

     for (var j=0; j<groupes.length;j++) {
       logFile.content += "\t"+groupes[j].properties.shortName +"\t";
       logFile.content += "\t"+groupes[j].properties.fullName +"\t";
       logFile.content += "\t"+groupes[j].properties.displayName +"\n";
     }
  }

The file is created with the user name shown correctly. However the group properties 'shortName', 'fullName' and 'displayName' are all null. In fact I printed out all the properties of the 'groupes' object and every field of the object is 'undefined'.

Does any body know what I am doing wrong?

Any help would be greatly appreciated.

Norm.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

以可爱出名 2024-11-25 10:42:32

最简单的方法就是彻底改变它。相反,对于每个组,询问它包含哪些组和哪些用户。最后,将其翻转。

您需要从根组开始。 Alfresco 中的 groups JS 对象将为您提供这些以及其他内容。它由 ScriptAuthorityService 实现,因此您可能需要查看 JavaDocs

首先,获取根组

var rootGroups = groups.getAllRootGroups() ;

对于每个组,获取该组中的所有用户(直接用户和继承用户) getAllUsers(),并将它们存储在某处。现在,使用 getChildGroups() 获取所有子组。以相同的方式处理每一个,并根据需要进行递归。

The easiest way would be to turn it on its head. Instead, for each group ask what groups and what users it contains. At the end, invert it.

You'll want to start with the Root Groups. The groups JS object in Alfresco will give you these, and others. It's implemented by ScriptAuthorityService, so you'll likely want to look at the JavaDocs

First up, get the root groups

var rootGroups = groups.getAllRootGroups() ;

For each group, get all the users in the group (direct and inherited) with getAllUsers(), and store those somewhere. Now, get all the child groups with getChildGroups(). Process each of these in the same way, recursing as needed.

看轻我的陪伴 2024-11-25 10:42:32

我需要类似的东西(完整的组列表),所以我这样做了:

var temp = [];

function addGroups (groups)
  {
    for each (group in groups)
      {
        temp.push(group.getDisplayName());
        addGroups(group.getChildGroups());
      }
  }

addGroups(groups.getAllRootGroups());

这在一定程度上有效。问题是 getDisplayName() 返回一个非常不漂亮的组名称。通常,在处理文档并显示与用户关联的组名称时,我会执行 people.getContainerGroups() 并使用 group.properties["cm:authorityName"] 来获取可显示的名称(如上所述),但是我收到的组getAllRootGroups() 没有属性(group.properties 未定义)。

有谁知道为什么以这种方式返回的组列表不会具有与 people.getContainerGroups() 返回的属性相同的属性?

I needed something similar (a complete list of groups) so I did this:

var temp = [];

function addGroups (groups)
  {
    for each (group in groups)
      {
        temp.push(group.getDisplayName());
        addGroups(group.getChildGroups());
      }
  }

addGroups(groups.getAllRootGroups());

This works to a point. The problem is that getDisplayName() returns a very non-pretty group name. Normally when dealing with documents and displaying a group name associated with a user I would do people.getContainerGroups() and use group.properties["cm:authorityName"] to get a displayable name (as mentioned above), however the groups I receive from getAllRootGroups() do not have properties (group.properties is undefined).

Does anyone have any idea why the group list returned this way wouldn't have the same properties as those returned by people.getContainerGroups()?

影子的影子 2024-11-25 10:42:32

我猜您使用了错误的属性名称。

您需要以下信息:

  • 全名:groupes[j].properties["usr:authorityName"]
  • 显示名称:groupes[j].properties["usr:authorityDisplayName"]
  • 短名称:我不知道:) 也许 groupes[j].properties["usr:authorityShortName"]

您也可以只获取 NodeRef id。

然后登录 Alfresco 浏览器。然后进入管理控制台-->节点浏览器

粘贴 id(它应该类似于 workspace://spacesStore //biglongUUID)。在那里您可以看到与该组相关的所有属性。

或者您可以循环groupes[k].properties 映射并打印所有属性。

I guess you're using the wrong properties name.

You need the following:

  • Full Name: groupes[j].properties["usr:authorityName"]
  • Display Name: groupes[j].properties["usr:authorityDisplayName"]
  • Short Name: I don't know :) maybe groupes[j].properties["usr:authorityShortName"]

You can also just get the NodeRef id.

Then login to Alfresco explorer. Then go to the administration console --> Node Browser

Paste the id (it should be something like workspace://spacesStore//biglongUUID).There you can see al the properties related to the group.

Or you could just loop the groupes[k].properties map and print all the properties.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文