Skip to content

Commit

Permalink
Expose a group service for content
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriziovitale committed Jul 6, 2020
1 parent a107775 commit 6180c9d
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 3 deletions.
18 changes: 18 additions & 0 deletions lib/content-services/src/lib/group/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export * from './public-api';
18 changes: 18 additions & 0 deletions lib/content-services/src/lib/group/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export * from './services/group.service';
43 changes: 43 additions & 0 deletions lib/content-services/src/lib/group/services/group.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Injectable } from '@angular/core';
import { GroupEntry } from '@alfresco/js-api';
import { AlfrescoApiService } from '@alfresco/adf-core';

@Injectable({
providedIn: 'root'
})
export class GroupService {
constructor(
private alfrescoApiService: AlfrescoApiService
) {}

async listAllGroupMembershipsForPerson(personId: string, opts?: any, accumulator = []): Promise<GroupEntry[]> {
const groupsPaginated = await this.alfrescoApiService.groupsApi.listGroupMembershipsForPerson(personId, opts);
accumulator = [...accumulator, ...groupsPaginated.list.entries];
if (groupsPaginated.list.pagination.hasMoreItems) {
const skip = groupsPaginated.list.pagination.skipCount + groupsPaginated.list.pagination.count;
return this.listAllGroupMembershipsForPerson(personId, {
maxItems: opts.maxItems,
skipCount: skip
}, accumulator);
} else {
return accumulator;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class NodePermissionService {
* @returns List of members
*/
getGroupMemberByGroupName(groupName: string, opts?: any): Observable<GroupMemberPaging> {
return from(this.apiService.groupsApi.getGroupMembers(groupName, opts));
return from(this.apiService.groupsApi.listGroupMemberships(groupName, opts));
}

private formattedRoleName(displayName, siteName): string {
Expand Down
1 change: 1 addition & 0 deletions lib/content-services/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export * from './lib/content-metadata/index';
export * from './lib/permission-manager/index';
export * from './lib/content-node-share/index';
export * from './lib/tree-view/index';
export * from './lib/group/index';

export * from './lib/content.module';
5 changes: 3 additions & 2 deletions lib/core/services/alfresco-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
Activiti,
SearchApi,
Node,
GroupsApi,
AlfrescoApiCompatibility, AlfrescoApiConfig
} from '@alfresco/js-api';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
Expand Down Expand Up @@ -95,8 +96,8 @@ export class AlfrescoApiService {
return this.getInstance().core.classesApi;
}

get groupsApi(): Core.GroupsApi {
return this.getInstance().core.groupsApi;
get groupsApi(): GroupsApi {
return new GroupsApi(this.getInstance());
}

constructor(
Expand Down

0 comments on commit 6180c9d

Please sign in to comment.