if (parent.isFirstIteration()) {
String format = type.toLowerCase().trim();
// Export URL build
ExportConf conf = null;
if (parent.getTable().getTableConfiguration().getExportConfiguration().get(format) != null) {
conf = parent.getTable().getTableConfiguration().getExportConfiguration().get(format);
}
else{
conf = new ExportConf(format);
parent.getTable().getTableConfiguration().getExportConfiguration().put(format, conf);
}
// Default mode (export using filter)
StringBuilder exportUrl = null;
if(StringUtils.isBlank(url)){
exportUrl = UrlUtils.getCurrentUri(request);
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_TYPE, "f");
conf.setHasCustomUrl(false);
}
// Custom mode (export using controller)
else{
exportUrl = new StringBuilder(url.trim());
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_TYPE, "c");
conf.setHasCustomUrl(true);
}
if (StringUtils.isNotBlank(fileName)) {
conf.setFileName(fileName.trim());
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_NAME, this.fileName);
}
if (StringUtils.isNotBlank(fileExtension)) {
conf.setFileExtension(fileExtension);
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_EXTENSION, this.fileExtension);
}
if (StringUtils.isNotBlank(label)) {
conf.setLabel(StringUtils.escape(this.escapeXml, this.label.trim()));
}
if (StringUtils.isNotBlank(cssClass)) {
conf.setCssClass(new StringBuilder(cssClass.trim()));
}
if (StringUtils.isNotBlank(cssStyle)) {
conf.setCssStyle(new StringBuilder(cssStyle.trim()));
}
if (StringUtils.isNotBlank(method)) {
HttpMethod httpMethod = null;
try {
httpMethod = HttpMethod.valueOf(this.method.toUpperCase().trim());
} catch (IllegalArgumentException e) {
StringBuilder sb = new StringBuilder();
sb.append("'");
sb.append(this.method);
sb.append("' is not a valid HTTP method. Possible values are: ");
sb.append(EnumUtils.printPossibleValuesOf(HttpMethod.class));
throw new JspException(sb.toString());
}
conf.setMethod(httpMethod);
}
if (StringUtils.isNotBlank(orientation)) {
Orientation orientationEnum = null;
try {
orientationEnum = Orientation.valueOf(this.orientation.toUpperCase().trim());
} catch (IllegalArgumentException e) {
StringBuilder sb = new StringBuilder();
sb.append("'");
sb.append(this.orientation);
sb.append("' is not a valid orientation. Possible values are: ");
sb.append(EnumUtils.printPossibleValuesOf(Orientation.class));
throw new JspException(sb.toString());
}
conf.setOrientation(orientationEnum);
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_ORIENTATION, orientation);
}
if (StringUtils.isNotBlank(mimeType)) {
conf.setMimeType(mimeType.trim());
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_MIME_TYPE, mimeType.trim());
}
if (includeHeader != null) {
conf.setIncludeHeader(includeHeader);
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_HEADER, includeHeader);
}
if (autoSize != null) {
conf.setAutoSize(autoSize);
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_AUTOSIZE, autoSize);
}
// Finalizes the export URL
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_ID, parent.getTable().getId());
UrlUtils.addParameter(exportUrl, ExportUtils.DDL_DT_REQUESTPARAM_EXPORT_FORMAT, format);
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));
logger.debug("Export configuration for the type {} has been updated", format);
}
return EVAL_PAGE;