added inner method name to GroupManager
This commit is contained in:
parent
18cba6c067
commit
0508aa0e3a
|
@ -37,6 +37,7 @@ import org.gcube.common.gxrest.response.outbound.GXOutboundErrorResponse;
|
|||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
|
||||
import org.gcube.common.storagehub.model.exceptions.InvalidCallParameters;
|
||||
import org.gcube.common.storagehub.model.exceptions.InvalidItemException;
|
||||
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
||||
import org.gcube.common.storagehub.model.types.NodeProperty;
|
||||
|
@ -45,6 +46,7 @@ import org.gcube.data.access.storagehub.Constants;
|
|||
import org.gcube.data.access.storagehub.Utils;
|
||||
import org.gcube.data.access.storagehub.exception.MyAuthException;
|
||||
import org.gcube.data.access.storagehub.handlers.CredentialHandler;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -65,6 +67,8 @@ public class GroupManager {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public List<String> getGroups(){
|
||||
|
||||
InnerMethodName.instance.set("getGroups");
|
||||
|
||||
JackrabbitSession session = null;
|
||||
List<String> groups= new ArrayList<>();
|
||||
try {
|
||||
|
@ -99,6 +103,7 @@ public class GroupManager {
|
|||
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
||||
public String createGroup(@FormParam("group") String group, @FormParam("accessType") AccessType accessType){
|
||||
|
||||
InnerMethodName.instance.set("createGroup");
|
||||
|
||||
JackrabbitSession session = null;
|
||||
String groupId = null;
|
||||
|
@ -132,6 +137,8 @@ public class GroupManager {
|
|||
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
||||
public String deleteGroup(@PathParam("group") String group){
|
||||
|
||||
InnerMethodName.instance.set("deleteGroup");
|
||||
|
||||
JackrabbitSession session = null;
|
||||
try {
|
||||
|
||||
|
@ -166,6 +173,8 @@ public class GroupManager {
|
|||
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
||||
public boolean addUserToGroup(@PathParam("id") String groupId, @FormParam("userId") String userId){
|
||||
|
||||
InnerMethodName.instance.set("addUserToGroup");
|
||||
|
||||
JackrabbitSession session = null;
|
||||
boolean success = false;
|
||||
try {
|
||||
|
@ -179,6 +188,9 @@ public class GroupManager {
|
|||
Group group = (Group)usrManager.getAuthorizable(groupId);
|
||||
User user = (User)usrManager.getAuthorizable(userId);
|
||||
|
||||
if (group.isMember(user))
|
||||
throw new InvalidCallParameters("user "+userId+" is already member of group "+groupId);
|
||||
|
||||
success = group.addMember(user);
|
||||
|
||||
String folderName = group.getPrincipal().getName();
|
||||
|
@ -205,6 +217,8 @@ public class GroupManager {
|
|||
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
||||
public boolean removeUserFromGroup(@PathParam("groupId") String groupId, @PathParam("userId") String userId){
|
||||
|
||||
InnerMethodName.instance.set("removeUserFromGroup");
|
||||
|
||||
JackrabbitSession session = null;
|
||||
boolean success = false;
|
||||
try {
|
||||
|
@ -218,6 +232,9 @@ public class GroupManager {
|
|||
Group group = (Group)usrManager.getAuthorizable(groupId);
|
||||
User user = (User)usrManager.getAuthorizable(userId);
|
||||
|
||||
if (!group.isMember(user))
|
||||
throw new InvalidCallParameters("user "+userId+" is not member of group "+groupId);
|
||||
|
||||
//delete folder on user
|
||||
String folderName = group.getPrincipal().getName();
|
||||
Node folder = getVreFolderNode(session, folderName);
|
||||
|
@ -251,6 +268,8 @@ public class GroupManager {
|
|||
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
||||
public List<String> getUsersOfGroup(@PathParam("groupId") String groupId){
|
||||
|
||||
InnerMethodName.instance.set("getUsersOfGroup");
|
||||
|
||||
JackrabbitSession session = null;
|
||||
List<String> users = new ArrayList<>();
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue