001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and contributors. 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 * Vladimir Pasquier <vpasquier@nuxeo.com> 016 */ 017 018package org.nuxeo.ecm.platform.groups.audit.operation; 019 020import java.io.File; 021import java.io.IOException; 022 023import org.nuxeo.ecm.automation.core.Constants; 024import org.nuxeo.ecm.automation.core.annotations.Context; 025import org.nuxeo.ecm.automation.core.annotations.Operation; 026import org.nuxeo.ecm.automation.core.annotations.OperationMethod; 027import org.nuxeo.ecm.core.api.Blob; 028import org.nuxeo.ecm.core.api.Blobs; 029import org.nuxeo.ecm.platform.groups.audit.ExcelExportConstants; 030import org.nuxeo.ecm.platform.groups.audit.service.ExcelExportService; 031 032/** 033 * Export Groups returns the Nuxeo groups excel report listing subgroups/users as a blob 034 * 035 * @since 5.7 036 */ 037@Operation(id = ExportGroups.ID, category = Constants.CAT_USERS_GROUPS, label = "ExportGroups", description = "Export Groups returns the Nuxeo groups excel report listing subgroups/users") 038public class ExportGroups { 039 040 public static final String ID = "UserManager.ExportGroups"; 041 042 @Context 043 ExcelExportService service; 044 045 @OperationMethod 046 public Blob run() throws IOException { 047 File export = service.getExcelReport(ExcelExportConstants.EXCEL_EXPORT_ALL_GROUPS); 048 if (export != null) { 049 return Blobs.createBlob(export); 050 } 051 return null; 052 } 053}