removed new is call to create context

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/vre-deploy@183526 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2020-01-16 13:41:22 +00:00
parent 16c47d31ca
commit 3ea6221167
2 changed files with 28 additions and 40 deletions

View File

@ -46,11 +46,6 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.gcube.information-system</groupId>
<artifactId>resource-registry-context-client</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency>
<dependency> <dependency>
<groupId>com.google.gwt</groupId> <groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId> <artifactId>gwt-user</artifactId>

View File

@ -2,14 +2,8 @@ package org.gcube.portlets.admin.vredeployer.server;
import java.util.List; import java.util.List;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.portal.mailing.EmailNotification; import org.gcube.common.portal.mailing.EmailNotification;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.informationsystem.model.impl.entity.ContextImpl;
import org.gcube.informationsystem.model.reference.entity.Context;
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClient;
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientFactory;
import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.RoleManager; import org.gcube.vomanagement.usermanagement.RoleManager;
import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.UserManager;
@ -17,7 +11,6 @@ import org.gcube.vomanagement.usermanagement.exception.RoleRetrievalFault;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager; import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames; import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -53,36 +46,36 @@ public class NewVRECreatedThread implements Runnable {
@Override @Override
public void run() { public void run() {
handleVRECreatedNotificationEmail(creatorUserName, creatorFullName, vreScope); handleVRECreatedNotificationEmail(creatorUserName, creatorFullName, vreScope);
handleVRECreatedContextAddonResourceRegistry(vreScope, vreName, currentScopeGroupId); //handleVRECreatedContextAddonResourceRegistry(vreScope, vreName, currentScopeGroupId);
} }
private void handleVRECreatedContextAddonResourceRegistry(String vreScope, String vreName, long currentScopeGroupId) { // private void handleVRECreatedContextAddonResourceRegistry(String vreScope, String vreName, long currentScopeGroupId) {
try { // try {
final GCubeGroup voGroup = gm.getGroup(currentScopeGroupId); // final GCubeGroup voGroup = gm.getGroup(currentScopeGroupId);
//
String currentScope = gm.getInfrastructureScope(currentScopeGroupId); // String currentScope = gm.getInfrastructureScope(currentScopeGroupId);
_log.debug("handleVRECreatedContextAddonResourceRegistry, VO Scope= " + currentScope); // _log.debug("handleVRECreatedContextAddonResourceRegistry, VO Scope= " + currentScope);
ScopeProvider.instance.set(currentScope); // ScopeProvider.instance.set(currentScope);
ResourceRegistryContextClient rrClient = ResourceRegistryContextClientFactory.create(); // ResourceRegistryContextClient rrClient = ResourceRegistryContextClientFactory.create();
Context context = new ContextImpl(vreName); // Context context = new ContextImpl(vreName);
//
List<Context> contexts = rrClient.all(); // List<Context> contexts = rrClient.all();
Context parent = null; // Context parent = null;
for(Context c : contexts){ // for(Context c : contexts){
if(c.getName().compareTo(voGroup.getGroupName()) == 0){ // if(c.getName().compareTo(voGroup.getGroupName()) == 0){
parent = c; // parent = c;
break; // break;
} // }
} // }
_log.debug("setting parent as= " + parent.getName()); // _log.debug("setting parent as= " + parent.getName());
context.setParent(parent); // context.setParent(parent);
_log.debug("creating context: " + context.toString()); // _log.debug("creating context: " + context.toString());
rrClient.create(context); // rrClient.create(context);
_log.debug("created context OK"); // _log.debug("created context OK");
} catch (Exception e) { // } catch (Exception e) {
_log.error("an error occurred wehn creating new context on Resource Registry" , e); // _log.error("an error occurred wehn creating new context on Resource Registry" , e);
} // }
} // }
private void handleVRECreatedNotificationEmail(String newUserUserName, String newUserFullName, String vreScope) { private void handleVRECreatedNotificationEmail(String newUserUserName, String newUserFullName, String vreScope) {