solved a bug with scope maps

This commit is contained in:
lucio 2020-04-07 19:14:43 +02:00
parent f62a477b84
commit d0a7c0520a
4 changed files with 49 additions and 36 deletions

View File

@ -27,7 +27,6 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">

View File

@ -3,7 +3,9 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.source=1.8

View File

@ -61,7 +61,6 @@
<groupId>org.gcube.core</groupId> <groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId> <artifactId>common-scope-maps</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.core</groupId> <groupId>org.gcube.core</groupId>
<artifactId>common-scope</artifactId> <artifactId>common-scope</artifactId>

View File

@ -36,6 +36,7 @@ import org.gcube.common.authorizationservice.util.Constants;
import org.gcube.common.authorizationservice.util.TokenPersistence; import org.gcube.common.authorizationservice.util.TokenPersistence;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.api.ServiceMap; import org.gcube.common.scope.api.ServiceMap;
import org.gcube.common.scope.impl.ScopedServiceMap;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -62,8 +63,15 @@ public class TokenManager {
CalledMethodProvider.instance.set("retrieve"); CalledMethodProvider.instance.set("retrieve");
log.info("token retreiver called with token {}",token); log.info("token retreiver called with token {}",token);
AuthorizationEntry info = persistence.getAuthorizationEntry(token); AuthorizationEntry info = null;
try {
info = persistence.getAuthorizationEntry(token);
} catch ( Throwable t) {
log.error("erorr on authorization", t);
throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity("error on authorization").type(MediaType.TEXT_PLAIN).build());
}
log.info("info retrieved {}",info); log.info("info retrieved {}",info);
if (info == null){ if (info == null){
@ -74,13 +82,15 @@ public class TokenManager {
try{ try{
ScopeProvider.instance.set(info.getContext()); ScopeProvider.instance.set(info.getContext());
ServiceMap map = ServiceMap.instance; log.info("current context is {}", info.getContext());
ServiceMap map = ((ScopedServiceMap)ServiceMap.instance).currentMap();
log.info("map is {}", map);
ScopeProvider.instance.reset(); ScopeProvider.instance.reset();
info.setMap(map); info.setMap(map);
}catch(Exception e){ log.info("map set");
}catch(Throwable e){
log.error("error retrieving map for {}", info.getContext(), e); log.error("error retrieving map for {}", info.getContext(), e);
} }
log.debug("returning info {}", info); log.debug("returning info {}", info);
return info; return info;
@ -104,16 +114,19 @@ public class TokenManager {
for (String token : tokens ) { for (String token : tokens ) {
try { try {
AuthorizationEntry info = persistence.getAuthorizationEntry(token); AuthorizationEntry info = persistence.getAuthorizationEntry(token);
try{ try{
ScopeProvider.instance.set(info.getContext()); ScopeProvider.instance.set(info.getContext());
ServiceMap map = ServiceMap.instance; ServiceMap map = ((ScopedServiceMap)ServiceMap.instance).currentMap();
ScopeProvider.instance.reset(); ScopeProvider.instance.reset();
info.setMap(map); info.setMap(map);
}catch(Exception e){ }catch(Throwable e){
log.error("error retrieving map for {}", info.getContext(), e); log.error("error retrieving map for {}", info.getContext(), e);
} }
toReturn.add(info); toReturn.add(info);
}catch(Exception e) {} }catch(Exception t) {
log.error("erorr on authorization", t);
}
} }
log.info("info retrieved {}",toReturn); log.info("info retrieved {}",toReturn);