You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
user-registration-hook/src/main/java/org/gcube/portal/usersaccount/WorkspaceCreateAccountThrea...

44 lines
1.5 KiB
Java

package org.gcube.portal.usersaccount;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WorkspaceCreateAccountThread implements Runnable {
private static Logger _log = LoggerFactory.getLogger(WorkspaceCreateAccountThread.class);
private String newUserUserName;
public WorkspaceCreateAccountThread(String newUserUserName, String newUserFullName, String newUserEmailAddress) {
super();
this.newUserUserName = newUserUserName;
_log.info("Calling HomeLibrary for Workspace creation to new user: " + newUserUserName + " ("+newUserFullName+")");
}
@Override
public void run() {
getWS(newUserUserName, "/"+PortalContext.getConfiguration().getInfrastructureName());
}
public static Workspace getWS(String currentUsername, String context) {
String username = currentUsername;
String authorizationToken = PortalContext.getConfiguration().getCurrentUserToken(context, username);
SecurityTokenProvider.instance.set(authorizationToken);
ScopeProvider.instance.set(context);
try {
Workspace toReturn = HomeLibrary.getUserWorkspace(username);
_log.info("Done Workspace creation for user: " + currentUsername);
return toReturn;
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
}