2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright 2009 University of California at Berkeley
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
16 * https://source.collectionspace.org/collection-space/LICENSE.txt
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
24 package org.collectionspace.services.report.nuxeo;
27 import java.io.FileInputStream;
28 import java.io.FileNotFoundException;
29 import java.io.FileOutputStream;
30 import java.io.InputStream;
31 import java.nio.file.Files;
32 import java.sql.Connection;
33 import java.sql.SQLException;
34 import java.util.HashMap;
35 import java.util.List;
38 import javax.ws.rs.core.MediaType;
39 import javax.naming.NamingException;
40 import javax.ws.rs.core.Response;
42 import net.sf.jasperreports.engine.JRException;
43 import net.sf.jasperreports.engine.JRExporter;
44 import net.sf.jasperreports.engine.JRExporterParameter;
45 import net.sf.jasperreports.engine.JRParameter;
46 import net.sf.jasperreports.engine.JasperCompileManager;
47 import net.sf.jasperreports.engine.JasperFillManager;
48 import net.sf.jasperreports.engine.JasperPrint;
49 import net.sf.jasperreports.engine.export.JRCsvExporter;
50 import net.sf.jasperreports.engine.export.JRCsvExporterParameter;
51 import net.sf.jasperreports.engine.export.JRHtmlExporter;
52 import net.sf.jasperreports.engine.export.JRPdfExporter;
53 import net.sf.jasperreports.engine.export.JRXmlExporter;
54 import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter;
55 import net.sf.jasperreports.engine.export.ooxml.JRPptxExporter;
56 import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter;
58 import org.collectionspace.authentication.AuthN;
59 import org.collectionspace.services.ReportJAXBSchema;
60 import org.collectionspace.services.account.AccountResource;
61 import org.collectionspace.services.authorization.AuthZ;
62 import org.collectionspace.services.authorization.CSpaceResource;
63 import org.collectionspace.services.authorization.PermissionException;
64 import org.collectionspace.services.authorization.URIResourceImpl;
65 import org.collectionspace.services.authorization.perms.ActionType;
66 import org.collectionspace.services.report.ResourceActionGroup;
67 import org.collectionspace.services.report.ResourceActionGroupList;
68 import org.collectionspace.services.report.ReportsCommon.ForRoles;
69 import org.collectionspace.services.report.MIMEType;
70 import org.collectionspace.services.report.MIMETypeItemType;
71 import org.collectionspace.services.report.ReportsCommon;
72 import org.collectionspace.services.report.ReportsOuputMimeList;
73 import org.collectionspace.services.client.PoxPayloadIn;
74 import org.collectionspace.services.client.PoxPayloadOut;
75 import org.collectionspace.services.client.ReportClient;
76 import org.collectionspace.services.common.CSWebApplicationException;
77 import org.collectionspace.services.common.ServiceMain;
78 import org.collectionspace.services.common.api.JEEServerDeployment;
79 import org.collectionspace.services.common.api.FileTools;
80 import org.collectionspace.services.common.api.Tools;
81 import org.collectionspace.services.common.authorization_mgt.ActionGroup;
82 import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
83 import org.collectionspace.services.common.context.ServiceBindingUtils;
84 import org.collectionspace.services.common.context.ServiceContext;
85 import org.collectionspace.services.common.document.BadRequestException;
86 import org.collectionspace.services.common.document.DocumentException;
87 import org.collectionspace.services.common.document.DocumentWrapper;
88 import org.collectionspace.services.common.invocable.Invocable;
89 import org.collectionspace.services.common.invocable.InvocationContext;
90 import org.collectionspace.services.common.storage.JDBCTools;
91 import org.collectionspace.services.config.service.ServiceBindingType;
92 import org.collectionspace.services.config.types.PropertyItemType;
93 import org.collectionspace.services.jaxb.InvocableJAXBSchema;
94 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
95 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
96 import org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl;
97 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
99 import org.jfree.util.Log;
101 import org.nuxeo.ecm.core.api.model.PropertyException;
102 import org.nuxeo.ecm.core.api.DocumentModel;
104 import org.slf4j.Logger;
105 import org.slf4j.LoggerFactory;
108 * ReportDocumentModelHandler
110 * $LastChangedRevision: $
111 * $LastChangedDate: $
113 public class ReportDocumentModelHandler extends NuxeoDocumentModelHandler<ReportsCommon> {
114 private final Logger logger = LoggerFactory.getLogger(ReportDocumentModelHandler.class);
115 private static String REPORTS_FOLDER = "reports";
116 private static String CSID_LIST_SEPARATOR = ",";
118 private static String REPORTS_STD_CSID_PARAM = "csid";
119 private static String REPORTS_STD_GROUPCSID_PARAM = "groupcsid";
120 private static String REPORTS_STD_CSIDLIST_PARAM = "csidlist";
121 private static String REPORTS_STD_TENANTID_PARAM = "tenantid";
124 // Map the MIME types from the service bindings to our payload output
126 public ReportsOuputMimeList getSupportMIMETypes(
127 ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
129 // Create a new payload response instance and initialize it
131 ReportsOuputMimeList result = new ReportsOuputMimeList();
132 MIMEType resultMIMEType = result.getMIMETypeList();
133 if (resultMIMEType == null) {
134 result.setMIMETypeList(resultMIMEType = new MIMEType());
136 List<MIMETypeItemType> resultMIMETypeItemList = resultMIMEType.getMIMEType();
139 // Read the MIME type values from the service bindings and put into our response payload
141 TenantBindingConfigReaderImpl tReader =
142 ServiceMain.getInstance().getTenantBindingConfigReader();
143 ServiceBindingType reportServiceBinding = tReader.getServiceBinding(ctx.getTenantId(), ctx.getServiceName());
144 List<PropertyItemType> bindingsMIMETypeList = ServiceBindingUtils.getPropertyValueList(reportServiceBinding, ServiceBindingUtils.OUTPUT_MIME_PROP);
146 if (bindingsMIMETypeList != null) {
147 for (PropertyItemType bindingItemMimeType : bindingsMIMETypeList) {
148 MIMETypeItemType resultMimeTypeItem = new MIMETypeItemType();
149 String displayName = bindingItemMimeType.getDisplayName();
150 if (displayName != null && displayName.trim().isEmpty() == false) {
151 resultMimeTypeItem.setKey(displayName);
153 resultMimeTypeItem.setKey(bindingItemMimeType.getValue());
155 resultMimeTypeItem.setValue(bindingItemMimeType.getValue());
156 resultMIMETypeItemList.add(resultMimeTypeItem);
163 public InputStream invokeReport(
164 ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
166 ReportsCommon reportsCommon,
167 InvocationContext invContext,
168 StringBuffer outMimeType,
169 StringBuffer outReportFileName) throws Exception {
170 CoreSessionInterface repoSession = null;
171 boolean releaseRepoSession = false;
173 // Ensure the current user has permission to run this report
174 if (isAuthoritzed(reportsCommon) == false) {
175 String msg = String.format("Report Resource: The user '%s' is not authorized to run the report '%s' CSID='%s'",
176 AuthN.get().getUserId(), reportsCommon.getName(), csid);
177 throw new PermissionException(msg);
180 String invocationMode = invContext.getMode();
181 String modeProperty = null;
182 HashMap<String, Object> params = new HashMap<String, Object>();
183 params.put(REPORTS_STD_TENANTID_PARAM, ctx.getTenantId());
184 boolean checkDocType = true;
186 // Note we set before we put in the default ones, so they cannot override tenant or CSID.
187 setParamsFromContext(params, invContext);
189 if (Invocable.INVOCATION_MODE_SINGLE.equalsIgnoreCase(invocationMode)) {
190 modeProperty = InvocableJAXBSchema.SUPPORTS_SINGLE_DOC;
191 params.put(REPORTS_STD_CSID_PARAM, invContext.getSingleCSID());
192 } else if (Invocable.INVOCATION_MODE_LIST.equalsIgnoreCase(invocationMode)) {
193 modeProperty = InvocableJAXBSchema.SUPPORTS_DOC_LIST;
194 List<String> csids = null;
195 InvocationContext.ListCSIDs listThing = invContext.getListCSIDs();
196 if (listThing!=null) {
197 csids = listThing.getCsid();
199 if (csids==null||csids.isEmpty()){
200 throw new BadRequestException(
201 "ReportResource: Report invoked in list mode, with no csids in list." );
203 StringBuilder sb = new StringBuilder();
204 boolean first = true;
205 for(String csidItem : csids) {
209 sb.append(CSID_LIST_SEPARATOR);
212 params.put(REPORTS_STD_CSIDLIST_PARAM, sb.toString());
213 } else if(Invocable.INVOCATION_MODE_GROUP.equalsIgnoreCase(invocationMode)) {
214 modeProperty = InvocableJAXBSchema.SUPPORTS_GROUP;
215 params.put(REPORTS_STD_GROUPCSID_PARAM, invContext.getGroupCSID());
216 } else if(Invocable.INVOCATION_MODE_NO_CONTEXT.equalsIgnoreCase(invocationMode)) {
217 modeProperty = InvocableJAXBSchema.SUPPORTS_NO_CONTEXT;
218 checkDocType = false;
220 throw new BadRequestException("ReportResource: unknown Invocation Mode: "
224 NuxeoRepositoryClientImpl repoClient = (NuxeoRepositoryClientImpl)this.getRepositoryClient(ctx);
225 repoSession = this.getRepositorySession();
226 if (repoSession == null) {
227 repoSession = repoClient.getRepositorySession(ctx);
228 releaseRepoSession = true;
231 // Get properties from the report docModel, and release the session
232 String reportFileNameProperty;
234 DocumentWrapper<DocumentModel> wrapper = repoClient.getDoc(repoSession, ctx, csid);
235 DocumentModel docModel = wrapper.getWrappedObject();
236 Boolean supports = (Boolean) NuxeoUtils.getProperyValue(docModel, modeProperty); //docModel.getPropertyValue(modeProperty);
237 if(supports == null || !supports) {
238 throw new BadRequestException(
239 "ReportResource: This Report does not support Invocation Mode: "
243 List<String> forDocTypeList =
244 (List<String>) NuxeoUtils.getProperyValue(docModel, InvocableJAXBSchema.FOR_DOC_TYPES); //docModel.getPropertyValue(InvocableJAXBSchema.FOR_DOC_TYPES);
245 if (forDocTypeList==null || !forDocTypeList.contains(invContext.getDocType())) {
246 throw new BadRequestException(
247 "ReportResource: Invoked with unsupported document type: "
248 +invContext.getDocType());
251 reportFileNameProperty = (String) NuxeoUtils.getProperyValue(docModel, ReportJAXBSchema.FILENAME); //docModel.getPropertyValue(ReportJAXBSchema.FILENAME)); // Set the outgoing param with the report file name
253 // If the invocation context contains a MIME type then use it. Otherwise, look in the report resource. If no MIME type in the report resource,
254 // use the default MIME type.
256 if (!Tools.isEmpty(invContext.getOutputMIME())) {
257 outMimeType.append(invContext.getOutputMIME());
258 } else if (Tools.isEmpty(outMimeType.toString()) && params.containsKey("OutputMIME")) {
259 // See UCB - https://github.com/cspace-deployment/services/pull/140/files
260 outMimeType.append(params.get("OutputMIME"));
263 String reportOutputMime = (String) NuxeoUtils.getProperyValue(docModel, ReportJAXBSchema.OUTPUT_MIME); //docModel.getPropertyValue(ReportJAXBSchema.OUTPUT_MIME);
264 if (!Tools.isEmpty(reportOutputMime)) {
265 outMimeType.append(reportOutputMime);
267 outMimeType.append(ReportClient.DEFAULT_REPORT_OUTPUT_MIME);
270 } catch (PropertyException pe) {
271 if (logger.isDebugEnabled()) {
272 logger.debug("Property exception getting report values: ", pe);
275 } catch (DocumentException de) {
276 if (logger.isDebugEnabled()) {
277 logger.debug("Problem getting report report: ", de);
280 } catch (Exception e) {
281 if (logger.isDebugEnabled()) {
282 logger.debug("Caught exception ", e);
284 throw new DocumentException(e);
286 if (releaseRepoSession && repoSession != null) {
287 repoClient.releaseRepositorySession(ctx, repoSession);
291 return buildReportResult(csid, params, reportFileNameProperty, outMimeType.toString(), outReportFileName);
294 private void setParamsFromContext(Map<String, Object> params, InvocationContext invContext) {
295 InvocationContext.Params icParams = invContext.getParams();
296 if(icParams!= null) {
297 List<InvocationContext.Params.Param> icParamList = icParams.getParam();
298 if(icParamList != null) {
299 for(InvocationContext.Params.Param param:icParamList) {
300 String key = param.getKey();
301 String value = param.getValue();
302 if(!Tools.isEmpty(key) && !Tools.isEmpty(value)) {
303 params.put(key, value);
311 private InputStream buildReportResult(String reportCSID,
312 HashMap<String, Object> params, String reportFileName, String outputMimeType, StringBuffer outReportFileName)
314 Connection conn = null;
315 InputStream result = null;
318 String fileNameBase = Tools.getFilenameBase(reportFileName);
319 String compiledReportFilename = fileNameBase+ReportClient.COMPILED_REPORT_EXTENSION;
320 String reportDescriptionFilename = fileNameBase+ReportClient.REPORT_DECSRIPTION_EXTENSION;
322 String basePath = ServiceMain.getInstance().getServerRootDir() +
323 File.separator + JEEServerDeployment.CSPACE_DIR_NAME +
324 File.separator + REPORTS_FOLDER +
325 // File.separator + tenantName +
326 File.separator; // + reportFileName;
328 String compiledFilePath = basePath+compiledReportFilename;
329 File f = new File(compiledFilePath);
330 if(!f.exists()) { // Need to compile the file
331 // First verify that there is a source file.
332 String sourceFilePath = basePath+reportDescriptionFilename;
333 File f2 = new File(sourceFilePath);
334 if(!f2.exists()) { // Missing source file - error!
335 logger.error("Report for csid={} is missing the specified source file: {}",
336 reportCSID, sourceFilePath);
337 throw new RuntimeException("Report is missing the specified source file!");
339 logger.info("Report for csid={} is not compiled. Compiling first, and saving to: {}",
340 reportCSID, compiledFilePath);
341 JasperCompileManager.compileReportToFile(sourceFilePath, compiledFilePath);
344 conn = getConnection();
346 if (logger.isTraceEnabled()) {
347 logger.trace("ReportResource for csid=" + reportCSID
348 +" output as "+outputMimeType+" using report file: "+compiledFilePath);
350 FileInputStream fileStream = new FileInputStream(compiledFilePath);
352 // export report to pdf and build a response with the bytes
353 //JasperExportManager.exportReportToPdf(jasperprint);
355 JRExporter exporter = null;
356 // Strip extension from report filename.
357 String outputFilename = reportFileName;
358 // Strip extension from report filename.
359 int idx = outputFilename.lastIndexOf(".");
361 outputFilename = outputFilename.substring(0, idx);
362 // Strip any sub-dir from report filename.
363 idx = outputFilename.lastIndexOf(File.separator);
365 outputFilename = outputFilename.substring(idx+1);
366 if(outputMimeType.equals(MediaType.APPLICATION_XML)) {
367 params.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.TRUE);
368 exporter = new JRXmlExporter();
369 outputFilename = outputFilename+".xml";
370 } else if(outputMimeType.equals(MediaType.TEXT_HTML)) {
371 exporter = new JRHtmlExporter();
372 outputFilename = outputFilename+".html";
373 } else if(outputMimeType.equals(ReportClient.PDF_MIME_TYPE)) {
374 exporter = new JRPdfExporter();
375 outputFilename = outputFilename+".pdf";
376 } else if(outputMimeType.equals(ReportClient.CSV_MIME_TYPE)) {
377 params.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.TRUE);
378 exporter = new JRCsvExporter();
379 exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, ",");
380 outputFilename = outputFilename+".csv";
381 } else if(outputMimeType.equals(ReportClient.TSV_MIME_TYPE)) {
382 params.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.TRUE);
383 exporter = new JRCsvExporter();
384 exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, "\t");
385 outputFilename = outputFilename+".csv";
386 } else if(outputMimeType.equals(ReportClient.MSWORD_MIME_TYPE) // Understand msword as docx
387 || outputMimeType.equals(ReportClient.OPEN_DOCX_MIME_TYPE)) {
388 exporter = new JRDocxExporter();
389 outputFilename = outputFilename+".docx";
390 } else if(outputMimeType.equals(ReportClient.MSEXCEL_MIME_TYPE) // Understand msexcel as xlsx
391 || outputMimeType.equals(ReportClient.OPEN_XLSX_MIME_TYPE)) {
392 exporter = new JRXlsxExporter();
393 outputFilename = outputFilename+".xlsx";
394 } else if(outputMimeType.equals(ReportClient.MSPPT_MIME_TYPE) // Understand msppt as xlsx
395 || outputMimeType.equals(ReportClient.OPEN_PPTX_MIME_TYPE)) {
396 exporter = new JRPptxExporter();
397 outputFilename = outputFilename+".pptx";
399 logger.error("Reporting: unsupported output MIME type - defaulting to PDF");
400 exporter = new JRPdfExporter();
401 outputFilename = outputFilename+"-default-to.pdf";
403 outReportFileName.append(outputFilename); // Set the out going param to the report's final file name
404 // FIXME: Logging temporarily set to INFO level for CSPACE-5766;
405 // can change to TRACE or DEBUG level as warranted thereafter
406 if (logger.isInfoEnabled()) {
407 logger.info(FileTools.getJavaTmpDirInfo());
410 JasperPrint jasperPrint = JasperFillManager.fillReport(fileStream, params,conn);
412 // Report will be to a temporary file.
413 File tempOutputFile = Files.createTempFile("report-", null).toFile();
414 FileOutputStream tempOutputStream = new FileOutputStream(tempOutputFile);
415 exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
416 exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, tempOutputStream);
417 exporter.exportReport();
418 tempOutputStream.close();
420 result = new FileInputStream(tempOutputFile);
422 } catch (SQLException sqle) {
423 // SQLExceptions can be chained. We have at least one exception, so
424 // set up a loop to make sure we let the user know about all of them
425 // if there happens to be more than one.
426 if (logger.isDebugEnabled()) {
427 SQLException tempException = sqle;
428 while (null != tempException) {
429 logger.debug("SQL Exception: " + sqle.getLocalizedMessage());
431 // loop to the next exception
432 tempException = tempException.getNextException();
435 Response response = Response.status(
436 Response.Status.INTERNAL_SERVER_ERROR).entity(
437 "Invoke failed (SQL problem) on Report csid=" + reportCSID).type("text/plain").build();
438 throw new CSWebApplicationException(sqle, response);
439 } catch (JRException jre) {
440 if (logger.isDebugEnabled()) {
441 logger.debug("JR Exception: " + jre.getLocalizedMessage() + " Cause: "+jre.getCause());
443 Response response = Response.status(
444 Response.Status.INTERNAL_SERVER_ERROR).entity(
445 "Invoke failed (Jasper problem) on Report csid=" + reportCSID).type("text/plain").build();
446 throw new CSWebApplicationException(jre, response);
447 } catch (FileNotFoundException fnfe) {
448 if (logger.isDebugEnabled()) {
449 logger.debug("FileNotFoundException: " + fnfe.getLocalizedMessage());
451 Response response = Response.status(
452 Response.Status.INTERNAL_SERVER_ERROR).entity(
453 "Invoke failed (SQL problem) on Report csid=" + reportCSID).type("text/plain").build();
454 throw new CSWebApplicationException(fnfe, response);
459 } catch (SQLException sqle) {
460 // SQLExceptions can be chained. We have at least one exception, so
461 // set up a loop to make sure we let the user know about all of them
462 // if there happens to be more than one.
463 if (logger.isDebugEnabled()) {
464 logger.debug("SQL Exception closing connection: "
465 + sqle.getLocalizedMessage());
467 } catch (Exception e) {
468 if (logger.isDebugEnabled()) {
469 logger.debug("Exception closing connection", e);
476 private Connection getConnection() throws NamingException, SQLException {
477 Connection result = null;
479 ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
481 String repositoryName = ctx.getRepositoryName();
482 if (repositoryName != null && repositoryName.trim().isEmpty() == false) {
483 String cspaceInstanceId = ServiceMain.getInstance().getCspaceInstanceId();
484 String databaseName = JDBCTools.getDatabaseName(repositoryName, cspaceInstanceId);
485 result = JDBCTools.getConnection(JDBCTools.NUXEO_READER_DATASOURCE_NAME, databaseName);
487 } catch (Exception e) {
489 throw new NamingException();
496 * Check to see if the current user is authorized to run/invoke this report. If the report
497 * did not specify any permissions, we assume that the current user is authorized to run the report.
498 * @param reportsCommon
501 protected boolean isAuthoritzedWithPermissions(ReportsCommon reportsCommon) {
502 boolean result = true;
504 ResourceActionGroupList resourceActionGroupList = reportsCommon.getResourceActionGroupList();
505 if (resourceActionGroupList != null) {
506 String tenantId = AuthN.get().getCurrentTenantId();
507 for (ResourceActionGroup resourceActionGroup: resourceActionGroupList.getResourceActionGroup()) {
508 String resourceName = resourceActionGroup.getResourceName();
509 ActionGroup actionGroup = ActionGroup.creatActionGroup(resourceActionGroup.getActionGroup());
510 for (ActionType actionType: actionGroup.getActions()) {
511 CSpaceResource res = new URIResourceImpl(tenantId, resourceName, AuthZ.getMethod(actionType));
512 if (AuthZ.get().isAccessAllowed(res) == false) {
523 * Returns true if we found any required permissions.
525 * @param reportCommon
528 private boolean hasRequiredPermissions(ReportsCommon reportCommon) {
529 boolean result = false;
532 result = reportCommon.getResourceActionGroupList().getResourceActionGroup().size() > 0;
533 } catch (NullPointerException e) {
534 // ignore exception, we're just testing to see if we have any list elements
541 * Returns true if we found any required roles.
543 * @param reportCommon
546 private boolean hasRequiredRoles(ReportsCommon reportCommon) {
547 boolean result = false;
550 result = reportCommon.getForRoles().getRoleDisplayName().size() > 0;
551 } catch (NullPointerException e) {
552 // ignore exception, we're just testing to see if we have any list elements
559 * The current user is authorized to run the report if:
560 * 1. No permissions or roles are specified in the report
561 * 2. No roles are specified, but permissions are specified and the current user has those permissions
562 * 3. Roles are specified and the current user is a member of at least one of the roles.
564 * @param reportsCommon
567 protected boolean isAuthoritzed(ReportsCommon reportsCommon) {
568 boolean result = true;
570 if (hasRequiredRoles(reportsCommon)) {
571 result = isAuthorizedWithRoles(reportsCommon);
572 } else if (hasRequiredPermissions(reportsCommon)) {
573 result = isAuthoritzedWithPermissions(reportsCommon);
579 protected boolean isAuthorizedWithRoles(ReportsCommon reportCommon) {
580 boolean result = false;
582 ForRoles forRolesList = reportCommon.getForRoles();
583 if (forRolesList != null) {
584 AccountResource accountResource = new AccountResource();
585 List<String> roleDisplayNameList = accountResource.getAccountRoles(AuthN.get().getUserId(), AuthN.get().getCurrentTenantId());
586 for (String target : forRolesList.getRoleDisplayName()) {
587 if (Tools.listContainsIgnoreCase(roleDisplayNameList, target)) {