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

Fixed the id columns

parent e171b057
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"
Showing
with 19 additions and 68 deletions
...@@ -67,10 +67,7 @@ public class TokenEndpoint { ...@@ -67,10 +67,7 @@ public class TokenEndpoint {
TokenNotEligableException { TokenNotEligableException {
log.debug("endpoint create developer token, principal={}", principal); log.debug("endpoint create developer token, principal={}", principal);
/* check */ /* check */
final List<Token> tokens = tokenService.findAll(principal) final List<Token> tokens = tokenService.findAll(principal);
.stream()
.filter(t -> Objects.isNull(t.getDeleted()))
.collect(Collectors.toList());
log.trace("found all tokens {}", tokens); log.trace("found all tokens {}", tokens);
if (tokens.size() >= authenticationConfig.getTokenCount()) { if (tokens.size() >= authenticationConfig.getTokenCount()) {
log.error("Failed to create token, already exceeded maximum quota of {}", authenticationConfig.getTokenCount()); log.error("Failed to create token, already exceeded maximum quota of {}", authenticationConfig.getTokenCount());
......
...@@ -75,7 +75,7 @@ public class AuthenticationServiceImpl implements AuthenticationService { ...@@ -75,7 +75,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
@Override @Override
@Transactional @Transactional
public void verifyToken(String authorization) throws TokenRevokedException { public void verifyToken(String authorization) {
final String hash = authenticationMapper.authorizationToTokenHash(authorization); final String hash = authenticationMapper.authorizationToTokenHash(authorization);
final Optional<Token> optional = tokenRepository.findByTokenHash(hash); final Optional<Token> optional = tokenRepository.findByTokenHash(hash);
if (optional.isEmpty()) { if (optional.isEmpty()) {
...@@ -83,10 +83,6 @@ public class AuthenticationServiceImpl implements AuthenticationService { ...@@ -83,10 +83,6 @@ public class AuthenticationServiceImpl implements AuthenticationService {
return; return;
} }
final Token token = optional.get(); final Token token = optional.get();
if (token.getDeleted() != null) {
log.warn("Token with hash {} is marked as revoked", hash);
throw new TokenRevokedException("Token is marked as revoked");
}
token.setLastUsed(Instant.now()); token.setLastUsed(Instant.now());
tokenRepository.save(token); tokenRepository.save(token);
log.info("Updated token usage of token with hash {}", hash); log.info("Updated token usage of token with hash {}", hash);
......
...@@ -107,7 +107,6 @@ public class MariaDbServiceImpl extends HibernateConnector implements DatabaseSe ...@@ -107,7 +107,6 @@ public class MariaDbServiceImpl extends HibernateConnector implements DatabaseSe
} finally { } finally {
dataSource.close(); dataSource.close();
} }
database.setDeleted(Instant.now()) /* method has void, only for debug logs */;
/* save in metadata database */ /* save in metadata database */
databaseRepository.deleteById(databaseId); databaseRepository.deleteById(databaseId);
log.info("Deleted database with id {}", databaseId); log.info("Deleted database with id {}", databaseId);
......
...@@ -89,7 +89,6 @@ public class IdentifierServiceIntegrationTest extends BaseUnitTest { ...@@ -89,7 +89,6 @@ public class IdentifierServiceIntegrationTest extends BaseUnitTest {
.created(IDENTIFIER_2_CREATED) .created(IDENTIFIER_2_CREATED)
.lastModified(IDENTIFIER_2_MODIFIED) .lastModified(IDENTIFIER_2_MODIFIED)
.publicationYear(IDENTIFIER_2_PUBLICATION_YEAR) .publicationYear(IDENTIFIER_2_PUBLICATION_YEAR)
.deleted(Instant.now().minus(4, ChronoUnit.MINUTES))
.publisher(IDENTIFIER_2_PUBLISHER) .publisher(IDENTIFIER_2_PUBLISHER)
.type(IDENTIFIER_2_TYPE) .type(IDENTIFIER_2_TYPE)
.build()); .build());
......
...@@ -25,17 +25,13 @@ ENV METADATA_USERNAME=root ...@@ -25,17 +25,13 @@ ENV METADATA_USERNAME=root
ENV METADATA_PASSWORD=dbrepo ENV METADATA_PASSWORD=dbrepo
ENV MARIADB_DATABASE="${METADATA_DB}" ENV MARIADB_DATABASE="${METADATA_DB}"
ENV MARIADB_ROOT_PASSWORD="${METADATA_PASSWORD}" ENV MARIADB_ROOT_PASSWORD="${METADATA_PASSWORD}"
ENV MARIADB_USERNAME="${METADATA_USERNAME}"
ENV MARIADB_PASSWORD="${METADATA_PASSWORD}"
# Scripts are copied to /docker-entrypoint-initdb.d/ in docker-compose from analyze service # Scripts are copied to /docker-entrypoint-initdb.d/ in docker-compose from analyze service
HEALTHCHECK --interval=10s --timeout=5s --retries=12 CMD mysqladmin ping --user="$METADATA_USERNAME" --password="$METADATA_PASSWORD" --silent HEALTHCHECK --interval=10s --timeout=5s --retries=12 CMD mysqladmin ping --user="$METADATA_USERNAME" --password="$METADATA_PASSWORD" --silent
WORKDIR /docker-entrypoint-initdb.d WORKDIR /docker-entrypoint-initdb.d
COPY ./setup-schema.sql ./1.sql COPY ./setup-schema.sql ./setup-schema.sql
COPY ./setup-user.sh ./2.sh
RUN chmod +x ./2.sh
WORKDIR /app WORKDIR /app
......
...@@ -40,8 +40,4 @@ public class TokenBriefDto { ...@@ -40,8 +40,4 @@ public class TokenBriefDto {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC")
private Instant expires; private Instant expires;
@Schema(example = "2020-08-04 11:13:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC")
private Instant deleted;
} }
...@@ -40,10 +40,6 @@ public class TokenDto { ...@@ -40,10 +40,6 @@ public class TokenDto {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC")
private Instant expires; private Instant expires;
@Schema(example = "2020-08-04 11:13:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC")
private Instant deleted;
@NotBlank @NotBlank
@Schema(example = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c") @Schema(example = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")
private String token; private String token;
......
...@@ -62,8 +62,4 @@ public class DatabaseDto { ...@@ -62,8 +62,4 @@ public class DatabaseDto {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC")
private Instant created; private Instant created;
@Schema(example = "2020-08-04 11:13:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC")
private Instant deleted;
} }
...@@ -53,8 +53,4 @@ public class ViewBriefDto { ...@@ -53,8 +53,4 @@ public class ViewBriefDto {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC")
private Instant lastModified; private Instant lastModified;
@Schema(example = "2020-08-04 11:13:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC")
private Instant deleted;
} }
...@@ -56,8 +56,4 @@ public class ViewDto { ...@@ -56,8 +56,4 @@ public class ViewDto {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC")
private Instant lastModified; private Instant lastModified;
@Schema(example = "2020-08-04 11:13:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC")
private Instant deleted;
} }
...@@ -47,9 +47,6 @@ public class RelatedIdentifierDto { ...@@ -47,9 +47,6 @@ public class RelatedIdentifierDto {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC")
private Instant lastModified; private Instant lastModified;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", timezone = "UTC")
private Instant deleted;
} }
...@@ -22,10 +22,8 @@ import java.util.List; ...@@ -22,10 +22,8 @@ import java.util.List;
@ToString @ToString
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Where(clause = "deleted is null")
@EntityListeners(AuditingEntityListener.class) @EntityListeners(AuditingEntityListener.class)
@EqualsAndHashCode(onlyExplicitlyIncluded = true) @EqualsAndHashCode(onlyExplicitlyIncluded = true)
@SQLDelete(sql = "update mdb_containers set deleted = NOW() where id = ?")
@Table(name = "mdb_containers") @Table(name = "mdb_containers")
public class Container { public class Container {
...@@ -75,7 +73,4 @@ public class Container { ...@@ -75,7 +73,4 @@ public class Container {
@LastModifiedDate @LastModifiedDate
private Instant lastModified; private Instant lastModified;
@Column
private Instant deleted;
} }
...@@ -26,8 +26,8 @@ public class ContainerImage { ...@@ -26,8 +26,8 @@ public class ContainerImage {
@Id @Id
@EqualsAndHashCode.Include @EqualsAndHashCode.Include
@GenericGenerator(name = "native", strategy = "native") @GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "native") @Column(updatable = false, nullable = false)
public Long id; public Long id;
@Column(nullable = false) @Column(nullable = false)
......
...@@ -23,8 +23,8 @@ public class ContainerImageDate { ...@@ -23,8 +23,8 @@ public class ContainerImageDate {
@Id @Id
@EqualsAndHashCode.Include @EqualsAndHashCode.Include
@GenericGenerator(name = "native", strategy = "native") @GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "native") @Column(updatable = false, nullable = false)
private Long id; private Long id;
@Column(name = "iid") @Column(name = "iid")
......
...@@ -23,8 +23,8 @@ public class ContainerImageEnvironmentItem { ...@@ -23,8 +23,8 @@ public class ContainerImageEnvironmentItem {
@Id @Id
@EqualsAndHashCode.Include @EqualsAndHashCode.Include
@GenericGenerator(name = "native", strategy = "native") @GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "native") @Column(updatable = false, nullable = false)
public Long id; public Long id;
@Id @Id
......
...@@ -24,9 +24,7 @@ import java.util.List; ...@@ -24,9 +24,7 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Document(indexName = "databaseindex", createIndex = false) @Document(indexName = "databaseindex", createIndex = false)
@Where(clause = "deleted is null")
@EntityListeners(AuditingEntityListener.class) @EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update mdb_databases set deleted = NOW() where id = ?")
@javax.persistence.Table(name = "mdb_databases", uniqueConstraints = { @javax.persistence.Table(name = "mdb_databases", uniqueConstraints = {
@UniqueConstraint(columnNames = {"id", "internalName"}) @UniqueConstraint(columnNames = {"id", "internalName"})
}) })
...@@ -34,8 +32,8 @@ public class Database { ...@@ -34,8 +32,8 @@ public class Database {
@Id @Id
@EqualsAndHashCode.Include @EqualsAndHashCode.Include
@GenericGenerator(name = "native", strategy = "native") @GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "native") @Column(updatable = false, nullable = false)
private Long id; private Long id;
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
...@@ -87,7 +85,4 @@ public class Database { ...@@ -87,7 +85,4 @@ public class Database {
@LastModifiedDate @LastModifiedDate
private Instant lastModified; private Instant lastModified;
@Column
private Instant deleted;
} }
...@@ -23,8 +23,8 @@ public class View { ...@@ -23,8 +23,8 @@ public class View {
@Id @Id
@EqualsAndHashCode.Include @EqualsAndHashCode.Include
@GenericGenerator(name = "native", strategy = "native") @GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "native") @Column(updatable = false, nullable = false)
private Long id; private Long id;
@Id @Id
...@@ -69,7 +69,4 @@ public class View { ...@@ -69,7 +69,4 @@ public class View {
@LastModifiedDate @LastModifiedDate
private Instant lastModified; private Instant lastModified;
@Column
private Instant deleted;
} }
...@@ -31,8 +31,8 @@ public class Table { ...@@ -31,8 +31,8 @@ public class Table {
@Id @Id
@EqualsAndHashCode.Include @EqualsAndHashCode.Include
@GenericGenerator(name = "native", strategy = "native") @GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "native") @Column(updatable = false, nullable = false)
private Long id; private Long id;
@Id @Id
......
...@@ -32,8 +32,8 @@ public class TableColumn implements Comparable<TableColumn> { ...@@ -32,8 +32,8 @@ public class TableColumn implements Comparable<TableColumn> {
@Id @Id
@EqualsAndHashCode.Include @EqualsAndHashCode.Include
@GenericGenerator(name = "native", strategy = "native") @GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "native") @Column(updatable = false, nullable = false)
private Long id; private Long id;
@Id @Id
......
...@@ -24,8 +24,8 @@ public class ColumnConcept implements Serializable { ...@@ -24,8 +24,8 @@ public class ColumnConcept implements Serializable {
@Id @Id
@EqualsAndHashCode.Include @EqualsAndHashCode.Include
@GenericGenerator(name = "native", strategy = "native") @GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "native") @Column(updatable = false, nullable = false)
private Long cid; private Long cid;
@Id @Id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment