Implemented Feature #4877 remove VRE association to single Category constraint
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@134338 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2dcf8b5e4c
commit
1be03d5f66
|
@ -1,4 +1,8 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
|
<Changeset component="org.gcube.portlets-user.join-vre.3.2.0" date="2016-11-17">
|
||||||
|
<Change>Removed ASL Session</Change>
|
||||||
|
<Change>Implemented Feature #4877 remove VRE association to single Category constraint</Change>
|
||||||
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.join-vre.3.1.0"
|
<Changeset component="org.gcube.portlets-user.join-vre.3.1.0"
|
||||||
date="2016-10-03">
|
date="2016-10-03">
|
||||||
<Change>Added support for invite-only closed groups</Change>
|
<Change>Added support for invite-only closed groups</Change>
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GroupMembershipType;
|
import org.gcube.vomanagement.usermanagement.model.GroupMembershipType;
|
||||||
import org.gcube.vomanagement.usermanagement.model.MembershipRequestStatus;
|
import org.gcube.vomanagement.usermanagement.model.MembershipRequestStatus;
|
||||||
import org.gcube.vomanagement.usermanagement.model.VirtualGroup;
|
import org.gcube.vomanagement.usermanagement.model.VirtualGroup;
|
||||||
|
import org.gcube.vomanagement.usermanagement.util.ManagementUtils;
|
||||||
|
|
||||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
import com.liferay.portal.kernel.cache.CacheRegistryUtil;
|
import com.liferay.portal.kernel.cache.CacheRegistryUtil;
|
||||||
|
@ -113,13 +114,12 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
* @throws PortalException
|
* @throws PortalException
|
||||||
*/
|
*/
|
||||||
public LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalSitesMappedToVRE() throws Exception {
|
public LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalSitesMappedToVRE() throws Exception {
|
||||||
|
|
||||||
|
|
||||||
GroupManager gm = new LiferayGroupManager();
|
GroupManager gm = new LiferayGroupManager();
|
||||||
LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
|
LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
|
||||||
|
|
||||||
long currentSiteGroupId = getSiteFromServletRequest(getThreadLocalRequest()).getGroupId();
|
long currentSiteGroupId = getSiteFromServletRequest(getThreadLocalRequest()).getGroupId();
|
||||||
List<VirtualGroup> currentSiteVGroups = getVirtualGroups(currentSiteGroupId);
|
List<VirtualGroup> currentSiteVGroups = gm.getVirtualGroups(currentSiteGroupId);
|
||||||
|
|
||||||
for (VirtualGroup vg : currentSiteVGroups) {
|
for (VirtualGroup vg : currentSiteVGroups) {
|
||||||
ArrayList<VRE> toCreate = new ArrayList<VRE>();
|
ArrayList<VRE> toCreate = new ArrayList<VRE>();
|
||||||
VRECategory cat = new VRECategory(1L, vg.getName(), vg.getDescription());
|
VRECategory cat = new VRECategory(1L, vg.getName(), vg.getDescription());
|
||||||
|
@ -144,39 +144,37 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
|
|
||||||
//for each root sub organizations (VO)
|
//for each root sub organizations (VO)
|
||||||
for (GCubeGroup vOrg : rootGroupVO.getChildren()) {
|
for (GCubeGroup vOrg : rootGroupVO.getChildren()) {
|
||||||
for (GCubeGroup vreOrganization : vOrg.getChildren()) {
|
for (GCubeGroup vreSite : vOrg.getChildren()) {
|
||||||
long vreID = vreOrganization.getGroupId();
|
long vreID = vreSite.getGroupId();
|
||||||
String vreName = vreOrganization.getGroupName();
|
String vreName = vreSite.getGroupName();
|
||||||
String vreDescription = vreOrganization.getDescription();
|
String vreDescription = vreSite.getDescription();
|
||||||
|
|
||||||
long logoId = vreOrganization.getLogoId();
|
long logoId = vreSite.getLogoId();
|
||||||
String vreLogoURL = gm.getGroupLogoURL(logoId);
|
String vreLogoURL = gm.getGroupLogoURL(logoId);
|
||||||
String groupName = gm.getInfrastructureScope(vreOrganization.getGroupId());
|
String groupName = gm.getInfrastructureScope(vreSite.getGroupId());
|
||||||
String friendlyURL = GCubePortalConstants.PREFIX_GROUP_URL+vreOrganization.getFriendlyURL();
|
String friendlyURL = GCubePortalConstants.PREFIX_GROUP_URL+vreSite.getFriendlyURL();
|
||||||
|
|
||||||
String catName = gm.getVirtualGroup(vreID).getName();
|
List<VirtualGroup> vreGroups = gm.getVirtualGroups(vreID);
|
||||||
|
for (VirtualGroup vreGroup : vreGroups) {
|
||||||
VRECategory toLookFor = null;
|
|
||||||
for (VRECategory vre : toReturn.keySet()) {
|
for (VRECategory vre : toReturn.keySet()) {
|
||||||
if (vre.getName().compareTo(catName)==0)
|
if (vre.getName().compareTo(vreGroup.getName())==0) {
|
||||||
toLookFor = vre;
|
ArrayList<VRE> toUpdate = toReturn.get(vre);
|
||||||
}
|
|
||||||
if (toLookFor != null) {
|
|
||||||
ArrayList<VRE> toUpdate = toReturn.get(toLookFor);
|
|
||||||
UserBelonging belongs = UserBelonging.NOT_BELONGING;
|
UserBelonging belongs = UserBelonging.NOT_BELONGING;
|
||||||
VRE toAdd = new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName, friendlyURL, belongs, getVREMembershipType(vreOrganization.getMembershipType()));
|
VRE toAdd = new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName, friendlyURL, belongs, getVREMembershipType(vreSite.getMembershipType()));
|
||||||
if (currUser != null) {
|
if (currUser != null) {
|
||||||
//check if the user belongs to it
|
//check if the user belongs to it
|
||||||
if (currUserGroups.contains(vreOrganization)) {
|
if (currUserGroups.contains(vreSite)) {
|
||||||
toAdd.setUserBelonging(UserBelonging.BELONGING);
|
toAdd.setUserBelonging(UserBelonging.BELONGING);
|
||||||
}
|
}
|
||||||
else if (checkPending(currUser.getUsername(), vreOrganization.getGroupId()))
|
else if (checkPending(currUser.getUsername(), vreSite.getGroupId()))
|
||||||
toAdd.setUserBelonging(UserBelonging.PENDING);
|
toAdd.setUserBelonging(UserBelonging.PENDING);
|
||||||
}
|
}
|
||||||
toUpdate.add(toAdd);
|
toUpdate.add(toAdd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//sort the vres in the groups
|
//sort the vres in the groups
|
||||||
for (VRECategory cat : toReturn.keySet()) {
|
for (VRECategory cat : toReturn.keySet()) {
|
||||||
|
@ -433,48 +431,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* read the list of virtual groups the current site (i-marine, services etc. ) should show up
|
|
||||||
* @param actualGroupId
|
|
||||||
* @return he list of virtual groups the current site (i-marine, services etc. ) should show up
|
|
||||||
* @throws GroupRetrievalFault
|
|
||||||
* @throws VirtualGroupNotExistingException
|
|
||||||
*/
|
|
||||||
private List<VirtualGroup> getVirtualGroups(long actualGroupId) throws GroupRetrievalFault, VirtualGroupNotExistingException {
|
|
||||||
List<VirtualGroup> toReturn = new ArrayList<VirtualGroup>();
|
|
||||||
try {
|
|
||||||
long userId = LiferayUserManager.getAdmin().getUserId();
|
|
||||||
PrincipalThreadLocal.setName(userId);
|
|
||||||
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(UserLocalServiceUtil.getUser(userId));
|
|
||||||
PermissionThreadLocal.setPermissionChecker(permissionChecker);
|
|
||||||
Group site = GroupLocalServiceUtil.getGroup(actualGroupId);
|
|
||||||
_log.debug("Set Thread Permission done, getVirtual Group of " + site.getName());
|
|
||||||
if (site.getExpandoBridge().getAttribute(CustomAttributeKeys.VIRTUAL_GROUP.getKeyName()) == null || site.getExpandoBridge().getAttribute(CustomAttributeKeys.VIRTUAL_GROUP.getKeyName()).equals("")) {
|
|
||||||
String warningMessage = String.format("Attribute %s not initialized.", CustomAttributeKeys.VIRTUAL_GROUP.getKeyName());
|
|
||||||
_log.warn(warningMessage);
|
|
||||||
throw new VirtualGroupNotExistingException(warningMessage);
|
|
||||||
} else {
|
|
||||||
String[] values = (String[]) site.getExpandoBridge().getAttribute(CustomAttributeKeys.VIRTUAL_GROUP.getKeyName());
|
|
||||||
VirtualGroup toAdd = new VirtualGroup();
|
|
||||||
if (values != null && values.length > 0) {
|
|
||||||
for (int i = 0; i < values.length; i++) {
|
|
||||||
toAdd = new VirtualGroup();
|
|
||||||
String[] splits = values[i].split("\\|");
|
|
||||||
toAdd.setName(splits[0]);
|
|
||||||
toAdd.setDescription(splits[1]);
|
|
||||||
toReturn.add(toAdd);
|
|
||||||
_log.debug("VirtualGroup selected found for " + site.getName() + " -> " + toAdd.getName());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
toAdd.setName("NoVirtualGroupAssigned");
|
|
||||||
toAdd.setDescription("NoVirtualGroupDescription");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
|
|
Loading…
Reference in New Issue