Skip to content

Commit

Permalink
Merge pull request #176 from chris-allan/session-bean-executor-priority
Browse files Browse the repository at this point in the history
Session bean actions should happen at `SYSTEM` priority
  • Loading branch information
jburel committed Mar 22, 2024
2 parents d094154 + 6c1426b commit 82d598f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions src/main/java/ome/services/sessions/SessionBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import ome.security.basic.LightAdminPrivileges;
import ome.services.sessions.SessionManager.CreationRequest;
import ome.services.util.Executor;
import ome.services.util.Executor.Priority;
import ome.system.Principal;

import org.slf4j.Logger;
Expand Down Expand Up @@ -94,7 +95,7 @@ public Session createUserSession(final long timeToLiveMs,
cd.size() > 0 ? cd.getContext().get("omero.agent") : null;
try {
final Principal principal = principal(defaultGroup, user);
Future<Session> future = ex.submit(new Callable<Session>(){
Future<Session> future = ex.submit(Priority.SYSTEM, new Callable<Session>(){
public Session call() throws Exception {
final CreationRequest req = new CreationRequest();
req.principal = principal;
Expand Down Expand Up @@ -153,7 +154,7 @@ public Session createSessionWithTimeouts(@NotNull final Principal principal,
final String agent =
cd.size() > 0 ? cd.getContext().get("omero.agent") : null;
try {
Future<Session> future = ex.submit(new Callable<Session>(){
Future<Session> future = ex.submit(Priority.SYSTEM, new Callable<Session>(){
public Session call() throws Exception {
SessionManager.CreationRequest req = new SessionManager.CreationRequest();
req.principal = principal;
Expand Down Expand Up @@ -213,7 +214,7 @@ public int getReferenceCount(@NotNull String sessionUuid) {

@RolesAllowed( { "user", "guest" })
public Session updateSession(@NotNull final Session session) {
Future<Session> future = ex.submit(new Callable<Session>(){
Future<Session> future = ex.submit(Priority.SYSTEM, new Callable<Session>(){
public Session call() throws Exception {
return mgr.update(session);
}});
Expand All @@ -222,7 +223,7 @@ public Session call() throws Exception {

@RolesAllowed( { "user", "guest" })
public int closeSession(@NotNull final Session session) {
Future<Integer> future = ex.submit(new Callable<Integer>(){
Future<Integer> future = ex.submit(Priority.SYSTEM, new Callable<Integer>(){
public Integer call() throws Exception {
return mgr.close(session.getUuid());
}});
Expand All @@ -232,7 +233,7 @@ public Integer call() throws Exception {
@RolesAllowed("user")
public java.util.List<Session> getMyOpenSessions() {
final String uuid = currentContext().getCurrentSessionUuid();
Future<List<Session>> future = ex.submit(new Callable<List<Session>>(){
Future<List<Session>> future = ex.submit(Priority.SYSTEM, new Callable<List<Session>>(){
public List<Session> call() throws Exception {
return mgr.findSameUser(uuid);
}});
Expand All @@ -242,7 +243,7 @@ public List<Session> call() throws Exception {
@RolesAllowed("user")
public java.util.List<Session> getMyOpenAgentSessions(final String agent) {
final String uuid = currentContext().getCurrentSessionUuid();
Future<List<Session>> future = ex.submit(new Callable<List<Session>>(){
Future<List<Session>> future = ex.submit(Priority.SYSTEM, new Callable<List<Session>>(){
public List<Session> call() throws Exception {
return mgr.findSameUser(uuid, agent);
}});
Expand All @@ -252,7 +253,7 @@ public List<Session> call() throws Exception {
@RolesAllowed("user")
public java.util.List<Session> getMyOpenClientSessions() {
final String uuid = currentContext().getCurrentSessionUuid();
Future<List<Session>> future = ex.submit(new Callable<List<Session>>(){
Future<List<Session>> future = ex.submit(Priority.SYSTEM, new Callable<List<Session>>(){
public List<Session> call() throws Exception {
return mgr.findSameUser(uuid, "OMERO.insight",
"OMERO.web", "OMERO.importer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private void expectsExecutorSubmit() {
exMock.expects(once()).method("submit").will(new Stub(){

public Object invoke(Invocation arg0) throws Throwable {
Callable callable = (Callable) arg0.parameterValues.get(0);
Callable callable = (Callable) arg0.parameterValues.get(1);
final Object rv = callable.call();
return new Future() {

Expand Down Expand Up @@ -154,4 +154,4 @@ public StringBuffer describeTo(StringBuffer arg0) {
return arg0;
}});
}
}
}

0 comments on commit 82d598f

Please sign in to comment.