added check when the file uploaded is null

This commit is contained in:
Francesco Mangiacrapa 2024-09-24 16:31:02 +02:00
parent 58fc9d0d52
commit f6a0682777
1 changed files with 59 additions and 52 deletions

View File

@ -484,8 +484,10 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
// Iterating on the files upload for the section
for (int i = 0; i < files.size(); i++) {
FileUploaded file = files.get(i);
if (file != null && file.getFilePath() != null) {
String formFieldName = file.getFilePath().getFormFieldLabel();
LOG.debug("Uploading file: " + file.getFileName() + ", from formFieldName: " + formFieldName);
LOG.debug(
"Uploading file: " + file.getFileName() + ", from formFieldName: " + formFieldName);
FilePathDV filePath = retrieveFilePathForGcubeProfileFieldName(formFieldName, profile);
LOG.info("Found {} for the form fieldName {}", filePath, formFieldName);
if (filePath == null) {
@ -495,7 +497,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
}
// Collecting Fileset per Field Definition
FileSetDataObject collFieldDef = collectFilesetPerFieldDef.get(filePath.getFieldDefinition());
FileSetDataObject collFieldDef = collectFilesetPerFieldDef
.get(filePath.getFieldDefinition());
if (collFieldDef == null) {
collFieldDef = new FileSetDataObject();
collFieldDef.setFilePathDV(filePath);
@ -521,6 +524,10 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
collectFilesetPerFieldDef.put(filePath.getFieldDefinition(), collFieldDef);
} else {
throw new Exception("Error occurred on uploading file in the section: " + sectionJSONPath
+ ". Please upload it/them again and retry");
}
}
}
@ -1138,8 +1145,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
long groupId = pContext.getCurrentGroupId(this.getThreadLocalRequest());
if (user == null || scope == null) {
LOG.warn("called readDataEntryPresentationConfig with invalid parameter user: " + user + ", in the scope: "
+ scope, ", returning null");
LOG.warn("called readDataEntryPresentationConfig with invalid parameter user: " + user
+ ", in the scope: " + scope, ", returning null");
return null;
}
@ -1284,8 +1291,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
* @throws Exception the exception
*/
@Override
public StepPerformedResultDV performActionSteps(String profileID, String projectID, String optionalMessage, ActionDefinitionDV action)
throws Exception {
public StepPerformedResultDV performActionSteps(String profileID, String projectID, String optionalMessage,
ActionDefinitionDV action) throws Exception {
LOG.info("performActionSteps called for profileID {}, projectID {}, action: " + action, profileID, projectID);
ProjectsCaller client = GeoportalClientCaller.projects();