Merge branch 'master' into bug2842

This commit is contained in:
Daniel Lisunkin committed 2019-09-19 18:03:11 +02:00
commit a6d5476cf2
6 files changed
+27 -20

No files matched your search

@@ -5,7 +5,7 @@ public final class TrackFilesExportParameters {
public static final String FORMAT = "format";
/**
* Which data schould be included
* Which data should be included
*/
public static final String DATA = "data";
@@ -135,11 +135,11 @@ public class FixLoaderAndTracker implements TrackingDataLoader {
private final Set<AbstractLoadingJob> loadingJobs = ConcurrentHashMap.newKeySet();
/**
* This map contains the last maneuver for each deviceId that was sent back. It is used to efficiently piggyback a
* This map contains the last maneuver for each competitor ID that was sent back. It is used to efficiently piggyback a
* notification about new possible maneuvers into the response to adding a GPS fix for smart phone tracking. This
* allows the client to not require any additional polling for maneuver retrieval. The map is never cleared, as it
* will not take a lot of memory itself, and will not grow further after each smart phone device pushed at least one
* GPS fix.
* will not take a lot of memory itself, and will not grow by one entry for each competitor for which a fix
* was submitted through the smartphone tracking connector.
*/
private final ConcurrentHashMap<UUID, Maneuver> lastNotifiedManeuverCache = new ConcurrentHashMap<>();
@@ -18,6 +18,7 @@ import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import com.sap.sse.common.NoCorrespondingServiceRegisteredException;
import com.sap.sse.common.fileupload.FileUploadConstants;
import com.sap.sse.filestorage.InvalidPropertiesException;
import com.sap.sse.filestorage.OperationFailedException;
@@ -33,10 +34,6 @@ public class FileUploadServlet extends AbstractFileUploadServlet {
private static final Logger logger = Logger.getLogger(FileUploadServlet.class.getName());
public static final String JSON_FILE_NAME = "file_name";
public static final String JSON_FILE_URI = "file_uri";
/**
* The maximum size of an image uploaded by a user as a team image, in megabytes (1024*1024 bytes)
*/
@@ -73,20 +70,20 @@ public class FileUploadServlet extends AbstractFileUploadServlet {
if (fileItem.getSize() > 1024 * 1024 * MAX_SIZE_IN_MB) {
final String errorMessage = "Image is larger than " + MAX_SIZE_IN_MB + "MB";
logger.warning("Ignoring file storage request because file "+fileName+" is larger than "+MAX_SIZE_IN_MB+"MB");
result.put("status", Status.INTERNAL_SERVER_ERROR.name());
result.put("message", errorMessage);
result.put(FileUploadConstants.STATUS, Status.INTERNAL_SERVER_ERROR.name());
result.put(FileUploadConstants.MESSAGE, errorMessage);
} else {
final URI fileUri = getService().getFileStorageManagementService().getActiveFileStorageService()
.storeFile(fileItem.getInputStream(), fileExtension, fileItem.getSize());
result.put(JSON_FILE_NAME, fileName);
result.put(JSON_FILE_URI, fileUri.toString());
result.put(FileUploadConstants.FILE_NAME, fileName);
result.put(FileUploadConstants.FILE_URI, fileUri.toString());
}
} catch (IOException | OperationFailedException | InvalidPropertiesException
| NoCorrespondingServiceRegisteredException | UnauthorizedException e) {
final String errorMessage = "Could not store file"+ (e.getMessage()==null?"":(": " + e.getMessage()));
logger.log(Level.WARNING, "Could not store file", e);
result.put("status", Status.INTERNAL_SERVER_ERROR.name());
result.put("message", errorMessage);
result.put(FileUploadConstants.STATUS, Status.INTERNAL_SERVER_ERROR.name());
result.put(FileUploadConstants.MESSAGE, errorMessage);
}
resultList.add(result);
}
@@ -6,6 +6,7 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: SAP
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: com.sap.sse.common,
com.sap.sse.common.fileupload,
com.sap.sse.common.filter,
com.sap.sse.common.filter.impl,
com.sap.sse.common.impl,
@@ -0,0 +1,8 @@
package com.sap.sse.common.fileupload;
public interface FileUploadConstants {
String FILE_NAME = "file_name";
String FILE_URI = "file_uri";
String MESSAGE = "message";
String STATUS = "status";
}
@@ -26,6 +26,7 @@ import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.SubmitButton;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.sap.sse.common.fileupload.FileUploadConstants;
import com.sap.sse.gwt.client.Notification;
import com.sap.sse.gwt.client.Notification.NotificationType;
@@ -66,8 +67,8 @@ public class URLFieldWithFileUpload extends Composite implements HasValue<String
@Override
public void onSubmitComplete(SubmitCompleteEvent event) {
final JSONObject resultJson = parseAfterReplacingSurroundingPreElement(event.getResults()).isObject();
Notification.notify(stringMessages.removeResult(resultJson.get("status").isString().stringValue(),
resultJson.get("message") == null ? "" : resultJson.get("message").isString().stringValue()), NotificationType.INFO);
Notification.notify(stringMessages.removeResult(resultJson.get(FileUploadConstants.STATUS).isString().stringValue(),
resultJson.get(FileUploadConstants.MESSAGE) == null ? "" : resultJson.get(FileUploadConstants.MESSAGE).isString().stringValue()), NotificationType.INFO);
setURL("");
}
});
@@ -126,14 +127,14 @@ public class URLFieldWithFileUpload extends Composite implements HasValue<String
String result = event.getResults();
JSONArray resultJson = parseAfterReplacingSurroundingPreElement(result).isArray();
if (resultJson != null) {
if (resultJson.get(0).isObject().get("file_uri") != null) {
uri = resultJson.get(0).isObject().get("file_uri").isString().stringValue();
if (resultJson.get(0).isObject().get(FileUploadConstants.FILE_URI) != null) {
uri = resultJson.get(0).isObject().get(FileUploadConstants.FILE_URI).isString().stringValue();
setValue(uri, true);
removeButton.setEnabled(true);
Notification.notify(stringMessages.uploadSuccessful(), NotificationType.SUCCESS);
} else {
Notification.notify(stringMessages.fileUploadResult(resultJson.get(0).isObject().get("status").isString().stringValue(),
resultJson.get(0).isObject().get("message").isString().stringValue()), NotificationType.ERROR);
Notification.notify(stringMessages.fileUploadResult(resultJson.get(0).isObject().get(FileUploadConstants.STATUS).isString().stringValue(),
resultJson.get(0).isObject().get(FileUploadConstants.MESSAGE).isString().stringValue()), NotificationType.ERROR);
}
}
}