103 SHARE_WEB = ConfigProperties.getPropertyParam(
"share_web");
105 CONTEXT = String.valueOf(System.currentTimeMillis());
108 if (!contentDispositionHeader.getFileName().contains(
".csv")) {
109 throw new DataFormatException();
113 saveFile(fileInputStream, filePath);
114 outString =
"File saved to server location : " + filePath;
116 File datei =
new File(filePath);
117 FileInputStream fis =
new FileInputStream(filePath);
118 InputStreamReader isr =
new InputStreamReader(fis,
"UTF8");
119 BufferedReader br =
new BufferedReader(isr);
121 while ((line = br.readLine()) !=
null) {
127 if (datei.exists()) {
131 if (CSV.JSON_STRING.contains(
"errors")) {
132 return Response.status(Response.Status.BAD_REQUEST).entity(CSV.JSON_STRING).header(
"Content-Type",
"application/json;charset=UTF-8").build();
135 Transformer.writeVocabularyStatisticsToDatabase(
vocab);
137 return Response.status(200).entity(CSV.JSON_STRING).header(
"Content-Type",
"application/json;charset=UTF-8").build();
140 if (e.toString().contains(
"DataFormatException")) {
141 JSONObject errorOutput =
new JSONObject();
142 JSONArray errorArray =
new JSONArray();
143 errorArray.add(
"error: wrong file type, must be .csv");
144 errorOutput.put(
"errors", 1);
145 errorOutput.put(
"messages", errorArray);
146 return Response.status(Response.Status.BAD_REQUEST).entity(errorOutput).header(
"Content-Type",
"application/json;charset=UTF-8").build();
148 return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(Logging.getMessageJSON(e,
"v1.rest.ImportcsvResource"))
149 .header(
"Content-Type",
"application/json;charset=UTF-8").build();