Skip to content

Commit

Permalink
fix: fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikRevich committed Dec 8, 2024
1 parent 59a93e9 commit eb81b5b
Show file tree
Hide file tree
Showing 37 changed files with 1,225 additions and 342 deletions.
2 changes: 1 addition & 1 deletion cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
<auth>false</auth>
<typeMappings>
<typeMapping>binary=byte[]</typeMapping>
<typeMapping>file=byte[]</typeMapping>
<typeMapping>file=File</typeMapping>
</typeMappings>
<configOptions>
<additionalModelTypeAnnotations>@lombok.Data @lombok.AllArgsConstructor(staticName = "of")</additionalModelTypeAnnotations>
Expand Down
16 changes: 8 additions & 8 deletions cli/src/main/java/com/objectstorage/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import com.objectstorage.entity.PropertiesEntity;
import com.objectstorage.service.command.BaseCommandService;
import com.objectstorage.service.command.external.clean.CleanExternalCommandService;
import com.objectstorage.service.command.external.clean.object.CleanObjectExternalCommandService;
import com.objectstorage.service.command.external.cleanall.CleanAllExternalCommandService;
import com.objectstorage.service.command.external.content.ContentExternalCommandService;
import com.objectstorage.service.command.external.download.DownloadExternalCommandService;
import com.objectstorage.service.command.external.download.object.DownloadObjectExternalCommandService;
import com.objectstorage.service.command.external.apply.ApplyExternalCommandService;
import com.objectstorage.service.command.external.withdraw.WithdrawExternalCommandService;
import com.objectstorage.service.command.external.version.VersionExternalCommandService;
Expand All @@ -16,8 +16,8 @@
import com.objectstorage.service.visualization.label.clean.CleanCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.cleanall.CleanAllCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.content.ContentCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.download.DownloadCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.topology.TopologyCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.download.backup.DownloadBackupCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.download.object.DownloadObjectCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.withdraw.WithdrawCommandVisualizationLabel;
import com.objectstorage.service.visualization.label.version.VersionCommandVisualizationLabel;
import com.objectstorage.service.visualization.state.VisualizationState;
Expand All @@ -38,10 +38,10 @@
BaseCommandService.class,
ApplyExternalCommandService.class,
WithdrawExternalCommandService.class,
CleanExternalCommandService.class,
CleanObjectExternalCommandService.class,
CleanAllExternalCommandService.class,
ContentExternalCommandService.class,
DownloadExternalCommandService.class,
DownloadObjectExternalCommandService.class,
VersionExternalCommandService.class,
VersionExternalCommandService.class,
HealthCheckInternalCommandService.class,
Expand All @@ -55,8 +55,8 @@
CleanCommandVisualizationLabel.class,
CleanAllCommandVisualizationLabel.class,
ContentCommandVisualizationLabel.class,
DownloadCommandVisualizationLabel.class,
TopologyCommandVisualizationLabel.class,
DownloadObjectCommandVisualizationLabel.class,
DownloadBackupCommandVisualizationLabel.class,
VersionCommandVisualizationLabel.class,
VisualizationService.class,
VisualizationState.class
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.objectstorage.converter;

