solved a bug with scope maps
This commit is contained in:
parent
f62a477b84
commit
d0a7c0520a
|
@ -27,7 +27,6 @@
|
|||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
|
|
|
@ -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.compliance=1.8
|
||||
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.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
1
pom.xml
1
pom.xml
|
@ -61,7 +61,6 @@
|
|||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope-maps</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope</artifactId>
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.gcube.common.authorizationservice.util.Constants;
|
|||
import org.gcube.common.authorizationservice.util.TokenPersistence;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.api.ServiceMap;
|
||||
import org.gcube.common.scope.impl.ScopedServiceMap;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
@ -62,8 +63,15 @@ public class TokenManager {
|
|||
CalledMethodProvider.instance.set("retrieve");
|
||||
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);
|
||||
|
||||
if (info == null){
|
||||
|
@ -74,13 +82,15 @@ public class TokenManager {
|
|||
|
||||
try{
|
||||
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();
|
||||
info.setMap(map);
|
||||
}catch(Exception e){
|
||||
log.info("map set");
|
||||
}catch(Throwable e){
|
||||
log.error("error retrieving map for {}", info.getContext(), e);
|
||||
}
|
||||
|
||||
log.debug("returning info {}", info);
|
||||
return info;
|
||||
|
||||
|
@ -104,16 +114,19 @@ public class TokenManager {
|
|||
for (String token : tokens ) {
|
||||
try {
|
||||
AuthorizationEntry info = persistence.getAuthorizationEntry(token);
|
||||
|
||||
try{
|
||||
ScopeProvider.instance.set(info.getContext());
|
||||
ServiceMap map = ServiceMap.instance;
|
||||
ServiceMap map = ((ScopedServiceMap)ServiceMap.instance).currentMap();
|
||||
ScopeProvider.instance.reset();
|
||||
info.setMap(map);
|
||||
}catch(Exception e){
|
||||
}catch(Throwable e){
|
||||
log.error("error retrieving map for {}", info.getContext(), e);
|
||||
}
|
||||
toReturn.add(info);
|
||||
}catch(Exception e) {}
|
||||
}catch(Exception t) {
|
||||
log.error("erorr on authorization", t);
|
||||
}
|
||||
}
|
||||
log.info("info retrieved {}",toReturn);
|
||||
|
||||
|
|
Loading…
Reference in New Issue