Skip to content

Commit

Permalink
Merge pull request #592 from groldan/jackson-bindings/missing_subtype…
Browse files Browse the repository at this point in the history
…_declarations

Add @JsonSubTypes to ConfigInfoDto and @tostring to all JSON DTOs
  • Loading branch information
groldan authored Jan 22, 2025
2 parents dce90a6 + aac7b18 commit 959d463
Show file tree
Hide file tree
Showing 24 changed files with 80 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@JsonSubTypes({
@JsonSubTypes.Type(value = Workspace.class),
Expand All @@ -19,6 +20,7 @@
@JsonSubTypes.Type(value = Published.class)
})
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public abstract class CatalogInfoDto extends InfoDto {
private Date dateCreated;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("CoverageInfo")
public class Coverage extends Resource {
private String nativeFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("CoverageStoreInfo")
public class CoverageStore extends Store {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("DataStoreInfo")
public class DataStore extends Store {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("FeatureTypeInfo")
public class FeatureType extends Resource {
private String cqlFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import com.fasterxml.jackson.annotation.JsonSubTypes;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@JsonSubTypes({@JsonSubTypes.Type(value = WMSStore.class), @JsonSubTypes.Type(value = WMTSStore.class)})
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonSubTypes({@JsonSubTypes.Type(value = WMSStore.class), @JsonSubTypes.Type(value = WMTSStore.class)})
public abstract class HTTPStore extends Store {
private String capabilitiesURL;
private String username;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import java.util.Set;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("LayerInfo")
public class Layer extends Published {
public enum WMSInterpolation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.geotools.jackson.databind.dto.Envelope;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("LayerGroupInfo")
public class LayerGroup extends Published {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("MapInfo")
public class Map extends CatalogInfoDto {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("NamespaceInfo")
public class Namespace extends CatalogInfoDto {
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@JsonSubTypes({@JsonSubTypes.Type(value = Layer.class), @JsonSubTypes.Type(value = LayerGroup.class)})
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonSubTypes({@JsonSubTypes.Type(value = Layer.class), @JsonSubTypes.Type(value = LayerGroup.class)})
public abstract class Published extends CatalogInfoDto {

public enum PublishedType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.geotools.jackson.databind.dto.CRS;
import org.geotools.jackson.databind.dto.Envelope;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = Coverage.class),
@JsonSubTypes.Type(value = FeatureType.class),
@JsonSubTypes.Type(value = WMSLayer.class),
@JsonSubTypes.Type(value = WMTSLayer.class)
})
@Data
@EqualsAndHashCode(callSuper = true)
public abstract class Resource extends CatalogInfoDto {
public enum ProjectionPolicy {
FORCE_DECLARED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = CoverageStore.class),
@JsonSubTypes.Type(value = DataStore.class),
@JsonSubTypes.Type(value = HTTPStore.class)
})
@Data
@EqualsAndHashCode(callSuper = true)
public abstract class Store extends CatalogInfoDto {
private String name;
private String workspace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.geotools.jackson.databind.dto.VersionDto;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("StyleInfo")
public class Style extends CatalogInfoDto {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("WMSLayerInfo")
public class WMSLayer extends Resource {
private String forcedRemoteStyle = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("WMSStoreInfo")
public class WMSStore extends HTTPStore {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("WMTSLayerInfo")
public class WMTSLayer extends Resource {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@JsonTypeName("WMTSStoreInfo")
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("WMTSStoreInfo")
public class WMTSStore extends HTTPStore {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("WorkspaceInfo")
public class Workspace extends CatalogInfoDto {
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@
*/
package org.geoserver.jackson.databind.config.dto;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.geoserver.jackson.databind.catalog.dto.InfoDto;

@EqualsAndHashCode(callSuper = true)
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = GeoServer.class),
@JsonSubTypes.Type(value = Logging.class),
@JsonSubTypes.Type(value = Service.class),
@JsonSubTypes.Type(value = Settings.class)
})
public class ConfigInfoDto extends InfoDto {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.geoserver.config.GeoServerInfo;
import org.geoserver.jackson.databind.catalog.dto.MetadataMapDto;

/** DTO for {@link GeoServerInfo} */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("GeoServerInfo")
@Data
public class GeoServer extends ConfigInfoDto {
public enum ResourceErrorHandling {
OGC_EXCEPTION_REPORT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.geoserver.config.LoggingInfo;

/** DTO for {@link LoggingInfo} */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("LoggingInfo")
@Data
public class Logging extends ConfigInfoDto {
private String level;
private String location;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Set;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.geoserver.catalog.LayerInfo.WMSInterpolation;
import org.geoserver.catalog.impl.AuthorityURL;
import org.geoserver.catalog.impl.LayerIdentifier;
Expand All @@ -33,6 +34,9 @@
import org.geotools.jackson.databind.dto.NameDto;

/** DTO for {@link ServiceInfo} */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = Service.WmsService.class),
@JsonSubTypes.Type(value = Service.WfsService.class),
Expand All @@ -41,8 +45,6 @@
@JsonSubTypes.Type(value = Service.WmtsService.class),
@JsonSubTypes.Type(value = Service.GenericService.class)
})
@Data
@EqualsAndHashCode(callSuper = true)
public abstract class Service extends ConfigInfoDto {
private String name;
private String workspace;
Expand Down Expand Up @@ -78,14 +80,16 @@ public abstract class Service extends ConfigInfoDto {
*/
private Map<String, String> internationalAbstract;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("ServiceInfo")
@Data
public static class GenericService extends Service {}

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("WMSInfo")
@Data
public static class WmsService extends Service {
// Works well as POJO, no need to create a separate DTO
private WatermarkInfoImpl watermark;
Expand Down Expand Up @@ -149,9 +153,10 @@ public static class WmsService extends Service {
private Boolean exceptionOnInvalidDimension;
}

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("WFSInfo")
@Data
public static class WfsService extends Service {
private Map<Version, GMLInfoImpl> GML;
private int maxFeatures;
Expand Down Expand Up @@ -182,9 +187,10 @@ public static class WfsService extends Service {
private String csvDateFormat;
}

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("WCSInfo")
@Data
public static class WcsService extends Service {
private boolean GMLPrefixing;
private long maxInputMemory;
Expand All @@ -197,9 +203,10 @@ public static class WcsService extends Service {
private int defaultDeflateCompressionLevel;
}

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("WPSInfo")
@Data
public static class WpsService extends Service {
private double connectionTimeout;
private int resourceExpirationTimeout;
Expand Down Expand Up @@ -238,8 +245,9 @@ public static class Process {
}

/** DTO for {@link WMTSInfo} */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@JsonTypeName("WMTSInfo")
@Data
public static class WmtsService extends Service {}
}
Loading

0 comments on commit 959d463

Please sign in to comment.