Getting Group Metadata - Alfresco Content Services - 23.4 - 23.4 - Ready - Alfresco - external

Alfresco Content Services

Platform
Alfresco
Product
Alfresco Content Services
Release
23.4
License

Getting metadata for a group uses the getGroup method of the GroupsApi.

For more information about this ReST API endpoint, see Get Group Metadata.

For a description of the common parameters, such as fields, see Common Parameters.

import org.alfresco.core.handler.GroupsApi;
import org.alfresco.core.model.GroupEntry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.List;

@Component
public class GetGroupCmd {
    static final Logger LOGGER = LoggerFactory.getLogger(GetGroupCmd.class);

    @Autowired
    GroupsApi groupsApi;

    public void execute(String groupId) throws IOException {
        List<String> fields = null;
        List<String> include = null;

        GroupEntry groupEntry = groupsApi.getGroup(groupId, include, fields).getBody();
        LOGGER.info("Got group metadata  {}", groupEntry.getEntry());
    }
}

Executing this code will get metadata for a group, in this case we are getting metadata for a group with id hr, note that you have to prefix group ids with GROUP_:

% java -jar target/rest-api-0.0.1-SNAPSHOT.jar get-group GROUP_hr

2021-05-06 10:31:37.864  INFO 25363 --- [           main] o.a.tutorial.restapi.RestApiApplication  : Started RestApiApplication in 3.763 seconds (JVM running for 4.242)
2021-05-06 10:31:37.866  INFO 25363 --- [           main] o.a.tutorial.restapi.RestApiApplication  : args[0]: get-group
2021-05-06 10:31:37.868  INFO 25363 --- [           main] o.a.tutorial.restapi.RestApiApplication  : args[1]: GROUP_hr
2021-05-06 10:31:38.025  INFO 25363 --- [           main] o.alfresco.tutorial.restapi.GetGroupCmd  : Got group metadata  class Group {
    id: GROUP_hr
    displayName: Human Resources
    isRoot: true
    parentIds: null
    zones: null
}