Fixing post request

This commit is contained in:
Francesco Mangiacrapa 2023-03-24 10:35:59 +01:00
parent c6694cd856
commit 7c0928b1e9
2 changed files with 16 additions and 10 deletions

View File

@ -26,7 +26,7 @@ public class GeoportalRequest {
@JsonProperty(P_GCUBE_SCOPE)
private String gcubeScope;
@JsonProperty(P_TARGET_APP)
private String targetApp;
private String targetAppName;
/**
* It is the UCD ID {usecase_id}
*/

View File

@ -285,19 +285,25 @@ public class GeoportalResolver {
"The scope '" + scope + "' does not matching any scope in the infrastructure. Is it valid?",
this.getClass(), helpURI);
TargetAppGeoportalCodes resoruceGeoportalCodes = TargetAppGeoportalCodes
.valueOfName(jsonRequest.getTargetApp());
String targetAppName = jsonRequest.getTargetAppName();
if (resoruceGeoportalCodes == null) {
LOG.error("Target application parameter is null/malformed");
TargetAppGeoportalCodes resoruceGeoportalCodes = null;
if (targetAppName == null) {
resoruceGeoportalCodes = TargetAppGeoportalCodes.GEO;
LOG.info("Target application using default: " + resoruceGeoportalCodes);
LOG.error("Target application parameter is null, using default: " + resoruceGeoportalCodes);
} else {
List<String> targetApps = Arrays.asList(TargetAppGeoportalCodes.values()).stream()
.map(TargetAppGeoportalCodes::getTarget_app).collect(Collectors.toList());
throw ExceptionManager.badRequestException(req,
"Target application is null/malformed. It must be: " + targetApps, this.getClass(), helpURI);
resoruceGeoportalCodes = TargetAppGeoportalCodes.valueOfName(jsonRequest.getTargetAppName());
if (resoruceGeoportalCodes == null) {
LOG.error("Target application parameter is malformed");
List<String> targetApps = Arrays.asList(TargetAppGeoportalCodes.values()).stream()
.map(TargetAppGeoportalCodes::getTarget_app).collect(Collectors.toList());
throw ExceptionManager.badRequestException(req,
"Target application is wrong. It must be one value of: " + targetApps, this.getClass(),
helpURI);
}
}
String linkURL = String.format("%s/%s/%s/%s/%s", serverUrl, resoruceGeoportalCodes.getId(), vreName,