Fixing code to allow to operate on VO which does not have a

corresponding organization
This commit is contained in:
Luca Frosini 2019-10-10 14:26:15 +02:00
parent 0d55676462
commit 6580680f6f
1 changed files with 15 additions and 2 deletions

View File

@ -224,12 +224,25 @@ public class CKANUser extends CKAN {
throw e;
}
}
addUserToOrganization();
try {
addUserToOrganization();
}catch (Exception e) {
// The organization could not exists and this is fine in some cases like organization create or
// for listing items at VO level. The organization corresponding to the VO could not exists.
logger.warn("Add user to organization {} failed. This is acceptable in the case the request is at VO level and the corresponding orgnization does not esists and should not, as well as when the organization is going to be created", CKANOrganization.getCKANOrganizationName());
}
}
protected void parseResult() {
name = result.get(NAME).asText();
apiKey = result.get(API_KEY).asText();
try {
apiKey = result.get(API_KEY).asText();
}catch (Exception e) {
if(name.compareTo(getCKANUsername())==0) {
throw e;
}
}
}
protected static String getCKANUsername(String username) {