*/
@SuppressWarnings("unchecked")
private void processExportAttributes(Arguments arguments, Element element, Map<String, Map<ConfType, Object>> configs, HttpServletRequest request, HttpServletResponse response,
String tableId) {
ExportConf conf = null;
String exportFormat = null;
if (hasAttribute(element, "type")) {
exportFormat = element.getAttributeValue(DataTablesDialect.DIALECT_PREFIX + ":type").trim().toLowerCase();
conf = new ExportConf(exportFormat);
} else {
throw new ConfigurationProcessingException(
"The attribute 'dt:type' is required when defining an export configuration.");
}
StringBuilder exportUrl = null;
// Custom mode (export using controller)
if (element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":url")) {
exportUrl = new StringBuilder(AttributeUtils.parseStringAttribute(arguments, element,
DataTablesDialect.DIALECT_PREFIX + ":url").trim());
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_TYPE, "c");
conf.setHasCustomUrl(true);
}
// Default mode (export using filter)
else{
exportUrl = UrlUtils.getCurrentUri(request);
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_TYPE, "f");
conf.setHasCustomUrl(false);
}
if (hasAttribute(element, "fileName")) {
String fileName = getStringValue(element, "fileName");
conf.setFileName(fileName);
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_NAME, fileName);
}
if (hasAttribute(element, "mimeType")) {
String mimeType = getStringValue(element, "mimeType");
conf.setMimeType(mimeType);
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_MIME_TYPE, mimeType);
}
if (hasAttribute(element, "label")) {
conf.setLabel(getStringValue(element, "label"));
}
if (hasAttribute(element, "cssStyle")) {
conf.setCssStyle(new StringBuilder(getStringValue(element, "cssStyle")));
}
if (hasAttribute(element, "cssClass")) {
conf.setCssClass(new StringBuilder(getStringValue(element, "cssClass")));
}
if (hasAttribute(element, "includeHeader")) {
String includeHeader = getStringValue(element, "includeHeader");
conf.setIncludeHeader(Boolean.parseBoolean(includeHeader));
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_HEADER, includeHeader);
}
if (hasAttribute(element, "method")) {
String methodStr = element.getAttributeValue(DataTablesDialect.DIALECT_PREFIX + ":method");
HttpMethod methodEnum = null;
try {
methodEnum = HttpMethod.valueOf(methodStr.toUpperCase().trim());
} catch (IllegalArgumentException e) {
StringBuilder sb = new StringBuilder();
sb.append("'");
sb.append(methodStr);
sb.append("' is not a valid HTTP method. Possible values are: ");
sb.append(EnumUtils.printPossibleValuesOf(HttpMethod.class));
throw new ConfigurationProcessingException(sb.toString());
}
conf.setMethod(methodEnum);
}
if (hasAttribute(element, "autoSize")) {
String autosize = getStringValue(element, "autoSize");
conf.setAutoSize(Boolean.parseBoolean(autosize));
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_AUTOSIZE, autosize);
}
if (hasAttribute(element, "exportClass")) {
conf.setExportClass(getStringValue(element, "exportClass"));
}
if (hasAttribute(element, "fileExtension")) {
String fileExtension = getStringValue(element, "fileExtension");
conf.setFileExtension(fileExtension);
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_EXTENSION, fileExtension);
}
if (hasAttribute(element, "orientation")) {
String orientationStr = element.getAttributeValue(DataTablesDialect.DIALECT_PREFIX + ":orientation");
Orientation orientationEnum = null;
try {
orientationEnum = Orientation.valueOf(orientationStr.toUpperCase().trim());
} catch (IllegalArgumentException e) {
StringBuilder sb = new StringBuilder();
sb.append("'");
sb.append(orientationStr);
sb.append("' is not a valid orientation. Possible values are: ");
sb.append(EnumUtils.printPossibleValuesOf(Orientation.class));
throw new ConfigurationProcessingException(sb.toString());
}
conf.setOrientation(orientationEnum);
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_ORIENTATION, orientationStr);
}
// Finalizes export URL
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_ID, tableId);
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_FORMAT, exportFormat);
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_IN_PROGRESS, "y");
UrlUtils.addParameter(exportUrl, WebConstants.DANDELION_ASSET_FILTER_STATE, false);
conf.setUrl(UrlUtils.getProcessedUrl(exportUrl, request, response));
if (conf != null) {
if (configs.get(tableId).containsKey(ConfType.EXPORT)) {
((Map<String, ExportConf>) configs.get(tableId).get(ConfType.EXPORT)).put(exportFormat, conf);