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>
|
||||
<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"
|
||||
date="2016-10-03">
|
||||
<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.MembershipRequestStatus;
|
||||
import org.gcube.vomanagement.usermanagement.model.VirtualGroup;
|
||||
import org.gcube.vomanagement.usermanagement.util.ManagementUtils;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
import com.liferay.portal.kernel.cache.CacheRegistryUtil;
|
||||
|
@ -113,13 +114,12 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
|||
* @throws PortalException
|
||||
*/
|
||||
public LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalSitesMappedToVRE() throws Exception {
|
||||
|
||||
|
||||
GroupManager gm = new LiferayGroupManager();
|
||||
LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
|
||||
|
||||
long currentSiteGroupId = getSiteFromServletRequest(getThreadLocalRequest()).getGroupId();
|
||||
List<VirtualGroup> currentSiteVGroups = getVirtualGroups(currentSiteGroupId);
|
||||
List<VirtualGroup> currentSiteVGroups = gm.getVirtualGroups(currentSiteGroupId);
|
||||
|
||||
for (VirtualGroup vg : currentSiteVGroups) {
|
||||
ArrayList<VRE> toCreate = new ArrayList<VRE>();
|
||||
VRECategory cat = new VRECategory(1L, vg.getName(), vg.getDescription());
|
||||
|
@ -144,36 +144,34 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
|||
|
||||
//for each root sub organizations (VO)
|
||||
for (GCubeGroup vOrg : rootGroupVO.getChildren()) {
|
||||
for (GCubeGroup vreOrganization : vOrg.getChildren()) {
|
||||
long vreID = vreOrganization.getGroupId();
|
||||
String vreName = vreOrganization.getGroupName();
|
||||
String vreDescription = vreOrganization.getDescription();
|
||||
for (GCubeGroup vreSite : vOrg.getChildren()) {
|
||||
long vreID = vreSite.getGroupId();
|
||||
String vreName = vreSite.getGroupName();
|
||||
String vreDescription = vreSite.getDescription();
|
||||
|
||||
long logoId = vreOrganization.getLogoId();
|
||||
long logoId = vreSite.getLogoId();
|
||||
String vreLogoURL = gm.getGroupLogoURL(logoId);
|
||||
String groupName = gm.getInfrastructureScope(vreOrganization.getGroupId());
|
||||
String friendlyURL = GCubePortalConstants.PREFIX_GROUP_URL+vreOrganization.getFriendlyURL();
|
||||
String groupName = gm.getInfrastructureScope(vreSite.getGroupId());
|
||||
String friendlyURL = GCubePortalConstants.PREFIX_GROUP_URL+vreSite.getFriendlyURL();
|
||||
|
||||
String catName = gm.getVirtualGroup(vreID).getName();
|
||||
|
||||
VRECategory toLookFor = null;
|
||||
for (VRECategory vre : toReturn.keySet()) {
|
||||
if (vre.getName().compareTo(catName)==0)
|
||||
toLookFor = vre;
|
||||
}
|
||||
if (toLookFor != null) {
|
||||
ArrayList<VRE> toUpdate = toReturn.get(toLookFor);
|
||||
UserBelonging belongs = UserBelonging.NOT_BELONGING;
|
||||
VRE toAdd = new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName, friendlyURL, belongs, getVREMembershipType(vreOrganization.getMembershipType()));
|
||||
if (currUser != null) {
|
||||
//check if the user belongs to it
|
||||
if (currUserGroups.contains(vreOrganization)) {
|
||||
toAdd.setUserBelonging(UserBelonging.BELONGING);
|
||||
List<VirtualGroup> vreGroups = gm.getVirtualGroups(vreID);
|
||||
for (VirtualGroup vreGroup : vreGroups) {
|
||||
for (VRECategory vre : toReturn.keySet()) {
|
||||
if (vre.getName().compareTo(vreGroup.getName())==0) {
|
||||
ArrayList<VRE> toUpdate = toReturn.get(vre);
|
||||
UserBelonging belongs = UserBelonging.NOT_BELONGING;
|
||||
VRE toAdd = new VRE(vreID,vreName, vreDescription, vreLogoURL, groupName, friendlyURL, belongs, getVREMembershipType(vreSite.getMembershipType()));
|
||||
if (currUser != null) {
|
||||
//check if the user belongs to it
|
||||
if (currUserGroups.contains(vreSite)) {
|
||||
toAdd.setUserBelonging(UserBelonging.BELONGING);
|
||||
}
|
||||
else if (checkPending(currUser.getUsername(), vreSite.getGroupId()))
|
||||
toAdd.setUserBelonging(UserBelonging.PENDING);
|
||||
}
|
||||
toUpdate.add(toAdd);
|
||||
}
|
||||
else if (checkPending(currUser.getUsername(), vreOrganization.getGroupId()))
|
||||
toAdd.setUserBelonging(UserBelonging.PENDING);
|
||||
}
|
||||
toUpdate.add(toAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -400,11 +398,11 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
|||
|
||||
@Override
|
||||
public String isExistingInvite(long groupId) {
|
||||
|
||||
|
||||
_log.debug("initiating Store");
|
||||
initStore();
|
||||
_log.debug("initStore OK");
|
||||
|
||||
|
||||
String email = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest()).getEmail();
|
||||
String infraScope = null;
|
||||
try {
|
||||
|
@ -433,48 +431,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue