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