Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session bean actions should happen at SYSTEM priority #176

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}});
}
}
}
Loading