Commit 1ff2ae48 authored by Rustam Lotsmanenko (EPAM)'s avatar Rustam Lotsmanenko (EPAM)
Browse files

Merge remote-tracking branch 'origin/integration-master' into test

# Conflicts:
#	.mvn/community-maven.settings.xml
#	backup-core/pom.xml
#	backup-core/src/main/java/org/opengroup/osdu/backup/api/BackupApi.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/api/BackupCollectionApi.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/exception/AppExceptionHandler.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/manager/AssetBackupManager.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/model/BackupCollection.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/model/BackupRole.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/repository/BackupCollectionRepository.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/repository/BackupStampRepository.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/service/BackupCollectionService.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/service/impl/BackupCollectionServiceImpl.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/shedulers/SchedulerService.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/shedulers/TearDownBackupScheduledTask.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/shedulers/impl/SchedulerServiceImpl.java
#	backup-core/src/main/java/org/opengroup/osdu/backup/shedulers/impl/TearDownScheduler.java
#	backup-core/src/test/java/org/opengroup/osdu/backup/shedulers/impl/SchedulerServiceImplTest.java
#	docs/core.png
#	docs/core.puml
#	docs/datarepos.png
#	docs/datarepos.puml
#	pom.xml
#	provider/backup-gcp/README.md
#	provider/backup-gcp/cloudbuild/Dockerfile.cloudbuild
#	provider/backup-gcp/cloudbuild/cloudbuild.yaml
#	provider/backup-gcp/pom.xml
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/manager/DatastoreBackupManager.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/manager/ElasticBackupManager.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/manager/SQLBackupManager.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/mapper/BackupCollectionMapper.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/mapper/CollectionStateMapper.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/model/entity/BackupCollectionEntity.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/model/entity/BackupScheduleEntity.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/model/entity/CollectionStateEntity.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/repository/BackupCollectionEntityRepository.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/repository/BackupStampsEntityRepository.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/repository/CollectionStateEntityRepository.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/repository/DatastoreBackupCollectionRepository.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/repository/DatastoreBackupStampRepository.java
#	provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/repository/DatastoreCollectionStateRepository.java
#	provider/backup-gcp/src/main/resources/application.properties
#	testing/backup-test-core/pom.xml
#	testing/backup-test-core/src/main/java/org/opengroup/osdu/backup/Config.java
#	testing/backup-test-core/src/main/java/org/opengroup/osdu/backup/HttpClient.java
#	testing/backup-test-core/src/main/java/org/opengroup/osdu/backup/TestBase.java
#	testing/backup-test-core/src/main/java/org/opengroup/osdu/backup/util/AssetUtil.java
#	testing/backup-test-gcp/pom.xml
#	testing/backup-test-gcp/src/test/java/org/opengroup/osdu/backup/ConfigGCP.java
#	testing/backup-test-gcp/src/test/java/org/opengroup/osdu/backup/HttpClientGCP.java
#	testing/backup-test-gcp/src/test/java/org/opengroup/osdu/backup/util/AssetUtilGCP.java
#	testing/backup-test-gcp/src/test/java/org/opengroup/osdu/backup/util/GoogleServiceAccount.java
#	testing/pom.xml
parents 5fd37b5f b0dc1d01
......@@ -29,8 +29,8 @@
<publish.releases.id>community-maven-via-job-token</publish.releases.id>
<repo.releases.url>https://community.opengroup.org/api/v4/groups/17/-/packages/maven</repo.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/380/packages/maven</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/380/packages/maven</publish.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/118/packages/maven</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/118/packages/maven</publish.releases.url>
</properties>
</profile>
......@@ -50,8 +50,8 @@
<publish.releases.id>community-maven-via-private-token</publish.releases.id>
<repo.releases.url>https://community.opengroup.org/api/v4/groups/17/-/packages/maven</repo.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/380/packages/maven</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/380/packages/maven</publish.releases.url>
<publish.snapshots.url>https://community.opengroup.org/api/v4/projects/118/packages/maven</publish.snapshots.url>
<publish.releases.url>https://community.opengroup.org/api/v4/projects/118/packages/maven</publish.releases.url>
</properties>
</profile>
</profiles>
......
......@@ -3,15 +3,11 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>backup-core</artifactId>
<description>Backup service Core on GCP</description>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<artifactId>backup-service</artifactId>
<groupId>org.opengroup.osdu</groupId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
......@@ -20,6 +16,10 @@
<openapi.version>1.4.8</openapi.version>
</properties>
<artifactId>backup-core</artifactId>
<description>Backup service Core on GCP</description>
<version>0.0.2</version>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu</groupId>
......@@ -35,6 +35,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
......@@ -84,5 +88,10 @@
<artifactId>springdoc-openapi-data-rest</artifactId>
<version>${openapi.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-data-rest</artifactId>
<version>${openapi.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
/*
* Copyright 2020 Google LLC
* Copyright 2020 EPAM Systems, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opengroup.osdu.backup.api;
import java.util.EnumMap;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.opengroup.osdu.backup.locator.Asset;
import org.opengroup.osdu.backup.model.BackupImportRequest;
import org.opengroup.osdu.backup.model.BackupRole;
import org.opengroup.osdu.backup.model.BackupSchedule;
import org.opengroup.osdu.backup.model.BackupStamp;
import org.opengroup.osdu.backup.service.BackupService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.annotation.RequestScope;
@Slf4j
@RestController
@RequestScope
@RequiredArgsConstructor
@PreAuthorize("@authorizationFilter.hasPermission('" + BackupRole.BACKUP + "')")
public class BackupApi {
private final BackupService backupService;
@PostMapping("/schedule")
public ResponseEntity<BackupSchedule> submitBackupSchedule(
@RequestBody BackupSchedule backupSchedule) {
BackupSchedule savedBackupSchedule = backupService.submitBackupSchedule(backupSchedule);
return new ResponseEntity<>(savedBackupSchedule, HttpStatus.CREATED);
}
@PutMapping("/schedule")
public ResponseEntity<BackupSchedule> updateBackupSchedule(
@RequestBody BackupSchedule backupSchedule) {
BackupSchedule savedBackupSchedule = backupService.updateBackupSchedule(backupSchedule);
return new ResponseEntity<>(savedBackupSchedule, HttpStatus.ACCEPTED);
}
@GetMapping("/schedule")
public ResponseEntity<BackupSchedule> getScheduleById(@RequestParam String id) {
return new ResponseEntity<>(backupService.getBackupSchedule(id), HttpStatus.OK);
}
@PostMapping("/backup_import")
public ResponseEntity<BackupStamp> submitImport(@RequestBody BackupImportRequest backupId) {
BackupStamp stamp = backupService.submitBackupImportRequest(backupId);
return new ResponseEntity<>(stamp, HttpStatus.OK);
}
@GetMapping("/list_schedules")
public ResponseEntity<List<BackupSchedule>> listSchedules() {
return new ResponseEntity<>(backupService.listSchedules(), HttpStatus.OK);
}
@GetMapping("/list_backups")
public ResponseEntity<EnumMap<Asset, List<BackupStamp>>> listBackups() {
return new ResponseEntity<>(backupService.listBackups(), HttpStatus.OK);
}
}
......@@ -17,56 +17,97 @@
package org.opengroup.osdu.backup.api;
import java.util.Collections;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.opengroup.osdu.backup.logging.AuditLogger;
import org.opengroup.osdu.backup.model.BackupCollection;
import org.opengroup.osdu.backup.model.BackupRole;
import org.opengroup.osdu.backup.model.CollectionState;
import org.opengroup.osdu.backup.service.BackupCollectionService;
import org.opengroup.osdu.backup.validation.CreateCollection;
import org.opengroup.osdu.backup.validation.UpdateCollection;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.annotation.RequestScope;
@Slf4j
@RestController
@RequestMapping(value = "/collection")
@RequestScope
@RequiredArgsConstructor
@PreAuthorize("@authorizationFilter.hasPermission('" + BackupRole.BACKUP + "')")
@PreAuthorize("@authorizationFilter.hasPermission('" + BackupRole.ADMIN + "')")
@Validated
public class BackupCollectionApi {
private final BackupCollectionService collectionService;
@PostMapping("/collection")
public ResponseEntity<BackupCollection> createCollection(@RequestBody BackupCollection collection) {
private final AuditLogger auditLogger;
@PostMapping
public ResponseEntity<BackupCollection> createCollection(
@Validated(CreateCollection.class) @RequestBody BackupCollection collection) {
BackupCollection backupCollection = collectionService.saveCollection(collection);
this.auditLogger.createCollectionSuccess(Collections.singletonList(backupCollection.toString()));
return new ResponseEntity<>(backupCollection, HttpStatus.CREATED);
}
@PutMapping("/collection/{name}")
public ResponseEntity<BackupCollection> updateCollection(@PathVariable String name,
@RequestBody BackupCollection collection) {
BackupCollection backupCollection = collectionService.update(collection);
return new ResponseEntity<>(backupCollection, HttpStatus.CREATED);
@PutMapping("/{collectionName}")
public ResponseEntity<BackupCollection> updateCollection(
@PathVariable String collectionName,
@Validated(UpdateCollection.class) @RequestBody BackupCollection collection) {
BackupCollection backupCollection = collectionService.update(collection, collectionName);
this.auditLogger.updateCollectionSuccess(Collections.singletonList(backupCollection.toString()));
return new ResponseEntity<>(backupCollection, HttpStatus.ACCEPTED);
}
@GetMapping("/{collectionName}")
public ResponseEntity<BackupCollection> getCollectionConfig(@PathVariable String collectionName) {
BackupCollection collection = collectionService.getCollectionConfiguration(collectionName);
this.auditLogger.readCollectionConfigurationSuccess(Collections.singletonList(collection.toString()));
return new ResponseEntity<>(collection, HttpStatus.OK);
}
@DeleteMapping("/{collectionName}")
public ResponseEntity deleteCollection(@PathVariable String collectionName) {
collectionService.deleteCollectionConfiguration(collectionName);
this.auditLogger.deleteCollectionSuccess(Collections.singletonList(collectionName));
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@GetMapping("/list")
public ResponseEntity<List<BackupCollection>> listCollections() {
List<BackupCollection> collectionList = collectionService.listCollectionsConfigurations();
this.auditLogger.readListCollectionsSuccess(Collections.singletonList(collectionList.toString()));
return new ResponseEntity<>(collectionList, HttpStatus.OK);
}
@GetMapping("/collection/{name}")
public ResponseEntity<List<CollectionState>> getCollectionStates(@PathVariable String name) {
List<CollectionState> collectionStates = collectionService.getCollectionStates(name);
@GetMapping("/states/{collectionName}")
public ResponseEntity<List<CollectionState>> getCollectionStates(@PathVariable String collectionName,
@RequestParam(required = false) String success) {
List<CollectionState> collectionStates = collectionService.getCollectionStates(collectionName);
this.auditLogger.readCollectionStatesSuccess(Collections.singletonList(collectionStates.toString()));
return new ResponseEntity<>(collectionStates, HttpStatus.OK);
}
@GetMapping("/collection/restore/{stateId}")
@PatchMapping("/restore/{stateId}")
public ResponseEntity<CollectionState> restoreCollection(@PathVariable String stateId) {
CollectionState collectionState = collectionService.restoreCollection(stateId);
return new ResponseEntity<>(collectionState, HttpStatus.OK);
this.auditLogger.restoreCollectionSuccess(Collections.singletonList(collectionState.toString()));
return new ResponseEntity<>(collectionState, HttpStatus.ACCEPTED);
}
......
......@@ -16,13 +16,18 @@
*/
package org.opengroup.osdu.backup.exception;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
@ControllerAdvice
@Slf4j
......@@ -33,6 +38,18 @@ public class AppExceptionHandler {
return this.getErrorResponse(e);
}
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<Map<String, String>> handleValidationExceptions(
MethodArgumentNotValidException ex) {
Map<String, String> errors = new HashMap<>();
ex.getBindingResult().getAllErrors().forEach((error) -> {
String fieldName = ((FieldError) error).getField();
String errorMessage = error.getDefaultMessage();
errors.put(fieldName, errorMessage);
});
return new ResponseEntity<>(errors, HttpStatus.BAD_REQUEST);
}
private ResponseEntity<Object> getErrorResponse(AppException e) {
String exceptionMsg = Objects.nonNull(e.getOriginalException())
......
package org.opengroup.osdu.backup.logging;
import static java.lang.String.format;
import com.google.common.base.Strings;
import java.util.List;
import org.opengroup.osdu.core.common.logging.audit.AuditAction;
import org.opengroup.osdu.core.common.logging.audit.AuditPayload;
import org.opengroup.osdu.core.common.logging.audit.AuditStatus;
public class AuditEvents {
private static final String CREATE_COLLECTION_ACTION_ID = "BU001";
private static final String CREATE_COLLECTION_MESSAGE = "Create collection";
private static final String UPDATE_COLLECTION_ACTION_ID = "BU002";
private static final String UPDATE_COLLECTION_MESSAGE = "Update collection";
private static final String READ_COLLECTION_CONFIG_ACTION_ID = "BU003";
private static final String READ_COLLECTION_CONFIG_MESSAGE = "Read collection configuration";
private static final String DELETE_COLLECTION_ACTION_ID = "BU004";
private static final String DELETE_COLLECTION_MESSAGE = "Delete collection";
private static final String READ_LIST_COLLECTIONS_ACTION_ID = "BU005";
private static final String READ_LIST_COLLECTIONS_MESSAGE = "Read list collections";
private static final String READ_COLLECTION_STATES_ACTION_ID = "BU006";
private static final String READ_COLLECTION_STATES_MESSAGE = "Read collection states";
private static final String RESTORE_COLLECTION_ACTION_ID = "BU007";
private static final String RESTORE_COLLECTION_MESSAGE = "Restore collection";
private final String user;
public AuditEvents(String user) {
if (Strings.isNullOrEmpty(user)) {
throw new IllegalArgumentException("User not provided for audit events.");
}
this.user = user;
}
public AuditPayload getCreateCollectionEvent(AuditStatus status, List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.CREATE)
.status(status)
.user(this.user)
.actionId(CREATE_COLLECTION_ACTION_ID)
.message(getStatusMessage(status, CREATE_COLLECTION_MESSAGE))
.resources(resources)
.build();
}
public AuditPayload getUpdateCollectionEvent(AuditStatus status, List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.UPDATE)
.status(status)
.user(this.user)
.actionId(UPDATE_COLLECTION_ACTION_ID)
.message(getStatusMessage(status, UPDATE_COLLECTION_MESSAGE))
.resources(resources)
.build();
}
public AuditPayload getReadCollectionConfigEvent(AuditStatus status, List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.READ)
.status(status)
.user(this.user)
.actionId(READ_COLLECTION_CONFIG_ACTION_ID)
.message(getStatusMessage(status, READ_COLLECTION_CONFIG_MESSAGE))
.resources(resources)
.build();
}
public AuditPayload getDeleteCollectionEvent(AuditStatus status, List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.DELETE)
.status(status)
.user(this.user)
.actionId(DELETE_COLLECTION_ACTION_ID)
.message(getStatusMessage(status, DELETE_COLLECTION_MESSAGE))
.resources(resources)
.build();
}
public AuditPayload getReadListCollectionsEvent(AuditStatus status, List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.READ)
.status(status)
.user(this.user)
.actionId(READ_LIST_COLLECTIONS_ACTION_ID)
.message(getStatusMessage(status, READ_LIST_COLLECTIONS_MESSAGE))
.resources(resources)
.build();
}
public AuditPayload getReadCollectionStatesEvent(AuditStatus status, List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.READ)
.status(status)
.user(this.user)
.actionId(READ_COLLECTION_STATES_ACTION_ID)
.message(getStatusMessage(status, READ_COLLECTION_STATES_MESSAGE))
.resources(resources)
.build();
}
public AuditPayload getRestoreCollectionEvent(AuditStatus status, List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.UPDATE)
.status(status)
.user(this.user)
.actionId(RESTORE_COLLECTION_ACTION_ID)
.message(getStatusMessage(status, RESTORE_COLLECTION_MESSAGE))
.resources(resources)
.build();
}
private String getStatusMessage(AuditStatus status, String message) {
return format("%s - %s", message, status.name().toLowerCase());
}
}
\ No newline at end of file
package org.opengroup.osdu.backup.logging;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.logging.audit.AuditPayload;
import org.opengroup.osdu.core.common.logging.audit.AuditStatus;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
@Component
@RequestScope
@RequiredArgsConstructor
public class AuditLogger {
private final JaxRsDpsLog logger;
private final DpsHeaders headers;
private AuditEvents auditEvents = null;
private AuditEvents getAuditEvents() {
if (this.auditEvents == null) {
this.auditEvents = new AuditEvents(this.headers.getUserEmail());
}
return auditEvents;
}
public void createCollectionSuccess(List<String> resources) {
writeLog(getAuditEvents().getCreateCollectionEvent(AuditStatus.SUCCESS, resources));
}
public void createCollectionFailure(List<String> resources) {
writeLog(getAuditEvents().getCreateCollectionEvent(AuditStatus.FAILURE, resources));
}
public void updateCollectionSuccess(List<String> resources) {
writeLog(getAuditEvents().getUpdateCollectionEvent(AuditStatus.SUCCESS, resources));
}
public void updateCollectionFailure(List<String> resources) {
writeLog(getAuditEvents().getUpdateCollectionEvent(AuditStatus.FAILURE, resources));
}
public void readCollectionConfigurationSuccess(List<String> resources) {
writeLog(getAuditEvents().getReadCollectionConfigEvent(AuditStatus.SUCCESS, resources));
}
public void readCollectionConfigurationFailure(List<String> resources) {
writeLog(getAuditEvents().getReadCollectionConfigEvent(AuditStatus.FAILURE, resources));
}
public void deleteCollectionSuccess(List<String> resources) {
writeLog(getAuditEvents().getDeleteCollectionEvent(AuditStatus.SUCCESS, resources));
}
public void deleteCollectionFailure(List<String> resources) {
writeLog(getAuditEvents().getDeleteCollectionEvent(AuditStatus.FAILURE, resources));
}
public void readListCollectionsSuccess(List<String> resources) {
writeLog(getAuditEvents().getReadListCollectionsEvent(AuditStatus.SUCCESS, resources));
}
public void readListCollectionsFailure(List<String> resources) {
writeLog(getAuditEvents().getReadListCollectionsEvent(AuditStatus.FAILURE, resources));
}
public void readCollectionStatesSuccess(List<String> resources) {
writeLog(getAuditEvents().getReadCollectionStatesEvent(AuditStatus.SUCCESS, resources));
}
public void readCollectionStatesFailure(List<String> resources) {
writeLog(getAuditEvents().getReadCollectionStatesEvent(AuditStatus.FAILURE, resources));
}
public void restoreCollectionSuccess(List<String> resources) {
writeLog(getAuditEvents().getRestoreCollectionEvent(AuditStatus.SUCCESS, resources));
}
public void restoreCollectionFailure(List<String> resources) {
writeLog(getAuditEvents().getRestoreCollectionEvent(AuditStatus.FAILURE, resources));
}
private void writeLog(AuditPayload log) {
this.logger.audit(log);
}
}
\ No newline at end of file
......@@ -25,8 +25,6 @@ public interface AssetBackupManager {
BackupStamp exportBackupWithResult(BackupSchedule backupSchedule);
void exportBackup(BackupSchedule backupSchedule);
BackupStamp importBackup(String backupId);
void deleteBackups(List<BackupStamp> backupStamps);
......
......@@ -18,29 +18,54 @@
package org.opengroup.osdu.backup.model;
import java.util.Set;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Positive;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.opengroup.osdu.backup.validation.CreateCollection;
import org.opengroup.osdu.backup.validation.UpdateCollection;
@Data
@EqualsAndHashCode(of = "collectionId")
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
public class BackupCollection {
@Null(groups = {CreateCollection.class, UpdateCollection.class})
private String collectionId;
@NotBlank(groups = CreateCollection.class)
private String collectionName;
private boolean active;
<