Skip to content

Commit

Permalink
Feature: implement Backup Service (#18)
Browse files Browse the repository at this point in the history
* fix: fixed bugs

* fix: fixed bugs

* fix: fixed bugs

* fix: fixed bugs

* fix: fixed bugs

* fix: fixed bugs

* fix: fixed bugs

* fix: fixed bugs

* fix: fixed bugs
  • Loading branch information
YarikRevich authored Nov 29, 2024
1 parent a9319e0 commit 0687917
Show file tree
Hide file tree
Showing 34 changed files with 1,194 additions and 474 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Features:
* Provides configurable data backups per vendor in the same workspace
* Makes user interaction similar to filesystem

! A mapping of file system to external vendor providers.

![](./docs/high-level-design.png)

![](./docs/detailed-design.png)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.objectstorage.converter;

import com.objectstorage.dto.ContentCompoundUnitDto;
import com.objectstorage.model.ValidationSecretsApplication;
import com.objectstorage.model.ValidationSecretsUnit;

import java.util.ArrayList;
import java.util.List;

/**
* Represents content compounds units to validation secrets application converter;
*/
public class ContentCompoundUnitsToValidationSecretsApplicationConverter {

/**
* Converts given content compound units to validation secrets application.
*
* @param contentCompoundUnits given content compounds units.
* @return converted validation secrets application.
*/
public static ValidationSecretsApplication convert(List<ContentCompoundUnitDto> contentCompoundUnits) {
List<ValidationSecretsUnit> validationSecretsUnits = new ArrayList<>();

contentCompoundUnits.forEach(
element -> validationSecretsUnits.add(
ValidationSecretsUnit.of(
element.getProvider(),
element.getCredentials())));

return ValidationSecretsApplication.of(validationSecretsUnits);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.objectstorage.converter;

import com.objectstorage.dto.ContentCompoundUnitDto;
import com.objectstorage.dto.RepositoryContentApplicationUnitDto;
import com.objectstorage.model.ValidationSecretsApplication;
import com.objectstorage.model.ValidationSecretsUnit;

import java.util.ArrayList;
import java.util.List;

/**
* Represents repository content application units to validation secrets application converter;
*/
public class RepositoryContentApplicationUnitsToValidationSecretsApplicationConverter {

/**
* Converts given content compound units to validation secrets application.
*
* @param repositoryContentApplicationUnits given repository content application units.
* @return converted validation secrets application.
*/
public static ValidationSecretsApplication convert(
List<RepositoryContentApplicationUnitDto> repositoryContentApplicationUnits) {
List<ValidationSecretsUnit> validationSecretsUnits = new ArrayList<>();

repositoryContentApplicationUnits.forEach(
element -> validationSecretsUnits.add(
ValidationSecretsUnit.of(
element.getProvider(),
element.getCredentials())));

return ValidationSecretsApplication.of(validationSecretsUnits);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.objectstorage.dto;

import com.objectstorage.model.CredentialsFieldsFull;
import com.objectstorage.model.Provider;
import com.objectstorage.model.ValidationSecretsUnit;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* Represents content compound unit dto.
*/
@Getter
@AllArgsConstructor(staticName = "of")
public class ContentCompoundUnitDto {
/**
* Represents root location for internal file system.
*/
private RepositoryContentUnitDto repositoryContentUnitDto;

/**
* Represents provider.
*/
private Provider provider;

/**
* Represents full credentials fields.
*/
private CredentialsFieldsFull credentials;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;

/**
* Represents dto used to represent the earliest temporate content.
*/
@Getter
@AllArgsConstructor(staticName = "of")
public class EarliestTemporateContentDto {
/**
* Represents target provider.
* Represents content compound units.
*/
private ValidationSecretsApplication validationSecretsApplication;
private List<ContentCompoundUnitDto> contentCompoundUnits;

/**
* Represents file location.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.objectstorage.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.io.InputStream;

/**
* Represents folder content unit.
*/
@Getter
@AllArgsConstructor(staticName = "of")
public class FolderContentUnitDto {
/**
* Represents folder entity name.
*/
private String location;

/**
* Represents folder entity content.
*/
private byte[] content;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.objectstorage.dto;

import com.objectstorage.model.CredentialsFieldsFull;
import com.objectstorage.model.Provider;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* Represents repository content application unit.
*/
@Getter
@AllArgsConstructor(staticName = "of")
public class RepositoryContentApplicationUnitDto {
/**
* Represents root location for internal file system.
*/
private String root;

/**
* Represents provider.
*/
private Provider provider;

/**
* Represents full credentials fields.
*/
private CredentialsFieldsFull credentials;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.objectstorage.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* Represents repository content unit.
*/
@Getter
@AllArgsConstructor(staticName = "of")
public class TemporateContentUnitDto {
/**
* Represents provider.
*/
private Integer provider;

/**
* Represents se.
*/
private Integer secret;

/**
* Represents file location.
*/
private String location;

/**
* Represents file hash.
*/
private String hash;

/**
* Represents created at timestamp.
*/
private Long createdAt;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.objectstorage.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* Represents vendor object listing.
*/
@Getter
@AllArgsConstructor(staticName = "of")
public class VendorObjectListingDto {
/**
* Represent location.
*/
private String location;

/**
* Represents created at timestamp.
*/
private Long createdAt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,6 @@ public static class Security {
*/
@Getter
public static class TemporateStorage {
/**
* Represents all supported content formats, which can be used by ObjectStorage
* Temporate Storage.
*/
@Getter
public enum Format {
@JsonProperty("zip")
ZIP("zip"),

@JsonProperty("tar")
TAR("tar");

private final String value;

Format(String value) {
this.value = value;
}

public String toString() {
return value;
}
}

@Valid
@NotNull
@JsonProperty("format")
public Format format;

@NotNull
@JsonProperty("frequency")
public String frequency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public class PropertiesEntity {
@ConfigProperty(name = "workspace.content.backup.directory")
String workspaceContentBackupDirectory;

@ConfigProperty(name = "workspace.content.backup.unit")
String workspaceContentBackupUnit;

@ConfigProperty(name = "workspace.compression.file.name")
String workspaceCompressionFileName;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.objectstorage.exception;

import java.io.IOException;
import java.util.Arrays;
import java.util.Formatter;

/**
* Represents exception used when file units retrieval operation fails.
*/
public class FileUnitsRetrievalFailureException extends IOException {
public FileUnitsRetrievalFailureException() {
this("");
}

public FileUnitsRetrievalFailureException(Object... message) {
super(
new Formatter()
.format("File units retrieval operation failed: %s", Arrays.stream(message).toArray())
.toString());
}
}
Loading

0 comments on commit 0687917

Please sign in to comment.