mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
refactor(efs): move library usages to imports (#3903)
* refactor(efs): move library usages to imports * refactor(efs): replace wildcard imports and inline types with explicit imports
This commit is contained in:
1 parent
5fbaab1cca
commit
f8542e628b
6 files changed
+99
-38
No files matched your search
@@ -1,8 +1,38 @@
|
||||
package io.github.hectorvent.floci.services.efs;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.efs.model.*;
|
||||
import io.github.hectorvent.floci.services.efs.model.AccessPointDescription;
|
||||
import io.github.hectorvent.floci.services.efs.model.BackupPolicy;
|
||||
import io.github.hectorvent.floci.services.efs.model.CreateAccessPointRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.CreateFileSystemRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.CreateMountTargetRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.CreateTagsRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.DeleteTagsRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeAccessPointsResponse;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeFileSystemPolicyResponse;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeFileSystemsRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeFileSystemsResponse;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeMountTargetsRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeMountTargetsResponse;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeTagsRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeTagsResponse;
|
||||
import io.github.hectorvent.floci.services.efs.model.FileSystem;
|
||||
import io.github.hectorvent.floci.services.efs.model.FileSystemProtectionDescription;
|
||||
import io.github.hectorvent.floci.services.efs.model.ModifyMountTargetSecurityGroupsRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.MountTarget;
|
||||
import io.github.hectorvent.floci.services.efs.model.PutBackupPolicyRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.PutBackupPolicyResponse;
|
||||
import io.github.hectorvent.floci.services.efs.model.PutFileSystemPolicyRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.PutFileSystemPolicyResponse;
|
||||
import io.github.hectorvent.floci.services.efs.model.PutLifecycleConfigurationRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.PutLifecycleConfigurationResponse;
|
||||
import io.github.hectorvent.floci.services.efs.model.Tag;
|
||||
import io.github.hectorvent.floci.services.efs.model.TagResourceRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.UntagResourceRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.UpdateFileSystemProtectionRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.UpdateFileSystemRequest;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.BeanParam;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.GET;
|
||||
@@ -11,11 +41,15 @@ import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Path("/2015-02-01")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@@ -42,7 +76,7 @@ public class EfsController {
|
||||
|
||||
@GET
|
||||
@Path("/file-systems")
|
||||
public Response describeFileSystems(@Context HttpHeaders headers, @jakarta.ws.rs.BeanParam DescribeFileSystemsRequest request) {
|
||||
public Response describeFileSystems(@Context HttpHeaders headers, @BeanParam DescribeFileSystemsRequest request) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
DescribeFileSystemsResponse response = efsService.describeFileSystems(region, request);
|
||||
return Response.ok(response).build();
|
||||
@@ -84,11 +118,11 @@ public class EfsController {
|
||||
|
||||
@GET
|
||||
@Path("/tags/{FileSystemId}")
|
||||
public Response describeTags(@Context HttpHeaders headers, @PathParam("FileSystemId") String fileSystemId, @jakarta.ws.rs.BeanParam DescribeTagsRequest request) {
|
||||
public Response describeTags(@Context HttpHeaders headers, @PathParam("FileSystemId") String fileSystemId, @BeanParam DescribeTagsRequest request) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
FileSystem fs = efsService.getFileSystem(region, fileSystemId);
|
||||
|
||||
java.util.List<Tag> tags = fs.getTags() != null ? fs.getTags() : new java.util.ArrayList<>();
|
||||
List<Tag> tags = fs.getTags() != null ? fs.getTags() : new ArrayList<>();
|
||||
int maxItems = request.getMaxItems() != null ? request.getMaxItems() : 100;
|
||||
int startIndex = 0;
|
||||
if (request.getMarker() != null && !request.getMarker().isEmpty()) {
|
||||
@@ -100,7 +134,7 @@ public class EfsController {
|
||||
}
|
||||
}
|
||||
|
||||
java.util.List<Tag> paginated = new java.util.ArrayList<>();
|
||||
List<Tag> paginated = new ArrayList<>();
|
||||
String nextMarker = null;
|
||||
for (int i = startIndex; i < tags.size(); i++) {
|
||||
if (paginated.size() >= maxItems) {
|
||||
@@ -136,7 +170,7 @@ public class EfsController {
|
||||
|
||||
@DELETE
|
||||
@Path("/resource-tags/{ResourceId}")
|
||||
public Response untagResource(@Context HttpHeaders headers, @PathParam("ResourceId") String resourceId, @jakarta.ws.rs.BeanParam UntagResourceRequest request) {
|
||||
public Response untagResource(@Context HttpHeaders headers, @PathParam("ResourceId") String resourceId, @BeanParam UntagResourceRequest request) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
efsService.untagResource(region, resourceId, request.getTagKeys());
|
||||
return Response.ok().build();
|
||||
@@ -161,7 +195,7 @@ public class EfsController {
|
||||
|
||||
@GET
|
||||
@Path("/mount-targets")
|
||||
public Response describeMountTargets(@Context HttpHeaders headers, @jakarta.ws.rs.BeanParam DescribeMountTargetsRequest request) {
|
||||
public Response describeMountTargets(@Context HttpHeaders headers, @BeanParam DescribeMountTargetsRequest request) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
DescribeMountTargetsResponse response = efsService.describeMountTargets(region, request);
|
||||
return Response.ok(response).build();
|
||||
@@ -202,7 +236,7 @@ public class EfsController {
|
||||
|
||||
@GET
|
||||
@Path("/access-points")
|
||||
public Response describeAccessPoints(@Context HttpHeaders headers, @jakarta.ws.rs.QueryParam("FileSystemId") String fileSystemId, @jakarta.ws.rs.QueryParam("AccessPointId") String accessPointId) {
|
||||
public Response describeAccessPoints(@Context HttpHeaders headers, @QueryParam("FileSystemId") String fileSystemId, @QueryParam("AccessPointId") String accessPointId) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
DescribeAccessPointsResponse res = new DescribeAccessPointsResponse();
|
||||
res.setAccessPoints(efsService.describeAccessPoints(region, fileSystemId, accessPointId));
|
||||
|
||||
@@ -3,18 +3,20 @@ package io.github.hectorvent.floci.services.efs;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import jakarta.ws.rs.core.Response.Status;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class EfsException extends AwsException {
|
||||
|
||||
public EfsException(Status status, String errorCode, String message) {
|
||||
super(errorCode, message, status.getStatusCode());
|
||||
}
|
||||
|
||||
public EfsException(Status status, String errorCode, String message, java.util.Map<String, Object> extendedData) {
|
||||
public EfsException(Status status, String errorCode, String message, Map<String, Object> extendedData) {
|
||||
super(errorCode, message, status.getStatusCode(), extendedData);
|
||||
}
|
||||
|
||||
public static EfsException fileSystemAlreadyExists(String token, String fileSystemId) {
|
||||
return new EfsException(Status.CONFLICT, "FileSystemAlreadyExists", "File system with creation token " + token + " already exists.", java.util.Map.of("FileSystemId", fileSystemId));
|
||||
return new EfsException(Status.CONFLICT, "FileSystemAlreadyExists", "File system with creation token " + token + " already exists.", Map.of("FileSystemId", fileSystemId));
|
||||
}
|
||||
|
||||
public static EfsException fileSystemNotFound(String fileSystemId) {
|
||||
@@ -34,7 +36,7 @@ public class EfsException extends AwsException {
|
||||
}
|
||||
|
||||
public static EfsException accessPointAlreadyExists(String token, String accessPointId) {
|
||||
return new EfsException(Status.CONFLICT, "AccessPointAlreadyExists", "Access point with client token " + token + " already exists.", java.util.Map.of("AccessPointId", accessPointId));
|
||||
return new EfsException(Status.CONFLICT, "AccessPointAlreadyExists", "Access point with client token " + token + " already exists.", Map.of("AccessPointId", accessPointId));
|
||||
}
|
||||
|
||||
public static EfsException accessPointNotFound(String accessPointId) {
|
||||
|
||||
@@ -1,23 +1,47 @@
|
||||
package io.github.hectorvent.floci.services.efs;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.Resettable;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.core.common.Resettable;
|
||||
import io.github.hectorvent.floci.services.efs.model.*;
|
||||
import io.github.hectorvent.floci.services.efs.model.AccessPointDescription;
|
||||
import io.github.hectorvent.floci.services.efs.model.BackupPolicy;
|
||||
import io.github.hectorvent.floci.services.efs.model.CreateAccessPointRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.CreateFileSystemRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.CreateMountTargetRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.CreateTagsRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.DeleteTagsRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeFileSystemsRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeFileSystemsResponse;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeMountTargetSecurityGroupsResponse;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeMountTargetsRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.DescribeMountTargetsResponse;
|
||||
import io.github.hectorvent.floci.services.efs.model.FileSystem;
|
||||
import io.github.hectorvent.floci.services.efs.model.FileSystemProtectionDescription;
|
||||
import io.github.hectorvent.floci.services.efs.model.FileSystemSize;
|
||||
import io.github.hectorvent.floci.services.efs.model.LifecyclePolicy;
|
||||
import io.github.hectorvent.floci.services.efs.model.LifeCycleState;
|
||||
import io.github.hectorvent.floci.services.efs.model.ListTagsForResourceResponse;
|
||||
import io.github.hectorvent.floci.services.efs.model.ModifyMountTargetSecurityGroupsRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.MountTarget;
|
||||
import io.github.hectorvent.floci.services.efs.model.ReplicationOverwriteProtection;
|
||||
import io.github.hectorvent.floci.services.efs.model.Tag;
|
||||
import io.github.hectorvent.floci.services.efs.model.TagResourceRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.UpdateFileSystemProtectionRequest;
|
||||
import io.github.hectorvent.floci.services.efs.model.UpdateFileSystemRequest;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ApplicationScoped
|
||||
public class EfsService implements Resettable {
|
||||
@@ -41,17 +65,17 @@ public class EfsService implements Resettable {
|
||||
public EfsService(StorageFactory storageFactory, RegionResolver regionResolver) {
|
||||
this.regionResolver = regionResolver;
|
||||
this.fileSystemStore = storageFactory.create("efs", "efs-filesystems.json",
|
||||
new com.fasterxml.jackson.core.type.TypeReference<java.util.Map<String, FileSystem>>() {});
|
||||
new TypeReference<Map<String, FileSystem>>() {});
|
||||
this.mountTargetStore = storageFactory.create("efs", "efs-mounttargets.json",
|
||||
new com.fasterxml.jackson.core.type.TypeReference<java.util.Map<String, MountTarget>>() {});
|
||||
new TypeReference<Map<String, MountTarget>>() {});
|
||||
this.accessPointStore = storageFactory.create("efs", "efs-accesspoints.json",
|
||||
new com.fasterxml.jackson.core.type.TypeReference<java.util.Map<String, AccessPointDescription>>() {});
|
||||
new TypeReference<Map<String, AccessPointDescription>>() {});
|
||||
this.fileSystemPolicyStore = storageFactory.create("efs", "efs-policies.json",
|
||||
new com.fasterxml.jackson.core.type.TypeReference<java.util.Map<String, String>>() {});
|
||||
new TypeReference<Map<String, String>>() {});
|
||||
this.backupPolicyStore = storageFactory.create("efs", "efs-backuppolicies.json",
|
||||
new com.fasterxml.jackson.core.type.TypeReference<java.util.Map<String, BackupPolicy>>() {});
|
||||
new TypeReference<Map<String, BackupPolicy>>() {});
|
||||
this.lifecycleConfigurationStore = storageFactory.create("efs", "efs-lifecycle.json",
|
||||
new com.fasterxml.jackson.core.type.TypeReference<java.util.Map<String, List<LifecyclePolicy>>>() {});
|
||||
new TypeReference<Map<String, List<LifecyclePolicy>>>() {});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-5
@@ -1,18 +1,18 @@
|
||||
package io.github.hectorvent.floci.services.efs.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
|
||||
@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class)
|
||||
@RegisterForReflection
|
||||
public class DescribeTagsRequest {
|
||||
|
||||
private String fileSystemId;
|
||||
@jakarta.ws.rs.QueryParam("Marker")
|
||||
@QueryParam("Marker")
|
||||
private String marker;
|
||||
@jakarta.ws.rs.QueryParam("MaxItems")
|
||||
@QueryParam("MaxItems")
|
||||
private Integer maxItems;
|
||||
|
||||
public String getFileSystemId() {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package io.github.hectorvent.floci.services.efs.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import java.util.Objects;
|
||||
|
||||
@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class)
|
||||
@RegisterForReflection
|
||||
@@ -33,12 +34,12 @@ public class Tag {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Tag tag = (Tag) o;
|
||||
return java.util.Objects.equals(key, tag.key) &&
|
||||
java.util.Objects.equals(value, tag.value);
|
||||
return Objects.equals(key, tag.key) &&
|
||||
Objects.equals(value, tag.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return java.util.Objects.hash(key, value);
|
||||
return Objects.hash(key, value);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,19 +1,19 @@
|
||||
package io.github.hectorvent.floci.services.efs.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
|
||||
@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class)
|
||||
@RegisterForReflection
|
||||
public class UntagResourceRequest {
|
||||
|
||||
private String resourceId;
|
||||
|
||||
@jakarta.ws.rs.QueryParam("tagKeys")
|
||||
@QueryParam("tagKeys")
|
||||
private List<String> tagKeys;
|
||||
|
||||
public String getResourceId() {
|
||||
|
||||
Reference in new issue
Block a user