diaplyName bug with root scope containing dashes fixed

This commit is contained in:
lucio 2020-01-31 15:22:54 +01:00
parent ddbac93245
commit fae5173b17
1 changed files with 14 additions and 3 deletions

View File

@ -40,6 +40,8 @@ import org.gcube.common.authorization.control.annotations.AuthorizationControl;
import org.gcube.common.authorization.library.provider.AuthorizationProvider; import org.gcube.common.authorization.library.provider.AuthorizationProvider;
import org.gcube.common.gxrest.response.outbound.GXOutboundErrorResponse; 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.scope.impl.ScopeBean;
import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.common.storagehub.model.Excludes; import org.gcube.common.storagehub.model.Excludes;
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;
@ -57,6 +59,7 @@ import org.gcube.data.access.storagehub.handlers.CredentialHandler;
import org.gcube.data.access.storagehub.handlers.Node2ItemConverter; import org.gcube.data.access.storagehub.handlers.Node2ItemConverter;
import org.gcube.data.access.storagehub.handlers.VRE; import org.gcube.data.access.storagehub.handlers.VRE;
import org.gcube.data.access.storagehub.handlers.VREManager; import org.gcube.data.access.storagehub.handlers.VREManager;
import org.gcube.smartgears.context.application.ApplicationContext;
import org.gcube.smartgears.utils.InnerMethodName; import org.gcube.smartgears.utils.InnerMethodName;
import org.glassfish.jersey.media.multipart.FormDataParam; import org.glassfish.jersey.media.multipart.FormDataParam;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -67,6 +70,7 @@ public class GroupManager {
@Context ServletContext context; @Context ServletContext context;
private static final String VREMANAGER_ROLE = "VRE-Manager"; private static final String VREMANAGER_ROLE = "VRE-Manager";
private static final String INFRASTRUCTURE_MANAGER_ROLE = "Infrastructure-Manager"; private static final String INFRASTRUCTURE_MANAGER_ROLE = "Infrastructure-Manager";
@ -208,7 +212,7 @@ public class GroupManager {
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE, INFRASTRUCTURE_MANAGER_ROLE}, exception=MyAuthException.class) @AuthorizationControl(allowedRoles={VREMANAGER_ROLE, INFRASTRUCTURE_MANAGER_ROLE}, exception=MyAuthException.class)
public void addAdmin(@PathParam("id") String groupId, @FormParam("userId") String userId){ public void addAdmin(@PathParam("id") String groupId, @FormParam("userId") String userId){
InnerMethodName.instance.set("addAddmin"); InnerMethodName.instance.set("addAdmin");
JackrabbitSession session = null; JackrabbitSession session = null;
try { try {
@ -509,8 +513,15 @@ public class GroupManager {
Node sharedRootNode = session.getNode(Constants.SHARED_FOLDER_PATH); Node sharedRootNode = session.getNode(Constants.SHARED_FOLDER_PATH);
String name = groupId; String name = groupId;
String displayName = groupId.replaceAll("[^\\-]*\\-[^\\-]*\\-(.*)", "$1"); String currentScope = ScopeProvider.instance.get();
ScopeBean bean = new ScopeBean(currentScope);
while (!bean.is(Type.INFRASTRUCTURE)) {
bean = bean.enclosingScope();
}
String root = bean.toString().replaceAll("/", "");
String displayName = groupId.replaceAll(root+"-[^\\-]*\\-(.*)", "$1");
log.info("creating vreFolder with name {} and title {} and owner {}", name, displayName, owner); log.info("creating vreFolder with name {} and title {} and owner {}", name, displayName, owner);