added check when the file uploaded is null
This commit is contained in:
parent
58fc9d0d52
commit
f6a0682777
|
@ -137,7 +137,7 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
* Save geona data forms.
|
* Save geona data forms.
|
||||||
*
|
*
|
||||||
* @param profileID the profile ID
|
* @param profileID the profile ID
|
||||||
* @param optionalMessage the optional message
|
* @param optionalMessage the optional message
|
||||||
* @param tree_Node the tree node
|
* @param tree_Node the tree node
|
||||||
* @param stepsOnPostCreation the steps on post creation
|
* @param stepsOnPostCreation the steps on post creation
|
||||||
* @return the commit report
|
* @return the commit report
|
||||||
|
@ -484,43 +484,50 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
// Iterating on the files upload for the section
|
// Iterating on the files upload for the section
|
||||||
for (int i = 0; i < files.size(); i++) {
|
for (int i = 0; i < files.size(); i++) {
|
||||||
FileUploaded file = files.get(i);
|
FileUploaded file = files.get(i);
|
||||||
String formFieldName = file.getFilePath().getFormFieldLabel();
|
if (file != null && file.getFilePath() != null) {
|
||||||
LOG.debug("Uploading file: " + file.getFileName() + ", from formFieldName: " + formFieldName);
|
String formFieldName = file.getFilePath().getFormFieldLabel();
|
||||||
FilePathDV filePath = retrieveFilePathForGcubeProfileFieldName(formFieldName, profile);
|
LOG.debug(
|
||||||
LOG.info("Found {} for the form fieldName {}", filePath, formFieldName);
|
"Uploading file: " + file.getFileName() + ", from formFieldName: " + formFieldName);
|
||||||
if (filePath == null) {
|
FilePathDV filePath = retrieveFilePathForGcubeProfileFieldName(formFieldName, profile);
|
||||||
String error = "It is not possible to register the file " + formFieldName
|
LOG.info("Found {} for the form fieldName {}", filePath, formFieldName);
|
||||||
+ ", missing configuration in the filePaths config of: " + profile;
|
if (filePath == null) {
|
||||||
throw new Exception(error);
|
String error = "It is not possible to register the file " + formFieldName
|
||||||
|
+ ", missing configuration in the filePaths config of: " + profile;
|
||||||
|
throw new Exception(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collecting Fileset per Field Definition
|
||||||
|
FileSetDataObject collFieldDef = collectFilesetPerFieldDef
|
||||||
|
.get(filePath.getFieldDefinition());
|
||||||
|
if (collFieldDef == null) {
|
||||||
|
collFieldDef = new FileSetDataObject();
|
||||||
|
collFieldDef.setFilePathDV(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
File input = new File(file.getTempSystemPath());
|
||||||
|
LOG.debug("Temp file is: " + file.getTempSystemPath());
|
||||||
|
File tempDir = Files.createTempDirectory("GEOPORTAL_UPLOAD_").toFile();
|
||||||
|
|
||||||
|
String tmpDirPath = tempDir.getAbsolutePath();
|
||||||
|
File output = new File(tmpDirPath, file.getFileName());
|
||||||
|
// input.renameTo(output);
|
||||||
|
copyContent(input, output);
|
||||||
|
collFieldDef.addFile(output);
|
||||||
|
tempDirs.add(tempDir);
|
||||||
|
tempDir.deleteOnExit();
|
||||||
|
LOG.info("Temp file: " + file.getTempSystemPath() + ", copied to new file: "
|
||||||
|
+ file.getFileName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.warn("Skipping file: " + file.getFileName() + ". Error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collecting Fileset per Field Definition
|
|
||||||
FileSetDataObject collFieldDef = collectFilesetPerFieldDef.get(filePath.getFieldDefinition());
|
|
||||||
if (collFieldDef == null) {
|
|
||||||
collFieldDef = new FileSetDataObject();
|
|
||||||
collFieldDef.setFilePathDV(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
File input = new File(file.getTempSystemPath());
|
|
||||||
LOG.debug("Temp file is: " + file.getTempSystemPath());
|
|
||||||
File tempDir = Files.createTempDirectory("GEOPORTAL_UPLOAD_").toFile();
|
|
||||||
|
|
||||||
String tmpDirPath = tempDir.getAbsolutePath();
|
|
||||||
File output = new File(tmpDirPath, file.getFileName());
|
|
||||||
// input.renameTo(output);
|
|
||||||
copyContent(input, output);
|
|
||||||
collFieldDef.addFile(output);
|
|
||||||
tempDirs.add(tempDir);
|
|
||||||
tempDir.deleteOnExit();
|
|
||||||
LOG.info("Temp file: " + file.getTempSystemPath() + ", copied to new file: "
|
|
||||||
+ file.getFileName());
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.warn("Skipping file: " + file.getFileName() + ". Error: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
collectFilesetPerFieldDef.put(filePath.getFieldDefinition(), collFieldDef);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1013,12 +1020,12 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Project deletedP = client.getProjectByID(profileID, projectID);
|
Project deletedP = client.getProjectByID(profileID, projectID);
|
||||||
if(deletedP!=null) {
|
if (deletedP != null) {
|
||||||
String error = "The project with id "+projectID+" still exists";
|
String error = "The project with id " + projectID + " still exists";
|
||||||
LOG.error(error +". Sending exception..");
|
LOG.error(error + ". Sending exception..");
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1138,8 +1145,8 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
long groupId = pContext.getCurrentGroupId(this.getThreadLocalRequest());
|
long groupId = pContext.getCurrentGroupId(this.getThreadLocalRequest());
|
||||||
|
|
||||||
if (user == null || scope == null) {
|
if (user == null || scope == null) {
|
||||||
LOG.warn("called readDataEntryPresentationConfig with invalid parameter user: " + user + ", in the scope: "
|
LOG.warn("called readDataEntryPresentationConfig with invalid parameter user: " + user
|
||||||
+ scope, ", returning null");
|
+ ", in the scope: " + scope, ", returning null");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1276,16 +1283,16 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
||||||
/**
|
/**
|
||||||
* Perform action steps.
|
* Perform action steps.
|
||||||
*
|
*
|
||||||
* @param profileID the profile ID
|
* @param profileID the profile ID
|
||||||
* @param projectID the project ID
|
* @param projectID the project ID
|
||||||
* @param optionalMessage the optional message
|
* @param optionalMessage the optional message
|
||||||
* @param action the action
|
* @param action the action
|
||||||
* @return the project DV
|
* @return the project DV
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public StepPerformedResultDV performActionSteps(String profileID, String projectID, String optionalMessage, ActionDefinitionDV action)
|
public StepPerformedResultDV performActionSteps(String profileID, String projectID, String optionalMessage,
|
||||||
throws Exception {
|
ActionDefinitionDV action) throws Exception {
|
||||||
LOG.info("performActionSteps called for profileID {}, projectID {}, action: " + action, profileID, projectID);
|
LOG.info("performActionSteps called for profileID {}, projectID {}, action: " + action, profileID, projectID);
|
||||||
|
|
||||||
ProjectsCaller client = GeoportalClientCaller.projects();
|
ProjectsCaller client = GeoportalClientCaller.projects();
|
||||||
|
|
Loading…
Reference in New Issue