import com.objectstorage.dto.ProcessedCredentialsDto;
import com.objectstorage.entity.ConfigEntity;
import com.objectstorage.model.CredentialsFieldsExternal;
import com.objectstorage.model.CredentialsFieldsFull;
Expand All @@ -9,7 +10,7 @@
/**
* Represents config credentials to ObjectStorage API Server content credentials converter.
*/
public class ConfigCredentialsToContentCredentialsConverter {
public class ConfigCredentialsToContentCredentialsConverter<T> {

/**
* Converts given config credentials to context exporter.
Expand All @@ -19,12 +20,15 @@ public class ConfigCredentialsToContentCredentialsConverter {
* @return converted context exporter.
*/
public static CredentialsFieldsFull convert(
ConfigEntity.Service.Provider provider, ConfigEntity.Service.Credentials configCredentials) {
ConfigEntity.Service.Provider provider, ProcessedCredentialsDto configCredentials) {
return switch (provider) {
case EXPORTER -> null;
case GIT_GITHUB -> CredentialsFieldsFull.of(
case S3 -> CredentialsFieldsFull.of(
CredentialsFieldsInternal.of(configCredentials.getId()),
CredentialsFieldsExternal.of(configCredentials.getToken()));
CredentialsFieldsExternal.of(
configCredentials.getFile(), configCredentials.getRegion()));
case GCS -> CredentialsFieldsFull.of(
CredentialsFieldsInternal.of(configCredentials.getId()),
CredentialsFieldsExternal.of(configCredentials.getFile(), null));
};
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public static Provider convert(ConfigEntity.Service.Provider configProvider) {
.filter(element -> Objects.equals(element.toString(), configProvider.toString()))
.map(Enum::name)
.toList()
.get(0));
.getFirst());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.objectstorage.converter;

import com.objectstorage.entity.ConfigEntity;
import com.objectstorage.model.Provider;

import java.util.Arrays;
import java.util.Objects;

/**
* Represents selected provider to ObjectStorage API Server content provider converter.
*/
public class SelectedProviderToContentProviderConverter {

/**
* Converts given config provider to content provider.
*
* @param selectedProvider given selected provider to be converted.
* @return converted content provider.
*/
public static Provider convert(String selectedProvider) {
return Provider.valueOf(
Arrays.stream(
ConfigEntity.Service.Provider.values())
.toList()
.stream()
.filter(element -> Objects.equals(element.toString(), selectedProvider))
.map(Enum::name)
.toList()
.getFirst());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.objectstorage.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.io.File;

/**
* Represents content upload object request details.
*/
@Getter
@AllArgsConstructor(staticName = "of")
public class ContentUploadObjectRequestDto {
private String authorization;

private String location;

private File file;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import lombok.Getter;

/**
* Represents input for download external command.
* Represents input for download backup external command.
*/
@Getter
@AllArgsConstructor(staticName = "of")
public class DownloadExternalCommandDto {
public class DownloadBackupExternalCommandDto {
private ConfigEntity config;

private String outputLocation;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.objectstorage.dto;

import com.objectstorage.entity.ConfigEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* Represents input for download object external command.
*/
@Getter
@AllArgsConstructor(staticName = "of")
public class DownloadObjectExternalCommandDto {
private ConfigEntity config;

private String provider;

private String outputLocation;

private String location;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.objectstorage.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* Represents processed credentials details.
*/
@Getter
@AllArgsConstructor(staticName = "of")
public class ProcessedCredentialsDto {
private Integer id;

private String file;

private String region;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.objectstorage.dto;

import com.objectstorage.entity.ConfigEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* Represents input for upload object external command.
*/
@Getter
@AllArgsConstructor(staticName = "of")
public class UploadObjectExternalCommandDto {
private ConfigEntity config;

private String location;

private String file;
}
22 changes: 5 additions & 17 deletions cli/src/main/java/com/objectstorage/entity/ConfigEntity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.objectstorage.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.annotation.Nullable;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand Down Expand Up @@ -63,38 +64,25 @@ public String toString() {
public Provider provider;

/**
* Represents credentials used for GCS provider authentication.
* Represents credentials used for selected provider authentication.
*/
@Getter
@NoArgsConstructor
public static class GCSCredentials {
@NotNull
public Integer id;

@Pattern(regexp = "^(((./)?)|((~/.)?)|((/?))?)([a-zA-Z/]*)((\\.([a-z]+))?)$")
public String file;
}

/**
* Represents credentials used for S3 provider authentication.
*/
@Getter
@NoArgsConstructor
public static class S3Credentials {
public static class Credentials {
@NotNull
public Integer id;

@Pattern(regexp = "^(((./)?)|((~/.)?)|((/?))?)([a-zA-Z/]*)((\\.([a-z]+))?)$")
public String file;

@NotBlank
@Nullable
public String region;
}

@Valid
@NotNull
@JsonProperty("credentials")
public Object credentials;
public Credentials credentials;
}

@Valid
Expand Down
14 changes: 10 additions & 4 deletions cli/src/main/java/com/objectstorage/entity/PropertiesEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@ public class PropertiesEntity {
@Value(value = "${progress.visualization.upload-response}")
private String progressVisualizationUploadResponseLabel;

@Value(value = "${progress.visualization.download-request}")
private String progressVisualizationDownloadRequestLabel;
@Value(value = "${progress.visualization.download-object-request}")
private String progressVisualizationDownloadObjectRequestLabel;

@Value(value = "${progress.visualization.download-response}")
private String progressVisualizationDownloadResponseLabel;
@Value(value = "${progress.visualization.download-object-response}")
private String progressVisualizationDownloadObjectResponseLabel;

@Value(value = "${progress.visualization.download-backup-request}")
private String progressVisualizationDownloadBackupRequestLabel;

@Value(value = "${progress.visualization.download-backup-response}")
private String progressVisualizationDownloadBackupResponseLabel;

@Value(value = "${progress.visualization.version-request}")
private String progressVisualizationVersionRequestLabel;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.objectstorage.exception;

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

/**
* Represents exception used when given cloud credentials file is not found.
*/
public class CloudCredentialsFileNotFoundException extends IOException {
public CloudCredentialsFileNotFoundException() {
this("");
}

public CloudCredentialsFileNotFoundException(Object... message) {
super(
new Formatter()
.format(
"Given cloud credentials file is not found: %s", Arrays.stream(message).toArray())
.toString());
}
}
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 given cloud credentials are not valid.
*/
public class CloudCredentialsValidationException extends IOException {
public CloudCredentialsValidationException() {
this("");
}

public CloudCredentialsValidationException(Object... message) {
super(
new Formatter()
.format("Given cloud credentials are not valid: %s", Arrays.stream(message).toArray())
.toString());
}
}
Loading

0 comments on commit eb81b5b

Please sign in to comment.