World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#173] Added JavaDocs where needed in common module. (#174)
Justin Mclean6b9fee863d95
diff --git a/common/src/main/java/com/datastrato/graviton/dto/AuditDTO.java b/common/src/main/java/com/datastrato/graviton/dto/AuditDTO.javaindex e691d358cb..9026edad54 100644--- a/common/src/main/java/com/datastrato/graviton/dto/AuditDTO.java+++ b/common/src/main/java/com/datastrato/graviton/dto/AuditDTO.java@@ -10,6 +10,7 @@ import java.time.Instant;import lombok.EqualsAndHashCode;import lombok.ToString;+/** Data transfer object representing audit information. */@EqualsAndHashCode@ToStringpublic class AuditDTO implements Audit {@@ -56,10 +57,20 @@ public class AuditDTO implements Audit {return lastModifiedTime;}+ /**+ * Creates a new Builder for constructing an Audit DTO.+ *+ * @return A new Builder instance.+ */public static Builder builder() {return new Builder();}+ /**+ * Builder class for constructing an AuditDTO instance.+ *+ * @param <S> The type of the builder instance.+ */public static class Builder<S extends Builder> {protected String creator;protected Instant createTime;@@ -68,26 +79,55 @@ public class AuditDTO implements Audit {public Builder() {}+ /**+ * Sets the creator for the audit.+ *+ * @param creator The creator of the audit.+ * @return The builder instance.+ */public S withCreator(String creator) {this.creator = creator;return (S) this;}+ /**+ * Sets the create time for the audit.+ *+ * @param createTime The create time of the audit.+ * @return The builder instance.+ */public S withCreateTime(Instant createTime) {this.createTime = createTime;return (S) this;}+ /**+ * Sets who last modified the audit.+ *+ * @param lastModifier The last modifier of the audit.+ * @return The builder instance.+ */public S withLastModifier(String lastModifier) {this.lastModifier = lastModifier;return (S) this;}+ /**+ * Sets the last modified time for the audit.+ *+ * @param lastModifiedTime The last modified time of the audit.+ * @return The builder instance.+ */public S withLastModifiedTime(Instant lastModifiedTime) {this.lastModifiedTime = lastModifiedTime;return (S) this;}+ /**+ * Builds an instance of AuditDTO using the builder's properties.+ *+ * @return An instance of AuditDTO.+ */public AuditDTO build() {return new AuditDTO(creator, createTime, lastModifier, lastModifiedTime);}diff --git a/common/src/main/java/com/datastrato/graviton/dto/CatalogDTO.java b/common/src/main/java/com/datastrato/graviton/dto/CatalogDTO.javaindex 026e83bd9c..db80dff761 100644--- a/common/src/main/java/com/datastrato/graviton/dto/CatalogDTO.java+++ b/common/src/main/java/com/datastrato/graviton/dto/CatalogDTO.java@@ -13,6 +13,7 @@ import javax.annotation.Nullable;import lombok.EqualsAndHashCode;import lombok.ToString;+/** Data transfer object representing catalog information. */@EqualsAndHashCode@ToStringpublic class CatalogDTO implements Catalog {@@ -70,10 +71,20 @@ public class CatalogDTO implements Catalog {return audit;}+ /**+ * Creates a new Builder for constructing a Catalog DTO.+ *+ * @return A new Builder instance.+ */public static Builder builder() {return new Builder();}+ /**+ * Builder class for constructing a CatalogDTO instance.+ *+ * @param <S> The type of the builder instance.+ */public static class Builder<S extends Builder> {protected String name;protected Type type;@@ -83,31 +94,67 @@ public class CatalogDTO implements Catalog {public Builder() {}+ /**+ * Sets the name of the catalog.+ *+ * @param name The name of the catalog.+ * @return The builder instance.+ */public S withName(String name) {this.name = name;return (S) this;}+ /**+ * Sets the type of the catalog.+ *+ * @param type The type of the catalog.+ * @return The builder instance.+ */public S withType(Type type) {this.type = type;return (S) this;}+ /**+ * Sets the comment of the catalog.+ *+ * @param comment The comment of the catalog.+ * @return The builder instance.+ */public S withComment(String comment) {this.comment = comment;return (S) this;}+ /**+ * Sets the properties of the catalog.+ *+ * @param properties The properties of the catalog.+ * @return The builder instance.+ */public Builder withProperties(Map<String, String> properties) {this.properties = properties;return (S) this;}+ /**+ * Sets the audit information of the catalog.+ *+ * @param audit The audit information of the catalog.+ * @return The builder instance.+ */public Builder withAudit(AuditDTO audit) {this.audit = audit;return (S) this;}+ /**+ * Builds an instance of CatalogDTO using the builder's properties.+ *+ * @return An instance of CatalogDTO.+ * @throws IllegalArgumentException If name, type or audit are not set.+ */public CatalogDTO build() {Preconditions.checkArgument(name != null && !name.isEmpty(), "name cannot be null or empty");Preconditions.checkArgument(type != null, "type cannot be null");diff --git a/common/src/main/java/com/datastrato/graviton/dto/MetalakeDTO.java b/common/src/main/java/com/datastrato/graviton/dto/MetalakeDTO.javaindex dc8527f2c5..4f24747ae7 100644--- a/common/src/main/java/com/datastrato/graviton/dto/MetalakeDTO.java+++ b/common/src/main/java/com/datastrato/graviton/dto/MetalakeDTO.java@@ -13,6 +13,7 @@ import javax.annotation.Nullable;import lombok.EqualsAndHashCode;import lombok.ToString;+/** Represents a Metalake Data Transfer Object (DTO) that implements the Metalake interface. */@EqualsAndHashCode@ToStringpublic class MetalakeDTO implements Metalake {@@ -61,6 +62,11 @@ public class MetalakeDTO implements Metalake {return audit;}+ /**+ * A builder class for constructing instances of MetalakeDTO.+ *+ * @param <S> The type of the builder subclass.+ */public static class Builder<S extends Builder> {protected String name;@@ -70,26 +76,56 @@ public class MetalakeDTO implements Metalake {public Builder() {}+ /**+ * Sets the name of the Metalake DTO.+ *+ * @param name The name of the Metalake DTO.+ * @return The builder instance.+ */public S withName(String name) {this.name = name;return (S) this;}+ /**+ * Sets the comment of the Metalake DTO.+ *+ * @param comment The comment of the Metalake DTO.+ * @return The builder instance.+ */public S withComment(String comment) {this.comment = comment;return (S) this;}+ /**+ * Sets the properties of the Metalake DTO.+ *+ * @param properties The properties of the Metalake DTO.+ * @return The builder instance.+ */public S withProperties(Map<String, String> properties) {this.properties = properties;return (S) this;}+ /**+ * Sets the audit information of the Metalake DTO.+ *+ * @param audit The audit information of the Metalake DTO.+ * @return The builder instance.+ */public S withAudit(AuditDTO audit) {this.audit = audit;return (S) this;}+ /**+ * Builds an instance of MetalakeDTO using the builder's properties.+ *+ * @return An instance of MetalakeDTO.+ * @throws IllegalArgumentException If the name or audit are not set.+ */public MetalakeDTO build() {Preconditions.checkArgument(name != null && !name.isEmpty(), "name cannot be null or empty");Preconditions.checkArgument(audit != null, "audit cannot be null");diff --git a/common/src/main/java/com/datastrato/graviton/dto/rel/ColumnDTO.java b/common/src/main/java/com/datastrato/graviton/dto/rel/ColumnDTO.javaindex 60817da515..d039baa40c 100644--- a/common/src/main/java/com/datastrato/graviton/dto/rel/ColumnDTO.java+++ b/common/src/main/java/com/datastrato/graviton/dto/rel/ColumnDTO.java@@ -14,6 +14,7 @@ import io.substrait.type.Type;import lombok.EqualsAndHashCode;import lombok.ToString;+/** Represents a Column DTO (Data Transfer Object). */@EqualsAndHashCode@ToStringpublic class ColumnDTO implements Column {@@ -31,6 +32,13 @@ public class ColumnDTO implements Column {private ColumnDTO() {}+ /**+ * Constructs a Column DTO.+ *+ * @param name The name of the column.+ * @param dataType The data type of the column.+ * @param comment The comment associated with the column.+ */private ColumnDTO(String name, Type dataType, String comment) {this.name = name;this.dataType = dataType;@@ -52,10 +60,20 @@ public class ColumnDTO implements Column {return comment;}+ /**+ * Creates a new Builder to build a Column DTO.+ *+ * @return A new Builder instance.+ */public static Builder builder() {return new Builder();}+ /**+ * Builder class for constructing ColumnDTO instances.+ *+ * @param <S> The type of the builder subclass.+ */public static class Builder<S extends Builder> {protected String name;@@ -64,21 +82,45 @@ public class ColumnDTO implements Column {public Builder() {}+ /**+ * Sets the name of the column.+ *+ * @param name The name of the column.+ * @return The Builder instance.+ */public S withName(String name) {this.name = name;return (S) this;}+ /**+ * Sets the data type of the column.+ *+ * @param dataType The data type of the column.+ * @return The Builder instance.+ */public S withDataType(Type dataType) {this.dataType = dataType;return (S) this;}+ /**+ * Sets the comment associated with the column.+ *+ * @param comment The comment associated with the column.+ * @return The Builder instance.+ */public S withComment(String comment) {this.comment = comment;return (S) this;}+ /**+ * Builds a Column DTO based on the provided builder parameters.+ *+ * @return A new ColumnDTO instance.+ * @throws NullPointerException If required fields name and data type are not set.+ */public ColumnDTO build() {Preconditions.checkNotNull(name, "Column name cannot be null");Preconditions.checkNotNull(dataType, "Column data type cannot be null");diff --git a/common/src/main/java/com/datastrato/graviton/dto/rel/SchemaDTO.java b/common/src/main/java/com/datastrato/graviton/dto/rel/SchemaDTO.javaindex cd52f71e87..c50b6c101d 100644--- a/common/src/main/java/com/datastrato/graviton/dto/rel/SchemaDTO.java+++ b/common/src/main/java/com/datastrato/graviton/dto/rel/SchemaDTO.java@@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;import com.google.common.base.Preconditions;import java.util.Map;+/** Represents a Schema DTO (Data Transfer Object). */public class SchemaDTO implements Schema {@JsonProperty("name")@@ -26,6 +27,14 @@ public class SchemaDTO implements Schema {private SchemaDTO() {}+ /**+ * Constructs a Schema DTO.+ *+ * @param name The name of the schema.+ * @param comment The comment associated with the schema.+ * @param properties The properties associated with the schema.+ * @param audit The audit information for the schema.+ */private SchemaDTO(String name, String comment, Map<String, String> properties, AuditDTO audit) {this.name = name;this.comment = comment;@@ -53,6 +62,11 @@ public class SchemaDTO implements Schema {return audit;}+ /**+ * Builder class for constructing SchemaDTO instances.+ *+ * @param <S> The type of the builder subclass.+ */public static class Builder<S extends Builder> {protected String name;protected String comment;@@ -61,26 +75,56 @@ public class SchemaDTO implements Schema {public Builder() {}+ /**+ * Sets the name of the schema.+ *+ * @param name The name of the schema.+ * @return The Builder instance.+ */public S withName(String name) {this.name = name;return (S) this;}+ /**+ * Sets the comment associated with the schema.+ *+ * @param comment The comment associated with the schema.+ * @return The Builder instance.+ */public S withComment(String comment) {this.comment = comment;return (S) this;}+ /**+ * Sets the properties associated with the schema.+ *+ * @param properties The properties associated with the schema.+ * @return The Builder instance.+ */public S withProperties(Map<String, String> properties) {this.properties = properties;return (S) this;}+ /**+ * Sets the audit information for the schema.+ *+ * @param audit The audit information for the schema.+ * @return The Builder instance.+ */public S withAudit(AuditDTO audit) {this.audit = audit;return (S) this;}+ /**+ * Builds a Schema DTO based on the provided builder parameters.+ *+ * @return A new SchemaDTO instance.+ * @throws IllegalArgumentException If required fields name and audit are not set.+ */public SchemaDTO build() {Preconditions.checkArgument(name != null && !name.isEmpty(), "name cannot be null or empty");Preconditions.checkArgument(audit != null, "audit cannot be null");diff --git a/common/src/main/java/com/datastrato/graviton/dto/rel/TableDTO.java b/common/src/main/java/com/datastrato/graviton/dto/rel/TableDTO.javaindex 462a3ec36b..2e9d11b666 100644--- a/common/src/main/java/com/datastrato/graviton/dto/rel/TableDTO.java+++ b/common/src/main/java/com/datastrato/graviton/dto/rel/TableDTO.java@@ -11,6 +11,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;import com.google.common.base.Preconditions;import java.util.Map;+/** Represents a Table DTO (Data Transfer Object). */public class TableDTO implements Table {@JsonProperty("name")@@ -30,6 +31,15 @@ public class TableDTO implements Table {private TableDTO() {}+ /**+ * Constructs a Table DTO.+ *+ * @param name The name of the table.+ * @param comment The comment associated with the table.+ * @param columns The columns of the table.+ * @param properties The properties associated with the table.+ * @param audit The audit information for the table.+ */private TableDTO(String name,String comment,@@ -68,10 +78,20 @@ public class TableDTO implements Table {return audit;}+ /**+ * Creates a new Builder to build a Table DTO.+ *+ * @return A new Builder instance.+ */public static Builder builder() {return new Builder();}+ /**+ * Builder class for constructing TableDTO instances.+ *+ * @param <S> The type of the builder subclass.+ */public static class Builder<S extends Builder> {protected String name;protected String comment;@@ -81,31 +101,67 @@ public class TableDTO implements Table {public Builder() {}+ /**+ * Sets the name of the table.+ *+ * @param name The name of the table.+ * @return The Builder instance.+ */public S withName(String name) {this.name = name;return (S) this;}+ /**+ * Sets the comment associated with the table.+ *+ * @param comment The comment associated with the table.+ * @return The Builder instance.+ */public S withComment(String comment) {this.comment = comment;return (S) this;}+ /**+ * Sets the columns of the table.+ *+ * @param columns The columns of the table.+ * @return The Builder instance.+ */public S withColumns(ColumnDTO[] columns) {this.columns = columns;return (S) this;}+ /**+ * Sets the properties associated with the table.+ *+ * @param properties The properties associated with the table.+ * @return The Builder instance.+ */public S withProperties(Map<String, String> properties) {this.properties = properties;return (S) this;}+ /**+ * Sets the audit information for the table.+ *+ * @param audit The audit information for the table.+ * @return The Builder instance.+ */public S withAudit(AuditDTO audit) {this.audit = audit;return (S) this;}+ /**+ * Builds a Table DTO based on the provided builder parameters.+ *+ * @return A new TableDTO instance.+ * @throws IllegalArgumentException If required fields name, columns and audit are not set.+ */public TableDTO build() {Preconditions.checkArgument(name != null && !name.isEmpty(), "name cannot be null or empty");Preconditions.checkArgument(diff --git a/common/src/main/java/com/datastrato/graviton/dto/requests/CatalogCreateRequest.java b/common/src/main/java/com/datastrato/graviton/dto/requests/CatalogCreateRequest.javaindex 2cd96aee9a..afc1c246a1 100644--- a/common/src/main/java/com/datastrato/graviton/dto/requests/CatalogCreateRequest.java+++ b/common/src/main/java/com/datastrato/graviton/dto/requests/CatalogCreateRequest.java@@ -14,6 +14,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents a request to create a catalog. */@Getter@EqualsAndHashCode@ToString@@ -33,10 +34,19 @@ public class CatalogCreateRequest implements RESTRequest {@JsonProperty("properties")private final Map<String, String> properties;+ /** Default constructor for CatalogCreateRequest. */public CatalogCreateRequest() {this(null, null, null, null);}+ /**+ * Constructor for CatalogCreateRequest.+ *+ * @param name The name of the catalog.+ * @param type The type of the catalog.+ * @param comment The comment for the catalog.+ * @param properties The properties for the catalog.+ */public CatalogCreateRequest(String name, Catalog.Type type, String comment, Map<String, String> properties) {this.name = name;@@ -45,6 +55,11 @@ public class CatalogCreateRequest implements RESTRequest {this.properties = properties;}+ /**+ * Validates the fields of the request.+ *+ * @throws IllegalArgumentException if name or type are not set.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(diff --git a/common/src/main/java/com/datastrato/graviton/dto/requests/CatalogUpdateRequest.java b/common/src/main/java/com/datastrato/graviton/dto/requests/CatalogUpdateRequest.javaindex e0b9b91b44..f232c3d0f0 100644--- a/common/src/main/java/com/datastrato/graviton/dto/requests/CatalogUpdateRequest.java+++ b/common/src/main/java/com/datastrato/graviton/dto/requests/CatalogUpdateRequest.java@@ -15,6 +15,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents an interface for catalog update requests. */@JsonIgnoreProperties(ignoreUnknown = true)@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)@JsonSubTypes({@@ -31,6 +32,11 @@ import lombok.ToString;})public interface CatalogUpdateRequest extends RESTRequest {+ /**+ * Returns the catalog change associated with this request.+ *+ * @return The catalog change.+ */CatalogChange catalogChange();@EqualsAndHashCode@@ -41,14 +47,25 @@ public interface CatalogUpdateRequest extends RESTRequest {@JsonProperty("newName")private final String newName;+ /** Default constructor for RenameCatalogRequest. */public RenameCatalogRequest() {this(null);}+ /**+ * Constructor for RenameCatalogRequest.+ *+ * @param newName The new name for the catalog.+ */public RenameCatalogRequest(String newName) {this.newName = newName;}+ /**+ * Validates the fields of the request.+ *+ * @throws IllegalArgumentException if the new name is not set.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -70,14 +87,25 @@ public interface CatalogUpdateRequest extends RESTRequest {@JsonProperty("newComment")private final String newComment;+ /**+ * Constructor for UpdateCatalogCommentRequest.+ *+ * @param newComment The new comment for the catalog.+ */public UpdateCatalogCommentRequest(String newComment) {this.newComment = newComment;}+ /** Default constructor for UpdateCatalogCommentRequest. */public UpdateCatalogCommentRequest() {this(null);}+ /**+ * Validates the fields of the request.+ *+ * @throws IllegalArgumentException if the new comment is not set.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -103,15 +131,27 @@ public interface CatalogUpdateRequest extends RESTRequest {@JsonProperty("value")private final String value;+ /**+ * Constructor for SetCatalogPropertyRequest.+ *+ * @param property The property to set.+ * @param value The value of the property.+ */public SetCatalogPropertyRequest(String property, String value) {this.property = property;this.value = value;}+ /** Default constructor for SetCatalogPropertyRequest. */public SetCatalogPropertyRequest() {this(null, null);}+ /**+ * Validates the fields of the request.+ *+ * @throws IllegalArgumentException if the property or value is not set.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -135,14 +175,25 @@ public interface CatalogUpdateRequest extends RESTRequest {@JsonProperty("property")private final String property;+ /**+ * Constructor for RemoveCatalogPropertyRequest.+ *+ * @param property The property to remove.+ */public RemoveCatalogPropertyRequest(String property) {this.property = property;}+ /** Default constructor for RemoveCatalogPropertyRequest. */public RemoveCatalogPropertyRequest() {this(null);}+ /**+ * Validates the fields of the request.+ *+ * @throws IllegalArgumentException if property is not set.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(diff --git a/common/src/main/java/com/datastrato/graviton/dto/requests/CatalogUpdatesRequest.java b/common/src/main/java/com/datastrato/graviton/dto/requests/CatalogUpdatesRequest.javaindex 3edf00cadf..07ffe7af35 100644--- a/common/src/main/java/com/datastrato/graviton/dto/requests/CatalogUpdatesRequest.java+++ b/common/src/main/java/com/datastrato/graviton/dto/requests/CatalogUpdatesRequest.java@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents a request containing multiple catalog updates. */@Getter@EqualsAndHashCode@ToString@@ -19,14 +20,25 @@ public class CatalogUpdatesRequest implements RESTRequest {@JsonProperty("updates")private final List<CatalogUpdateRequest> updates;+ /**+ * Constructor for CatalogUpdatesRequest.+ *+ * @param requests The list of catalog update requests.+ */public CatalogUpdatesRequest(List<CatalogUpdateRequest> updates) {this.updates = updates;}+ /** Default constructor for CatalogUpdatesRequest. */public CatalogUpdatesRequest() {this(null);}+ /**+ * Validates each request in the list.+ *+ * @throws IllegalArgumentException if validation of any request fails.+ */@Overridepublic void validate() throws IllegalArgumentException {updates.forEach(RESTRequest::validate);diff --git a/common/src/main/java/com/datastrato/graviton/dto/requests/MetalakeCreateRequest.java b/common/src/main/java/com/datastrato/graviton/dto/requests/MetalakeCreateRequest.javaindex 8d8bde1def..209822dde1 100644--- a/common/src/main/java/com/datastrato/graviton/dto/requests/MetalakeCreateRequest.java+++ b/common/src/main/java/com/datastrato/graviton/dto/requests/MetalakeCreateRequest.java@@ -14,6 +14,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents a request to create a Metalake. */@Getter@EqualsAndHashCode@ToString@@ -30,11 +31,18 @@ public class MetalakeCreateRequest implements RESTRequest {@JsonProperty("properties")private final Map<String, String> properties;- // Only for Jackson deserialization+ /** Default constructor for MetalakeCreateRequest. (Used for Jackson deserialization.) */public MetalakeCreateRequest() {this(null, null, null);}+ /**+ * Constructor for MetalakeCreateRequest.+ *+ * @param name The name of the Metalake.+ * @param comment The comment for the Metalake.+ * @param properties The properties for the Metalake.+ */public MetalakeCreateRequest(String name, String comment, Map<String, String> properties) {super();@@ -43,6 +51,11 @@ public class MetalakeCreateRequest implements RESTRequest {this.properties = properties;}+ /**+ * Validates the fields of the request.+ *+ * @throws IllegalArgumentException if the name is not set.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(diff --git a/common/src/main/java/com/datastrato/graviton/dto/requests/MetalakeUpdateRequest.java b/common/src/main/java/com/datastrato/graviton/dto/requests/MetalakeUpdateRequest.javaindex d4bb5fed80..f28f061820 100644--- a/common/src/main/java/com/datastrato/graviton/dto/requests/MetalakeUpdateRequest.java+++ b/common/src/main/java/com/datastrato/graviton/dto/requests/MetalakeUpdateRequest.java@@ -15,6 +15,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents an interface for Metalake update requests. */@JsonIgnoreProperties(ignoreUnknown = true)@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)@JsonSubTypes({@@ -31,6 +32,11 @@ import lombok.ToString;})public interface MetalakeUpdateRequest extends RESTRequest {+ /**+ * Returns the Metalake change associated with this request.+ *+ * @return The Metalake change.+ */MetalakeChange metalakeChange();@EqualsAndHashCode@@ -41,14 +47,25 @@ public interface MetalakeUpdateRequest extends RESTRequest {@JsonProperty("newName")private final String newName;+ /**+ * Constructor for RenameMetalakeRequest.+ *+ * @param newName The new name for the Metalake.+ */public RenameMetalakeRequest(String newName) {this.newName = newName;}+ /** Default constructor for RenameMetalakeRequest. */public RenameMetalakeRequest() {this(null);}+ /**+ * Validates the fields of the request.+ *+ * @throws IllegalArgumentException if the new name is not set.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -70,14 +87,25 @@ public interface MetalakeUpdateRequest extends RESTRequest {@JsonProperty("newComment")private final String newComment;+ /**+ * Constructor for UpdateMetalakeCommentRequest.+ *+ * @param newComment The new comment for the Metalake.+ */public UpdateMetalakeCommentRequest(String newComment) {this.newComment = newComment;}+ /** Default constructor for UpdateMetalakeCommentRequest. */public UpdateMetalakeCommentRequest() {this(null);}+ /**+ * Validates the fields of the request.+ *+ * @throws IllegalArgumentException if the new comment is not set.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -102,15 +130,27 @@ public interface MetalakeUpdateRequest extends RESTRequest {@JsonProperty("value")private final String value;+ /**+ * Constructor for SetMetalakePropertyRequest.+ *+ * @param property The property to set.+ * @param value The value of the property.+ */public SetMetalakePropertyRequest(String property, String value) {this.property = property;this.value = value;}+ /** Default constructor for SetMetalakePropertyRequest. */public SetMetalakePropertyRequest() {this(null, null);}+ /**+ * Validates the fields of the request.+ *+ * @throws IllegalArgumentException if property or value are not set.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(@@ -134,14 +174,25 @@ public interface MetalakeUpdateRequest extends RESTRequest {@JsonProperty("property")private final String property;+ /**+ * Constructor for RemoveMetalakePropertyRequest.+ *+ * @param property The property to remove.+ */public RemoveMetalakePropertyRequest(String property) {this.property = property;}+ /** Default constructor for RemoveMetalakePropertyRequest. */public RemoveMetalakePropertyRequest() {this(null);}+ /**+ * Validates the fields of the request.+ *+ * @throws IllegalArgumentException if property is not set.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(diff --git a/common/src/main/java/com/datastrato/graviton/dto/requests/MetalakeUpdatesRequest.java b/common/src/main/java/com/datastrato/graviton/dto/requests/MetalakeUpdatesRequest.javaindex 13d9eeb8d9..704ef7697f 100644--- a/common/src/main/java/com/datastrato/graviton/dto/requests/MetalakeUpdatesRequest.java+++ b/common/src/main/java/com/datastrato/graviton/dto/requests/MetalakeUpdatesRequest.java@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents a request containing multiple Metalake updates. */@Getter@EqualsAndHashCode@ToString@@ -19,14 +20,25 @@ public class MetalakeUpdatesRequest implements RESTRequest {@JsonProperty("updates")private final List<MetalakeUpdateRequest> updates;+ /**+ * Constructor for MetalakeUpdatesRequest.+ *+ * @param requests The list of Metalake update requests.+ */public MetalakeUpdatesRequest(List<MetalakeUpdateRequest> updates) {this.updates = updates;}+ /** Default constructor for MetalakeUpdatesRequest. */public MetalakeUpdatesRequest() {this(null);}+ /**+ * Validates each request in the list.+ *+ * @throws IllegalArgumentException if validation of any request fails.+ */@Overridepublic void validate() throws IllegalArgumentException {updates.forEach(RESTRequest::validate);diff --git a/common/src/main/java/com/datastrato/graviton/dto/responses/BaseResponse.java b/common/src/main/java/com/datastrato/graviton/dto/responses/BaseResponse.javaindex 4d1f324be5..943eb7565a 100644--- a/common/src/main/java/com/datastrato/graviton/dto/responses/BaseResponse.java+++ b/common/src/main/java/com/datastrato/graviton/dto/responses/BaseResponse.java@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents a base response for REST API calls. */@Getter@EqualsAndHashCode@ToString@@ -19,15 +20,25 @@ public class BaseResponse implements RESTResponse {@JsonProperty("code")private final int code;+ /**+ * Constructor for BaseResponse.+ *+ * @param code The response code.+ */public BaseResponse(int code) {this.code = code;}- // This is the constructor that is used by Jackson deserializer+ /** Default constructor for BaseResponse. (Used for Jackson deserialization.) */public BaseResponse() {this.code = 0;}+ /**+ * Validates the response code.+ *+ * @throws IllegalArgumentException if code value is negative.+ */@Overridepublic void validate() throws IllegalArgumentException {Preconditions.checkArgument(code >= 0, "code must be >= 0");diff --git a/common/src/main/java/com/datastrato/graviton/dto/responses/CatalogListResponse.java b/common/src/main/java/com/datastrato/graviton/dto/responses/CatalogListResponse.javaindex 43703b4212..2ba2465fd4 100644--- a/common/src/main/java/com/datastrato/graviton/dto/responses/CatalogListResponse.java+++ b/common/src/main/java/com/datastrato/graviton/dto/responses/CatalogListResponse.java@@ -13,6 +13,7 @@ import com.google.common.base.Preconditions;import lombok.EqualsAndHashCode;import lombok.ToString;+/** Represents a response containing a list of catalogs. */@EqualsAndHashCode(callSuper = true)@ToStringpublic class CatalogListResponse extends BaseResponse {@@ -22,21 +23,36 @@ public class CatalogListResponse extends BaseResponse {@JsonProperty("catalogs")private final NameIdentifier[] idents;+ /**+ * Constructor for CatalogListResponse. (Used for Jackson deserialization.)+ *+ * @param idents The array of catalog identifiers.+ */public CatalogListResponse(NameIdentifier[] idents) {super(0);this.idents = idents;}- // This is the constructor that is used by Jackson deserializer+ /** Default constructor for CatalogListResponse. */public CatalogListResponse() {super();this.idents = null;}+ /**+ * Returns the array of catalog identifiers.+ *+ * @return The array of identifiers.+ */public NameIdentifier[] getCatalogs() {return idents;}+ /**+ * Validates the response data.+ *+ * @throws IllegalArgumentException if catalog identifiers are not set.+ */@Overridepublic void validate() throws IllegalArgumentException {super.validate();diff --git a/common/src/main/java/com/datastrato/graviton/dto/responses/CatalogResponse.java b/common/src/main/java/com/datastrato/graviton/dto/responses/CatalogResponse.javaindex 0c9483adf5..7b0503aa43 100644--- a/common/src/main/java/com/datastrato/graviton/dto/responses/CatalogResponse.java+++ b/common/src/main/java/com/datastrato/graviton/dto/responses/CatalogResponse.java@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents a response containing catalog information. */@Getter@ToString@EqualsAndHashCode(callSuper = true)@@ -19,17 +20,27 @@ public class CatalogResponse extends BaseResponse {@JsonProperty("catalog")private final CatalogDTO catalog;+ /**+ * Constructor for CatalogResponse.+ *+ * @param catalog The catalog data transfer object.+ */public CatalogResponse(CatalogDTO catalog) {super(0);this.catalog = catalog;}- // This is the constructor that is used by Jackson deserializer+ /** Default constructor for CatalogResponse. (Used for Jackson deserialization.) */public CatalogResponse() {super();this.catalog = null;}+ /**+ * Validates the response data.+ *+ * @throws IllegalArgumentException if teh catalog name, type or audit is not set.+ */@Overridepublic void validate() throws IllegalArgumentException {super.validate();diff --git a/common/src/main/java/com/datastrato/graviton/dto/responses/DropResponse.java b/common/src/main/java/com/datastrato/graviton/dto/responses/DropResponse.javaindex f6a04554f2..9d12326903 100644--- a/common/src/main/java/com/datastrato/graviton/dto/responses/DropResponse.java+++ b/common/src/main/java/com/datastrato/graviton/dto/responses/DropResponse.java@@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;import lombok.EqualsAndHashCode;import lombok.ToString;+/** Represents a response for a drop operation. */@ToString@EqualsAndHashCode(callSuper = true)public class DropResponse extends BaseResponse {@@ -15,16 +16,27 @@ public class DropResponse extends BaseResponse {@JsonProperty("dropped")private final boolean dropped;+ /**+ * Constructor for DropResponse.+ *+ * @param dropped Whether the drop operation was successful.+ */public DropResponse(boolean dropped) {super(0);this.dropped = dropped;}+ /** Default constructor for DropResponse (used by Jackson deserializer). */public DropResponse() {super();this.dropped = false;}+ /**+ * Returns whether the drop operation was successful.+ *+ * @return True if the drop operation was successful, otherwise false.+ */public boolean dropped() {return dropped;}diff --git a/common/src/main/java/com/datastrato/graviton/dto/responses/ErrorConstants.java b/common/src/main/java/com/datastrato/graviton/dto/responses/ErrorConstants.javaindex 92d8bd4b43..a70975e0ca 100644--- a/common/src/main/java/com/datastrato/graviton/dto/responses/ErrorConstants.java+++ b/common/src/main/java/com/datastrato/graviton/dto/responses/ErrorConstants.java@@ -4,6 +4,7 @@*/package com.datastrato.graviton.dto.responses;+/** Constants representing error codes for responses. */public class ErrorConstants {public static final int REST_ERROR_CODE = 1000;public static final int ILLEGAL_ARGUMENTS_CODE = 1001;diff --git a/common/src/main/java/com/datastrato/graviton/dto/responses/MetalakeListResponse.java b/common/src/main/java/com/datastrato/graviton/dto/responses/MetalakeListResponse.javaindex 7c03668409..f5df4db868 100644--- a/common/src/main/java/com/datastrato/graviton/dto/responses/MetalakeListResponse.java+++ b/common/src/main/java/com/datastrato/graviton/dto/responses/MetalakeListResponse.java@@ -12,6 +12,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents a response containing a list of metalakes. */@Getter@EqualsAndHashCode(callSuper = true)@ToString@@ -20,17 +21,27 @@ public class MetalakeListResponse extends BaseResponse {@JsonProperty("metalakes")private final MetalakeDTO[] metalakes;+ /**+ * Constructor for MetalakeListResponse.+ *+ * @param metalakes The array of metalake DTOs.+ */public MetalakeListResponse(MetalakeDTO[] metalakes) {super(0);this.metalakes = metalakes;}- // This is the constructor that is used by Jackson deserializer+ /** Default constructor for MetalakeListResponse. (Used for Jackson deserialization.) */public MetalakeListResponse() {super();this.metalakes = null;}+ /**+ * Validates the response data.+ *+ * @throws IllegalArgumentException if name or audit information is not set.+ */@Overridepublic void validate() throws IllegalArgumentException {super.validate();diff --git a/common/src/main/java/com/datastrato/graviton/dto/responses/MetalakeResponse.java b/common/src/main/java/com/datastrato/graviton/dto/responses/MetalakeResponse.javaindex 72b004c89d..f846a318de 100644--- a/common/src/main/java/com/datastrato/graviton/dto/responses/MetalakeResponse.java+++ b/common/src/main/java/com/datastrato/graviton/dto/responses/MetalakeResponse.java@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;import lombok.Getter;import lombok.ToString;+/** Represents a response containing metalake information. */@Getter@ToString@EqualsAndHashCode(callSuper = true)@@ -19,17 +20,27 @@ public class MetalakeResponse extends BaseResponse {@JsonProperty("metalake")private final MetalakeDTO metalake;+ /**+ * Constructor for MetalakeResponse.+ *+ * @param metalake The metalake DTO.+ */public MetalakeResponse(MetalakeDTO metalake) {super(0);this.metalake = metalake;}- // This is the constructor that is used by Jackson deserializer+ /** Default constructor for MetalakeResponse. (Used for Jackson deserialization.) */public MetalakeResponse() {super();this.metalake = null;}+ /**+ * Validates the response data.+ *+ * @throws IllegalArgumentException if the metalake, name or audit information is not set.+ */@Overridepublic void validate() throws IllegalArgumentException {super.validate();diff --git a/common/src/main/java/com/datastrato/graviton/json/JsonUtils.java b/common/src/main/java/com/datastrato/graviton/json/JsonUtils.javaindex d97a332e70..e410d72f31 100644--- a/common/src/main/java/com/datastrato/graviton/json/JsonUtils.java+++ b/common/src/main/java/com/datastrato/graviton/json/JsonUtils.java@@ -28,6 +28,7 @@ import java.util.List;import org.slf4j.Logger;import org.slf4j.LoggerFactory;+/** Utility class for working with JSON data. */public class JsonUtils {private static final Logger LOG = LoggerFactory.getLogger(JsonUtils.class);@@ -36,10 +37,21 @@ public class JsonUtils {private static final String NAME = "name";+ /**+ * Abstract iterator class for iterating over elements of a JSON array.+ *+ * @param <T> The type of elements to convert and iterate.+ */abstract static class JsonArrayIterator<T> implements Iterator<T> {private final Iterator<JsonNode> elements;+ /**+ * Constructor for the JSON array iterator.+ *+ * @param property The property name of the JSON array.+ * @param node The JSON node containing the array.+ */JsonArrayIterator(String property, JsonNode node) {JsonNode pNode = node.get(property);Preconditions.checkArgument(@@ -61,9 +73,16 @@ public class JsonUtils {return convert(element);}+ /**+ * Convert a JSON node to the desired element type.+ *+ * @param element The JSON node to convert.+ * @return The converted element.+ */abstract T convert(JsonNode element);}+ /** Iterator for JSON arrays containing strings. */static class JsonStringArrayIterator extends JsonArrayIterator<String> {private final String property;@@ -80,6 +99,11 @@ public class JsonUtils {private static ObjectMapper mapper = null;+ /**+ * Get the shared ObjectMapper instance for JSON serialization/deserialization.+ *+ * @return The ObjectMapper instance.+ */public static ObjectMapper objectMapper() {if (mapper == null) {synchronized (JsonUtils.class) {@@ -95,6 +119,13 @@ public class JsonUtils {return mapper;}+ /**+ * Get a list of strings from a JSON node property.+ *+ * @param property The property name.+ * @param node The JSON node.+ * @return The list of strings or null if property is missing or null.+ */public static List<String> getStringListOrNull(String property, JsonNode node) {if (!node.has(property) || node.get(property).isNull()) {return null;@@ -105,6 +136,14 @@ public class JsonUtils {.build();}+ /**+ * Get a string value from a JSON node property.+ *+ * @param property The property name.+ * @param node The JSON node.+ * @return The string value.+ * @throws IllegalArgumentException if the property is missing in the JSON node.+ */public static String getString(String property, JsonNode node) {Preconditions.checkArgument(node.has(property), "Cannot parse missing string: %s", property);JsonNode pNode = node.get(property);@@ -120,6 +159,9 @@ public class JsonUtils {return pNode.asText();}+ // Nested classes for custom serialization and deserialization++ /** Custom JSON serializer for Substrait Type objects. */public static class TypeSerializer extends JsonSerializer<io.substrait.type.Type> {private final StringTypeVisitor visitor = new StringTypeVisitor();@@ -136,6 +178,7 @@ public class JsonUtils {}}+ /** Custom JSON deserializer for Substrait Type objects. */public static class TypeDeserializer extends JsonDeserializer<io.substrait.type.Type> {@Override@@ -150,6 +193,7 @@ public class JsonUtils {}}+ /** Custom JSON serializer for NameIdentifier objects. */public static class NameIdentifierSerializer extends JsonSerializer<NameIdentifier> {@Override@@ -163,6 +207,7 @@ public class JsonUtils {}}+ /** Custom JSON deserializer for NameIdentifier objects. */public static class NameIdentifierDeserializer extends JsonDeserializer<NameIdentifier> {@Overridediff --git a/common/src/main/java/com/datastrato/graviton/rest/RESTUtils.java b/common/src/main/java/com/datastrato/graviton/rest/RESTUtils.javaindex e5f0e21788..99d2af6172 100644--- a/common/src/main/java/com/datastrato/graviton/rest/RESTUtils.java+++ b/common/src/main/java/com/datastrato/graviton/rest/RESTUtils.java@@ -15,6 +15,7 @@ import java.net.URLEncoder;import java.nio.charset.StandardCharsets;import java.util.Map;+/** Utility class for working with REST related operations. */public class RESTUtils {private static final Joiner.MapJoiner FORM_JOINER = Joiner.on("&").withKeyValueSeparator("=");@@ -23,6 +24,12 @@ public class RESTUtils {private RESTUtils() {}+ /**+ * Remove trailing slashes from a path.+ *+ * @param path The path to strip trailing slashes from.+ * @return The path with trailing slashes removed.+ */public static String stripTrailingSlash(String path) {if (path == null) {return null;@@ -35,6 +42,12 @@ public class RESTUtils {return result;}+ /**+ * Encode a map of form data into an URL encoded string.+ *+ * @param formData The form data to encode.+ * @return The URL encoded form data string.+ */public static String encodeFormData(Map<?, ?> formData) {ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();formData.forEach(@@ -43,6 +56,12 @@ public class RESTUtils {return FORM_JOINER.join(builder.build());}+ /**+ * Decode an URL encoded form data string into a map.+ *+ * @param formString The URL encoded form data string.+ * @return The decoded form data map.+ */public static Map<String, String> decodeFormData(String formString) {return FORM_SPLITTER.split(formString).entrySet().stream().collect(@@ -50,6 +69,14 @@ public class RESTUtils {e -> decodeString(e.getKey()), e -> decodeString(e.getValue())));}+ /**+ * URL encode a string.+ *+ * @param toEncode The string to encode.+ * @return The URL encoded string.+ * @throws IllegalArgumentException If the input string is null.+ * @throws UncheckedIOException If URL encoding fails.+ */public static String encodeString(String toEncode) {Preconditions.checkArgument(toEncode != null, "Invalid string to encode: null");try {@@ -60,6 +87,14 @@ public class RESTUtils {}}+ /**+ * Decode an URL encoded string.+ *+ * @param encoded The URL encoded string to decode.+ * @return The decoded string.+ * @throws IllegalArgumentException if the input string is null.+ * @throws UncheckedIOException if URL decoding fails.+ */public static String decodeString(String encoded) {Preconditions.checkArgument(encoded != null, "Invalid string to decode: null");try {