added getGroupIdFromInfrastructureScope(String scope)
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@125662 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f1af2dc4a3
commit
e928e212b6
|
@ -84,6 +84,14 @@ public interface GroupManager {
|
|||
* @throws GroupRetrievalFault
|
||||
*/
|
||||
GCubeGroup getGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault;
|
||||
/**
|
||||
*
|
||||
* @param scope the infrastructure scope e.g. /gcube/devsec
|
||||
* @return the LR groupId, -1 otherwise
|
||||
* @throws UserManagementSystemException
|
||||
* @throws GroupRetrievalFault
|
||||
*/
|
||||
long getGroupIdFromInfrastructureScope(String scope) throws IllegalArgumentException, UserManagementSystemException, GroupRetrievalFault;
|
||||
/**
|
||||
*
|
||||
* @return an instance of @see {@link GCubeGroup} filled with the RootVO metadata
|
||||
|
|
|
@ -38,8 +38,6 @@ import com.liferay.portal.service.LayoutSetLocalServiceUtil;
|
|||
import com.liferay.portal.service.RoleServiceUtil;
|
||||
import com.liferay.portal.service.ServiceContext;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
import com.liferay.portlet.sites.util.Sites;
|
||||
import com.liferay.portlet.sites.util.SitesUtil;
|
||||
|
||||
public class LiferayGroupManager implements GroupManager {
|
||||
/**
|
||||
|
@ -66,7 +64,7 @@ public class LiferayGroupManager implements GroupManager {
|
|||
List<Group> children = g.getChildren(true);
|
||||
for (Group vo : children)
|
||||
vos.add(mapLRGroup(vo));
|
||||
return new GCubeGroup(g.getGroupId(), -1, g.getName(), g.getDescription(), g.getFriendlyURL(), logoId, vos);
|
||||
return new GCubeGroup(g.getGroupId(), -1, g.getName(), g.getDescription(), g.getFriendlyURL(), logoId, vos, g.getType()==GroupConstants.TYPE_SITE_RESTRICTED);
|
||||
} else{
|
||||
_log.warn("This groupId does not correspond to a VO ora VRE");
|
||||
return null;
|
||||
|
@ -166,7 +164,7 @@ public class LiferayGroupManager implements GroupManager {
|
|||
try {
|
||||
GroupLocalServiceUtil.getGroup(groupId).getParentGroupId();
|
||||
} catch (PortalException e) {
|
||||
throw new GroupRetrievalFault("Group not existing", e);
|
||||
throw new GroupRetrievalFault("Group not existing ", e);
|
||||
} catch (SystemException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -183,7 +181,7 @@ public class LiferayGroupManager implements GroupManager {
|
|||
g = GroupLocalServiceUtil.getGroup(ManagementUtils.getCompany().getCompanyId(), groupName);
|
||||
return g.getGroupId();
|
||||
} catch (PortalException e) {
|
||||
_log.warn(groupName + " Group not existing");
|
||||
_log.warn(groupName + " Group not existing -> "+ groupName);
|
||||
} catch (SystemException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -206,6 +204,56 @@ public class LiferayGroupManager implements GroupManager {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws GroupRetrievalFault
|
||||
* @throws UserManagementSystemException
|
||||
*/
|
||||
@Override
|
||||
public long getGroupIdFromInfrastructureScope(String scope) throws IllegalArgumentException, UserManagementSystemException, GroupRetrievalFault {
|
||||
if (! scope.startsWith("/")) {
|
||||
throw new IllegalArgumentException("Scope should start with '/' ->" + scope);
|
||||
}
|
||||
if (scope.endsWith("/")) {
|
||||
throw new IllegalArgumentException("Scope should not end with '/' ->" + scope);
|
||||
}
|
||||
String[] splits = scope.split("/");
|
||||
if (splits.length > 4)
|
||||
throw new IllegalArgumentException("Scope is invalid, too many '/' ->" + scope);
|
||||
if (splits.length == 2) //is a root VO
|
||||
return getGroupId(splits[1]);
|
||||
else if (splits.length == 3) {//is a VO
|
||||
long parentGroupId = getGroupId(splits[1]);
|
||||
List<Group> vos = null;
|
||||
try {
|
||||
vos = GroupLocalServiceUtil.getGroups(ManagementUtils.getCompany().getCompanyId(), parentGroupId, true);
|
||||
} catch (SystemException e) {
|
||||
e.printStackTrace();
|
||||
} catch (PortalException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (Group group : vos) {
|
||||
if (group.getName().compareTo(splits[2])==0)
|
||||
return group.getGroupId();
|
||||
}
|
||||
}
|
||||
else if (splits.length == 4) {//is a VRE
|
||||
long parentGroupId = getGroupId(splits[2]);
|
||||
List<Group> vres = null;
|
||||
try {
|
||||
vres = GroupLocalServiceUtil.getGroups(ManagementUtils.getCompany().getCompanyId(), parentGroupId, true);
|
||||
} catch (SystemException e) {
|
||||
e.printStackTrace();
|
||||
} catch (PortalException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (Group group : vres) {
|
||||
if (group.getName().compareTo(splits[3])==0)
|
||||
return group.getGroupId();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -14,12 +14,12 @@ public class GCubeGroup implements Serializable {
|
|||
String friendlyURL;
|
||||
long logoId;
|
||||
List<GCubeGroup> children;
|
||||
boolean requestBasedGroup;
|
||||
|
||||
public GCubeGroup() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public GCubeGroup(long groupId, long parentGroupId, String groupName,
|
||||
String description, String friendlyURL, long logoId,
|
||||
List<GCubeGroup> children) {
|
||||
|
@ -31,6 +31,21 @@ public class GCubeGroup implements Serializable {
|
|||
this.friendlyURL = friendlyURL;
|
||||
this.logoId = logoId;
|
||||
this.children = children;
|
||||
this.requestBasedGroup = true;
|
||||
}
|
||||
|
||||
public GCubeGroup(long groupId, long parentGroupId, String groupName,
|
||||
String description, String friendlyURL, long logoId,
|
||||
List<GCubeGroup> children, boolean requestBasedGroup) {
|
||||
super();
|
||||
this.groupId = groupId;
|
||||
this.parentGroupId = parentGroupId;
|
||||
this.groupName = groupName;
|
||||
this.description = description;
|
||||
this.friendlyURL = friendlyURL;
|
||||
this.logoId = logoId;
|
||||
this.children = children;
|
||||
this.requestBasedGroup = requestBasedGroup;
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,17 +125,24 @@ public class GCubeGroup implements Serializable {
|
|||
public void setChildren(List<GCubeGroup> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public boolean isRequestBasedGroup() {
|
||||
return requestBasedGroup;
|
||||
}
|
||||
|
||||
public void setRequestBasedGroup(boolean requestBasedGroup) {
|
||||
this.requestBasedGroup = requestBasedGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GCubeGroup [groupId=" + groupId + ", parentGroupId="
|
||||
+ parentGroupId + ", groupName=" + groupName + ", description="
|
||||
+ description + ", friendlyURL=" + friendlyURL + ", logoId="
|
||||
+ logoId + ", children=" + children + "]";
|
||||
+ logoId + ", children=" + children + ", requestBasedGroup="
|
||||
+ requestBasedGroup + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
|
|
Loading…
Reference in New Issue