//
// Ensure the batch job supports the requested invocation context's document type
if (!Invocable.INVOCATION_MODE_NO_CONTEXT.equalsIgnoreCase(invocationCtx.getMode())) {
+ String invDocType = invocationCtx.getDocType();
ForDocTypes forDocTypes = batchCommon.getForDocTypes();
- if (forDocTypes != null) {
- List<String> forDocTypeList = toLowerCase(forDocTypes.getForDocType()); // convert all strings to lowercase.
- if (forDocTypeList == null || !forDocTypeList.contains(invocationCtx.getDocType().toLowerCase())) {
- String msg = String.format("BatchResource: The batch job '%s' CSID='%s' does not support the invocation document type '%s'.",
- batchCommon.getName(), csid, invocationCtx.getDocType());
- throw new BadRequestException(msg);
- }
+
+ List<String> forDocTypeList = (forDocTypes == null)
+ ? new ArrayList<String>()
+ : toLowerCase(forDocTypes.getForDocType()); // convert all strings to lowercase.
+
+ if (Invocable.INVOCATION_MODE_GROUP.equalsIgnoreCase(invocationCtx.getMode())) {
+ // In group mode, allow the context doc type to be Group or null, even if the report wasn't registered
+ // with those types.
+
+ forDocTypeList.add("group");
+ forDocTypeList.add(null);
+ }
+
+ if (!forDocTypeList.contains(invDocType.toLowerCase())) {
+ String msg = String.format("BatchResource: The batch job '%s' CSID='%s' does not support the invocation document type '%s'.",
+ batchCommon.getName(), csid, invDocType);
+ throw new BadRequestException(msg);
}
}
import java.nio.file.Files;
import java.sql.Connection;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
"ReportResource: This Report does not support Invocation Mode: "
+invocationMode);
}
- if (checkDocType) {
- List<String> forDocTypeList =
- (List<String>) NuxeoUtils.getProperyValue(docModel, InvocableJAXBSchema.FOR_DOC_TYPES); //docModel.getPropertyValue(InvocableJAXBSchema.FOR_DOC_TYPES);
- if (forDocTypeList==null || !forDocTypeList.contains(invContext.getDocType())) {
- throw new BadRequestException(
- "ReportResource: Invoked with unsupported document type: "
- +invContext.getDocType());
- }
- }
+ if (checkDocType) {
+ String invDocType = invContext.getDocType();
+ List<String> forDocTypeList = (List<String>) NuxeoUtils.getProperyValue(docModel, InvocableJAXBSchema.FOR_DOC_TYPES);
+
+ if (forDocTypeList == null) {
+ forDocTypeList = new ArrayList<String>();
+ }
+
+ if (Invocable.INVOCATION_MODE_GROUP.equalsIgnoreCase(invocationMode)) {
+ // In group mode, allow the context doc type to be Group or null, even if the report wasn't registered
+ // with those types.
+
+ forDocTypeList.add("Group");
+ forDocTypeList.add(null);
+ }
+
+ if (!forDocTypeList.contains(invDocType)) {
+ throw new BadRequestException(
+ "ReportResource: Invoked with unsupported document type: "
+ +invDocType);
+ }
+ }
reportFileNameProperty = (String) NuxeoUtils.getProperyValue(docModel, ReportJAXBSchema.FILENAME); //docModel.getPropertyValue(ReportJAXBSchema.FILENAME)); // Set the outgoing param with the report file name
//
// 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,