Fixed add to organization

This commit is contained in:
Luca Frosini 2022-04-21 17:12:41 +02:00
parent 7db232b970
commit c227d5069d
3 changed files with 8 additions and 13 deletions

View File

@ -139,13 +139,9 @@ public class CKANPackage extends CKAN implements Moderated {
PURGE = ITEM_PURGE;
managedResources = new ArrayList<CKANResource>();
ckanUser = CKANUserCache.getCurrrentCKANUser();
configuration = CatalogueConfigurationFactory.getInstance();
for(String supportedOrganization : configuration.getSupportedOrganizations()) {
ckanUser.addUserToOrganization(supportedOrganization);
}
ckanUser = CKANUserCache.getCurrrentCKANUser();
}

View File

@ -54,15 +54,9 @@ public class CKANPackageTrash {
public CKANPackageTrash() {
mapper = new ObjectMapper();
ckanUser = CKANUserCache.getCurrrentCKANUser();
configuration = CatalogueConfigurationFactory.getInstance();
supportedOrganizations = configuration.getSupportedOrganizations();
for(String supportedOrganization : supportedOrganizations) {
ckanUser.addUserToOrganization(supportedOrganization);
}
ownOnly = true;
}

View File

@ -9,8 +9,10 @@ import javax.ws.rs.core.Response.Status;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.authorization.utils.user.User;
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
import org.gcube.gcat.api.moderation.Moderated;
import org.gcube.gcat.api.roles.Role;
import org.gcube.gcat.configuration.CatalogueConfigurationFactory;
import org.gcube.gcat.utils.RandomString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -174,7 +176,10 @@ public class CKANUser extends CKAN {
}
}
try {
addUserToOrganization();
CatalogueConfiguration configuration = CatalogueConfigurationFactory.getInstance();
for(String supportedOrganization : configuration.getSupportedOrganizations()) {
addUserToOrganization(supportedOrganization);
}
}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.