001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Thomas Roger 016 */ 017 018package org.nuxeo.ecm.platform.usermanager.providers; 019 020import java.util.ArrayList; 021import java.util.List; 022 023import org.apache.commons.logging.Log; 024import org.apache.commons.logging.LogFactory; 025import org.nuxeo.ecm.core.api.DocumentModel; 026import org.nuxeo.ecm.core.api.NuxeoGroup; 027import org.nuxeo.ecm.platform.usermanager.UserManager; 028import org.nuxeo.runtime.api.Framework; 029 030/** 031 * Page provider listing {@link NuxeoGroup}s. 032 * 033 * @since 5.8 034 */ 035public class NuxeoGroupsPageProvider extends AbstractGroupsPageProvider<NuxeoGroup> { 036 037 private static final Log log = LogFactory.getLog(NuxeoGroupsPageProvider.class); 038 039 @Override 040 public List<NuxeoGroup> getCurrentPage() { 041 List<DocumentModel> groups = computeCurrentPage(); 042 List<NuxeoGroup> nuxeoGroups = new ArrayList<>(groups.size()); 043 UserManager userManager = Framework.getLocalService(UserManager.class); 044 for (DocumentModel group : groups) { 045 NuxeoGroup nuxeoGroup = userManager.getGroup( 046 group.getProperty(userManager.getGroupIdField()).getValue(String.class)); 047 nuxeoGroups.add(nuxeoGroup); 048 } 049 return nuxeoGroups; 050 } 051}