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

fix: revert transactional #3880

Merged
merged 2 commits into from
Jul 26, 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
import jakarta.ws.rs.OPTIONS;
import jakarta.ws.rs.core.Response;

public abstract class BaseResource {
public interface BaseResource {

/**
* OPTIONS implementation, so that {@link org.obiba.opal.web.security.AuthorizationInterceptor} can
* Default OPTIONS implementation, so that {@link org.obiba.opal.web.security.AuthorizationInterceptor} can
* set the Allow header with appropriate HTTP methods.
*
* @return
*/
@OPTIONS
public Response getOptions() {
default Response getOptions() {
return Response.ok().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
import org.obiba.magma.Variable;
import org.obiba.magma.VariableEntity;
import org.obiba.magma.js.views.JavascriptClause;
import org.obiba.opal.web.BaseResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

import jakarta.annotation.Nullable;
import java.util.*;

abstract class AbstractValueTableResource extends BaseResource {
abstract class AbstractValueTableResource {

private ValueTable valueTable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

import org.obiba.magma.ValueTable;
import org.obiba.magma.VariableValueSource;
import org.obiba.opal.web.BaseResource;

public interface ValueSetsResource {
public interface ValueSetsResource extends BaseResource {

void setValueTable(ValueTable valueTable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,32 @@

import com.google.common.collect.Lists;
import com.google.common.eventbus.EventBus;
import jakarta.annotation.Nullable;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Request;
import jakarta.ws.rs.core.Response;
import org.apache.commons.vfs2.FileSystemException;
import org.obiba.magma.Datasource;
import org.obiba.magma.security.Authorizer;
import org.obiba.magma.security.shiro.ShiroAuthorizer;
import org.obiba.opal.core.domain.Project;
import org.obiba.opal.core.service.ProjectsState;
import org.obiba.opal.core.event.DatasourceDeletedEvent;
import org.obiba.opal.core.runtime.NoSuchServiceException;
import org.obiba.opal.core.runtime.OpalRuntime;
import org.obiba.opal.core.security.OpalKeyStore;
import org.obiba.opal.core.service.*;
import org.obiba.opal.core.service.NoSuchProjectException;
import org.obiba.opal.core.service.ProjectService;
import org.obiba.opal.core.service.ProjectsState;
import org.obiba.opal.core.service.SubjectProfileService;
import org.obiba.opal.core.service.VCFSamplesMappingService;
import org.obiba.opal.core.service.security.ProjectsKeyStoreService;
import org.obiba.opal.spi.vcf.VCFStoreService;
import org.obiba.opal.web.BaseResource;
Expand All @@ -35,18 +50,13 @@
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import jakarta.annotation.Nullable;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Request;
import jakarta.ws.rs.core.Response;
import java.util.List;
import java.util.stream.Collectors;

@Component
@Scope("request")
@Path("/project/{name}")
public class ProjectResource extends BaseResource {
public class ProjectResource implements BaseResource {

private final static Authorizer authorizer = new ShiroAuthorizer();

Expand Down Expand Up @@ -84,15 +94,13 @@ public ProjectResource(
}

@GET
@Transactional(readOnly = true)
public Projects.ProjectDto get(@Context Request request, @PathParam("name") String name) {
Project project = getProject(name);
return Dtos.asDto(project, projectService);
}

@GET
@Path("/summary")
@Transactional(readOnly = true)
public Projects.ProjectSummaryDto getSummary(@Context Request request, @PathParam("name") String name) {
Project project = getProject(name);
return Dtos.asSummaryDto(project, projectService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
package org.obiba.opal.web.project;

import com.google.common.collect.Lists;
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;
import org.obiba.magma.NoSuchDatasourceException;
import org.obiba.magma.security.Authorizer;
import org.obiba.magma.security.shiro.ShiroAuthorizer;
Expand All @@ -23,27 +31,21 @@
import org.obiba.opal.web.ws.security.NoAuthorization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;
import java.net.URI;
import java.util.List;
import java.util.regex.Pattern;

@Component
@Path("/projects")
public class ProjectsResource extends BaseResource {
public class ProjectsResource implements BaseResource {

private final static Authorizer authorizer = new ShiroAuthorizer();

@Autowired
private ProjectService projectService;

@GET
@Transactional(readOnly = true)
@NoAuthorization
public List<Projects.ProjectDto> getProjects(@QueryParam("digest") @DefaultValue("false") boolean digest) {
List<Projects.ProjectDto> projects = Lists.newArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

@Component
@Path("/project/{project}/resource/{name}")
public class ProjectResourceReferenceResource extends BaseResource {
public class ProjectResourceReferenceResource implements BaseResource {

private final static Authorizer authorizer = new ShiroAuthorizer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

@Component
@Path("/project/{name}/resources")
public class ProjectResourceReferencesResource extends BaseResource {
public class ProjectResourceReferencesResource implements BaseResource {

private final static Authorizer authorizer = new ShiroAuthorizer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import static org.obiba.opal.core.domain.security.SubjectAcl.SubjectType;

public abstract class AbstractPermissionsResource extends BaseResource {
public abstract class AbstractPermissionsResource implements BaseResource {

public static final String DOMAIN = "opal";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.obiba.opal.web.BaseResource;
import org.springframework.beans.factory.annotation.Autowired;

public abstract class AbstractCommandsResource extends BaseResource {
public abstract class AbstractCommandsResource implements BaseResource {

protected CommandJobService commandJobService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@Scope("request")
@Path("/project/{name}/commands")
@SuppressWarnings("OverlyCoupledClass")
public class ProjectCommandsResource extends BaseResource {
public class ProjectCommandsResource implements BaseResource {

private static final Logger log = LoggerFactory.getLogger(ProjectCommandsResource.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Component
@Scope("request")
@Path("/service/r/cluster/{cname}/commands")
public class RClusterCommandsResource extends BaseResource {
public class RClusterCommandsResource implements BaseResource {

private static final Logger log = LoggerFactory.getLogger(RClusterCommandsResource.class);

Expand Down