From 392cffbcd6418e886bd41fcd27c319482de93097 Mon Sep 17 00:00:00 2001 From: Ray Lee Date: Tue, 18 Jun 2019 12:54:39 -0700 Subject: [PATCH] DRYD-654: Allow filtering reports and batch jobs by more than one mode. --- .../services/batch/BatchResource.java | 42 ++++---- .../services/client/IQueryManager.java | 58 +++++------ .../services/common/query/QueryManager.java | 45 +++++---- .../query/nuxeo/QueryManagerNuxeoImpl.java | 95 +++++++++++-------- .../services/report/ReportResource.java | 65 ++++++------- 5 files changed, 168 insertions(+), 137 deletions(-) diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/BatchResource.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/BatchResource.java index d4433426b..fb3c912da 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/BatchResource.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/BatchResource.java @@ -43,6 +43,8 @@ import org.collectionspace.services.common.invocable.InvocationResults; import org.collectionspace.services.common.query.QueryManager; import org.collectionspace.services.jaxb.AbstractCommonList; +import java.util.List; + import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -58,7 +60,7 @@ import javax.ws.rs.core.UriInfo; @Produces({"application/xml"}) @Consumes({"application/xml"}) public class BatchResource extends NuxeoBasedResource { - + protected final String COMMON_SCHEMA = "batch_common"; @Override @@ -77,7 +79,7 @@ public class BatchResource extends NuxeoBasedResource { public Class getCommonPartClass() { return BatchCommon.class; } - + // other resource methods and use the getRepositoryClient() methods. @Override protected AbstractCommonList getCommonList(UriInfo ui) { @@ -86,29 +88,29 @@ public class BatchResource extends NuxeoBasedResource { MultivaluedMap queryParams = ctx.getQueryParams(); DocumentHandler handler = createDocumentHandler(ctx); String docType = queryParams.getFirst(IQueryManager.SEARCH_TYPE_DOCTYPE); - String mode = queryParams.getFirst(IQueryManager.SEARCH_TYPE_INVOCATION_MODE); + List modes = queryParams.get(IQueryManager.SEARCH_TYPE_INVOCATION_MODE); String whereClause = null; DocumentFilter documentFilter = null; String common_part = ctx.getCommonPartLabel(); - + if (docType != null && !docType.isEmpty()) { whereClause = QueryManager.createWhereClauseForInvocableByDocType( common_part, docType); documentFilter = handler.getDocumentFilter(); documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND); } - - if (mode != null && !mode.isEmpty()) { + + if (modes != null && !modes.isEmpty()) { whereClause = QueryManager.createWhereClauseForInvocableByMode( - common_part, mode); + common_part, modes); documentFilter = handler.getDocumentFilter(); documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND); } - + if (whereClause !=null && logger.isDebugEnabled()) { logger.debug("The WHERE clause is: " + documentFilter.getWhereClause()); } - + getRepositoryClient(ctx).getFiltered(ctx, handler); AbstractCommonList list = (AbstractCommonList) handler.getCommonPartList(); return list; @@ -116,16 +118,16 @@ public class BatchResource extends NuxeoBasedResource { throw bigReThrow(e, ServiceMessages.LIST_FAILED); } } - + /** * Gets the authorityItem list for the specified authority * If partialPerm is specified, keywords will be ignored. - * + * * @param specifier either a CSID or one of the urn forms * @param partialTerm if non-null, matches partial terms * @param keywords if non-null, matches terms in the keyword index for items * @param ui passed to include additional parameters, like pagination controls - * + * * @return the authorityItem list */ @GET @@ -166,9 +168,9 @@ public class BatchResource extends NuxeoBasedResource { throw bigReThrow(e, ServiceMessages.SEARCH_FAILED); } } - + private String createWhereClauseForDocType(String docType) { - String trimmed = (docType == null)?"":docType.trim(); + String trimmed = (docType == null)?"":docType.trim(); if (trimmed.isEmpty()) { throw new RuntimeException("No docType specified."); } @@ -179,7 +181,7 @@ public class BatchResource extends NuxeoBasedResource { } private String createWhereClauseForMode(String mode) throws BadRequestException { - String trimmed = (mode == null)?"":mode.trim(); + String trimmed = (mode == null)?"":mode.trim(); if (trimmed.isEmpty()) { throw new RuntimeException("No mode specified."); } @@ -195,18 +197,18 @@ public class BatchResource extends NuxeoBasedResource { } return ptClause; } - + private BatchCommon getBatchCommon(String csid) throws Exception { BatchCommon result = null; - + ServiceContext ctx = createServiceContext(); PoxPayloadOut ppo = get(csid, ctx); PayloadPart batchCommonPart = ppo.getPart(BatchClient.SERVICE_COMMON_PART_NAME); result = (BatchCommon)batchCommonPart.getBody(); - + return result; } - + @POST @Path("{csid}") public InvocationResults invokeBatchJob( @@ -220,7 +222,7 @@ public class BatchResource extends NuxeoBasedResource { BatchDocumentModelHandler handler = (BatchDocumentModelHandler)createDocumentHandler(ctx); return handler.invokeBatchJob(ctx, csid, resourceMap, invContext, getBatchCommon(csid)); } catch (Exception e) { - String msg = String.format("%s Could not invoke batch job with CSID='%s'.", + String msg = String.format("%s Could not invoke batch job with CSID='%s'.", ServiceMessages.POST_FAILED, csid); throw bigReThrow(e, msg); } diff --git a/services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java b/services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java index e4133a6f1..f287539c4 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java +++ b/services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java @@ -1,4 +1,4 @@ -/** +/** * IQueryManager.java * * {Purpose of This Class} @@ -26,8 +26,10 @@ */ package org.collectionspace.services.client; +import java.util.List; + public interface IQueryManager { - + final static String SEARCH_GROUP_OPEN = "("; final static String SEARCH_GROUP_CLOSE = ")"; final static String SEARCH_TERM_SEPARATOR = " "; @@ -44,7 +46,7 @@ public interface IQueryManager { final static String SEARCH_QUALIFIER_OR = SEARCH_TERM_SEPARATOR + "OR" + SEARCH_TERM_SEPARATOR; final static String DEFAULT_SELECT_CLAUSE = "SELECT * FROM "; final static String CSID_QUERY_PARAM = "csid"; - + // // Nuxeo pseudo-values (and filters) for special document properties. @@ -57,7 +59,7 @@ public interface IQueryManager { // In the CMIS context, the prefix is nuxeo, not ecm final static String NUXEO_CMIS_IS_VERSION = "nuxeo:isVersion"; final static String NUXEO_CMIS_IS_VERSION_FILTER = NUXEO_CMIS_IS_VERSION + " = false"; - + // // Query params for CMIS queries on the relationship (Relation) table. // @@ -68,10 +70,10 @@ public interface IQueryManager { final static String SEARCH_RELATED_TO_CSID_AS_EITHER = "rtSbjOrObj"; final static String SEARCH_RELATED_MATCH_OBJ_DOCTYPES = "rtObjDocTypes"; final static String SELECT_DOC_TYPE_FIELD = "selectDocType"; - + final static String MARK_RELATED_TO_CSID_AS_SUBJECT = "mkRtSbj"; final static String MARK_RELATED_TO_CSID_AS_EITHER = "mkRtSbjOrObj"; - + // // Generic CMIS property mapping constants // @@ -84,14 +86,14 @@ public interface IQueryManager { final static String CMIS_NUXEO_TITLE = "dc:title"; final static String CMIS_CS_UPDATED_AT = CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA + ":" + CollectionSpaceClient.COLLECTIONSPACE_CORE_UPDATED_AT; - + // CollectionSpace CMIS property mapping constants final static String CMIS_TARGET_PREFIX = "DOC"; final static String CMIS_CORESCHEMA_PREFIX = "CORE"; // Relations CMIS property mapping constants final static String CMIS_RELATIONS_PREFIX = "REL"; - - final static String CMIS_JOIN_NUXEO_IS_VERSION_FILTER = + + final static String CMIS_JOIN_NUXEO_IS_VERSION_FILTER = IQueryManager.CMIS_TARGET_PREFIX + "." + IQueryManager.NUXEO_CMIS_IS_VERSION_FILTER; final static String CMIS_JOIN_TENANT_ID_FILTER = IQueryManager.CMIS_RELATIONS_PREFIX + "." + CollectionSpaceClient.CORE_TENANTID; @@ -101,31 +103,31 @@ public interface IQueryManager { final static String CMIS_TARGET_TITLE = CMIS_TARGET_PREFIX + "." + CMIS_NUXEO_TITLE; final static String CMIS_TARGET_NAME = CMIS_TARGET_PREFIX + "." + CMIS_NUXEO_NAME; final static String CMIS_TARGET_UPDATED_AT = CMIS_TARGET_PREFIX + "." + CMIS_CS_UPDATED_AT; - + final static String TENANT_USES_STARTING_WILDCARD_FOR_PARTIAL_TERM = "ptStartingWildcard"; final static String MAX_LIST_ITEMS_RETURNED_LIMIT_ON_JDBC_QUERIES = "maxListItemsReturnedLimitOnJdbcQueries"; final static String JDBC_QUERIES_ARE_TENANT_ID_RESTRICTED = "jdbcQueriesAreTenantIdRestricted"; public void execQuery(String queryString); - + public String getDatasourceName(); - + /** * Creates the where clause from keywords. - * + * * @param keywords the keywords - * + * * @return the string */ public String createWhereClauseFromKeywords(String keywords); - + public String createWhereClauseFromAdvancedSearch(String advancedSearch); final static boolean FILTER_EXCLUDE = true; final static boolean FILTER_INCLUDE = false; - + /** - * Creates a query to filter a qualified (string) field according to a list of string values. + * Creates a query to filter a qualified (string) field according to a list of string values. * @param qualifiedField The schema-qualified field to filter on * @param filterTerms the list of one or more strings to filter on * @param fExclude If true, will require qualifiedField NOT match the filters strings. @@ -133,13 +135,13 @@ public interface IQueryManager { * @return queryString */ public String createWhereClauseToFilterFromStringList(String qualifiedField, String[] filterTerms, boolean fExclude); - + /** * Creates the where clause for partial term match. - * + * * @param field the qualified field to match on * @param partialTerm the term to match against - * + * * @return the string */ public String createWhereClauseForPartialMatch(String dataSourceName, @@ -151,27 +153,29 @@ public interface IQueryManager { /** * Creates a filtering where clause from docType, for invocables. - * + * * @param schema the schema name for this invocable type * @param docType the docType - * + * * @return the string */ public String createWhereClauseForInvocableByDocType(String schema, String docType); - + /** * Creates a filtering where clause from invocation mode, for invocables. - * + * * @param schema the schema name for this invocable type * @param mode the mode - * + * * @return the string */ public String createWhereClauseForInvocableByMode(String schema, String mode); + public String createWhereClauseForInvocableByMode(String schema, List modes); + /* - * + * */ public String createWhereClauseFromCsid(String csid); - + } diff --git a/services/common/src/main/java/org/collectionspace/services/common/query/QueryManager.java b/services/common/src/main/java/org/collectionspace/services/common/query/QueryManager.java index 5790575c6..f53394013 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/query/QueryManager.java +++ b/services/common/src/main/java/org/collectionspace/services/common/query/QueryManager.java @@ -1,4 +1,4 @@ -/** +/** * QueryManager.java * * {Purpose of This Class} @@ -26,6 +26,8 @@ */ package org.collectionspace.services.common.query; +import java.util.List; + import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; @@ -36,32 +38,32 @@ import org.collectionspace.services.config.tenant.TenantBindingType; public class QueryManager { static private final IQueryManager queryManager = new QueryManagerNuxeoImpl(); - + /** * Creates the where clause from keywords. - * + * * @param keywords the keywords - * + * * @return the string */ static public String createWhereClauseFromKeywords(String keywords) { return queryManager.createWhereClauseFromKeywords(keywords); } - + static public String createWhereClauseFromAdvancedSearch(String keywords) { return queryManager.createWhereClauseFromAdvancedSearch(keywords); } - + static public String createWhereClauseFromCsid(String csid) { return queryManager.createWhereClauseFromCsid(csid); - } - + } + /** * Creates the where clause for partial term match. - * + * * @param field the qualified field to match on * @param partialTerm the term to match against - * + * * @return the string */ static public String createWhereClauseForPartialMatch(ServiceContext ctx, @@ -75,15 +77,15 @@ public class QueryManager { TenantBindingType tenantBinding = tReader.getTenantBinding(ctx.getTenantId()); String ptStartingWildcardValue = TenantBindingUtils.getPropertyValue(tenantBinding, IQueryManager.TENANT_USES_STARTING_WILDCARD_FOR_PARTIAL_TERM); - boolean ptStartingWildcard = (ptStartingWildcardValue==null) + boolean ptStartingWildcard = (ptStartingWildcardValue==null) || Boolean.parseBoolean(ptStartingWildcardValue); return queryManager.createWhereClauseForPartialMatch(queryManager.getDatasourceName(), repositoryName, cspaceInstanceId, field, ptStartingWildcard, partialTerm); } - + /** - * Creates a query to filter a qualified (string) field according to a list of string values. + * Creates a query to filter a qualified (string) field according to a list of string values. * @param qualifiedField The schema-qualified field to filter on * @param filterTerms the list of one or more strings to filter on * @param fExclude If true, will require qualifiedField NOT match the filters strings. @@ -94,29 +96,32 @@ public class QueryManager { return queryManager.createWhereClauseToFilterFromStringList(qualifiedField, filterTerms, fExclude); } - + /** * Creates a filtering where clause from docType, for invocables. - * + * * @param schema the schema name for this invocable type * @param docType the docType - * + * * @return the string */ static public String createWhereClauseForInvocableByDocType(String schema, String docType) { return queryManager.createWhereClauseForInvocableByDocType(schema, docType); } - + /** * Creates a filtering where clause from invocation mode, for invocables. - * + * * @param schema the schema name for this invocable type * @param mode the mode - * + * * @return the string */ static public String createWhereClauseForInvocableByMode(String schema, String mode) { return queryManager.createWhereClauseForInvocableByMode(schema, mode); } - + + static public String createWhereClauseForInvocableByMode(String schema, List modes) { + return queryManager.createWhereClauseForInvocableByMode(schema, modes); + } } diff --git a/services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java b/services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java index c947fedfc..65fa50e7c 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java @@ -1,4 +1,4 @@ -/** +/** * QueryManagerNuxeoImpl.java * * {Purpose of This Class} @@ -26,27 +26,24 @@ */ package org.collectionspace.services.common.query.nuxeo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -//import org.nuxeo.ecm.core.client.NuxeoClient; - - - +import org.apache.commons.lang3.StringUtils; import org.collectionspace.services.jaxb.InvocableJAXBSchema; -//import org.collectionspace.services.nuxeo.client.java.NuxeoConnector; -//import org.collectionspace.services.nuxeo.client.java.NxConnect; - import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.common.invocable.InvocableUtils; import org.collectionspace.services.common.storage.DatabaseProductType; import org.collectionspace.services.common.storage.JDBCTools; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class QueryManagerNuxeoImpl implements IQueryManager { private static String ECM_FULLTEXT_LIKE = "ecm:fulltext" @@ -64,7 +61,7 @@ public class QueryManagerNuxeoImpl implements IQueryManager { private static Pattern unescapedDblQuotes = Pattern.compile("(? modes) { if (schema == null || schema.isEmpty()) { throw new RuntimeException("No match schema specified."); } - String wClause = InvocableUtils.getPropertyNameForInvocationMode( - schema, trimmed) + " != 0"; - return wClause; + + if (modes == null || modes.isEmpty()) { + throw new RuntimeException("No mode specified."); + } + + List whereClauses = new ArrayList(); + + for (String mode : modes) { + String propName = InvocableUtils.getPropertyNameForInvocationMode(schema, mode.trim()); + + if (propName != null && !propName.isEmpty()) { + whereClauses.add(propName + " != 0"); + } + } + + if (whereClauses.size() > 1) { + return ("(" + StringUtils.join(whereClauses, " OR ") + ")"); + } + + if (whereClauses.size() > 0) { + return whereClauses.get(0); + } + + return ""; } /** @@ -329,9 +348,9 @@ public class QueryManagerNuxeoImpl implements IQueryManager { return fFilteredChars; } - + /** - * Creates a query to filter a qualified (string) field according to a list of string values. + * Creates a query to filter a qualified (string) field according to a list of string values. * @param qualifiedField The schema-qualified field to filter on * @param filterTerms the list of one or more strings to filter on * @param fExclude If true, will require qualifiedField NOT match the filters strings. @@ -345,18 +364,18 @@ public class QueryManagerNuxeoImpl implements IQueryManager { if (filterTerms.length == 1) { filterClause.append(fExclude?" <> '":" = '"); filterClause.append(filterTerms[0]); - filterClause.append('\''); + filterClause.append('\''); } else { filterClause.append(fExclude?" NOT IN (":" IN ("); for(int i=0; i0) { filterClause.append(','); } - filterClause.append('\''); + filterClause.append('\''); filterClause.append(filterTerms[i]); - filterClause.append('\''); + filterClause.append('\''); } - filterClause.append(')'); + filterClause.append(')'); } return filterClause.toString(); } diff --git a/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java b/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java index c9526b603..c15ad41bf 100644 --- a/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java +++ b/services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java @@ -24,6 +24,7 @@ package org.collectionspace.services.report; import java.io.InputStream; +import java.util.List; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.report.nuxeo.ReportDocumentModelHandler; @@ -70,7 +71,7 @@ public class ReportResource extends NuxeoBasedResource { private static String REPORTS_FOLDER = "reports"; private static String CSID_LIST_SEPARATOR = ","; final Logger logger = LoggerFactory.getLogger(ReportResource.class); - + private static String REPORTS_STD_CSID_PARAM = "csid"; private static String REPORTS_STD_GROUPCSID_PARAM = "groupcsid"; private static String REPORTS_STD_CSIDLIST_PARAM = "csidlist"; @@ -81,7 +82,7 @@ public class ReportResource extends NuxeoBasedResource { final String lastChangeRevision = "$LastChangedRevision: 1982 $"; return lastChangeRevision; } - + @Override public String getServiceName() { return ReportClient.SERVICE_NAME; @@ -91,7 +92,7 @@ public class ReportResource extends NuxeoBasedResource { public Class getCommonPartClass() { return ReportsCommon.class; } - + @Override protected AbstractCommonList getCommonList(UriInfo ui) { try { @@ -99,19 +100,19 @@ public class ReportResource extends NuxeoBasedResource { MultivaluedMap queryParams = ctx.getQueryParams(); DocumentHandler handler = createDocumentHandler(ctx); String docType = queryParams.getFirst(IQueryManager.SEARCH_TYPE_DOCTYPE); - String mode = queryParams.getFirst(IQueryManager.SEARCH_TYPE_INVOCATION_MODE); + List modes = queryParams.get(IQueryManager.SEARCH_TYPE_INVOCATION_MODE); String whereClause = null; DocumentFilter documentFilter = null; - String common_part =ctx.getCommonPartLabel(); + String common_part =ctx.getCommonPartLabel(); if (docType != null && !docType.isEmpty()) { whereClause = QueryManager.createWhereClauseForInvocableByDocType( common_part, docType); documentFilter = handler.getDocumentFilter(); documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND); } - if (mode != null && !mode.isEmpty()) { + if (modes != null && !modes.isEmpty()) { whereClause = QueryManager.createWhereClauseForInvocableByMode( - common_part, mode); + common_part, modes); documentFilter = handler.getDocumentFilter(); documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND); } @@ -131,9 +132,9 @@ public class ReportResource extends NuxeoBasedResource { * for information about the properties, and return that information. * See: http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JasperManager.html#loadReport%28java.lang.String%29 * to get the report from the file. - * Use: http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/base/JRBaseReport.html#getParameters%28%29 + * Use: http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/base/JRBaseReport.html#getParameters%28%29 * to get an array of http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JRParameter.html - * Cast each to JRBaseParameter and use isSystemDefined to filter out + * Cast each to JRBaseParameter and use isSystemDefined to filter out * the system defined parameters. */ @@ -146,13 +147,13 @@ public class ReportResource extends NuxeoBasedResource { @Path("{csid}/output") @Produces("application/pdf") public Response invokeReport( - @Context UriInfo ui, + @Context UriInfo ui, @PathParam("csid") String csid) { InvocationContext invContext = new InvocationContext(); invContext.setMode(Invocable.INVOCATION_MODE_NO_CONTEXT); return invokeReport(ui, csid, invContext); } - + /* * Publishes the report to the PublicItem service. The response is a URI to the corresponding PublicItem resource instance in * the form of /publicitems/{csid}. @@ -162,32 +163,32 @@ public class ReportResource extends NuxeoBasedResource { @POST @Path("{csid}/publish") public Response invokeReportAndPublish( - @Context ResourceMap resourceMap, + @Context ResourceMap resourceMap, @Context UriInfo uriInfo, @PathParam("csid") String csid, InvocationContext invContext) { Response response = null; - + try { StringBuffer outMimeType = new StringBuffer(); StringBuffer outReportFileName = new StringBuffer(); ServiceContext ctx = createServiceContext(); - InputStream reportInputStream = invokeReport(ctx, csid, invContext, outMimeType, outReportFileName); + InputStream reportInputStream = invokeReport(ctx, csid, invContext, outMimeType, outReportFileName); response = PublicItemUtil.publishToRepository( - (PublicitemsCommon)null, - resourceMap, - uriInfo, - getRepositoryClient(ctx), - ctx, - reportInputStream, + (PublicitemsCommon)null, + resourceMap, + uriInfo, + getRepositoryClient(ctx), + ctx, + reportInputStream, outReportFileName.toString()); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.POST_FAILED); } - + return response; } - + @POST @Path("{csid}") public Response invokeReport( @@ -195,24 +196,24 @@ public class ReportResource extends NuxeoBasedResource { @PathParam("csid") String csid, InvocationContext invContext) { Response response = null; - + try { StringBuffer outMimeType = new StringBuffer(); StringBuffer outFileName = new StringBuffer(); ServiceContext ctx = createServiceContext(); InputStream reportInputStream = invokeReport(ctx, csid, invContext, outMimeType, outFileName); - + // Need to set response type for what is requested... ResponseBuilder builder = Response.ok(reportInputStream, outMimeType.toString()); builder = builder.header("Content-Disposition","inline;filename=\""+ outFileName.toString() +"\""); - response = builder.build(); + response = builder.build(); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.POST_FAILED); } - + return response; } - + /* * Does the actual report generation and returns an InputStream with the results. */ @@ -223,7 +224,7 @@ public class ReportResource extends NuxeoBasedResource { StringBuffer outMimeType, StringBuffer outReportFileName) throws Exception { InputStream result = null; - + if (csid == null || "".equals(csid)) { logger.error("invokeReport: missing csid!"); Response response = Response.status(Response.Status.BAD_REQUEST).entity( @@ -231,15 +232,15 @@ public class ReportResource extends NuxeoBasedResource { "text/plain").build(); throw new CSWebApplicationException(response); } - + if (logger.isTraceEnabled()) { logger.trace("invokeReport with csid=" + csid); } - + ReportDocumentModelHandler handler = (ReportDocumentModelHandler)createDocumentHandler(ctx); result = handler.invokeReport(ctx, csid, invContext, outMimeType, outReportFileName); - + return result; } - + } -- 2.47.3