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.scope.api.ScopeProvider;
|
||||||
import org.gcube.common.storagehub.model.acls.AccessType;
|
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||||
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
|
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.InvalidItemException;
|
||||||
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
||||||
import org.gcube.common.storagehub.model.types.NodeProperty;
|
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.Utils;
|
||||||
import org.gcube.data.access.storagehub.exception.MyAuthException;
|
import org.gcube.data.access.storagehub.exception.MyAuthException;
|
||||||
import org.gcube.data.access.storagehub.handlers.CredentialHandler;
|
import org.gcube.data.access.storagehub.handlers.CredentialHandler;
|
||||||
|
import org.gcube.smartgears.utils.InnerMethodName;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -64,7 +66,9 @@ public class GroupManager {
|
||||||
@Path("")
|
@Path("")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public List<String> getGroups(){
|
public List<String> getGroups(){
|
||||||
|
|
||||||
|
InnerMethodName.instance.set("getGroups");
|
||||||
|
|
||||||
JackrabbitSession session = null;
|
JackrabbitSession session = null;
|
||||||
List<String> groups= new ArrayList<>();
|
List<String> groups= new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
@ -98,7 +102,8 @@ public class GroupManager {
|
||||||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||||
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
||||||
public String createGroup(@FormParam("group") String group, @FormParam("accessType") AccessType accessType){
|
public String createGroup(@FormParam("group") String group, @FormParam("accessType") AccessType accessType){
|
||||||
|
|
||||||
|
InnerMethodName.instance.set("createGroup");
|
||||||
|
|
||||||
JackrabbitSession session = null;
|
JackrabbitSession session = null;
|
||||||
String groupId = null;
|
String groupId = null;
|
||||||
|
@ -131,7 +136,9 @@ public class GroupManager {
|
||||||
@Path("{group}")
|
@Path("{group}")
|
||||||
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
||||||
public String deleteGroup(@PathParam("group") String group){
|
public String deleteGroup(@PathParam("group") String group){
|
||||||
|
|
||||||
|
InnerMethodName.instance.set("deleteGroup");
|
||||||
|
|
||||||
JackrabbitSession session = null;
|
JackrabbitSession session = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -165,7 +172,9 @@ public class GroupManager {
|
||||||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||||
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
||||||
public boolean addUserToGroup(@PathParam("id") String groupId, @FormParam("userId") String userId){
|
public boolean addUserToGroup(@PathParam("id") String groupId, @FormParam("userId") String userId){
|
||||||
|
|
||||||
|
InnerMethodName.instance.set("addUserToGroup");
|
||||||
|
|
||||||
JackrabbitSession session = null;
|
JackrabbitSession session = null;
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
|
@ -178,7 +187,10 @@ public class GroupManager {
|
||||||
|
|
||||||
Group group = (Group)usrManager.getAuthorizable(groupId);
|
Group group = (Group)usrManager.getAuthorizable(groupId);
|
||||||
User user = (User)usrManager.getAuthorizable(userId);
|
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);
|
success = group.addMember(user);
|
||||||
|
|
||||||
String folderName = group.getPrincipal().getName();
|
String folderName = group.getPrincipal().getName();
|
||||||
|
@ -204,7 +216,9 @@ public class GroupManager {
|
||||||
@Path("{groupId}/users/{userId}")
|
@Path("{groupId}/users/{userId}")
|
||||||
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
||||||
public boolean removeUserFromGroup(@PathParam("groupId") String groupId, @PathParam("userId") String userId){
|
public boolean removeUserFromGroup(@PathParam("groupId") String groupId, @PathParam("userId") String userId){
|
||||||
|
|
||||||
|
InnerMethodName.instance.set("removeUserFromGroup");
|
||||||
|
|
||||||
JackrabbitSession session = null;
|
JackrabbitSession session = null;
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
|
@ -217,7 +231,10 @@ public class GroupManager {
|
||||||
|
|
||||||
Group group = (Group)usrManager.getAuthorizable(groupId);
|
Group group = (Group)usrManager.getAuthorizable(groupId);
|
||||||
User user = (User)usrManager.getAuthorizable(userId);
|
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
|
//delete folder on user
|
||||||
String folderName = group.getPrincipal().getName();
|
String folderName = group.getPrincipal().getName();
|
||||||
Node folder = getVreFolderNode(session, folderName);
|
Node folder = getVreFolderNode(session, folderName);
|
||||||
|
@ -250,7 +267,9 @@ public class GroupManager {
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE}, exception=MyAuthException.class)
|
||||||
public List<String> getUsersOfGroup(@PathParam("groupId") String groupId){
|
public List<String> getUsersOfGroup(@PathParam("groupId") String groupId){
|
||||||
|
|
||||||
|
InnerMethodName.instance.set("getUsersOfGroup");
|
||||||
|
|
||||||
JackrabbitSession session = null;
|
JackrabbitSession session = null;
|
||||||
List<String> users = new ArrayList<>();
|
List<String> users = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue