|
|
|
@ -12,12 +12,10 @@ import java.io.IOException;
|
|
|
|
|
import java.io.StringReader;
|
|
|
|
|
import java.rmi.RemoteException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Hashtable;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
|
import javax.xml.parsers.DocumentBuilder;
|
|
|
|
@ -36,6 +34,7 @@ import org.gcube.application.framework.core.session.SessionManager;
|
|
|
|
|
import org.gcube.application.framework.vremanagement.vremanagement.impl.VREGeneratorEvo;
|
|
|
|
|
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
|
|
|
|
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
|
|
|
|
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
|
|
|
|
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
|
|
|
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|
|
|
|
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
|
|
@ -47,22 +46,11 @@ import org.gcube.common.resources.gcore.GenericResource;
|
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
|
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
|
|
|
|
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
|
|
|
|
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
|
|
|
|
import org.gcube.portal.custom.communitymanager.PortletsIdManager;
|
|
|
|
|
import org.gcube.portal.custom.communitymanager.SiteManagerUtil;
|
|
|
|
|
import org.gcube.portal.custom.communitymanager.ThemesIdManager;
|
|
|
|
|
import org.gcube.portal.custom.communitymanager.components.GCUBELayoutTab;
|
|
|
|
|
import org.gcube.portal.custom.communitymanager.components.GCUBEPortlet;
|
|
|
|
|
import org.gcube.portal.custom.communitymanager.components.GCUBESiteLayout;
|
|
|
|
|
import org.gcube.portal.custom.communitymanager.impl.OrganizationManagerImpl;
|
|
|
|
|
import org.gcube.portal.custom.communitymanager.types.GCUBELayoutType;
|
|
|
|
|
import org.gcube.portal.custom.communitymanager.impl.GCubeSiteManagerImpl;
|
|
|
|
|
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|
|
|
|
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
|
|
|
|
import org.gcube.portal.databook.server.DatabookStore;
|
|
|
|
|
import org.gcube.portal.databook.shared.Feed;
|
|
|
|
|
import org.gcube.portal.databook.shared.FeedType;
|
|
|
|
|
import org.gcube.portal.databook.shared.PrivacyLevel;
|
|
|
|
|
import org.gcube.portal.databook.shared.UserInfo;
|
|
|
|
|
import org.gcube.portal.databook.shared.ex.FeedIDNotFoundException;
|
|
|
|
|
import org.gcube.portlets.admin.vredeployer.client.VredeployerService;
|
|
|
|
|
import org.gcube.portlets.admin.vredeployer.client.model.VREFunctionalityModel;
|
|
|
|
|
import org.gcube.portlets.admin.vredeployer.shared.GHNMemory;
|
|
|
|
@ -88,14 +76,12 @@ import org.gcube.vomanagement.usermanagement.GroupManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.RoleManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayRoleManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.model.GroupModel;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.model.UserModel;
|
|
|
|
|
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.GCubeUser;
|
|
|
|
|
import org.gcube.vremanagement.vremodel.cl.stubs.types.FunctionalityItem;
|
|
|
|
|
import org.gcube.vremanagement.vremodel.cl.stubs.types.GHN;
|
|
|
|
|
import org.gcube.vremanagement.vremodel.cl.stubs.types.GHNsPerFunctionality;
|
|
|
|
@ -119,18 +105,13 @@ import org.xml.sax.InputSource;
|
|
|
|
|
import org.xml.sax.SAXException;
|
|
|
|
|
|
|
|
|
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|
|
|
|
import com.liferay.portal.NoSuchRoleException;
|
|
|
|
|
import com.liferay.portal.kernel.exception.PortalException;
|
|
|
|
|
import com.liferay.portal.kernel.exception.SystemException;
|
|
|
|
|
import com.liferay.portal.kernel.util.WebKeys;
|
|
|
|
|
import com.liferay.portal.model.Company;
|
|
|
|
|
import com.liferay.portal.model.Group;
|
|
|
|
|
import com.liferay.portal.model.Organization;
|
|
|
|
|
import com.liferay.portal.model.Role;
|
|
|
|
|
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
|
|
|
|
import com.liferay.portal.service.RoleLocalServiceUtil;
|
|
|
|
|
import com.liferay.portal.model.Theme;
|
|
|
|
|
import com.liferay.portal.model.User;
|
|
|
|
|
import com.liferay.portal.service.GroupLocalServiceUtil;
|
|
|
|
|
import com.liferay.portal.service.LayoutSetLocalServiceUtil;
|
|
|
|
|
import com.liferay.portal.service.ThemeLocalServiceUtil;
|
|
|
|
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
|
|
|
|
import com.liferay.portal.theme.ThemeDisplay;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -170,6 +151,9 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|
|
|
|
private static final String DESIGNER = "Designer";
|
|
|
|
|
private static final String MANAGER = "Manager";
|
|
|
|
|
|
|
|
|
|
private static final String VRE_MANAGER = "VRE-Manager";
|
|
|
|
|
private static final String VRE_DESIGNER = "VRE-Designer";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
@ -295,16 +279,14 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|
|
|
|
*/
|
|
|
|
|
private String getFullname(String screenName) {
|
|
|
|
|
UserManager um = new LiferayUserManager();
|
|
|
|
|
UserModel user = null;
|
|
|
|
|
GCubeUser user = null;
|
|
|
|
|
try {
|
|
|
|
|
user = um.getUserByScreenName(screenName);
|
|
|
|
|
} catch (UserManagementSystemException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (UserRetrievalFault e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (UserManagementPortalException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return user.getFullname();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -726,16 +708,19 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|
|
|
|
}
|
|
|
|
|
String designer = (String) getASLSession().getAttribute(DESIGNER);
|
|
|
|
|
String manager = (String) getASLSession().getAttribute(MANAGER);
|
|
|
|
|
|
|
|
|
|
log.info("\n*** ADDING user designer and manager, found designer: " + designer + " found manager: "+manager);
|
|
|
|
|
|
|
|
|
|
Organization vreCreated = createCommunityAndLayout(name);
|
|
|
|
|
if (vreCreated != null) {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
log.info("ADDING user designer and manager, found designer: " + designer + " found manager: "+manager);
|
|
|
|
|
|
|
|
|
|
long vreCreatedId = createCommunityAndLayoutAndHLFolder(name, description);
|
|
|
|
|
|
|
|
|
|
log.info("--- createCommunityAndLayout COMPLETED, vreCreatedId="+vreCreatedId);
|
|
|
|
|
|
|
|
|
|
if (vreCreatedId > 0) {
|
|
|
|
|
try {
|
|
|
|
|
org.gcube.vomanagement.usermanagement.model.GCubeGroup vreCreated = new LiferayGroupManager().getGroup(vreCreatedId);
|
|
|
|
|
log.info("--- CREATED LAYOUTS AND COMMUNITY OK, updating Calendar Application Profile.");
|
|
|
|
|
String vreScope = getScopeByOrganizationId(""+vreCreated.getOrganizationId());
|
|
|
|
|
String vreUrl = "/group/"+vreCreated.getName().toLowerCase();
|
|
|
|
|
String vreScope = new LiferayGroupManager().getInfrastructureScope(vreCreatedId);
|
|
|
|
|
String vreUrl = "/group/"+vreCreated.getGroupName().toLowerCase();
|
|
|
|
|
boolean calandarAppProfileUpdated = false;
|
|
|
|
|
try {
|
|
|
|
|
calandarAppProfileUpdated = updateApplicationProfile(CALENDAR_APPID, vreScope, vreUrl+"/calendar");
|
|
|
|
@ -752,27 +737,23 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|
|
|
|
}
|
|
|
|
|
log.info("updateApplicationProfile for " + CALENDAR_APPID + "="+calandarAppProfileUpdated);
|
|
|
|
|
log.info("updateApplicationProfile for " + NEWS_FEED_APPID + "="+newsFeedAppProfileUpdated);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("Trying to create VRE Group Folder through HomeLibrary ...");
|
|
|
|
|
createVRESharedGroupFolder(vreCreated, designer, manager, description);
|
|
|
|
|
|
|
|
|
|
log.info("--- createVRESharedGroupFolder OK, sending Message to designer.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserManager um = new LiferayUserManager();
|
|
|
|
|
UserModel userDesigner = um.getUserByScreenName(designer);
|
|
|
|
|
UserModel userManager = um.getUserByScreenName(manager);
|
|
|
|
|
GCubeUser userDesigner = um.getUserByUsername(designer);
|
|
|
|
|
GCubeUser userManager = um.getUserByUsername(manager);
|
|
|
|
|
|
|
|
|
|
Workspace workspace = HomeLibrary.getUserWorkspace(getASLSession().getUsername());
|
|
|
|
|
ArrayList<String> toSend = new ArrayList<String>();
|
|
|
|
|
toSend.add(designer);
|
|
|
|
|
String subject = "Definition approved and deployed";
|
|
|
|
|
String body = "Dear "+userDesigner.getFirstname()+", \n\n" + userManager.getFullname() + " has approved the deployment of the group you requested: " + name +".";
|
|
|
|
|
String body = "Dear "+userDesigner.getFirstName()+", \n\n" + userManager.getFullname() + " has approved the deployment of the group you requested: " + name +".";
|
|
|
|
|
body+=".\n\nThis group has been deployed successfully and is already available for you on this portal. Please, check your list.";
|
|
|
|
|
String messageId = workspace.getWorkspaceMessageManager().sendMessageToPortalLogins(subject, body, new ArrayList<String>(), toSend);
|
|
|
|
|
NotificationsManager nnm = new ApplicationNotificationsManager(getASLSession());
|
|
|
|
|
NotificationsManager nnm = new ApplicationNotificationsManager(
|
|
|
|
|
getThreadLocalRequest(),
|
|
|
|
|
getASLSession().getScope(),
|
|
|
|
|
new SocialNetworkingUser(getASLSession().getUsername(), getASLSession().getUserEmailAddress(), getASLSession().getUserFullName(), "")
|
|
|
|
|
);
|
|
|
|
|
if (nnm.notifyMessageReceived(designer, messageId, subject, body))
|
|
|
|
|
log.trace("Sending Definition create notification: " + subject + " OK");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -865,20 +846,20 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|
|
|
|
* @throws GroupRetrievalFault
|
|
|
|
|
* @throws UserManagementSystemException
|
|
|
|
|
*/
|
|
|
|
|
private void createVRESharedGroupFolder(Organization vreCreated, String designer, String manager, String description) throws Exception {
|
|
|
|
|
private void createVRESharedGroupFolder(org.gcube.vomanagement.usermanagement.model.GCubeGroup vreCreated, String designer, String manager, String description) throws Exception {
|
|
|
|
|
|
|
|
|
|
String currScope = ScopeProvider.instance.get();
|
|
|
|
|
ScopeProvider.instance.set("/"+getRootOrganizationName());
|
|
|
|
|
GroupManager gm = new LiferayGroupManager();
|
|
|
|
|
UserManager um = new LiferayUserManager();
|
|
|
|
|
|
|
|
|
|
GroupModel group = gm.getGroup(""+vreCreated.getOrganizationId());
|
|
|
|
|
String groupId = group.getGroupId();
|
|
|
|
|
org.gcube.vomanagement.usermanagement.model.GCubeGroup group = vreCreated;
|
|
|
|
|
long groupId = group.getGroupId();
|
|
|
|
|
|
|
|
|
|
String vreName = group.getGroupName();
|
|
|
|
|
String vreScope = gm.getScope(groupId);
|
|
|
|
|
String vreScope = gm.getInfrastructureScope(groupId);
|
|
|
|
|
|
|
|
|
|
List<UserModel> users = um.listUsersByGroup(group.getGroupId());
|
|
|
|
|
List<GCubeUser> users = um.listUsersByGroup(group.getGroupId());
|
|
|
|
|
String vreDesignerUserName = designer;
|
|
|
|
|
if (vreDesignerUserName != null) {
|
|
|
|
|
Workspace ws = HomeLibrary
|
|
|
|
@ -929,116 +910,18 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|
|
|
|
* @param usersToAdd the listo of users to add
|
|
|
|
|
* @throws InternalErrorException
|
|
|
|
|
*/
|
|
|
|
|
private static GCubeGroup createGroup(String vreScope, List<UserModel> usersToAdd) throws InternalErrorException {
|
|
|
|
|
private static GCubeGroup createGroup(String vreScope, List<GCubeUser> usersToAdd) throws InternalErrorException {
|
|
|
|
|
org.gcube.common.homelibrary.home.workspace.usermanager.UserManager gm = HomeLibrary
|
|
|
|
|
.getHomeManagerFactory().getUserManager();
|
|
|
|
|
GCubeGroup group = gm.createGroup(vreScope);
|
|
|
|
|
for (UserModel user : usersToAdd) {
|
|
|
|
|
group.addMember(user.getScreenName());
|
|
|
|
|
for (GCubeUser user : usersToAdd) {
|
|
|
|
|
group.addMember(user.getUsername());
|
|
|
|
|
}
|
|
|
|
|
return group;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param designer the username of the designer
|
|
|
|
|
* @param manager the username of the manager
|
|
|
|
|
* @param name the vre name
|
|
|
|
|
*/
|
|
|
|
|
private void shareCreatedVRENews(String designer, String manager, String name, String description) {
|
|
|
|
|
|
|
|
|
|
String text = "A new Virtual Research Environment is worming up. " + name + " announced open day is tomorrow!";
|
|
|
|
|
Date feedDate = new Date();
|
|
|
|
|
|
|
|
|
|
UserInfo managerInfo = null;
|
|
|
|
|
try {
|
|
|
|
|
managerInfo = getuserInfo(manager);
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
String previewTitle = "The new VRE " + name + " will be available starting from tomorrow";
|
|
|
|
|
Feed toShare = new Feed(UUID.randomUUID().toString(), FeedType.TWEET, managerInfo.getUsername(), feedDate,
|
|
|
|
|
"", "/group/data-e-infrastructure-gateway/join-new", ORGANIZATION_DEFAULT_LOGO_URL, text,
|
|
|
|
|
PrivacyLevel.VRES,
|
|
|
|
|
managerInfo.getFullName(),
|
|
|
|
|
managerInfo.getEmailaddress(),
|
|
|
|
|
managerInfo.getAvatarId(),
|
|
|
|
|
previewTitle,
|
|
|
|
|
description, "d4science.org", false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DatabookStore store = new DBCassandraAstyanaxImpl();
|
|
|
|
|
log.trace("Attempting to save Feed with text: " + text);
|
|
|
|
|
boolean result = store.saveUserFeed(toShare);
|
|
|
|
|
if (result) {
|
|
|
|
|
for (GroupModel vre : getUserVREs(manager)) {
|
|
|
|
|
String vreScope = getScopeByOrganizationId(vre.getGroupId());
|
|
|
|
|
log.trace("Attempting to write onto " + vreScope);
|
|
|
|
|
try {
|
|
|
|
|
store.saveFeedToVRETimeline(toShare.getKey(), vreScope);
|
|
|
|
|
} catch (FeedIDNotFoundException e) {
|
|
|
|
|
log.error("Error writing onto VRES Time Line" + vreScope);
|
|
|
|
|
} //save the feed
|
|
|
|
|
log.trace("Success writing onto " + vreScope);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param vreid the organizatio id in Liferay API
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String getScopeByOrganizationId(String vreid) {
|
|
|
|
|
GroupManager gm = new LiferayGroupManager();
|
|
|
|
|
try {
|
|
|
|
|
return gm.getScope(vreid);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("Could not find a scope for this VREid: " + vreid);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private UserInfo getuserInfo(String username) throws PortalException, SystemException {
|
|
|
|
|
log.debug("getuserInfo for " + username);
|
|
|
|
|
String email = username+"@isti.cnr.it";
|
|
|
|
|
String fullName = username+" FULL";
|
|
|
|
|
String thumbnailURL = "images/Avatar_default.png";
|
|
|
|
|
String accountURL = "";
|
|
|
|
|
if (!isTesting) {
|
|
|
|
|
getUserVREs(username);
|
|
|
|
|
com.liferay.portal.model.UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
|
|
|
|
|
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
|
|
|
|
|
fullName = user.getFirstName() + " " + user.getLastName();
|
|
|
|
|
email = user.getEmailAddress();
|
|
|
|
|
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
|
|
|
|
|
accountURL = themeDisplay.getURLMyAccount().toString();
|
|
|
|
|
}
|
|
|
|
|
return new UserInfo(username, fullName, thumbnailURL, email, accountURL, true, false, null);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param username
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private ArrayList<GroupModel> getUserVREs(String username) {
|
|
|
|
|
log.debug("getUserVREs for " + username);
|
|
|
|
|
ArrayList<GroupModel> toReturn = new ArrayList<GroupModel>();
|
|
|
|
|
com.liferay.portal.model.User currUser;
|
|
|
|
|
try {
|
|
|
|
|
GroupManager gm = new LiferayGroupManager();
|
|
|
|
|
currUser = OrganizationsUtil.validateUser(username);
|
|
|
|
|
|
|
|
|
|
for (Organization org : currUser.getOrganizations())
|
|
|
|
|
if (gm.isVRE(org.getOrganizationId()+"")) {
|
|
|
|
|
GroupModel toAdd = gm.getGroup(""+org.getOrganizationId());
|
|
|
|
|
toReturn.add(toAdd);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("Failed reading User VREs for : " + username);
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return toReturn;
|
|
|
|
|
}
|
|
|
|
|
return toReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -1186,34 +1069,35 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|
|
|
|
*/
|
|
|
|
|
private boolean vreExists(String vreName) {
|
|
|
|
|
GroupManager gm = new LiferayGroupManager();
|
|
|
|
|
String currOrgid = ""+getASLSession().getGroupId();
|
|
|
|
|
|
|
|
|
|
List<GroupModel> vres = null;
|
|
|
|
|
try {
|
|
|
|
|
vres = gm.listSubGroupsByGroup(currOrgid);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return gm.getGroupId(vreName) >= 0;
|
|
|
|
|
} catch (UserManagementSystemException | GroupRetrievalFault e) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
for (GroupModel vre : vres) {
|
|
|
|
|
if (vre.getGroupName().equals(vreName))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates the community and its layout in Liferay
|
|
|
|
|
*/
|
|
|
|
|
private Organization createCommunityAndLayout(String vreName) {
|
|
|
|
|
private long createCommunityAndLayoutAndHLFolder(String vreName, String description) {
|
|
|
|
|
|
|
|
|
|
if (vreExists(vreName)) {
|
|
|
|
|
log.warn("VRE Exists already");
|
|
|
|
|
return null;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ASLSession session = getASLSession();
|
|
|
|
|
log.info("TRYING READING CURRENT ORG ID");
|
|
|
|
|
long currOrgid = session.getGroupId(); //VO ID
|
|
|
|
|
log.info("TRYING READING CURRENT VO ID");
|
|
|
|
|
GroupManager gm = new LiferayGroupManager();
|
|
|
|
|
long parentVirtualOrganizationId = -1;
|
|
|
|
|
try {
|
|
|
|
|
parentVirtualOrganizationId = gm.getGroupIdFromInfrastructureScope(session.getScope());
|
|
|
|
|
} catch (IllegalArgumentException | UserManagementSystemException
|
|
|
|
|
| GroupRetrievalFault e1) {
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
log.info("CURRENT VO ID="+parentVirtualOrganizationId);
|
|
|
|
|
|
|
|
|
|
String desc = (session.getAttribute(DESCRIPTION) == null) ? "No Description found": session.getAttribute(DESCRIPTION).toString(); //desc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1222,88 +1106,75 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|
|
|
|
String manager = (String) session.getAttribute(MANAGER);
|
|
|
|
|
log.info("Manager found Name : " + manager);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
GCUBESiteLayout siteLayout = OrganizationManagerImpl.getBaseLayout(vreName, false, session.getUsername());
|
|
|
|
|
long groupModelid = OrganizationManagerImpl.createVRE(session.getUsername(), vreName, desc, currOrgid, siteLayout, OrganizationsUtil.getgCubeThemeId(ThemesIdManager.GCUBE_LOGGEDIN_THEME));
|
|
|
|
|
|
|
|
|
|
String themid = "";
|
|
|
|
|
themid = SiteManagerUtil.getgCubeThemeId(ThemesIdManager.GCUBE_LOGGEDIN_THEME);
|
|
|
|
|
|
|
|
|
|
log.info("Assigning theme with id: " + themid + " to VRE in creation");
|
|
|
|
|
|
|
|
|
|
GCUBESiteLayout siteLayout = GCubeSiteManagerImpl.getBaseLayout(vreName, false, session.getUsername());
|
|
|
|
|
org.gcube.vomanagement.usermanagement.model.GCubeGroup vreCreated = gm.createVRE(vreName, parentVirtualOrganizationId, desc);
|
|
|
|
|
|
|
|
|
|
long groupId = vreCreated.getGroupId();
|
|
|
|
|
Group lrGroup = GroupLocalServiceUtil.getGroup(groupId);
|
|
|
|
|
GCubeUser userBean = new LiferayUserManager().getUserByUsername(session.getUsername());
|
|
|
|
|
User lrUser = UserLocalServiceUtil.getUser(userBean.getUserId());
|
|
|
|
|
|
|
|
|
|
SiteManagerUtil.createLayout(lrGroup, lrUser, siteLayout);
|
|
|
|
|
|
|
|
|
|
Theme themeToApply = ThemeLocalServiceUtil.getTheme(SiteManagerUtil.getCompany().getCompanyId(), themid, false);
|
|
|
|
|
//update theme
|
|
|
|
|
LayoutSetLocalServiceUtil.updateLookAndFeel(groupId, themeToApply.getThemeId(), "", "", false);
|
|
|
|
|
log.debug("LayoutSet Theme with id " + themid + " Applied Correctly");
|
|
|
|
|
|
|
|
|
|
log.info("Assigned theme with id: " + themid + " to groupid: " + groupId);
|
|
|
|
|
|
|
|
|
|
//the method above create a VRE and assign the manager Role to the person that triggers the creation
|
|
|
|
|
//however the VRE-Designer and the VRE-Manager persons of the VRE could be different and need to be created too
|
|
|
|
|
UserManager uman = new LiferayUserManager();
|
|
|
|
|
|
|
|
|
|
Organization toReturn = OrganizationLocalServiceUtil.getOrganization(groupModelid);
|
|
|
|
|
Group vreCreated = toReturn.getGroup();
|
|
|
|
|
|
|
|
|
|
//if the manager is not the one who triggered the creation
|
|
|
|
|
String currUser = session.getUsername();
|
|
|
|
|
log.info("***Username of who triggered the creation is: " + currUser);
|
|
|
|
|
|
|
|
|
|
log.info("Trying to create VRE Group Folder through HomeLibrary ...");
|
|
|
|
|
createVRESharedGroupFolder(vreCreated, designer, manager, description);
|
|
|
|
|
|
|
|
|
|
log.info("--- createVRESharedGroupFolder OK, sending Message to designer.");
|
|
|
|
|
|
|
|
|
|
RoleManager rm = new LiferayRoleManager();
|
|
|
|
|
|
|
|
|
|
if (manager.compareTo(currUser) != 0) {
|
|
|
|
|
//add the role VRE-Manager
|
|
|
|
|
long uid = Long.parseLong(uman.getUserId(manager));
|
|
|
|
|
Role created = createRole("VRE-Manager", vreName, uid);
|
|
|
|
|
log.info("Admin Role "+ created.getName() + " Created Successfully");
|
|
|
|
|
long userId = uman.getUserId(manager);
|
|
|
|
|
uman.assignUserToGroup(groupId, userId);
|
|
|
|
|
log.info("Added manager " + manager + " to group " + vreName + " with Success");
|
|
|
|
|
|
|
|
|
|
uman.assignUserToGroup(""+vreCreated.getClassPK(), ""+uid);
|
|
|
|
|
log.info("Added manager " + manager + " to group " + vreCreated.getName() + " with Success");
|
|
|
|
|
|
|
|
|
|
log.info("Assigning Role: VRE-Manager");
|
|
|
|
|
RoleManager rm = new LiferayRoleManager();
|
|
|
|
|
rm.assignRoleToUser(""+vreCreated.getClassPK(), ""+created.getRoleId(), ""+uid);
|
|
|
|
|
log.info("Assigning Role: VRE-Manager");
|
|
|
|
|
long roleId = rm.getRoleIdByName(VRE_MANAGER);
|
|
|
|
|
rm.assignRoleToUser(userId, groupId, roleId);
|
|
|
|
|
log.info("Admin Role VRE-Manager Associated to user " + manager + " .... returning ...");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//if the designer is different
|
|
|
|
|
if (designer.compareTo(manager) != 0) {
|
|
|
|
|
//add the role VRE-Designer
|
|
|
|
|
long uid = Long.parseLong(uman.getUserId(designer));
|
|
|
|
|
Role created = createRole("VRE-Designer", vreName, uid);
|
|
|
|
|
log.info("Admin Role "+ created.getName() + " Created Successfully");
|
|
|
|
|
|
|
|
|
|
uman.assignUserToGroup(""+vreCreated.getClassPK(), ""+uid);
|
|
|
|
|
log.info("Added designer " + designer + " to group " + vreCreated.getName() + " with Success");
|
|
|
|
|
|
|
|
|
|
RoleManager rm = new LiferayRoleManager();
|
|
|
|
|
rm.assignRoleToUser(""+vreCreated.getClassPK(), ""+created.getRoleId(), ""+uid);
|
|
|
|
|
long userId = uman.getUserId(designer);
|
|
|
|
|
uman.assignUserToGroup(groupId, userId);
|
|
|
|
|
log.info("Added designer " + designer + " to group " + vreName + " with Success");
|
|
|
|
|
long roleId = rm.getRoleIdByName(VRE_DESIGNER);
|
|
|
|
|
rm.assignRoleToUser(userId, groupId, roleId);
|
|
|
|
|
log.info("Admin Role VRE-Designer Associated to user " + designer + " .... returning ...");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return toReturn;
|
|
|
|
|
|
|
|
|
|
return groupId;
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return null;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Create a Regular Manager Role for the community
|
|
|
|
|
* @param vreName
|
|
|
|
|
* @return
|
|
|
|
|
* @throws PortalException
|
|
|
|
|
* @throws SystemException
|
|
|
|
|
*/
|
|
|
|
|
protected static Role createRole(String roleName, String vreName, long userid){
|
|
|
|
|
try {
|
|
|
|
|
Company company = OrganizationsUtil.getCompany();
|
|
|
|
|
String roletoAdd = roleName+"-" + vreName.replaceAll(" ", "-");
|
|
|
|
|
Role toCreate = null;
|
|
|
|
|
try {
|
|
|
|
|
toCreate = RoleLocalServiceUtil.getRole(company.getCompanyId(), roletoAdd);
|
|
|
|
|
} catch (NoSuchRoleException e) {
|
|
|
|
|
log.debug("Adding Role: " + roletoAdd);
|
|
|
|
|
return RoleLocalServiceUtil.addRole(userid, company.getCompanyId(), roletoAdd, null, roleName +" of " + vreName, LIFERAY_REGULAR_ROLE_ID);
|
|
|
|
|
}
|
|
|
|
|
return toCreate;
|
|
|
|
|
|
|
|
|
|
} catch (PortalException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (SystemException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* CHECK IF THE VRE DEPLOYMENT IS FINISHED
|
|
|
|
@ -1394,98 +1265,6 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|
|
|
|
*/
|
|
|
|
|
private DeployReport simulateReport() {
|
|
|
|
|
DeployReport reportToReturn = new DeployReport();
|
|
|
|
|
//
|
|
|
|
|
// Random random = new Random();
|
|
|
|
|
// int pick = random.nextInt(5);
|
|
|
|
|
//
|
|
|
|
|
// reportToReturn.setStatus(Status.Running);
|
|
|
|
|
//
|
|
|
|
|
// GHNonCloudReport cloudDeploy = new GHNonCloudReport();
|
|
|
|
|
// Status globalstatus;
|
|
|
|
|
// Status singlestatus;
|
|
|
|
|
//
|
|
|
|
|
// switch (pick) {
|
|
|
|
|
// case 0:
|
|
|
|
|
// cloudDeploy.setStatus(Status.Running);
|
|
|
|
|
// Status[] statuses = {Status.Failed,Status.Running, Status.Failed, Status.Failed, Status.Finished};
|
|
|
|
|
// cloudDeploy.setDeployingState(statuses);
|
|
|
|
|
//
|
|
|
|
|
// globalstatus = Status.Running;
|
|
|
|
|
// singlestatus = Status.Running;
|
|
|
|
|
// break;
|
|
|
|
|
// case 1:
|
|
|
|
|
// cloudDeploy.setStatus(Status.Waiting);
|
|
|
|
|
// Status[] status1 = {Status.Running, Status.Running, Status.Running, Status.Running, Status.Finished,
|
|
|
|
|
// Status.Failed,Status.Running, Status.Failed, Status.Failed, Status.Finished};
|
|
|
|
|
// cloudDeploy.setDeployingState(status1);
|
|
|
|
|
//
|
|
|
|
|
// globalstatus = Status.Finished;
|
|
|
|
|
// singlestatus = Status.Finished;
|
|
|
|
|
// break;
|
|
|
|
|
// case 2:
|
|
|
|
|
// cloudDeploy.setStatus(Status.Failed);
|
|
|
|
|
// Status[] status2 = {Status.Running, Status.Failed, Status.Failed, Status.Running, Status.Finished,
|
|
|
|
|
// Status.Failed,Status.Running, Status.Failed, Status.Failed, Status.Finished};
|
|
|
|
|
// cloudDeploy.setDeployingState(status2);
|
|
|
|
|
//
|
|
|
|
|
// globalstatus = Status.Failed;
|
|
|
|
|
// singlestatus = Status.Failed;
|
|
|
|
|
// break;
|
|
|
|
|
// case 3:
|
|
|
|
|
// cloudDeploy.setStatus(Status.Waiting);
|
|
|
|
|
// Status[] status3 = {Status.Running, Status.Running, Status.Running, Status.Waiting, Status.Waiting};
|
|
|
|
|
// cloudDeploy.setDeployingState(status3);
|
|
|
|
|
//
|
|
|
|
|
// globalstatus = Status.Waiting;
|
|
|
|
|
// singlestatus = Status.Running;
|
|
|
|
|
// case 4:
|
|
|
|
|
// cloudDeploy.setStatus(Status.Finished);
|
|
|
|
|
// Status[] status4 = {Status.Running, Status.Running, Status.Running, Status.Waiting, Status.Waiting};
|
|
|
|
|
// cloudDeploy.setDeployingState(status4);
|
|
|
|
|
//
|
|
|
|
|
// globalstatus = Status.Waiting;
|
|
|
|
|
// singlestatus = Status.Waiting;
|
|
|
|
|
// default:
|
|
|
|
|
// Status[] statusd = {Status.Skipped, Status.Skipped, Status.Skipped, Status.Skipped, Status.Skipped};
|
|
|
|
|
// cloudDeploy.setDeployingState(statusd);
|
|
|
|
|
//
|
|
|
|
|
// globalstatus = Status.Waiting;
|
|
|
|
|
// singlestatus = Status.Waiting;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// reportToReturn.setCloudDeployingReport(cloudDeploy);
|
|
|
|
|
//
|
|
|
|
|
// ResourceDeployingReport rmdr = new ResourceDeployingReport();
|
|
|
|
|
// rmdr.setStatus(singlestatus);
|
|
|
|
|
//
|
|
|
|
|
// FunctionalityDeployingReport fdr = new FunctionalityDeployingReport();
|
|
|
|
|
//
|
|
|
|
|
// //creating func table
|
|
|
|
|
// Hashtable<FunctionalityReport, List<ServiceReport>> funtable = new Hashtable<FunctionalityReport, List<ServiceReport>>();
|
|
|
|
|
// for (int i = 0; i < 5; i++) {
|
|
|
|
|
// FunctionalityReport fr = new FunctionalityReport();
|
|
|
|
|
// fr.setFunctionalityId("0000");
|
|
|
|
|
// fr.setFunctionalityName("Search Potente");
|
|
|
|
|
// fr.setStatus(Status.Running);
|
|
|
|
|
//
|
|
|
|
|
// List<ServiceReport> sreports = new ArrayList<ServiceReport>();
|
|
|
|
|
//
|
|
|
|
|
// for (int j = 0; j < 7; j++) {
|
|
|
|
|
// ServiceReport sr = new ServiceReport();
|
|
|
|
|
// sr.setServiceClass("search");
|
|
|
|
|
// sr.setServiceName("ft indexer");
|
|
|
|
|
// sr.setServiceVersion("1.0");
|
|
|
|
|
// sreports.add(sr);
|
|
|
|
|
// }
|
|
|
|
|
// funtable.put(fr, sreports);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// fdr.setFunctionalityTable(funtable);
|
|
|
|
|
// fdr.setStatus(Status.Running);
|
|
|
|
|
// fdr.setResourceManagerReport(null);
|
|
|
|
|
//
|
|
|
|
|
// reportToReturn.setFunctionalityDeployingReport(fdr);
|
|
|
|
|
// reportToReturn.setStatus(globalstatus);
|
|
|
|
|
return reportToReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1514,41 +1293,6 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
|
|
|
|
|
return ret.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return the built layout of a rootVO
|
|
|
|
|
* @throws SystemException .
|
|
|
|
|
* @throws PortalException .
|
|
|
|
|
*/
|
|
|
|
|
public GCUBESiteLayout getBaseLayout(String voName, OrganizationManagerImpl orgManager, boolean isVO) throws PortalException, SystemException {
|
|
|
|
|
GCUBESiteLayout siteLayout = null;
|
|
|
|
|
String email = OrganizationManagerImpl.validateUser(getASLSession().getUsername()).getEmailAddress();
|
|
|
|
|
siteLayout = new GCUBESiteLayout(OrganizationManagerImpl.getCompany(), voName, email);
|
|
|
|
|
siteLayout.addTab(new GCUBELayoutTab(voName, GCUBELayoutType.ONE_COL,
|
|
|
|
|
new GCUBEPortlet("gCube Loggedin", PortletsIdManager.getLRPortletId(PortletsIdManager.GCUBE_LOGGEDIN))));
|
|
|
|
|
|
|
|
|
|
//create tab Users and Roles with 2 subtabs
|
|
|
|
|
GCUBELayoutTab usersAndRoles = new GCUBELayoutTab("Administration", GCUBELayoutType.ONE_COL,
|
|
|
|
|
new GCUBEPortlet("Navigation", PortletsIdManager.getLRPortletId(PortletsIdManager.LR_NAVIGATION)));
|
|
|
|
|
GCUBELayoutTab usersTab = new GCUBELayoutTab("Manage User and Requests", GCUBELayoutType.ONE_COL,
|
|
|
|
|
new GCUBEPortlet("Users", PortletsIdManager.getLRPortletId(PortletsIdManager.GCUBE_USERS_MANAGE)));
|
|
|
|
|
GCUBELayoutTab usersAddTab = new GCUBELayoutTab("Add new Users", GCUBELayoutType.ONE_COL,
|
|
|
|
|
new GCUBEPortlet("Users", PortletsIdManager.getLRPortletId(PortletsIdManager.GCUBE_ADD_USERS_MANAGE)));
|
|
|
|
|
GCUBELayoutTab rolesTab = new GCUBELayoutTab("Add new Roles", GCUBELayoutType.ONE_COL,
|
|
|
|
|
new GCUBEPortlet("Roles", PortletsIdManager.getLRPortletId(PortletsIdManager.GCUBE_ROLES_MANAGE)));
|
|
|
|
|
usersAndRoles.addSubTab(usersTab);
|
|
|
|
|
usersAndRoles.addSubTab(usersAddTab);
|
|
|
|
|
usersAndRoles.addSubTab(rolesTab);
|
|
|
|
|
//add the tab
|
|
|
|
|
siteLayout.addTab(usersAndRoles);
|
|
|
|
|
if (isVO)
|
|
|
|
|
siteLayout.addTab(new GCUBELayoutTab("Resources Management", GCUBELayoutType.ONE_COL,
|
|
|
|
|
new GCUBEPortlet("Resources Management", PortletsIdManager.getLRPortletId(PortletsIdManager.RESOURCES_MANAGEMENT))));
|
|
|
|
|
else
|
|
|
|
|
siteLayout.addTab(new GCUBELayoutTab("Calendar", GCUBELayoutType.ONE_COL,
|
|
|
|
|
new GCUBEPortlet("Calendar", PortletsIdManager.getLRPortletId(PortletsIdManager.LR_CALENDAR)), true));
|
|
|
|
|
return siteLayout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|