Skip to content

Commit

Permalink
Merge pull request #571 from devgateway/fix/OCMAKU-669
Browse files Browse the repository at this point in the history
OCMAKU-669 Test Procurment Plan Excel upload with WPS Office
  • Loading branch information
lilitk authored Jun 12, 2020
2 parents 9c248d8 + e2e8158 commit 7308610
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void validate(Form<?> form) {
map.put("encoding",
ImportProcurementPlanItemsPage.this.form
.getModelObject().getFiles().iterator().next().getContentType());
map.put("allowed", Constants.ContentType.XLSX);
map.put("allowed", String.join(" , ", Constants.ContentType.ALL_XLSX));
form.error(getString("ExcelContentTypeValidator"), map);
return;
}
Expand Down Expand Up @@ -170,7 +170,7 @@ public Boolean checkExcelContentType() {
}
FileMetadata file = form.getModelObject().getFiles().iterator().next();
logger.info("Content type was " + file.getContentType());
return file.getContentType().equals(Constants.ContentType.XLSX);
return Constants.ContentType.ALL_XLSX.contains(file.getContentType());
}

public Boolean checkExcelFormat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ files.help=Upload Excel file contaning procurement plan items for import
ExcelFormatValidator=This document does not match the required format, please upload with the correct format. \
It must have one sheet, and on row 8 it must have the column names as defined in the template.
ExcelImportErrorValidator=There was an error importing the file. Please review the data and ensure it adheres to the format. Error was:
ExcelContentTypeValidator=Upload file encoding is ${encoding}. Only ${allowed} is allowed. Please upload only .xlsx \
ExcelContentTypeValidator=Upload file encoding is ${encoding}. Only ${allowed} are allowed. Please upload only .xlsx \
files!
6 changes: 6 additions & 0 deletions web/src/main/java/org/devgateway/toolkit/web/Constants.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package org.devgateway.toolkit.web;

import com.google.common.collect.ImmutableSet;

import java.util.Set;

/**
* @author mpostelnicu
*/
Expand All @@ -11,5 +15,7 @@ private Constants() {

public static class ContentType {
public static final String XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
public static final String WPS_XLSX = "application/wps-office.xlsx";
public static final Set<String> ALL_XLSX = ImmutableSet.of(XLSX, WPS_XLSX);
}
}

0 comments on commit 7308610

Please sign in to comment.