Skip to content
Snippets Groups Projects
Unverified Commit 3df53324 authored by Martin Weise's avatar Martin Weise
Browse files

Added not allowed exception, mistook the sequence name

parent aebbb062
No related branches found
No related tags found
4 merge requests!129New module for citation as they occur multiple,!121Modified logging, modified logging level, modified flasgger endpoint,!113Resolve "Bugs related with Query Service",!109Resolve "Use MariaDB for metadata database"
...@@ -61,7 +61,6 @@ public class IdentifierServiceIntegrationTest extends BaseUnitTest { ...@@ -61,7 +61,6 @@ public class IdentifierServiceIntegrationTest extends BaseUnitTest {
private ImageRepository imageRepository; private ImageRepository imageRepository;
@BeforeEach @BeforeEach
@Transactional
public void beforeEach() { public void beforeEach() {
userRepository.save(USER_1); userRepository.save(USER_1);
imageRepository.save(IMAGE_1); imageRepository.save(IMAGE_1);
...@@ -77,7 +76,6 @@ public class IdentifierServiceIntegrationTest extends BaseUnitTest { ...@@ -77,7 +76,6 @@ public class IdentifierServiceIntegrationTest extends BaseUnitTest {
} }
@Test @Test
@Transactional
public void findAll_succeeds() { public void findAll_succeeds() {
/* mock */ /* mock */
......
...@@ -39,7 +39,7 @@ public class Database { ...@@ -39,7 +39,7 @@ public class Database {
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumns({ @JoinColumns({
@JoinColumn(name = "Creator", referencedColumnName = "UserID") @JoinColumn(name = "created_by", referencedColumnName = "UserID")
}) })
private User creator; private User creator;
...@@ -65,7 +65,7 @@ public class Database { ...@@ -65,7 +65,7 @@ public class Database {
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumns({ @JoinColumns({
@JoinColumn(name = "Contactperson", referencedColumnName = "UserID") @JoinColumn(name = "contact_person", referencedColumnName = "UserID")
}) })
private User contact; private User contact;
......
...@@ -24,7 +24,7 @@ public class Creator { ...@@ -24,7 +24,7 @@ public class Creator {
@Id @Id
@EqualsAndHashCode.Include @EqualsAndHashCode.Include
@GeneratedValue(generator = "creators-sequence") @GeneratedValue(generator = "creators-sequence")
@GenericGenerator(name = "creatos-sequence", strategy = "increment") @GenericGenerator(name = "creators-sequence", strategy = "increment")
@Column(updatable = false, nullable = false) @Column(updatable = false, nullable = false)
private Long id; private Long id;
......
...@@ -147,16 +147,16 @@ CREATE TABLE IF NOT EXISTS mdb_databases ...@@ -147,16 +147,16 @@ CREATE TABLE IF NOT EXISTS mdb_databases
name character varying(255) NOT NULL, name character varying(255) NOT NULL,
internal_name character varying(255) NOT NULL, internal_name character varying(255) NOT NULL,
exchange character varying(255) NOT NULL, exchange character varying(255) NOT NULL,
Description TEXT, description TEXT,
Engine VARCHAR(20), engine character varying(20),
is_public BOOLEAN NOT NULL DEFAULT TRUE, is_public BOOLEAN NOT NULL DEFAULT TRUE,
Creator BIGINT, created_by bigint,
Contactperson BIGINT, contact_person bigint,
created timestamp NOT NULL DEFAULT NOW(), created timestamp NOT NULL DEFAULT NOW(),
last_modified timestamp, last_modified timestamp,
PRIMARY KEY (id), PRIMARY KEY (id),
FOREIGN KEY (Creator) REFERENCES mdb_users (UserID), FOREIGN KEY (created_by) REFERENCES mdb_users (UserID),
FOREIGN KEY (Contactperson) REFERENCES mdb_users (UserID), FOREIGN KEY (contact_person) REFERENCES mdb_users (UserID),
FOREIGN KEY (id) REFERENCES mdb_containers (id) /* currently we only support one-to-one */ FOREIGN KEY (id) REFERENCES mdb_containers (id) /* currently we only support one-to-one */
); );
......
...@@ -11,7 +11,6 @@ import io.micrometer.core.annotation.Timed; ...@@ -11,7 +11,6 @@ import io.micrometer.core.annotation.Timed;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.jacoco.core.internal.flow.IProbeIdGenerator;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -20,7 +19,6 @@ import org.springframework.web.bind.annotation.*; ...@@ -20,7 +19,6 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.ws.rs.NotAllowedException;
import java.security.Principal; import java.security.Principal;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -51,7 +49,7 @@ public class TableEndpoint extends AbstractEndpoint { ...@@ -51,7 +49,7 @@ public class TableEndpoint extends AbstractEndpoint {
public ResponseEntity<List<TableBriefDto>> list(@NotNull @PathVariable("id") Long containerId, public ResponseEntity<List<TableBriefDto>> list(@NotNull @PathVariable("id") Long containerId,
@NotNull @PathVariable("databaseId") Long databaseId, @NotNull @PathVariable("databaseId") Long databaseId,
Principal principal) Principal principal)
throws DatabaseNotFoundException { throws DatabaseNotFoundException, NotAllowedException {
log.debug("endpoint list tables, containerId={}, databaseId={}, principal={}", containerId, databaseId, log.debug("endpoint list tables, containerId={}, databaseId={}, principal={}", containerId, databaseId,
principal); principal);
if (!hasDatabasePermission(containerId, databaseId, "TABLES_VIEW", principal)) { if (!hasDatabasePermission(containerId, databaseId, "TABLES_VIEW", principal)) {
...@@ -75,7 +73,8 @@ public class TableEndpoint extends AbstractEndpoint { ...@@ -75,7 +73,8 @@ public class TableEndpoint extends AbstractEndpoint {
@NotNull @Valid @RequestBody TableCreateDto createDto, @NotNull @Valid @RequestBody TableCreateDto createDto,
@NotNull Principal principal) @NotNull Principal principal)
throws ImageNotSupportedException, DatabaseNotFoundException, TableMalformedException, AmqpException, throws ImageNotSupportedException, DatabaseNotFoundException, TableMalformedException, AmqpException,
TableNameExistsException, ContainerNotFoundException, UserNotFoundException, QueryMalformedException { TableNameExistsException, ContainerNotFoundException, UserNotFoundException, QueryMalformedException,
NotAllowedException {
log.debug("endpoint create table, containerId={}, databaseId={}, createDto={}, principal={}", containerId, log.debug("endpoint create table, containerId={}, databaseId={}, createDto={}, principal={}", containerId,
databaseId, createDto, principal); databaseId, createDto, principal);
if (!hasDatabasePermission(containerId, databaseId, "TABLE_CREATE", principal)) { if (!hasDatabasePermission(containerId, databaseId, "TABLE_CREATE", principal)) {
...@@ -99,7 +98,7 @@ public class TableEndpoint extends AbstractEndpoint { ...@@ -99,7 +98,7 @@ public class TableEndpoint extends AbstractEndpoint {
@NotNull @PathVariable("databaseId") Long databaseId, @NotNull @PathVariable("databaseId") Long databaseId,
@NotNull @PathVariable("tableId") Long tableId, @NotNull @PathVariable("tableId") Long tableId,
Principal principal) Principal principal)
throws TableNotFoundException, DatabaseNotFoundException, ContainerNotFoundException { throws TableNotFoundException, DatabaseNotFoundException, ContainerNotFoundException, NotAllowedException {
log.debug("endpoint find table, containerId={}, databaseId={}, tableId={}, principal={}", containerId, log.debug("endpoint find table, containerId={}, databaseId={}, tableId={}, principal={}", containerId,
databaseId, tableId, principal); databaseId, tableId, principal);
if (!hasTablePermission(containerId, databaseId, tableId, "TABLE_INFO", principal)) { if (!hasTablePermission(containerId, databaseId, tableId, "TABLE_INFO", principal)) {
...@@ -119,7 +118,7 @@ public class TableEndpoint extends AbstractEndpoint { ...@@ -119,7 +118,7 @@ public class TableEndpoint extends AbstractEndpoint {
public ResponseEntity<TableBriefDto> update(@NotNull @PathVariable("id") Long containerId, public ResponseEntity<TableBriefDto> update(@NotNull @PathVariable("id") Long containerId,
@NotNull @PathVariable("databaseId") Long databaseId, @NotNull @PathVariable("databaseId") Long databaseId,
@NotNull @PathVariable("tableId") Long tableId, @NotNull @PathVariable("tableId") Long tableId,
@NotNull Principal principal) { @NotNull Principal principal) throws NotAllowedException {
log.debug("endpoint update table, containerId={}, databaseId={}, tableId={}, principal={}", containerId, log.debug("endpoint update table, containerId={}, databaseId={}, tableId={}, principal={}", containerId,
databaseId, tableId, principal); databaseId, tableId, principal);
if (!hasTablePermission(containerId, databaseId, tableId, "TABLE_UPDATE", principal)) { if (!hasTablePermission(containerId, databaseId, tableId, "TABLE_UPDATE", principal)) {
...@@ -141,7 +140,8 @@ public class TableEndpoint extends AbstractEndpoint { ...@@ -141,7 +140,8 @@ public class TableEndpoint extends AbstractEndpoint {
@NotNull @PathVariable("tableId") Long tableId, @NotNull @PathVariable("tableId") Long tableId,
@NotNull Principal principal) @NotNull Principal principal)
throws TableNotFoundException, DatabaseNotFoundException, ImageNotSupportedException, throws TableNotFoundException, DatabaseNotFoundException, ImageNotSupportedException,
DataProcessingException, ContainerNotFoundException, TableMalformedException, QueryMalformedException { DataProcessingException, ContainerNotFoundException, TableMalformedException, QueryMalformedException,
NotAllowedException {
log.debug("endpoint delete table, containerId={}, databaseId={}, tableId={}, principal={}", containerId, log.debug("endpoint delete table, containerId={}, databaseId={}, tableId={}, principal={}", containerId,
databaseId, tableId, principal); databaseId, tableId, principal);
if (!hasTablePermission(containerId, databaseId, tableId, "TABLE_DELETE", principal)) { if (!hasTablePermission(containerId, databaseId, tableId, "TABLE_DELETE", principal)) {
......
package at.tuwien.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(code = HttpStatus.METHOD_NOT_ALLOWED)
public class NotAllowedException extends Exception {
public NotAllowedException(String msg) {
super(msg);
}
public NotAllowedException(String msg, Throwable thr) {
super(msg, thr);
}
public NotAllowedException(Throwable thr) {
super(thr);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment