Refactored api.

This commit is contained in:
Marcus Handte
2024-02-29 17:45:59 +01:00
parent f18dbb57bd
commit 9a06bb2630
204 changed files with 19939 additions and 1970 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(":android-sdk")
implementation "javax.xml.bind:jaxb-api:${versionJaxb}"
implementation "jakarta.xml.bind:jakarta.xml.bind-api:${versionJaxb}"
implementation "androidx.appcompat:appcompat:${versionAndroidXAppcompat}"
implementation "androidx.work:work-runtime:${versionAndroidXWork}"
implementation "com.google.android.material:material:${versionGoogleMaterial}"
+24 -15
View File
@@ -5,10 +5,10 @@ apply plugin: 'maven-publish'
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.4'
classpath 'org.handte.gradle:gradle-android-eclipse:1.0.0'
classpath "gradle.plugin.org.openbakery:plugin:0.21.0"
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.4'
classpath 'org.handte.gradle:gradle-android-eclipse:1.0.0'
classpath "gradle.plugin.org.openbakery:plugin:0.21.0"
}
repositories {
maven {
@@ -19,6 +19,16 @@ buildscript {
}
}
plugins.withType(JavaPlugin) {
afterEvaluate {
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
}
}
allprojects {
apply plugin: 'maven-publish'
@@ -29,18 +39,18 @@ allprojects {
// set versions for our libraries
ext {
// api dependencies
versionJavaee = '8.0.0'
versionJaxb = '2.3.1'
versionJavaee = '10.0.0'
versionJaxb = '4.0.1'
versionAnnotation = '1.3.2'
versionSwagger = '1.5.22'
versionSwagger = '2.2.16'
versionGeojson = '1.8.1'
// wildfly dependencies, keep in sync
versionJackson = '2.10.5'
versionResteasy = '3.13.2.Final'
versionJackson = '2.14.3'
versionResteasy = '6.2.5.Final'
versionWildfly = '21.0.0.Final'
versionPicketbox = '5.0.3.Final'
versionHibernate = '5.3.18.Final'
versionHibernateSearch = '5.10.7.Final'
versionHibernate = '6.2.2.Final'
versionHibernateSearch = '6.2.2.Final'
// built-in infinispan dependency
versionInfinispan = '9.4.20.Final'
// testing dependencies
@@ -48,8 +58,8 @@ allprojects {
versionArquillianContainer = '2.2.0.Final'
versionArquillianJunit = '1.5.0.Final'
// thorntail dependencies
versionPostgres = '42.7.1'
versionH2database = '1.4.196'
versionThorntail = '2.6.0.Final'
// other frameworks
mapstructVersion = '1.3.1.Final'
// shared android dependencies
@@ -59,8 +69,8 @@ allprojects {
versionAndroidXPreference = '1.2.0'
versionRobolectric = '4.9'
// locoslab libraries and code
versionGeometry = '1.1.4'
versionCarta = '1.1.4'
versionGeometry = '1.4.0'
versionCarta = '1.3.0'
// tools
versionCli = '1.4'
}
@@ -105,7 +115,6 @@ subprojects {
} else {
// standard java configration
apply plugin: 'java-library'
sourceCompatibility = '1.8'
task sourcesJar(type: Jar) {
classifier = 'sources'
+26 -64
View File
@@ -1,83 +1,45 @@
plugins {
id 'com.benjaminsproule.swagger' version '1.0.14'
id 'io.swagger.core.v3.swagger-gradle-plugin' version '2.2.19'
}
description = 'MoWeSta Common Api'
dependencies {
api "javax.xml.bind:jaxb-api:${versionJaxb}"
api "de.grundid.opendatalab:geojson-jackson:${versionGeojson}"
configurations {
// add a configuration to support swagger generation for jakarta namespace
swagger { transitive = true }
}
dependencies {
api "jakarta.xml.bind:jakarta.xml.bind-api:${versionJaxb}"
api "io.swagger.core.v3:swagger-annotations-jakarta:${versionSwagger}"
api "de.grundid.opendatalab:geojson-jackson:${versionGeojson}"
api "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
testImplementation "junit:junit:${versionJunit}"
testImplementation "org.glassfish.jaxb:jaxb-runtime:${versionJaxb}"
compileClasspath "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
compileClasspath "io.swagger:swagger-annotations:${versionSwagger}"
compileClasspath "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
// explicity require jakarta jaxrs integration for swagger
swagger "io.swagger.core.v3:swagger-jaxrs2-jakarta:${versionSwagger}"
}
// add compile only dependencies to testCompile without duplicating them
sourceSets {
//test.compileClasspath += configurations.compileOnly
tasks.resolve {
outputFileName = 'mowesta'
outputFormat = 'JSON'
prettyPrint = 'TRUE'
resourcePackages = [ 'com.mowesta.api' ]
outputDir = file("${project.buildDir}/swagger")
classpath = sourceSets.main.runtimeClasspath + sourceSets.main.compileClasspath
buildClasspath = configurations.swagger // use jakarta swagger artifacts for processing
openApiFile = file("${project.projectDir}/src/main/resources/openapi.json")
}
// generate swagger documenation from api using a plugin
swagger {
apiSource {
attachSwaggerArtifact = true
locations = [
'com.mowesta.api.device.IDeviceService',
'com.mowesta.api.location.ILocationService',
'com.mowesta.api.log.ILogService',
'com.mowesta.api.measurement.IMeasurementService',
'com.mowesta.api.settings.ISettingsService',
'com.mowesta.api.user.IUserService',
'com.mowesta.api.version.IVersionService',
'com.mowesta.api.weather.IWeatherService',
]
schemes = ['https']
host = 'www.mowesta.com'
basePath = '/api'
info {
title = 'Mowesta Service'
version = project.version
description = 'The application programming '
termsOfService = 'https://mowesta.com/terms-of-service'
contact {
email = 'nes-admin@uni-due.de'
name = 'Networked Embedded Systems'
url = 'https://www.nes.uni-due.de'
}
license {
url = 'https://www.mowesta.com/license'
name = 'Mowesta License'
}
}
swaggerFileName = 'mowesta'
swaggerDirectory = "${project.buildDir}/swagger"
securityDefinition {
name = 'device'
description = 'Operations requiring device privileges.'
type = 'apiKey'
keyLocation = 'header'
keyName = 'Authorization'
}
securityDefinition {
name = 'user'
description = 'Operations requiring a valid user.'
type = 'basic'
}
securityDefinition {
name = 'admin'
description = 'Operations requiring admin privileges.'
type = 'basic'
}
}
build {
dependsOn 'resolve'
}
build.dependsOn("generateSwaggerDocumentation")
publish.dependsOn("generateSwaggerDocumentation")
// add the swagger defintion to the artifacts published by this module
publishing {
publications {
@@ -3,18 +3,19 @@ package com.mowesta.api;
import java.util.ArrayList;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* A wrapper class that technically represents an array of
@@ -32,7 +33,7 @@ import io.swagger.annotations.ApiModel;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description = "Represents a list of elements.")
@Schema(description = "Represents a list of elements.")
public class Batch<T> {
/**
@@ -43,6 +44,7 @@ public class Batch<T> {
@XmlElementWrapper
@XmlElement(name="element")
@JsonProperty(value="elements")
@Schema(description = "The elements contained in this batch.")
private List<T> elements = new ArrayList<>();
/**
@@ -1,14 +1,14 @@
package com.mowesta.api;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* A WGS84 coordinate.
@@ -22,21 +22,21 @@ import io.swagger.annotations.ApiModelProperty;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description = "Represents a wgs84 coordinate.")
@Schema(description = "Represents a wgs84 coordinate.")
public class Coordinate {
/**
* The latitude.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value = "The latitude of the coordinate.", required = true)
@Schema(description = "The latitude of the coordinate.", requiredMode = RequiredMode.REQUIRED)
private double latitude;
/**
* The longitude.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value = "The longitude of the coordinate.", required = true)
@Schema(description = "The longitude of the coordinate.", requiredMode = RequiredMode.REQUIRED)
private double longitude;
/**
@@ -2,15 +2,14 @@ package com.mowesta.api;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
/**
@@ -27,35 +26,35 @@ import io.swagger.annotations.ApiModelProperty;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description="Represents an entity.")
@Schema(description="Represents an entity.")
public class Entity {
/**
* The unique identifier of the data.
*/
@XmlAttribute
@ApiModelProperty(value="The unique identifier of the data.")
@Schema(description="The unique identifier of the data.")
private long id;
/**
* The time stamp when the data was created.
*/
@XmlAttribute
@ApiModelProperty(value="The time stamp when the data was created.")
@Schema(description="The time stamp when the data was created.")
private long creationTime;
/**
* The time stamp when the data was last modified.
*/
@XmlAttribute
@ApiModelProperty(value="The time stamp when the data was last modified.")
@Schema(description="The time stamp when the data was last modified.")
private long modificationTime;
/**
* A flag to indicate whether the data was deleted.
*/
@XmlAttribute
@ApiModelProperty(value="A flag to indicate whether the data was deleted.")
@Schema(description="A flag to indicate whether the data was deleted.")
private boolean deleted;
/**
@@ -0,0 +1,239 @@
package com.mowesta.api;
/**
* A stringified list of http status codes to simplfy the use of swagger. These
* are the status codes that are defined as integer in HttpServletResponse.
*
* @author marcus
*/
public interface HttpStatus {
/**
* Status code (100) indicating the client can continue.
*/
public static final String CONTINUE = "100";
/**
* Status code (101) indicating the server is switching protocols according to Upgrade header.
*/
public static final String SWITCHING_PROTOCOLS = "101";
/**
* Status code (200) indicating the request succeeded normally.
*/
public static final String OK = "200";
/**
* Status code (201) indicating the request succeeded and created a new resource on the server.
*/
public static final String CREATED = "201";
/**
* Status code (202) indicating that a request was accepted for processing, but was not completed.
*/
public static final String ACCEPTED = "202";
/**
* Status code (203) indicating that the meta information presented by the client did not originate from the server.
*/
public static final String NON_AUTHORITATIVE_INFORMATION = "203";
/**
* Status code (204) indicating that the request succeeded but that there was no new information to return.
*/
public static final String NO_CONTENT = "204";
/**
* Status code (205) indicating that the agent <em>SHOULD</em> reset the document view which caused the request to be
* sent.
*/
public static final String RESET_CONTENT = "205";
/**
* Status code (206) indicating that the server has fulfilled the partial GET request for the resource.
*/
public static final String PARTIAL_CONTENT = "206";
/**
* Status code (300) indicating that the requested resource corresponds to any one of a set of representations, each
* with its own specific location.
*/
public static final String MULTIPLE_CHOICES = "300";
/**
* Status code (301) indicating that the resource has permanently moved to a new location, and that future references
* should use a new URI with their requests.
*/
public static final String MOVED_PERMANENTLY = "301";
/**
* Status code (302) indicating that the resource has temporarily moved to another location, but that future references
* should still use the original URI to access the resource.
*
* This definition is being retained for backwards compatibility. FOUND is now the preferred definition.
*/
public static final String MOVED_TEMPORARILY = "302";
/**
* Status code (302) indicating that the resource reside temporarily under a different URI. Since the redirection might
* be altered on occasion, the client should continue to use the Request-URI for future requests.(HTTP/1.1) To represent
* the status code (302), it is recommended to use this variable.
*/
public static final String FOUND = "302";
/**
* Status code (303) indicating that the response to the request can be found under a different URI.
*/
public static final String SEE_OTHER = "303";
/**
* Status code (304) indicating that a conditional GET operation found that the resource was available and not modified.
*/
public static final String NOT_MODIFIED = "304";
/**
* Status code (305) indicating that the requested resource <em>MUST</em> be accessed through the proxy given by the
* <code><em>Location</em></code> field.
*/
public static final String USE_PROXY = "305";
/**
* Status code (307) indicating that the requested resource resides temporarily under a different URI. The temporary URI
* <em>SHOULD</em> be given by the <code><em>Location</em></code> field in the response.
*/
public static final String TEMPORARY_REDIRECT = "307";
/**
* Status code (400) indicating the request sent by the client was syntactically incorrect.
*/
public static final String BAD_REQUEST = "400";
/**
* Status code (401) indicating that the request requires HTTP authentication.
*/
public static final String UNAUTHORIZED = "401";
/**
* Status code (402) reserved for future use.
*/
public static final String PAYMENT_REQUIRED = "402";
/**
* Status code (403) indicating the server understood the request but refused to fulfill it.
*/
public static final String FORBIDDEN = "403";
/**
* Status code (404) indicating that the requested resource is not available.
*/
public static final String NOT_FOUND = "404";
/**
* Status code (405) indicating that the method specified in the <code><em>Request-Line</em></code> is not allowed for
* the resource identified by the <code><em>Request-URI</em></code>.
*/
public static final String METHOD_NOT_ALLOWED = "405";
/**
* Status code (406) indicating that the resource identified by the request is only capable of generating response
* entities which have content characteristics not acceptable according to the accept headers sent in the request.
*/
public static final String NOT_ACCEPTABLE = "406";
/**
* Status code (407) indicating that the client <em>MUST</em> first authenticate itself with the proxy.
*/
public static final String PROXY_AUTHENTICATION_REQUIRED = "407";
/**
* Status code (408) indicating that the client did not produce a request within the time that the server was prepared
* to wait.
*/
public static final String REQUEST_TIMEOUT = "408";
/**
* Status code (409) indicating that the request could not be completed due to a conflict with the current state of the
* resource.
*/
public static final String CONFLICT = "409";
/**
* Status code (410) indicating that the resource is no longer available at the server and no forwarding address is
* known. This condition <em>SHOULD</em> be considered permanent.
*/
public static final String GONE = "410";
/**
* Status code (411) indicating that the request cannot be handled without a defined
* <code><em>Content-Length</em></code>.
*/
public static final String LENGTH_REQUIRED = "411";
/**
* Status code (412) indicating that the precondition given in one or more of the request-header fields evaluated to
* false when it was tested on the server.
*/
public static final String PRECONDITION_FAILED = "412";
/**
* Status code (413) indicating that the server is refusing to process the request because the request entity is larger
* than the server is willing or able to process.
*/
public static final String REQUEST_ENTITY_TOO_LARGE = "413";
/**
* Status code (414) indicating that the server is refusing to service the request because the
* <code><em>Request-URI</em></code> is longer than the server is willing to interpret.
*/
public static final String REQUEST_URI_TOO_LONG = "414";
/**
* Status code (415) indicating that the server is refusing to service the request because the entity of the request is
* in a format not supported by the requested resource for the requested method.
*/
public static final String UNSUPPORTED_MEDIA_TYPE = "415";
/**
* Status code (416) indicating that the server cannot serve the requested byte range.
*/
public static final String REQUESTED_RANGE_NOT_SATISFIABLE = "416";
/**
* Status code (417) indicating that the server could not meet the expectation given in the Expect request header.
*/
public static final String EXPECTATION_FAILED = "417";
/**
* Status code (500) indicating an error inside the HTTP server which prevented it from fulfilling the request.
*/
public static final String INTERNAL_SERVER_ERROR = "500";
/**
* Status code (501) indicating the HTTP server does not support the functionality needed to fulfill the request.
*/
public static final String NOT_IMPLEMENTED = "501";
/**
* Status code (502) indicating that the HTTP server received an invalid response from a server it consulted when acting
* as a proxy or gateway.
*/
public static final String BAD_GATEWAY = "502";
/**
* Status code (503) indicating that the HTTP server is temporarily overloaded, and unable to handle the request.
*/
public static final String SERVICE_UNAVAILABLE = "503";
/**
* Status code (504) indicating that the server did not receive a timely response from the upstream server while acting
* as a gateway or proxy.
*/
public static final String GATEWAY_TIMEOUT = "504";
/**
* Status code (505) indicating that the server does not support or refuses to support the HTTP protocol version that
* was used in the request message.
*/
public static final String HTTP_VERSION_NOT_SUPPORTED = "505";
}
@@ -3,20 +3,20 @@ package com.mowesta.api;
import java.util.ArrayList;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* An abstract base class for pages.
@@ -32,28 +32,28 @@ import io.swagger.annotations.ApiModelProperty;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description="Represents a page.")
@Schema(description="Represents a page.")
public abstract class Page<T> {
/**
* The size of the page, i.e. the maximum number of elements.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The maximum number of elements on the page.", required=true)
@Schema(description="The maximum number of elements on the page.", requiredMode = RequiredMode.REQUIRED)
private int size;
/**
* The offset of the elements (0-based).
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The page offset (0-based) in number of elements.", required=true)
@Schema(description="The page offset (0-based) in number of elements.", requiredMode = RequiredMode.REQUIRED)
private int offset;
/**
* The total number of elements available.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The total number of elements available.", required=true)
@Schema(description="The total number of elements available.", requiredMode = RequiredMode.REQUIRED)
private int total;
/**
@@ -64,7 +64,7 @@ public abstract class Page<T> {
@XmlElementWrapper
@XmlElement(name="element")
@JsonProperty(value="elements") // force jackson to keep the name
@ApiModelProperty(value="The elements of the page.", required=true)
@Schema(description="The elements of the page.", requiredMode = RequiredMode.REQUIRED)
private List<T> elements = new ArrayList<>();
/**
@@ -1,11 +1,10 @@
package com.mowesta.api;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.QueryParam;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.QueryParam;
/**
* A bean parameter to configure a page.
@@ -37,7 +36,7 @@ public class PageConfig {
/**
* The page offset in terms of elements.
*/
@ApiParam(name="pageOffset", value="The offset in terms of elements.", defaultValue="0")
@Parameter(name="pageOffset", description = "The offset in terms of elements.")
@Min(0)
@QueryParam("pageOffset")
@DefaultValue("0")
@@ -46,7 +45,7 @@ public class PageConfig {
/**
* The maximum number of elements on the page.
*/
@ApiParam(name="pageSize", value="The maximum number of elements on the page.", defaultValue="20", allowableValues="range[1,1000]")
@Parameter(name="pageSize", description="The maximum number of elements on the page.")
@Min(1)
@Max(1000)
@QueryParam("pageSize")
@@ -1,9 +1,9 @@
package com.mowesta.api;
import javax.validation.constraints.NotNull;
import javax.ws.rs.QueryParam;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.QueryParam;
import io.swagger.annotations.ApiParam;
/**
* The context of a search.
@@ -17,14 +17,14 @@ public class SearchContext {
*/
@NotNull
@QueryParam("language")
@ApiParam(value="The language of the user interface.", allowableValues = "de, en, es, fr, it", example = "de", required = true)
@Parameter(description="The language of the user interface.", example = "de", required = true)
private Language language;
/**
* The (optional) location of the user.
*/
@QueryParam("location")
@ApiParam(value="The optional position of the user specified as longitude,latitude.", example = "7.065991,50.779012", required = false)
@Parameter(description="The optional position of the user specified as longitude,latitude.", example = "7.065991,50.779012", required = false)
private Coordinate location;
/**
@@ -1,9 +1,9 @@
package com.mowesta.api;
import javax.validation.constraints.Min;
import javax.ws.rs.QueryParam;
import jakarta.validation.constraints.Min;
import jakarta.ws.rs.QueryParam;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Parameter;
/**
* A bean parameter to avoid repeated definition of time ranges. This simplifies
@@ -17,14 +17,14 @@ public class TimeRange {
/**
* The start time of the time range in Epoch milliseconds.
*/
@ApiParam(value = "The start time in Epoch milliseconds.", example="1576921935000", required = true)
@Parameter(description = "The start time in Epoch milliseconds.", example="1576921935000", required = true)
@QueryParam("start") long start;
/**
* The duration of the time range in milliseconds.
*/
@Min(value = 0)
@ApiParam(value = "The duration in milliseconds.", example = "60000", allowableValues = "range[0, infinity]", required = true)
@Parameter(description = "The duration in milliseconds.", example = "60000", required = true)
@QueryParam("duration") long duration;
/**
@@ -1,13 +1,13 @@
package com.mowesta.api.device;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.mowesta.api.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* * A data transfer object for a device with associated swagger and jaxb
@@ -16,14 +16,14 @@ import io.swagger.annotations.ApiModelProperty;
* @author Ole
*/
@XmlRootElement
@ApiModel(description = "Represents a device.", parent = Entity.class)
@Schema(description = "Represents a device.", allOf = Entity.class)
public class Device extends Entity {
/**
* The owning user or null.
*/
@XmlAttribute
@ApiModelProperty(value="The id of the owning user or null, if there is none.")
@Schema(description="The id of the owning user or null, if there is none.")
private Long user;
/**
@@ -31,28 +31,28 @@ public class Device extends Entity {
*/
@NotNull
@XmlAttribute(required=true)
@ApiModelProperty(value="The operating system.", required=true)
@Schema(description="The operating system.", requiredMode = RequiredMode.REQUIRED)
private OperatingSystem os;
/**
* The manufacturer name.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The manufacturer name, see android.os.Build.MANUFACTURER.", required=true)
@Schema(description="The manufacturer name, see android.os.Build.MANUFACTURER.", requiredMode = RequiredMode.REQUIRED)
private String manufacturer;
/**
* The device name (industrial design).
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The device name, see android.os.Build.DEVICE.", required=true)
@Schema(description="The device name, see android.os.Build.DEVICE.", requiredMode = RequiredMode.REQUIRED)
private String device;
/**
* The model name.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The model name, see android.os.Build.MODEL.", required=true)
@Schema(description="The model name, see android.os.Build.MODEL.", requiredMode = RequiredMode.REQUIRED)
private String model;
/**
@@ -1,10 +1,10 @@
package com.mowesta.api.device;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Represents a device with it's secret auth token assigned by the server
@@ -13,14 +13,14 @@ import io.swagger.annotations.ApiModelProperty;
* @author Marcus
*/
@XmlRootElement
@ApiModel(description = "Represents a device with a secret token.", parent = Device.class)
@Schema(description = "Represents a device with a secret token.", allOf = Device.class)
public class DeviceHandle extends Device {
/**
* The secret token used for authenticating the device.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value = "The secret token used for authenticating the device.", required = true)
@Schema(description = "The secret token used for authenticating the device.", requiredMode = RequiredMode.REQUIRED)
private String token;
/**
@@ -1,15 +1,15 @@
package com.mowesta.api.device;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* A device registration is used to register a device.
@@ -23,7 +23,7 @@ import io.swagger.annotations.ApiModelProperty;
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@XmlRootElement
@ApiModel(description = "Represents information about a device.")
@Schema(description = "Represents information about a device.")
public class DeviceInfo {
/**
@@ -31,28 +31,28 @@ public class DeviceInfo {
*/
@NotNull
@XmlAttribute(required=true)
@ApiModelProperty(value="The operating system.", required=true)
@Schema(description="The operating system.", requiredMode = RequiredMode.REQUIRED)
private OperatingSystem os;
/**
* The manufacturer name.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The manufacturer name, see android.os.Build.MANUFACTURER.", required=true)
@Schema(description="The manufacturer name, see android.os.Build.MANUFACTURER.", requiredMode = RequiredMode.REQUIRED)
private String manufacturer;
/**
* The device name (industrial design).
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The device name, see android.os.Build.DEVICE.", required=true)
@Schema(description="The device name, see android.os.Build.DEVICE.", requiredMode = RequiredMode.REQUIRED)
private String device;
/**
* The model name.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The model name, see android.os.Build.MODEL.", required=true)
@Schema(description="The model name, see android.os.Build.MODEL.", requiredMode = RequiredMode.REQUIRED)
private String model;
/**
@@ -1,9 +1,8 @@
package com.mowesta.api.device;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
import com.mowesta.api.Page;
@@ -14,6 +13,6 @@ import com.mowesta.api.Page;
*/
@XmlRootElement
@XmlSeeAlso(Device.class)
@ApiModel(description = "Represents a page of devices.", parent = Page.class)
@Schema(description = "Represents a page of devices.", allOf = Page.class)
public class DevicePage extends Page<Device> {
}
@@ -1,41 +1,40 @@
package com.mowesta.api.device;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.ws.rs.BeanParam;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.annotation.security.PermitAll;
import jakarta.annotation.security.RolesAllowed;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.BeanParam;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import com.mowesta.api.HttpStatus;
import com.mowesta.api.PageConfig;
import com.mowesta.api.Tags;
import com.mowesta.api.access.Authorizations;
import com.mowesta.api.access.Roles;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
/**
* A service to manage devices.
*
* @author Ole
*/
@Api
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/")
@@ -51,16 +50,18 @@ public interface IDeviceService {
*/
@POST
@Path("devices")
@ApiOperation(value = "Creates a new device and returns its handle.",
notes = "The response will include the auth token to be stored on the device and supplied as authentication " +
"on all subsequent api calls. Note that the auth token can not be requested after creation, " +
"so when losing the auth token you may lose access to the device data.",
tags = {Tags.DEFAULT, Tags.DEVICE})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_CREATED, message = "The device was created successfully.", response = DeviceHandle.class)
})
@Operation(summary = "Creates a new device and returns its handle.",
description = "The response will include the auth token to be stored on the device and supplied as authentication " +
"on all subsequent api calls. Note that the auth token can not be requested after creation, " +
"so when losing the auth token you may lose access to the device data.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.CREATED, description = "The device was created successfully.",
content = @Content(schema=@Schema(implementation = DeviceHandle.class)))
}
)
@PermitAll
Response createDevice(@ApiParam(value = "Necessary data from to create a device.", required = true) @NotNull @Valid DeviceInfo info);
Response createDevice(@Parameter(description = "Necessary data from to create a device.", required = true) @NotNull @Valid DeviceInfo info);
/**
@@ -71,17 +72,21 @@ public interface IDeviceService {
*/
@POST
@Path("devices/current/user")
@ApiOperation(value = "Connects a device created without user account with a user account.",
notes = "Executing this is operation requires a valid device and a valid user authentication to be transmitted simultaneously. ",
tags = {Tags.DEFAULT, Tags.DEVICE})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "The device or user credentials are missing or incorrect."),
@ApiResponse(code = HttpServletResponse.SC_CONFLICT, message = "The device is already connected to a user account.", response=Device.class),
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The device has been connected to the user account.", response=Device.class),
})
@Operation(summary = "Connects a device created without user account with a user account.",
description = "Executing this is operation requires a valid device and a valid user authentication to be transmitted simultaneously.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "The device has been connected to the user account.",
content = @Content(schema=@Schema(implementation = Device.class))),
@ApiResponse(responseCode = HttpStatus.CONFLICT, description = "The device is already connected to a user account.",
content = @Content(schema=@Schema(implementation = Device.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "The device or user credentials are missing or incorrect.")
},
security = { @SecurityRequirement(name = Authorizations.DEVICE), @SecurityRequirement(name = Authorizations.USER) }
)
@PermitAll
@RolesAllowed({Roles.DEVICE, Roles.USER})
Response setCurrentDeviceUser(@ApiParam(value = "The device data.", required = true)@NotNull @Valid Device device);
Response setCurrentDeviceUser(@Parameter(description = "The device data.", required = true)@NotNull @Valid Device device);
/**
* Returns the current device.
@@ -90,12 +95,16 @@ public interface IDeviceService {
*/
@GET
@Path("devices/current")
@ApiOperation(value = "Returns the current device.", authorizations = {@Authorization(Authorizations.DEVICE)}, tags = {Tags.DEFAULT, Tags.DEVICE})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The operation was successful.", response= Device.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device was not found."),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
})
@Operation(summary = "Returns the current device.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Device retrieved successfully.",
content = @Content(schema=@Schema(implementation = Device.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "Device id does not exist."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges.")
},
security = @SecurityRequirement(name = Authorizations.DEVICE)
)
@RolesAllowed({Roles.DEVICE})
Response getCurrentDevice();
@@ -106,12 +115,15 @@ public interface IDeviceService {
*/
@DELETE
@Path("devices/current")
@ApiOperation(value = "Deletes the current device.", authorizations = {@Authorization(Authorizations.DEVICE)}, tags = {Tags.DEFAULT, Tags.DEVICE})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The device was deleted successfully."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device was not found."),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
})
@Operation(summary = "Returns the current device.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "The device was deleted successfully."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "Device id does not exist."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges.")
},
security = @SecurityRequirement(name = Authorizations.DEVICE)
)
@RolesAllowed({Roles.DEVICE})
Response deleteCurrentDevice();
@@ -125,12 +137,15 @@ public interface IDeviceService {
*/
@GET
@Path("users/current/devices")
@ApiOperation(value = "Returns the list of devices for the current user.", authorizations = {@Authorization(Authorizations.USER)}, tags = {Tags.DEFAULT, Tags.DEVICE})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The list of devices of the current user", response=DevicePage.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device was not found."),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
})
@Operation(summary = "Returns a page of devices for the current user.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Device page retrieved successfully.",
content = @Content(schema=@Schema(implementation = DevicePage.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges.")
},
security = @SecurityRequirement(name = Authorizations.USER)
)
@RolesAllowed({Roles.USER})
Response getCurrentUserDevices(@BeanParam @Valid PageConfig config);
@@ -144,14 +159,17 @@ public interface IDeviceService {
*/
@DELETE
@Path("devices/{id: [0-9]+}")
@ApiOperation(value = "Deletes a device and it's visits.", authorizations = {@Authorization(Authorizations.USER), @Authorization(Authorizations.ADMIN)}, tags = {Tags.DEFAULT, Tags.DEVICE})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The device was deleted successfully."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device does not exists."),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
})
@Operation(summary = "Deletes a device and it's data.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "The device was deleted successfully."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "Device id does not exist."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges.")
},
security = { @SecurityRequirement(name = Authorizations.USER), @SecurityRequirement(name = Authorizations.ADMIN) }
)
@RolesAllowed({Roles.USER, Roles.ADMIN})
Response deleteDevice(@ApiParam(value = "The device id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response deleteDevice(@Parameter(description = "The device id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
@@ -162,14 +180,18 @@ public interface IDeviceService {
*/
@GET
@Path("devices/{id: [0-9]+}")
@ApiOperation(value = "Gets a device.", authorizations = {@Authorization(Authorizations.ADMIN), @Authorization(Authorizations.USER)}, tags = {Tags.DEFAULT, Tags.DEVICE})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The device returned successfully.", response=Device.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device does not exists."),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
})
@Operation(summary = "Gets a device.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "The device returned successfully.",
content = @Content(schema=@Schema(implementation = Device.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "Device id does not exist."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges.")
},
security = { @SecurityRequirement(name = Authorizations.USER), @SecurityRequirement(name = Authorizations.ADMIN) }
)
@RolesAllowed({Roles.USER, Roles.ADMIN})
Response getDevice(@ApiParam(value = "The device id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getDevice(@Parameter(description = "The device id.", required = true) @PathParam("id") @Valid @Min(0) long id);
// admin functions
@@ -182,12 +204,16 @@ public interface IDeviceService {
*/
@GET
@Path("devices")
@ApiOperation(value = "Returns all devices.", authorizations = @Authorization(Authorizations.ADMIN), tags = {Tags.DEFAULT, Tags.DEVICE})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The request was successful.", response = DevicePage.class),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for retrieval."),
@ApiResponse(code = HttpServletResponse.SC_BAD_REQUEST, message = "Invalid request parameter.")
})
@Operation(summary = "Gets a device.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Device page retrieved successfully.",
content = @Content(schema=@Schema(implementation = DevicePage.class))),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid request parameter."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges.")
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
@RolesAllowed({Roles.ADMIN})
Response getDevices(@BeanParam @Valid PageConfig pageConfig);
@@ -201,14 +227,18 @@ public interface IDeviceService {
*/
@PUT
@Path("devices/{id: [0-9]+}")
@ApiOperation(value = "Sets the values of a device.", authorizations = {@Authorization(Authorizations.ADMIN)}, tags = {Tags.DEFAULT, Tags.DEVICE})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The device returned successfully.", response=Device.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The device does not exists."),
@ApiResponse(code = HttpServletResponse.SC_CONFLICT, message = "The device has been updated in parallel."),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges for executing this method.")
})
@Operation(summary = "Sets the values of a device.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Device updated successfully.",
content = @Content(schema=@Schema(implementation = Device.class))),
@ApiResponse(responseCode = HttpStatus.CONFLICT, description = "Parallel device modification.",
content = @Content(schema=@Schema(implementation = Device.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "Device id does not exist."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges.")
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
@RolesAllowed({Roles.ADMIN})
Response setDevice(@ApiParam(value = "The device id.", required = true) @PathParam("id") @Valid @Min(0) long id, @ApiParam("The device values.") @Valid @NotNull Device device);
Response setDevice(@Parameter(description = "The device id.", required = true) @PathParam("id") @Valid @Min(0) long id, @Parameter(description = "The device values.") @Valid @NotNull Device device);
}
@@ -1,12 +1,12 @@
package com.mowesta.api.location;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Represents a city with full details.
@@ -14,7 +14,7 @@ import io.swagger.annotations.ApiModelProperty;
* @author Marcus
*/
@XmlRootElement
@ApiModel(description = "Represents a city with all details.", parent = Location.class)
@Schema(description = "Represents a city with all details.", allOf = Location.class)
public class City extends Location {
/**
@@ -22,28 +22,28 @@ public class City extends Location {
*/
@NotNull
@XmlAttribute(required = true)
@ApiModelProperty(value = "The timezone of the city.", required = true)
@Schema(description = "The timezone of the city.", requiredMode = RequiredMode.REQUIRED)
private String timezone;
/**
* A flag to indicate whether this is the capital of the country.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value = "A flag to indicate whether the city is a capital.", required = true)
@Schema(description = "A flag to indicate whether the city is a capital.", requiredMode = RequiredMode.REQUIRED)
private boolean capital;
/**
* The optional population of the city.
*/
@XmlAttribute(required = false)
@ApiModelProperty(value = "The population of the city.", required = false)
@Schema(description = "The population of the city.", requiredMode = RequiredMode.NOT_REQUIRED)
private Integer population;
/**
* The optional wikipedia entry.
*/
@XmlAttribute(required = false)
@ApiModelProperty(value = "The optional wikipedia entry of the city.", required = false)
@Schema(description = "The optional wikipedia entry of the city.", requiredMode = RequiredMode.NOT_REQUIRED)
private String wikipedia;
/**
@@ -51,7 +51,7 @@ public class City extends Location {
*/
@NotNull
@XmlAttribute(required = true)
@ApiModelProperty(value = "The type of the city.", required = true)
@Schema(description = "The type of the city.", requiredMode = RequiredMode.NOT_REQUIRED)
private CityType type;
/**
@@ -59,14 +59,14 @@ public class City extends Location {
*/
@NotNull
@XmlElement(required = false)
@ApiModelProperty(value = "The country of the city.", required = false)
@Schema(description = "The country of the city.", requiredMode = RequiredMode.NOT_REQUIRED)
private Country country;
/**
* The state of the city.
*/
@XmlElement(required = false)
@ApiModelProperty(value = "The state of the city.", required = false)
@Schema(description = "The state of the city.", requiredMode = RequiredMode.NOT_REQUIRED)
private State state;
/**
@@ -1,11 +1,11 @@
package com.mowesta.api.location;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
import com.mowesta.api.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* A page of cities.
@@ -14,7 +14,7 @@ import io.swagger.annotations.ApiModel;
*/
@XmlRootElement
@XmlSeeAlso(City.class)
@ApiModel(description = "Represents a page of cities.", parent = Page.class)
@Schema(description = "Represents a page of cities.", allOf = Page.class)
public class CityPage extends Page<City> {
}
@@ -1,8 +1,8 @@
package com.mowesta.api.location;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Represents a country.
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModel;
* @author Marcus
*/
@XmlRootElement
@ApiModel(description = "Represents a country with all details.", parent = Location.class)
@Schema(description = "Represents a country with all details.", allOf = Location.class)
public class Country extends Location {
}
@@ -1,11 +1,11 @@
package com.mowesta.api.location;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
import com.mowesta.api.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Represents a page of countries.
@@ -14,7 +14,7 @@ import io.swagger.annotations.ApiModel;
*/
@XmlRootElement
@XmlSeeAlso(Country.class)
@ApiModel(description = "Represents a page of countries.", parent = Page.class)
@Schema(description = "Represents a page of countries.", allOf = Page.class)
public class CountryPage extends Page<Country> {
}
@@ -1,38 +1,37 @@
package com.mowesta.api.location;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.ws.rs.BeanParam;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.annotation.security.PermitAll;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.BeanParam;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
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.MediaType;
import jakarta.ws.rs.core.Response;
import org.geojson.Geometry;
import com.mowesta.api.HttpStatus;
import com.mowesta.api.PageConfig;
import com.mowesta.api.SearchContext;
import com.mowesta.api.Tags;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* The api to query and fetch locations.
*
* @author Marcus
*/
@Api
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/")
@@ -49,14 +48,17 @@ public interface ILocationService {
*/
@GET
@Path("locations/search")
@ApiOperation(value = "Returns a page of locations whose name matches the term.", tags = { Tags.DEFAULT, Tags.LOCATION })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="Location hierarchy page retrieved successfully.", response=LocationHierarchyPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
@Operation(summary = "Returns a page of locations whose name matches the term.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Location hierarchy page retrieved successfully.",
content = @Content(schema=@Schema(implementation = LocationHierarchyPage.class))),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid request parameter.")
}
)
@PermitAll
Response searchLocations(@BeanParam @Valid PageConfig pageConfig, @BeanParam @Valid SearchContext context,
@ApiParam(value="The search term.", required=true) @QueryParam("term") @NotNull @Valid String term);
@Parameter(description="The search term.", required=true) @QueryParam("term") @NotNull @Valid String term);
/**
* Searches for a particular city by name.
@@ -68,14 +70,17 @@ public interface ILocationService {
*/
@GET
@Path("cities/search")
@ApiOperation(value = "Returns a page of cities that match the specified search term.", tags = { Tags.DEFAULT, Tags.LOCATION })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="The page of cities.", response=CityPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
@Operation(summary = "Returns a page of cities that match the specified search term.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "The page of cities.",
content = @Content(schema=@Schema(implementation = CityPage.class))),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid request parameter.")
}
)
@PermitAll
Response searchCities(@BeanParam @Valid PageConfig pageConfig, @BeanParam @Valid SearchContext context,
@ApiParam(value="The search term.", required=true) @QueryParam("term") @NotNull @Valid String term);
@Parameter(description="The search term.", required=true) @QueryParam("term") @NotNull @Valid String term);
/**
@@ -90,17 +95,20 @@ public interface ILocationService {
*/
@GET
@Path("cities/resolve")
@ApiOperation(value = "Returns a page of cities within a certain area defined by two coordiantes.", tags = { Tags.DEFAULT, Tags.LOCATION })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="The page of cities.", response=CityPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
@Operation(summary ="Returns a page of cities within a certain area defined by two coordiantes.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "The page of cities.",
content = @Content(schema=@Schema(implementation = CityPage.class))),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid request parameter.")
}
)
@PermitAll
Response resolveCities(@BeanParam @Valid PageConfig pageConfig,
@ApiParam(value = "The longitude of the first coordinate.", required = true) @QueryParam("longitude1") double longitude1,
@ApiParam(value = "The latitude of the first coordinate.", required = true) @QueryParam("latitude1") double latitude1,
@ApiParam(value = "The longitude of the second coordinate.", required = true) @QueryParam("longitude2") double longitude2,
@ApiParam(value = "The latitude of the second coordinate.", required = true) @QueryParam("latitude2") double latitude2);
@Parameter(description = "The longitude of the first coordinate.", required = true) @QueryParam("longitude1") double longitude1,
@Parameter(description = "The latitude of the first coordinate.", required = true) @QueryParam("latitude1") double latitude1,
@Parameter(description = "The longitude of the second coordinate.", required = true) @QueryParam("longitude2") double longitude2,
@Parameter(description = "The latitude of the second coordinate.", required = true) @QueryParam("latitude2") double latitude2);
/**
* Returns a page of cities.
@@ -110,11 +118,14 @@ public interface ILocationService {
*/
@GET
@Path("cities")
@ApiOperation(value = "Returns a page of cities.", tags = { Tags.DEFAULT, Tags.LOCATION })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="City page retrieved successfully.", response=CityPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
@Operation(summary ="Returns a page of cities.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "The page of cities.",
content = @Content(schema=@Schema(implementation = CityPage.class))),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid request parameter.")
}
)
@PermitAll
Response getCities(@BeanParam @Valid PageConfig pageConfig);
@@ -126,13 +137,16 @@ public interface ILocationService {
*/
@GET
@Path("cities/{id: [0-9]+}")
@ApiOperation(value = "Gets a city with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "City retrieved successfully.", response=City.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The city does not exists."),
})
@Operation(summary = "Gets a city with a particular id.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "City retrieved successfully.",
content = @Content(schema=@Schema(implementation = City.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "The city id does not exists.")
}
)
@PermitAll
Response getCity(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getCity(@Parameter(description = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
* Returns a geojson representation of the city boundaries.
@@ -142,15 +156,18 @@ public interface ILocationService {
*/
@GET
@Path("cities/{id: [0-9]+}/boundary")
@ApiOperation(value = "Gets the city boundary for a city with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "City boundary retrieved successfully.", response=Geometry.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "The city boundary are not available."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The city does not exist."),
})
@Operation(summary = "Gets the city boundary for a city with a particular id.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "City boundary retrieved successfully.",
content = @Content(schema=@Schema(implementation = Geometry.class))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "The city boundary is not available."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "The city id does not exists.")
}
)
@PermitAll
@Produces({MediaType.APPLICATION_JSON})
Response getCityBoundary(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getCityBoundary(@Parameter(description = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
@@ -161,11 +178,14 @@ public interface ILocationService {
*/
@GET
@Path("states")
@ApiOperation(value = "Returns a page of states.", tags = { Tags.DEFAULT, Tags.LOCATION })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="State page retrieved successfully.", response=StatePage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
@Operation(summary = "Returns a page of states.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "State page retrieved successfully.",
content = @Content(schema=@Schema(implementation = StatePage.class))),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid request parameter.")
}
)
@PermitAll
Response getStates(@BeanParam @Valid PageConfig pageConfig);
@@ -177,13 +197,16 @@ public interface ILocationService {
*/
@GET
@Path("states/{id: [0-9]+}")
@ApiOperation(value = "Gets a state with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "State retrieved successfully.", response=State.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The state does not exists."),
})
@Operation(summary = "Gets a state with a particular id.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "State retrieved successfully.",
content = @Content(schema=@Schema(implementation = State.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "The state does not exists.")
}
)
@PermitAll
Response getState(@ApiParam(value = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getState(@Parameter(description = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
* Returns a geojson representation of the state boundaries.
@@ -193,15 +216,18 @@ public interface ILocationService {
*/
@GET
@Path("states/{id: [0-9]+}/boundary")
@ApiOperation(value = "Gets the state boundary for a state with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "State boundary retrieved successfully.", response=Geometry.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "The state boundary are not available."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The state does not exist."),
})
@Operation(summary = "Gets the state boundary for a state with a particular id.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "State boundary retrieved successfully.",
content = @Content(schema=@Schema(implementation = Geometry.class))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "The state boundary is not available."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "The state id does not exists.")
}
)
@PermitAll
@Produces({MediaType.APPLICATION_JSON})
Response getStateBoundary(@ApiParam(value = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getStateBoundary(@Parameter(description = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
* The deprecated version of the method that has a typo in the path name (state instead of states).
@@ -212,16 +238,19 @@ public interface ILocationService {
*/
@GET
@Path("state/{id: [0-9]+}/boundary")
@ApiOperation(value = "Deprecated: Gets the state boundary for a state with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "State boundary retrieved successfully.", response=Geometry.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "The state boundary are not available."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The state does not exist."),
})
@Operation(summary = "Gets the state boundary for a state with a particular id.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "State boundary retrieved successfully.",
content = @Content(schema=@Schema(implementation = Geometry.class))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "The state boundary is not available."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "The state id does not exists.")
}
)
@PermitAll
@Produces({MediaType.APPLICATION_JSON})
@Deprecated
Response getStateBoundaryDeprecated(@ApiParam(value = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getStateBoundaryDeprecated(@Parameter(description = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
@@ -233,13 +262,16 @@ public interface ILocationService {
*/
@GET
@Path("states/{id: [0-9]+}/cities")
@ApiOperation(value = "Gets a page of cities for a particular state ordered by importance.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Cities retrieved successfully.", response=CityPage.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The state does not exists."),
})
@Operation(summary = "Gets a page of cities for a particular state ordered by importance.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "City page retrieved successfully.",
content = @Content(schema=@Schema(implementation = CityPage.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "The state id does not exists.")
}
)
@PermitAll
Response getStateCities(@ApiParam(value = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id, @BeanParam @Valid PageConfig pageConfig);
Response getStateCities(@Parameter(description = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id, @BeanParam @Valid PageConfig pageConfig);
/**
* Returns a page of countries.
@@ -249,11 +281,14 @@ public interface ILocationService {
*/
@GET
@Path("countries")
@ApiOperation(value = "Returns a page of countries.", tags = { Tags.DEFAULT, Tags.LOCATION })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="Country page retrieved successfully.", response=CountryPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
@Operation(summary = "Returns a page of countries.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Country page retrieved successfully.",
content = @Content(schema=@Schema(implementation = CountryPage.class))),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid request parameter.")
}
)
@PermitAll
Response getCountries(@BeanParam @Valid PageConfig pageConfig);
@@ -265,13 +300,16 @@ public interface ILocationService {
*/
@GET
@Path("countries/{id: [0-9]+}")
@ApiOperation(value = "Gets a country with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Country retrieved successfully.", response=Country.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The country does not exists."),
})
@Operation(summary = "Gets a country with a particular id.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Country retrieved successfully.",
content = @Content(schema=@Schema(implementation = Country.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "The country does not exists.")
}
)
@PermitAll
Response getCountry(@ApiParam(value = "The country id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getCountry(@Parameter(description = "The country id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
* Returns a geojson representation of the country boundaries.
@@ -281,15 +319,18 @@ public interface ILocationService {
*/
@GET
@Path("countries/{id: [0-9]+}/boundary")
@ApiOperation(value = "Gets the country boundary for a country with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Country boundary retrieved successfully.", response=Geometry.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "The country boundary are not available."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The country does not exist."),
})
@Operation(summary = "Gets the country boundary for a country with a particular id.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Country boundary retrieved successfully.",
content = @Content(schema=@Schema(implementation = Geometry.class))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "The country boundary is not available."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "The country id does not exists.")
}
)
@PermitAll
@Produces({MediaType.APPLICATION_JSON})
Response getCountryBoundary(@ApiParam(value = "The country id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getCountryBoundary(@Parameter(description = "The country id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
* Returns a page of cities for a country ordered by importance.
@@ -300,13 +341,16 @@ public interface ILocationService {
*/
@GET
@Path("countries/{id: [0-9]+}/cities")
@ApiOperation(value = "Gets a page of cities for a particular country ordered by importance.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Cities retrieved successfully.", response=CityPage.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The country does not exists."),
})
@Operation(summary = "Gets a page of cities for a particular country ordered by importance.",
tags = { Tags.DEFAULT, Tags.LOCATION },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "City page retrieved successfully.",
content = @Content(schema=@Schema(implementation = CityPage.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "The country id does not exists.")
}
)
@PermitAll
Response getCountryCities(@ApiParam(value = "The country id.", required = true) @PathParam("id") @Valid @Min(0) long id, @BeanParam @Valid PageConfig pageConfig);
Response getCountryCities(@Parameter(description = "The country id.", required = true) @PathParam("id") @Valid @Min(0) long id, @BeanParam @Valid PageConfig pageConfig);
}
@@ -2,18 +2,18 @@ package com.mowesta.api.location;
import java.util.Map;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.mowesta.api.Coordinate;
import com.mowesta.api.Entity;
import com.mowesta.api.Language;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* A base class for cities, states and countries to share common
@@ -22,7 +22,7 @@ import io.swagger.annotations.ApiModelProperty;
* @author Marcus
*/
@XmlRootElement
@ApiModel(description = "Represents a location.", parent = Entity.class)
@Schema(description = "Represents a location.", allOf = Entity.class)
public class Location extends Entity {
/**
@@ -32,13 +32,13 @@ public class Location extends Entity {
@XmlElementWrapper
@XmlElement(name = "names")
@JsonProperty(value = "names")
@ApiModelProperty(value = "The names of the location by language code.")
@Schema(description = "The names of the location by language code.")
private Map<Language, String> names;
@NotNull
@XmlElement(required = true)
@ApiModelProperty(value = "The coordinate of the location.", required = true)
@Schema(description = "The coordinate of the location.", requiredMode = RequiredMode.REQUIRED)
private Coordinate coordinate;
/**
@@ -1,12 +1,12 @@
package com.mowesta.api.location;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* A location that has a parent and a type used to implement
@@ -15,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty;
* @author Marcus
*/
@XmlRootElement
@ApiModel(description = "Represents a hierarchy of locations.", parent = Location.class)
@Schema(description = "Represents a hierarchy of locations.", allOf = Location.class)
public class LocationHierarchy extends Location {
/**
@@ -23,14 +23,14 @@ public class LocationHierarchy extends Location {
*/
@NotNull
@XmlAttribute(required = true)
@ApiModelProperty(value = "The type of the location.", required = true)
@Schema(description = "The type of the location.", requiredMode = RequiredMode.REQUIRED)
private LocationType type;
/**
* The parent type (null for countries).
*/
@XmlElement(required = false)
@ApiModelProperty(value = "The parent of the location (country for states, country or state for cities, null for countries).", required = false)
@Schema(description = "The parent of the location (country for states, country or state for cities, null for countries).", requiredMode = RequiredMode.NOT_REQUIRED)
private LocationHierarchy parent;
/**
@@ -1,11 +1,11 @@
package com.mowesta.api.location;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
import com.mowesta.api.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Represents a page of location hierarchies.
@@ -14,7 +14,7 @@ import io.swagger.annotations.ApiModel;
*/
@XmlRootElement
@XmlSeeAlso(LocationHierarchy.class)
@ApiModel(description = "Represents a page of locations with their hierarchical relationship.", parent = Page.class)
@Schema(description = "Represents a page of locations with their hierarchical relationship.", allOf = Page.class)
public class LocationHierarchyPage extends Page<LocationHierarchy> {
}
@@ -1,16 +1,15 @@
package com.mowesta.api.location;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Represents a reference to a location.
@@ -24,7 +23,7 @@ import io.swagger.annotations.ApiModelProperty;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description="Represents a reference to a location.")
@Schema(description="Represents a reference to a location.")
public class LocationReference {
/**
@@ -32,14 +31,14 @@ public class LocationReference {
*/
@NotNull
@XmlAttribute(required = true)
@ApiModelProperty(value = "The location type.")
@Schema(description = "The location type.", requiredMode = RequiredMode.REQUIRED)
private LocationType type;
/**
* The location id.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value = "The location id.")
@Schema(description = "The location id.", requiredMode = RequiredMode.REQUIRED)
private long id;
/**
@@ -1,12 +1,11 @@
package com.mowesta.api.location;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
/**
* Represents a state with full details.
@@ -14,7 +13,7 @@ import javax.xml.bind.annotation.XmlRootElement;
* @author Sebastian, Tobias
*/
@XmlRootElement
@ApiModel(description = "Represents a state with all details.", parent = Location.class)
@Schema(description = "Represents a state with all details.", allOf = Location.class)
public class State extends Location {
/**
@@ -22,21 +21,21 @@ public class State extends Location {
*/
@NotNull
@XmlAttribute(required = true)
@ApiModelProperty(value = "The timezone of the state.", required = true)
@Schema(description = "The timezone of the state.", requiredMode = RequiredMode.REQUIRED)
private String timezone;
/**
* The optional population of the state.
*/
@XmlAttribute(required = false)
@ApiModelProperty(value = "The population of the state.", required = false)
@Schema(description = "The population of the state.", requiredMode = RequiredMode.NOT_REQUIRED)
private Integer population;
/**
* The optional wikipedia entry.
*/
@XmlAttribute(required = false)
@ApiModelProperty(value = "The optional wikipedia entry of the state.", required = false)
@Schema(description = "The optional wikipedia entry of the state.", requiredMode = RequiredMode.NOT_REQUIRED)
private String wikipedia;
/**
@@ -44,7 +43,7 @@ public class State extends Location {
*/
@NotNull
@XmlElement(required = false)
@ApiModelProperty(value = "The country of the state.", required = false)
@Schema(description = "The country of the state.", requiredMode = RequiredMode.NOT_REQUIRED)
private Country country;
/**
@@ -1,10 +1,9 @@
package com.mowesta.api.location;
import com.mowesta.api.Page;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
/**
* A page of states.
@@ -13,7 +12,7 @@ import javax.xml.bind.annotation.XmlSeeAlso;
*/
@XmlRootElement
@XmlSeeAlso(State.class)
@ApiModel(description = "Represents a page of states.", parent = Page.class)
@Schema(description = "Represents a page of states.", allOf = Page.class)
public class StatePage extends Page<State> {
}
@@ -1,15 +1,15 @@
package com.mowesta.api.log;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Represents statistics about the number of entities.
@@ -23,7 +23,7 @@ import io.swagger.annotations.ApiModelProperty;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description="Represents statistics about peristent entities.")
@Schema(description="Represents statistics about peristent entities.")
public class EntityStatistic {
/**
@@ -31,21 +31,21 @@ public class EntityStatistic {
*/
@NotNull
@XmlAttribute(required=true)
@ApiModelProperty(value="The name of the entity.", required=true)
@Schema(description = "The name of the entity.", requiredMode = RequiredMode.REQUIRED)
private String name;
/**
* The total number of entities.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The total number of stored entities.", required=true)
@Schema(description = "The total number of stored entities.", requiredMode = RequiredMode.REQUIRED)
private long total;
/**
* The number of deleted entities.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The number of deleted entities.", required=true)
@Schema(description = "The number of deleted entities.", requiredMode = RequiredMode.REQUIRED)
private long deleted;
/**
@@ -1,27 +1,28 @@
package com.mowesta.api.log;
import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.annotation.security.RolesAllowed;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import com.mowesta.api.HttpStatus;
import com.mowesta.api.Tags;
import com.mowesta.api.access.Authorizations;
import com.mowesta.api.access.Roles;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
/**
* A service that allows polling for log messages. A more
@@ -30,7 +31,6 @@ import io.swagger.annotations.Authorization;
*
* @author Marcus
*/
@Api
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path("/")
public interface ILogService {
@@ -43,15 +43,18 @@ public interface ILogService {
*/
@GET
@Path("log/messages")
@ApiOperation(value = "Returns a list of log messages starting from a particular id.", authorizations= { @Authorization(value=Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.SERVICE })
@Operation(summary = "Returns a list of log messages starting from a particular id.",
tags = { Tags.DEFAULT, Tags.SERVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Log messages retrieved successfully.",
content = @Content(array = @ArraySchema(schema=@Schema(implementation = LogMessage.class)))),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid request parameter."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
@RolesAllowed({Roles.ADMIN})
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="Log messages retrieved successfully.", response=LogMessage.class, responseContainer="List"),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges for retrieval."),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
Response getLogMessages(@QueryParam("from") @DefaultValue("0")
@ApiParam(value="The id of the first message to retrieve.") @Valid @Min(0) long from);
Response getLogMessages(@QueryParam("from") @DefaultValue("0") @Parameter(description = "The id of the first message to retrieve.") @Valid @Min(0) long from);
/**
* Returns a list of entity statistics for all entities.
@@ -60,12 +63,16 @@ public interface ILogService {
*/
@GET
@Path("log/entities")
@ApiOperation(value = "Returns a list of entity statistics.", authorizations= { @Authorization(value=Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.SERVICE })
@RolesAllowed({Roles.ADMIN})
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="Entity statistics retrieved successfully.", response=EntityStatistic.class, responseContainer="List"),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges for retrieval.")
})
@Operation(summary = "Returns a list of entity statistics.",
tags = { Tags.DEFAULT, Tags.SERVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Entity statistics retrieved successfully.",
content = @Content(array = @ArraySchema(schema=@Schema(implementation = EntityStatistic.class)))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
@RolesAllowed({Roles.ADMIN})
Response getEntityStatistics();
@@ -76,12 +83,16 @@ public interface ILogService {
*/
@GET
@Path("log/load")
@ApiOperation(value = "Returns the current load statistic.", authorizations= { @Authorization(value=Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.SERVICE })
@Operation(summary = "Returns the current load statistic.",
tags = { Tags.DEFAULT, Tags.SERVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Load statistic retrieved successfully.",
content = @Content(schema=@Schema(implementation = LoadStatistic.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
@RolesAllowed({Roles.ADMIN})
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="Load statistic retrieved successfully.", response=LoadStatistic.class),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges for retrieval.")
})
Response getLoadStatistic();
/**
@@ -91,11 +102,15 @@ public interface ILogService {
*/
@GET
@Path("log/system")
@ApiOperation(value = "Returns the system statistic.", authorizations= { @Authorization(value=Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.SERVICE }) @RolesAllowed({Roles.ADMIN})
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="System statistic retrieved successfully.", response=SystemStatistic.class),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges for retrieval.")
})
@Operation(summary = "Returns the system statistic.",
tags = { Tags.DEFAULT, Tags.SERVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "System statistic retrieved successfully.",
content = @Content(schema=@Schema(implementation = SystemStatistic.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
Response getSystemStatistic();
}
@@ -1,14 +1,14 @@
package com.mowesta.api.log;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Represents statistics about the system usage.
@@ -23,63 +23,63 @@ import io.swagger.annotations.ApiModelProperty;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description="Represents statistics about the system usage.")
@Schema(description="Represents statistics about the system usage.")
public class LoadStatistic {
/**
* The average cpu load over the last minute.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The average cpu load over the last minute.", required=true)
@Schema(description="The average cpu load over the last minute.", requiredMode = RequiredMode.REQUIRED)
private double cpuLoad;
/**
* The uptime of the jvm in milliseconds.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The uptime of the jvm in milliseconds.", required=true)
@Schema(description="The uptime of the jvm in milliseconds.", requiredMode = RequiredMode.REQUIRED)
private long uptime;
/**
* The number of garbage collector executions.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The total number of garbage collector executions.", required=true)
@Schema(description="The total number of garbage collector executions.", requiredMode = RequiredMode.REQUIRED)
private long gcCount;
/**
* The total time for garbage collection in milliseconds.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The total time for garbage collection in milliseconds.", required=true)
@Schema(description="The total time for garbage collection in milliseconds.", requiredMode = RequiredMode.REQUIRED)
private long gcDuration;
/**
* The maximum heap size available in bytes.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The maximum heap size available in bytes.", required=true)
@Schema(description="The maximum heap size available in bytes.", requiredMode = RequiredMode.REQUIRED)
private long maxHeapSize;
/**
* The used heap size available in bytes.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The used heap size available in bytes.", required=true)
@Schema(description="The used heap size available in bytes.", requiredMode = RequiredMode.REQUIRED)
private long usedHeapSize;
/**
* The maximum non heap size available in bytes.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The maximum non heap size available in bytes.", required=true)
@Schema(description="The maximum non heap size available in bytes.", requiredMode = RequiredMode.REQUIRED)
private long maxNonHeapSize;
/**
* The used non heap size available in bytes.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The used non heap size available in bytes.", required=true)
@Schema(description="The used non heap size available in bytes.", requiredMode = RequiredMode.REQUIRED)
private long usedNonHeapSize;
/**
@@ -1,16 +1,16 @@
package com.mowesta.api.log;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Represents a log message that is made accessible remotely
@@ -25,28 +25,28 @@ import io.swagger.annotations.ApiModelProperty;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description="Represents a log message.")
@Schema(description="Represents a log message.")
public class LogMessage {
/**
* The id of the message.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="An auto-generated sequential id.", required=true)
@Schema(description="An auto-generated sequential id.", requiredMode = RequiredMode.REQUIRED)
private long id;
/**
* The timestamp of the message.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The creation time in Epoch milliseconds.", required=true)
@Schema(description="The creation time in Epoch milliseconds.", requiredMode = RequiredMode.REQUIRED)
private long time;
/**
* The thread id.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The id of the thread.", required=true)
@Schema(description="The id of the thread.", requiredMode = RequiredMode.REQUIRED)
private int thread;
/**
@@ -54,42 +54,42 @@ public class LogMessage {
*/
@NotNull
@XmlAttribute(required=true)
@ApiModelProperty(value="The message severity.", required=true)
@Schema(description="The message severity.", requiredMode = RequiredMode.REQUIRED)
private String level;
/**
* The name of the logger creating the message.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The name of the logger.", required=true)
@Schema(description="The name of the logger.", requiredMode = RequiredMode.REQUIRED)
private String loggerName;
/**
* The name of the class creating the message.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The name of the class.", required=true)
@Schema(description="The name of the class.", requiredMode = RequiredMode.REQUIRED)
private String className;
/**
* The name of the method creating the message.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The name of the method.", required=true)
@Schema(description="The name of the method.", requiredMode = RequiredMode.REQUIRED)
private String methodName;
/**
* The message.
*/
@XmlElement(required=false)
@ApiModelProperty(value="The actual (optional) message.", required=false)
@Schema(description="The actual (optional) message.", requiredMode = RequiredMode.NOT_REQUIRED)
private String message;
/**
* An optional stack trace.
*/
@XmlElement(required=false)
@ApiModelProperty(value="An optional stack trace.", required=false)
@Schema(description="An optional stack trace.", requiredMode = RequiredMode.NOT_REQUIRED)
private String trace;
/**
@@ -1,14 +1,14 @@
package com.mowesta.api.log;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Represents information about the system.
@@ -22,63 +22,63 @@ import io.swagger.annotations.ApiModelProperty;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description="Represents information about the system.")
@Schema(description="Represents information about the system.")
public class SystemStatistic {
/**
* The architecture of the operating system.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The architecture of the operating system.", required=true)
@Schema(description="The architecture of the operating system.", requiredMode = RequiredMode.REQUIRED)
private String osArchitecture;
/**
* The name of the operating system.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value=" The name of the operating system.", required=true)
@Schema(description=" The name of the operating system.", requiredMode = RequiredMode.REQUIRED)
private String osName;
/**
* A version string of the operating system.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="A version string of the operating system.", required=true)
@Schema(description="A version string of the operating system.", requiredMode = RequiredMode.REQUIRED)
private String osVersion;
/**
* The name of the virtual machine.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The name of the virtual machine.", required=true)
@Schema(description="The name of the virtual machine.", requiredMode = RequiredMode.REQUIRED)
private String vmName;
/**
* The name of the virtual machine specification.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The name of the virtual machine specification.", required=true)
@Schema(description="The name of the virtual machine specification.", requiredMode = RequiredMode.REQUIRED)
private String vmSpecification;
/**
* The name of the virtual machine vendor.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The name of the virtual machine vendor.", required=true)
@Schema(description="The name of the virtual machine vendor.", requiredMode = RequiredMode.REQUIRED)
private String vmVendor;
/**
* A version string for the virtual machine.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="A version string for the virtual machine.", required=true)
@Schema(description="A version string for the virtual machine.", requiredMode = RequiredMode.REQUIRED)
private String vmVersion;
/**
* The number of available processors.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The number of available processors.", required=true)
@Schema(description="The number of available processors.", requiredMode = RequiredMode.REQUIRED)
private int processors;
/**
@@ -1,19 +1,19 @@
package com.mowesta.api.measurement;
import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.BeanParam;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.annotation.security.RolesAllowed;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.BeanParam;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import com.mowesta.api.HttpStatus;
import com.mowesta.api.PageConfig;
import com.mowesta.api.Tags;
import com.mowesta.api.TimeRange;
@@ -22,19 +22,18 @@ import com.mowesta.api.access.Roles;
import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
/**
* A service to manage measurements.
*
* @author Sebastian
*/
@Api
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path("/")
@@ -50,13 +49,16 @@ public interface IMeasurementService {
*/
@POST
@Path("devices/current/measurements")
@ApiOperation(value = "Adds a number of measurements for the current device.", authorizations = {
@Authorization(Authorizations.DEVICE) }, tags = { Tags.DEFAULT, Tags.DEVICE })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Measurements added successfully."),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "No valid authorization found.") })
@Operation(summary = "Adds a number of measurements for the current device.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Measurements added successfully."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = @SecurityRequirement(name = Authorizations.DEVICE)
)
@RolesAllowed({ Roles.DEVICE })
Response addCurrentDeviceMeasurements(@ApiParam(value = "The new measurements to add.", required = true) @Valid @NotNull List<Measurement> measurements);
Response addCurrentDeviceMeasurements(@Parameter(description = "The new measurements to add.", required = true) @Valid @NotNull List<Measurement> measurements);
/**
* Adds a single measurement for a device that has been captured now. In contrast
@@ -68,13 +70,17 @@ public interface IMeasurementService {
*/
@POST
@Path("devices/current/measurements/now")
@ApiOperation(value = "Adds a single measurement for the device that has been captured recently.", authorizations = {
@Authorization(Authorizations.DEVICE) }, tags = { Tags.DEFAULT, Tags.DEVICE })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Measurement added successfully.", response = Measurement.class),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "No valid authorization found.") })
@Operation(summary = "Adds a single measurement for the device that has been captured recently.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Measurement added successfully.",
content = @Content(schema = @Schema(implementation = Measurement.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = @SecurityRequirement(name = Authorizations.DEVICE)
)
@RolesAllowed({ Roles.DEVICE })
Response addCurrentDeviceMeasurement(@ApiParam(value = "The new measurement to add.", required = true) @Valid @NotNull Measurement measurement);
Response addCurrentDeviceMeasurement(@Parameter(description = "The new measurement to add.", required = true) @Valid @NotNull Measurement measurement);
/**
@@ -86,11 +92,15 @@ public interface IMeasurementService {
*/
@GET
@Path("devices/current/measurements")
@ApiOperation(value = "Returns a page of measurements of the current device from a certain time range.", authorizations = {
@Authorization(Authorizations.DEVICE) }, tags = { Tags.DEFAULT, Tags.DEVICE })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Measurements retrieved successfully.", response = MeasurementPage.class),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to retrieve the measurements.") })
@Operation(summary = "Returns a page of measurements of the current device from a certain time range.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Measurements retrieved successfully.",
content = @Content(schema = @Schema(implementation = MeasurementPage.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = @SecurityRequirement(name = Authorizations.DEVICE)
)
@RolesAllowed({ Roles.DEVICE })
Response getCurrentDeviceMeasurements(@BeanParam @Valid TimeRange timeRange, @BeanParam @Valid PageConfig pageConfig);
@@ -104,14 +114,18 @@ public interface IMeasurementService {
*/
@GET
@Path("devices/{id: ([0-9])+}/measurements")
@ApiOperation(value = "Returns a page of measurements of a specific device from a certain time range.",authorizations = {
@Authorization(Authorizations.USER), @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.DEVICE })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Measurements retrieved successfully.", response = MeasurementPage.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The measurements were not found."),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to retrieve the measurements.") })
@Operation(summary = "Returns a page of measurements of the current device from a certain time range.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Measurements retrieved successfully.",
content = @Content(schema = @Schema(implementation = MeasurementPage.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "The measurements were not found."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = { @SecurityRequirement(name = Authorizations.USER), @SecurityRequirement(name = Authorizations.ADMIN) }
)
@RolesAllowed({ Roles.USER, Roles.ADMIN })
Response getDeviceMeasurements(@ApiParam(value = "The device id.", required = true) @PathParam("id") long id, @BeanParam @Valid TimeRange timeRange, @BeanParam @Valid PageConfig pageConfig);
Response getDeviceMeasurements(@Parameter(description = "The device id.", required = true) @PathParam("id") long id, @BeanParam @Valid TimeRange timeRange, @BeanParam @Valid PageConfig pageConfig);
/**
@@ -123,11 +137,15 @@ public interface IMeasurementService {
*/
@GET
@Path("devices/measurements")
@ApiOperation(value = "Returns a page of measurements of all devices within a certain time range.",
authorizations = { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.DEVICE })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Measurements retrieved successfully.", response = MeasurementPage.class),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to retrieve the measurements.") })
@Operation(summary = "Returns a page of measurements of all devices within a certain time range.",
tags = { Tags.DEFAULT, Tags.DEVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Measurements retrieved successfully.",
content = @Content(schema = @Schema(implementation = MeasurementPage.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
@RolesAllowed({ Roles.ADMIN })
Response getAllMeasurementsByRange(@BeanParam @Valid TimeRange timeRange, @BeanParam @Valid PageConfig pageConfig);
}
@@ -1,21 +1,20 @@
package com.mowesta.api.measurement;
import java.util.HashMap;
import java.util.Map;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.mowesta.api.Coordinate;
import com.mowesta.api.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Represents a measurement of a device.
@@ -23,7 +22,7 @@ import io.swagger.annotations.ApiModelProperty;
* @author Sebastian, Tobias
*/
@XmlRootElement
@ApiModel(description = "Represents a measurement of a device at a particular point in time.", parent = Entity.class)
@Schema(description = "Represents a measurement of a device at a particular point in time.", allOf = Entity.class)
public class Measurement extends Entity {
/**
@@ -33,21 +32,21 @@ public class Measurement extends Entity {
* CPU_TEMPERATURE might be valuable, even without known where it was captured.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value = "The coordinate of the measurement (may be null, if GPS is not available).", required = false)
@Schema(description = "The coordinate of the measurement (may be null, if GPS is not available).", requiredMode = RequiredMode.NOT_REQUIRED)
private Coordinate coordinate;
/**
* The time stamp assigned by the device when the measurement was created.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value = "The timestamp of the measurement in Epoch milliseconds.", required = true)
@Schema(description = "The timestamp of the measurement in Epoch milliseconds.", requiredMode = RequiredMode.REQUIRED)
private long time;
/**
* The device id of the device that created the measurement.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value = "The device id of the measurement.", required = true)
@Schema(description = "The device id of the measurement.", requiredMode = RequiredMode.REQUIRED)
private long device;
/**
@@ -55,7 +54,7 @@ public class Measurement extends Entity {
*/
@NotNull
@XmlAttribute(required = true)
@ApiModelProperty(value = "The app version (version code on Android or build code on IOS).", required = true)
@Schema(description = "The app version (version code on Android or build code on IOS).", requiredMode = RequiredMode.REQUIRED)
private long version;
/**
@@ -64,26 +63,26 @@ public class Measurement extends Entity {
@XmlElementWrapper
@XmlElement(name = "data")
@JsonProperty(value = "data")
@ApiModelProperty(value = "The raw data captured by the device.")
@Schema(description = "The raw data captured by the device.")
private Map<MeasurementType, String> data = new HashMap<>();
/**
* The temperature calculated by the server.
*/
@XmlAttribute
@ApiModelProperty(value = "The calculated air temperature (estimated by the service) in centigrade, may be null.")
@Schema(description = "The calculated air temperature (estimated by the service) in centigrade, may be null.")
private Double temperature;
@XmlAttribute
@ApiModelProperty(value = "The calculated air pressure (estimated by the service) in hPA, may be null.")
@Schema(description = "The calculated air pressure (estimated by the service) in hPA, may be null.")
private Double pressure;
@XmlAttribute
@ApiModelProperty(value = "The calculated relative humidity (estimated by the service) in percent, may be null.")
@Schema(description = "The calculated relative humidity (estimated by the service) in percent, may be null.")
private Double humidity;
@XmlAttribute
@ApiModelProperty(value = "The calculated measurement rating (estimated by the service) from 0 (low quality) to 1 (high quality), may be null.")
@Schema(description = "The calculated measurement rating (estimated by the service) from 0 (low quality) to 1 (high quality), may be null.")
private Double rating;
/**
@@ -1,9 +1,8 @@
package com.mowesta.api.measurement;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
import com.mowesta.api.Page;
@@ -14,6 +13,6 @@ import com.mowesta.api.Page;
*/
@XmlRootElement
@XmlSeeAlso(Measurement.class)
@ApiModel(description = "Represents a page of measurements.", parent = Page.class)
@Schema(description = "Represents a page of measurements.", allOf = Page.class)
public class MeasurementPage extends Page<Measurement> {
}
@@ -1,35 +1,35 @@
package com.mowesta.api.settings;
import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.annotation.security.RolesAllowed;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import com.mowesta.api.HttpStatus;
import com.mowesta.api.Tags;
import com.mowesta.api.access.Authorizations;
import com.mowesta.api.access.Roles;
import com.mowesta.api.location.LocationHierarchy;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
/**
* A service to manage shared settings.
*
* @author Marcus
*/
@Api
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path("/")
@@ -43,11 +43,15 @@ public interface ISettingsService {
*/
@GET
@Path("users/current/settings")
@ApiOperation(value = "Returns the setting of the current user.", authorizations = { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.SETTINGS })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The request was successful.", response = Settings.class),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to access the user's settings."),
})
@Operation(summary = "Returns the settings of the current user.",
tags = { Tags.DEFAULT, Tags.SETTINGS },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Settings retrieved successfully.",
content = @Content(schema = @Schema(implementation = Settings.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = @SecurityRequirement(name = Authorizations.USER)
)
@RolesAllowed({Roles.USER})
Response getCurrentUserSettings();
@@ -58,11 +62,15 @@ public interface ISettingsService {
*/
@GET
@Path("users/current/locations")
@ApiOperation(value = "Returns the favorite locations of the current user.", authorizations = { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.SETTINGS })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "The request was successful.", response = LocationHierarchy.class, responseContainer = "List"),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to access the user's locations."),
})
@Operation(summary = "Returns the favorite locations of the current user.",
tags = { Tags.DEFAULT, Tags.SETTINGS },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Locations retrieved successfully.",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = LocationHierarchy.class)))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = @SecurityRequirement(name = Authorizations.USER)
)
@RolesAllowed({Roles.USER})
Response getCurrentUserLocations();
@@ -74,15 +82,20 @@ public interface ISettingsService {
*/
@PUT
@Path("users/current/settings")
@ApiOperation(value = "Updates the settings of the current user.", authorizations = { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.SETTINGS })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "User settings updated succesfully.", response=Settings.class),
@ApiResponse(code = HttpServletResponse.SC_CONFLICT, message = "Conflict due to parallel update.", response=Settings.class),
@ApiResponse(code = HttpServletResponse.SC_BAD_REQUEST, message = "Invalid request parameters."),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to access the user's settings.")
})
@Operation(summary = "Updates the settings of the current user.",
tags = { Tags.DEFAULT, Tags.SETTINGS },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Settings retrieved successfully.",
content = @Content(schema = @Schema(implementation = Settings.class))),
@ApiResponse(responseCode = HttpStatus.CONFLICT, description = "Conflict due to parallel update.",
content = @Content(schema = @Schema(implementation = Settings.class))),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid request parameters."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = @SecurityRequirement(name = Authorizations.USER)
)
@RolesAllowed({Roles.USER})
Response setCurrentUserSettings(@Valid @NotNull @ApiParam(value = "The settings to set.") Settings settings);
Response setCurrentUserSettings(@Valid @NotNull @Parameter(description = "The settings to set.") Settings settings);
@@ -4,17 +4,17 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.mowesta.api.Entity;
import com.mowesta.api.location.LocationReference;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Represents the user's settings that are shared across the user's apps.
@@ -22,7 +22,7 @@ import io.swagger.annotations.ApiModel;
* @author Marcus
*/
@XmlRootElement
@ApiModel(description = "Represents the user's settings.", parent = Entity.class)
@Schema(description = "Represents the user's settings.", allOf = Entity.class)
public class Settings extends Entity {
/**
@@ -33,6 +33,7 @@ public class Settings extends Entity {
@XmlElementWrapper
@XmlElement(name="location")
@JsonProperty(value="locations")
@Schema(description = "The user's favorite locations.")
private List<LocationReference> locations = new ArrayList<LocationReference>();
/**
@@ -1,12 +1,12 @@
package com.mowesta.api.user;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.mowesta.api.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* An email address of a particular user.
@@ -14,28 +14,28 @@ import io.swagger.annotations.ApiModelProperty;
* @author Marcus
*/
@XmlRootElement
@ApiModel(description="Represents a user.", parent=Entity.class)
@Schema(description="Represents a user.", allOf=Entity.class)
public class Email extends Entity {
/**
* The email address.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The email address.", required=true)
@Schema(description="The email address.", requiredMode = RequiredMode.REQUIRED)
private String address;
/**
* A flag to mark the email address as primary email.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="A flag to mark the email address as primary email.", required=true)
@Schema(description="A flag to mark the email address as primary email.", requiredMode = RequiredMode.REQUIRED)
private boolean correspondence;
/**
* A flag to mark the email address as verified.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="A flag to mark the email address as verified.", required=true)
@Schema(description="A flag to mark the email address as verified.", requiredMode = RequiredMode.REQUIRED)
private boolean verified;
/**
@@ -1,41 +1,41 @@
package com.mowesta.api.user;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.PathParam;
import javax.ws.rs.BeanParam;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.annotation.security.PermitAll;
import jakarta.annotation.security.RolesAllowed;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.BeanParam;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import com.mowesta.api.HttpStatus;
import com.mowesta.api.PageConfig;
import com.mowesta.api.Tags;
import com.mowesta.api.access.Authorizations;
import com.mowesta.api.access.Roles;
import com.mowesta.api.validation.EmailGroup;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
/**
* A service to manage users.
*
* @author Marcus
*/
@Api
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path("/")
@@ -50,12 +50,16 @@ public interface IUserService {
*/
@GET
@Path("devices/current/user")
@ApiOperation(value = "Returns the user that is associated with a device.", authorizations= { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.USER })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="User retrieved successfully.", response=User.class),
@ApiResponse(code=HttpServletResponse.SC_NO_CONTENT, message="Device is not associated with a user."),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="No valid authorization found.")
})
@Operation(summary = "Returns the user that is associated with a device.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "User retrieved successfully.",
content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "No user associated."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "No valid authorization found."),
},
security = @SecurityRequirement(name = Authorizations.DEVICE)
)
@RolesAllowed({Roles.DEVICE})
Response getCurrentDeviceUser();
@@ -66,11 +70,15 @@ public interface IUserService {
*/
@GET
@Path("users/current")
@ApiOperation(value = "Returns the user currently authorized.", authorizations= { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.USER })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="User retrieved successfully.", response=User.class),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="No valid authorization found.")
})
@Operation(summary = "Returns the user that is currently authorized.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "User retrieved successfully.",
content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "No valid authorization found."),
},
security = @SecurityRequirement(name = Authorizations.USER)
)
@RolesAllowed({Roles.USER})
Response getCurrentUser();
@@ -83,15 +91,20 @@ public interface IUserService {
*/
@PUT
@Path("users/current")
@ApiOperation(value = "Updates the currently authorized user.", authorizations= { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.USER })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="User updated successfully.", response=User.class),
@ApiResponse(code=HttpServletResponse.SC_CONFLICT, message="User modified in parallel.", response=User.class),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="No valid authorization found."),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid user.")
})
@Operation(summary = "Updates the currently authorized user.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "User updated successfully.",
content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = HttpStatus.CONFLICT, description = "User modified in parallel.",
content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "No valid authorization found."),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid user."),
},
security = @SecurityRequirement(name = Authorizations.USER)
)
@RolesAllowed({Roles.USER})
Response setCurrentUser(@ApiParam(value="The new user values to set.", required=true) @Valid @EmailGroup(requireVerifiedCorrespondence=true) User user);
Response setCurrentUser(@Parameter(description="The new user values to set.", required=true) @Valid @EmailGroup(requireVerifiedCorrespondence=true) User user);
/**
* Changes the password of the user that is currently
@@ -102,14 +115,18 @@ public interface IUserService {
*/
@PUT
@Path("users/current/password")
@ApiOperation(value="Sets the password of the currently authorized user.", authorizations= { @Authorization(Authorizations.USER) }, tags = { Tags.DEFAULT, Tags.USER })
@Operation(summary = "Sets the password of the currently authorized user.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Password updated successfully.",
content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "No valid authorization found."),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid password."),
},
security = @SecurityRequirement(name = Authorizations.USER)
)
@RolesAllowed({Roles.USER})
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="Password updated successfully.", response=User.class),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="No valid authorization found."),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid password.")
})
Response setCurrentPassword(@ApiParam(value="The new password to set.", required=true) @Valid UserPassword password);
Response setCurrentPassword(@Parameter(description="The new password to set.", required=true) @Valid UserPassword password);
// admin functions
@@ -122,15 +139,19 @@ public interface IUserService {
*/
@POST
@Path("users")
@ApiOperation(value = "Adds a user account with the specified roles and emails.", authorizations= { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.USER })
@Operation(summary = "Adds a user account with the specified roles and emails.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "User added successfully.",
content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = HttpStatus.CONFLICT, description = "User login exists already."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid user data."),
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
@RolesAllowed({Roles.ADMIN})
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_CREATED, message="User added successfully.", response=User.class),
@ApiResponse(code=HttpServletResponse.SC_CONFLICT, message="User login exists already."),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid user."),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges to add the user.")
})
Response addUser(@ApiParam(value="The data for the new user.", required=true) @Valid @EmailGroup User user);
Response addUser(@Parameter(description="The data for the new user.", required=true) @Valid @EmailGroup User user);
/**
@@ -141,14 +162,19 @@ public interface IUserService {
* @return The user with the specified id.
*/
@GET
@Path("users/{id: ([0-9])+}")
@ApiOperation(value = "Returns the user account with the specified id.", authorizations= { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.USER })
@Path("users/{id: ([0-9])+}")
@Operation(summary = "Returns the user account with the specified id.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "User retrieved successfully.",
content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "User id does not exist."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
@RolesAllowed({Roles.ADMIN})
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="User retrieved successfully.", response=User.class),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges to retrieve the user.")
})
Response getUser(@ApiParam(value="The id of the user to retrieve.", required=true) @PathParam("id") long id);
Response getUser(@Parameter(description="The id of the user to retrieve.", required=true) @PathParam("id") long id);
/**
* Updates a user. This method is only accessible to admins.
@@ -162,15 +188,21 @@ public interface IUserService {
*/
@PUT
@Path("users/{id: ([0-9])+}")
@ApiOperation(value = "Updates the values of a particular user account.", authorizations= { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.USER })
@Operation(summary = "Updates the values of a particular user account.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "User updated successfully.",
content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = HttpStatus.CONFLICT, description = "User modified in parallel.",
content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "User id does not exist."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
@ApiResponse(responseCode= HttpStatus.BAD_REQUEST, description="Invalid user data.")
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
@RolesAllowed({Roles.ADMIN})
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="User updated successfully.", response=User.class),
@ApiResponse(code=HttpServletResponse.SC_CONFLICT, message="User modified in parallel.", response=User.class),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges to retrieve the user."),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid user.")
})
Response setUser(@ApiParam(value="The id of the user to set.", required=true) @PathParam("id") long id, @ApiParam(value="The new user data to set.", required=true) @Valid @EmailGroup User user);
Response setUser(@Parameter(description="The id of the user to set.", required=true) @PathParam("id") long id, @Parameter(description="The new user data to set.", required=true) @Valid @EmailGroup User user);
/**
* Changes the password of a user. The accessible users
@@ -183,14 +215,19 @@ public interface IUserService {
*/
@PUT
@Path("users/{id: ([0-9])+}/password")
@ApiOperation(value="Sets the password of a user.", authorizations= { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.USER })
@Operation(summary = "Sets the password of a user.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Password updated successfully.",
content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "User id does not exist."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
@ApiResponse(responseCode= HttpStatus.BAD_REQUEST, description="Invalid password.")
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
@RolesAllowed({Roles.ADMIN})
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="Password updated successfully.", response=User.class),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Password modification not allowed."),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid password.")
})
Response setUserPassword(@ApiParam(value="The id of the user to change.", required=true) @PathParam("id") long id, @ApiParam(value="The new password.", required=true) @Valid UserPassword password);
Response setUserPassword(@Parameter(description="The id of the user to change.", required=true) @PathParam("id") long id, @Parameter(description="The new password.", required=true) @Valid UserPassword password);
/**
@@ -201,13 +238,17 @@ public interface IUserService {
*/
@GET
@Path("users")
@ApiOperation(value = "Returns a list of users.", authorizations= { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.USER })
@Operation(summary = "Returns a list of users.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "User page retrieved successfully.",
content = @Content(schema = @Schema(implementation = UserPage.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
@ApiResponse(responseCode= HttpStatus.BAD_REQUEST, description="Invalid request parameters.")
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
@RolesAllowed({Roles.ADMIN})
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="User page retrieved successfully.", response=UserPage.class),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges for retrieval."),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
Response getUsers(@BeanParam @Valid PageConfig pageConfig);
/**
@@ -219,14 +260,18 @@ public interface IUserService {
*/
@GET
@Path("users/search")
@ApiOperation(value = "Returns a list of users whose login name or name contains the term.", authorizations= { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.USER })
@RolesAllowed({Roles.ADMIN})
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="User page retrieved successfully.", response=UserPage.class),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Insufficient privileges for retrieval."),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
Response searchUsers(@BeanParam @Valid PageConfig pageConfig, @ApiParam(value="The search term.", required=true) @QueryParam("term") @NotNull @Valid String term);
@Operation(summary = "Returns a list of users whose login name or name contains the term.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "User page retrieved successfully.",
content = @Content(schema = @Schema(implementation = UserPage.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Insufficient privileges."),
@ApiResponse(responseCode= HttpStatus.BAD_REQUEST, description="Invalid request parameters.")
},
security = @SecurityRequirement(name = Authorizations.ADMIN)
)
@RolesAllowed({Roles.ADMIN})
Response searchUsers(@BeanParam @Valid PageConfig pageConfig, @Parameter(description="The search term.", required=true) @QueryParam("term") @NotNull @Valid String term);
// registration work-flow
@@ -238,15 +283,18 @@ public interface IUserService {
*/
@POST
@Path("users/register")
@ApiOperation(value = "Registers a new user and sends an email account verification.", tags = { Tags.DEFAULT, Tags.USER })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="User registered successfully.", response=User.class),
@ApiResponse(code=HttpServletResponse.SC_CONFLICT, message="User login already registered."),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid user registration.")
})
@Operation(summary = "Registers a new user and sends an email account verification.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "User registered successfully.",
content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = HttpStatus.CONFLICT, description = "User login already registered."),
@ApiResponse(responseCode= HttpStatus.BAD_REQUEST, description="Invalid user registration.")
}
)
@PermitAll
// TODO consider using 201 CREATED response with no body and location header.
Response registerUser(@ApiParam(value="The data of the new user.", required=true) @Valid UserRegistration user);
Response registerUser(@Parameter(description="The data of the new user.", required=true) @Valid UserRegistration user);
/**
* Sends an email with a password to the user.
@@ -256,15 +304,17 @@ public interface IUserService {
*/
@POST
@Path("users/reset")
@ApiOperation(value = "Sends a password reset email to the correspondence email account of a user.", tags = { Tags.DEFAULT, Tags.USER })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Reset email sent successfully."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "Login does not exist."),
@ApiResponse(code = HttpServletResponse.SC_BAD_REQUEST, message = "User email has not been verified.")
})
@Operation(summary = "Sends a password reset email to the correspondence email account of a user.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "Reset email sent successfully."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "Login does not exist."),
@ApiResponse(responseCode= HttpStatus.BAD_REQUEST, description="User email has not been verified.")
}
)
@PermitAll
// TODO consider returning error response when sending email has been ignored because minimum time between mails has not passed. + add test
Response resetUser(@ApiParam(value="The login of the user to reset.", required=true) @QueryParam("login") @Valid @NotNull String login);
Response resetUser(@Parameter(description="The login of the user to reset.", required=true) @QueryParam("login") @Valid @NotNull String login);
/**
@@ -277,16 +327,19 @@ public interface IUserService {
*/
@PUT
@Path("users/password/{token}")
@ApiOperation(value = "Sets the password of a user account using a token received via email.", tags = { Tags.DEFAULT, Tags.USER })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="Password updated successfully.", response=User.class),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Password modification not allowed."),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid token or password.")
})
@Operation(summary = "Sets the password of a user account using a token received via email.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Password updated successfully.",
content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Password modification not allowed."),
@ApiResponse(responseCode= HttpStatus.BAD_REQUEST, description="Invalid token or password.")
}
)
@PermitAll
// TODO return better status codes for: code expired, deleted, etc. Forbidden should be for authentication errors only.
Response resetUserPassword(@ApiParam(value="The secret token received via email.", required=true) @PathParam("token") @Valid @NotNull String token,
@ApiParam(value="The new user password.", required=true) @Valid UserPassword password);
Response resetUserPassword(@Parameter(description="The secret token received via email.", required=true) @PathParam("token") @Valid @NotNull String token,
@Parameter(description="The new user password.", required=true) @Valid UserPassword password);
/**
@@ -297,13 +350,15 @@ public interface IUserService {
*/
@PUT
@Path("users/verify/{token}")
@ApiOperation(value = "Verifies an email address using a token received via email.", tags = { Tags.DEFAULT, Tags.USER })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_NO_CONTENT, message="Email verified successfully."),
@ApiResponse(code=HttpServletResponse.SC_FORBIDDEN, message="Email verification is not valid."),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid token.")
})
@Operation(summary = "Verifies an email address using a token received via email.",
tags = { Tags.DEFAULT, Tags.USER },
responses = {
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "Email verified successfully."),
@ApiResponse(responseCode = HttpStatus.FORBIDDEN, description = "Email verification is not valid."),
@ApiResponse(responseCode= HttpStatus.BAD_REQUEST, description="Invalid token.")
}
)
@PermitAll
Response verifyUserEmail(@ApiParam(value="The secret token received via email.", required=true) @PathParam("token") @Valid @NotNull String token);
Response verifyUserEmail(@Parameter(description="The secret token received via email.", required=true) @PathParam("token") @Valid @NotNull String token);
}
@@ -3,19 +3,19 @@ package com.mowesta.api.user;
import java.util.ArrayList;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.mowesta.api.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* A data transfer object for a user with associated swagger and
@@ -24,7 +24,7 @@ import io.swagger.annotations.ApiModelProperty;
* @author Marcus
*/
@XmlRootElement
@ApiModel(description="Represents a user.", parent=Entity.class)
@Schema(description="Represents a user.", allOf=Entity.class)
public class User extends Entity {
/**
@@ -33,7 +33,7 @@ public class User extends Entity {
@NotNull
@Pattern(regexp = "(\\p{L}|[0-9]){5,32}", message = "Invalid login format (only letters an numbers, minimum 5 and maximum 32 characters).")
@XmlAttribute(required=true)
@ApiModelProperty(value="The (globally unique) login of the user.", required=true)
@Schema(description="The (globally unique) login of the user.", requiredMode = RequiredMode.REQUIRED)
private String login;
/**
@@ -42,14 +42,14 @@ public class User extends Entity {
@NotNull
@Pattern(regexp = "(\\p{L}| ){0,64}", message = "Invalid name format (only letters and space, maximum 64 characters).")
@XmlAttribute(required=false)
@ApiModelProperty(value="The human name of the user.", required=false)
@Schema(description="The human name of the user.", requiredMode = RequiredMode.NOT_REQUIRED)
private String name;
/**
* A flag to indicate that user account is suspended.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="A flag to indicate that user account is suspended.", required=true)
@Schema(description="A flag to indicate that user account is suspended.", requiredMode = RequiredMode.REQUIRED)
private boolean suspended;
/**
@@ -1,11 +1,11 @@
package com.mowesta.api.user;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
import com.mowesta.api.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* A page containing users. This class simply
@@ -16,7 +16,7 @@ import io.swagger.annotations.ApiModel;
*/
@XmlRootElement
@XmlSeeAlso(User.class)
@ApiModel(description="Represents a page of users.", parent=Page.class)
@Schema(description="Represents a page of users.", allOf=Page.class)
public class UserPage extends Page<User> {
}
@@ -1,16 +1,16 @@
package com.mowesta.api.user;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Represents a user password used during a password sent as a body
@@ -25,7 +25,7 @@ import io.swagger.annotations.ApiModelProperty;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description="Represents a user password.")
@Schema(description="Represents a user password.")
public class UserPassword {
/**
@@ -33,7 +33,7 @@ public class UserPassword {
*/
@NotNull
@Size(min=6)
@ApiModelProperty(value="The new password.", required=true)
@Schema(description="The new password.", requiredMode = RequiredMode.REQUIRED)
@XmlAttribute(required=true)
private String password;
@@ -1,12 +1,12 @@
package com.mowesta.api.user;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Represents a request to register a new user.
@@ -15,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty;
*
*/
@XmlRootElement
@ApiModel(description = "Represents a user registration.", parent = UserPassword.class)
@Schema(description = "Represents a user registration.", allOf = UserPassword.class)
public class UserRegistration extends UserPassword {
/**
@@ -23,7 +23,7 @@ public class UserRegistration extends UserPassword {
*/
@XmlAttribute(required=true)
@Pattern(regexp = "(\\p{L}|[0-9]){5,32}", message = "Invalid login format (only letters an numbers, minimum 5 and maximum 32 characters).")
@ApiModelProperty(value="The requested login name.", required=true)
@Schema(description="The requested login name.", requiredMode = RequiredMode.REQUIRED)
private String login;
/**
@@ -32,7 +32,7 @@ public class UserRegistration extends UserPassword {
@NotNull
@Pattern(regexp = "(\\p{L}| ){0,64}", message = "Invalid name format (only letters and space, maximum 64 characters).")
@XmlAttribute(required=true)
@ApiModelProperty(value="The human name.", required=true)
@Schema(description="The human name.", requiredMode = RequiredMode.REQUIRED)
private String name;
/**
@@ -41,7 +41,7 @@ public class UserRegistration extends UserPassword {
@NotNull
@Pattern(regexp=".+@.+\\..+", message="Invalid email address format.")
@XmlAttribute(required=true)
@ApiModelProperty(value="The email address.", required=true)
@Schema(description="The email address.", requiredMode = RequiredMode.REQUIRED)
private String email;
/**
@@ -6,8 +6,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;
/**
* An annotation to validate email groups.
@@ -3,8 +3,8 @@ package com.mowesta.api.validation;
import java.util.HashSet;
import java.util.Set;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import com.mowesta.api.user.Email;
import com.mowesta.api.user.User;
@@ -1,15 +1,15 @@
package com.mowesta.api.version;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Information about the build of the application.
@@ -23,14 +23,14 @@ import io.swagger.annotations.ApiModelProperty;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description="Represents version information about the running build.")
@Schema(description="Represents version information about the running build.")
public class BuildVersion {
/**
* The build time.
*/
@XmlAttribute(required=true)
@ApiModelProperty(value="The build time in Epoch milliseconds.", required=true)
@Schema(description="The build time in Epoch milliseconds.", requiredMode = RequiredMode.REQUIRED)
private long time;
/**
@@ -38,7 +38,7 @@ public class BuildVersion {
*/
@NotNull
@XmlAttribute(required=true)
@ApiModelProperty(value="The build number.", required=true)
@Schema(description="The build number.", requiredMode = RequiredMode.REQUIRED)
private String build;
/**
@@ -46,7 +46,7 @@ public class BuildVersion {
*/
@NotNull
@XmlAttribute(required=true)
@ApiModelProperty(value="The creator of the build.", required=true)
@Schema(description="The creator of the build.", requiredMode = RequiredMode.REQUIRED)
private String creator;
/**
@@ -54,7 +54,7 @@ public class BuildVersion {
*/
@NotNull
@XmlAttribute(required=true)
@ApiModelProperty(value="The version of the build.", required=true)
@Schema(description="The version of the build.", requiredMode = RequiredMode.REQUIRED)
private String version;
/**
@@ -1,27 +1,27 @@
package com.mowesta.api.version;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.annotation.security.PermitAll;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import com.mowesta.api.HttpStatus;
import com.mowesta.api.Tags;
/**
* An api to retrieve the build version.
*
* @author Marcus
*
*/
@Api
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path("/")
public interface IVersionService {
@@ -34,10 +34,12 @@ public interface IVersionService {
*/
@GET
@Path("versions/build")
@ApiOperation(value = "Returns the build version.", tags = { Tags.DEFAULT, Tags.SERVICE })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="Build version retrieved successfully.", response=BuildVersion.class)
})
@Operation(summary = "Returns the build version.",
tags = { Tags.DEFAULT, Tags.SERVICE },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Build version retrieved successfully.",
content = @Content(schema = @Schema(implementation = BuildVersion.class)))
})
@PermitAll
Response getBuildVersion();
@@ -1,27 +1,28 @@
package com.mowesta.api.weather;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.ws.rs.BeanParam;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.annotation.security.PermitAll;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import jakarta.ws.rs.BeanParam;
import jakarta.ws.rs.GET;
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.MediaType;
import jakarta.ws.rs.core.Response;
import com.mowesta.api.HttpStatus;
import com.mowesta.api.PageConfig;
import com.mowesta.api.Tags;
import com.mowesta.api.TimeRange;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* An api to access weather information.
@@ -29,7 +30,6 @@ import io.swagger.annotations.ApiResponses;
* @author Marcus
*
*/
@Api
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public interface IWeatherService {
@@ -43,14 +43,17 @@ public interface IWeatherService {
*/
@GET
@Path("cities/{id: [0-9]+}/forecast")
@ApiOperation(value = "Gets the weather forecast for a city with a particular id.", tags = {Tags.DEFAULT, Tags.WEATHER})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather forecast retrieved successfully.", response=WeatherForecast.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather forecast not available."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "City does not exist.")
})
@Operation(summary = "Gets the weather forecast for a city with a particular id.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather forecast retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherForecast.class))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "Weather forecast not available."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "City does not exist."),
}
)
@PermitAll
Response getCityForecast(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getCityForecast(@Parameter(description = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
@@ -61,13 +64,16 @@ public interface IWeatherService {
*/
@GET
@Path("forecasts/{id: [0-9]+}")
@ApiOperation(value = "Gets the weather forecast with a particular id.", tags = {Tags.DEFAULT, Tags.WEATHER})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather forecast retrieved successfully.", response=WeatherForecast.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "Weather forecast does not exist.")
})
@Operation(summary = "Gets the weather forecast with a particular id.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather forecast retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherForecast.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "Weather forecast does not exist."),
}
)
@PermitAll
Response getForecast(@ApiParam(value = "The forecast id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getForecast(@Parameter(description = "The forecast id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
@@ -79,13 +85,16 @@ public interface IWeatherService {
*/
@GET
@Path("forecasts/resolve")
@ApiOperation(value = "Searches the (closest) weather forecast for a particular location.", tags = {Tags.DEFAULT, Tags.WEATHER})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather forecast retrieved successfully.", response=WeatherForecast.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather forecast not available.")
})
@Operation(summary = "Searches the (closest) weather forecast for a particular location.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather forecast retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherForecast.class))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "Weather forecast not available."),
}
)
@PermitAll
Response resolveForecast(@ApiParam(value = "The longitude.", required = true) @QueryParam("longitude") double longitude, @ApiParam(value = "The latitude.", required = true) @QueryParam("latitude") double latitude);
Response resolveForecast(@Parameter(description = "The longitude.", required = true) @QueryParam("longitude") double longitude, @Parameter(description = "The latitude.", required = true) @QueryParam("latitude") double latitude);
/**
* Returns a page of weather reports of the specified station from a certain time range.
@@ -97,13 +106,16 @@ public interface IWeatherService {
*/
@GET
@Path("stations/{id}/reports")
@ApiOperation(value = "Returns a page of weather reports of a particular staton in a certain time range.", tags = { Tags.DEFAULT, Tags.WEATHER })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather reports retrieved successfully.", response = WeatherReportPage.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "Weather station not found.")
})
@Operation(summary = "Returns a page of weather reports of a particular staton in a certain time range.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather reports retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherReportPage.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "Weather station not found."),
}
)
@PermitAll
Response getStationReports(@ApiParam(value = "The station id.", required = true) @PathParam("id") long id, @BeanParam @Valid TimeRange timeRange, @BeanParam @Valid PageConfig pageConfig);
Response getStationReports(@Parameter(description = "The station id.", required = true) @PathParam("id") long id, @BeanParam @Valid TimeRange timeRange, @BeanParam @Valid PageConfig pageConfig);
/**
@@ -113,15 +125,18 @@ public interface IWeatherService {
* @return The page of reports.
*/
@GET
@Path("stations/{id}/reports/latest")
@ApiOperation(value = "Returns the latest weather report of a particular station.", tags = { Tags.DEFAULT, Tags.WEATHER })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather report retrieved successfully.", response = WeatherReport.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "No weather report for station available."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "Weather station not found.")
})
@Path("stations/{id}/reports/latest")
@Operation(summary = "Returns the latest weather report of a particular station.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather reports retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherReport.class))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "No weather report for station available."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "Weather station not found."),
}
)
@PermitAll
Response getLatestStationReport(@ApiParam(value = "The station id.", required = true) @PathParam("id") long id);
Response getLatestStationReport(@Parameter(description = "The station id.", required = true) @PathParam("id") long id);
/**
* Returns the closest weather station for a particular location.
@@ -132,13 +147,16 @@ public interface IWeatherService {
*/
@GET
@Path("stations/resolve")
@ApiOperation(value = "Searches the (closest) weather station for a particular location.", tags = {Tags.DEFAULT, Tags.WEATHER})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather station retrieved successfully.", response=WeatherStation.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather station not available.")
})
@Operation(summary = "Searches the (closest) weather station for a particular location.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather station retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherStation.class))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "Weather station not available."),
}
)
@PermitAll
Response resolveStation(@ApiParam(value = "The longitude.", required = true) @QueryParam("longitude") double longitude, @ApiParam(value = "The latitude.", required = true) @QueryParam("latitude") double latitude);
Response resolveStation(@Parameter(description = "The longitude.", required = true) @QueryParam("longitude") double longitude, @Parameter(description = "The latitude.", required = true) @QueryParam("latitude") double latitude);
/**
@@ -149,14 +167,17 @@ public interface IWeatherService {
*/
@GET
@Path("cities/{id: [0-9]+}/station")
@ApiOperation(value = "Gets the weather station for a city with a particular id.", tags = {Tags.DEFAULT, Tags.WEATHER})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather station retrieved successfully.", response=WeatherStation.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather station not available."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "City does not exist.")
})
@Operation(summary = "Gets the weather station for a city with a particular id.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather station retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherStation.class))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "Weather station not available."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "City does not exist."),
}
)
@PermitAll
Response getCityStation(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getCityStation(@Parameter(description = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
@@ -168,14 +189,17 @@ public interface IWeatherService {
* @return A page of weather stations matching the search term.
*/
@GET
@Path("stations")
@ApiOperation(value = "Returns a page of weather stations, possibly filtered by name.", tags = { Tags.DEFAULT, Tags.WEATHER })
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="Weather station page retrieved successfully.", response=WeatherStationPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
@Path("stations")
@Operation(summary = "Returns a page of weather stations, possibly filtered by name.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather station page retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherStationPage.class))),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid request parameter."),
}
)
@PermitAll
Response getStations(@ApiParam(value = "An optional search term to filter the result by name.", required = false) @QueryParam("term") String term, @BeanParam @Valid PageConfig pageConfig);
Response getStations(@Parameter(description = "An optional search term to filter the result by name.", required = false) @QueryParam("term") String term, @BeanParam @Valid PageConfig pageConfig);
/**
* Returns a particular station.
@@ -185,13 +209,16 @@ public interface IWeatherService {
*/
@GET
@Path("stations/{id: [0-9]+}")
@ApiOperation(value = "Gets a weather station with a particular id.", tags = {Tags.DEFAULT, Tags.WEATHER})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather station retrieved successfully.", response=WeatherStation.class),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "Weather station does not exist."),
})
@Operation(summary = "Gets a weather station with a particular id.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather station retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherStation.class))),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "Weather station does not exist."),
}
)
@PermitAll
Response getStation(@ApiParam(value = "The station id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getStation(@Parameter(description = "The station id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
@@ -202,14 +229,17 @@ public interface IWeatherService {
*/
@GET
@Path("cities/{id: [0-9]+}/condition")
@ApiOperation(value = "Gets the current weather condition for a city with a particular id.", tags = {Tags.DEFAULT, Tags.WEATHER})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather condition retrieved successfully.", response=WeatherCondition.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather condition not available."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "City does not exist.")
})
@Operation(summary = "Gets the current weather condition for a city with a particular id.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather condition retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherCondition.class))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "Weather condition not available."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "City does not exist."),
}
)
@PermitAll
Response getCityCondition(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getCityCondition(@Parameter(description = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
@@ -220,11 +250,14 @@ public interface IWeatherService {
*/
@GET
@Path("videos")
@ApiOperation(value = "Returns a page of weather videos.", tags = {Tags.DEFAULT, Tags.WEATHER})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather video page retrieved successfully.", response=WeatherVideoPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
@Operation(summary = "Returns a page of weather videos.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather video page retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherVideoPage.class))),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid request parameter."),
}
)
@PermitAll
Response getVideos(@BeanParam @Valid PageConfig pageConfig);
@@ -238,13 +271,16 @@ public interface IWeatherService {
*/
@GET
@Path("videos/resolve")
@ApiOperation(value = "Returns a page of weather videos relevant for a location.", tags = {Tags.DEFAULT, Tags.WEATHER})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather video page retrieved successfully.", response=WeatherVideoPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
@Operation(summary = "Returns a page of weather videos relevant for a location.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather video page retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherVideoPage.class))),
@ApiResponse(responseCode = HttpStatus.BAD_REQUEST, description = "Invalid request parameter."),
}
)
@PermitAll
Response resolveVideos(@ApiParam(value = "The longitude.", required = true) @QueryParam("longitude") double longitude, @ApiParam(value = "The latitude.", required = true) @QueryParam("latitude") double latitude, @BeanParam @Valid PageConfig pageConfig);
Response resolveVideos(@Parameter(description = "The longitude.", required = true) @QueryParam("longitude") double longitude, @Parameter(description = "The latitude.", required = true) @QueryParam("latitude") double latitude, @BeanParam @Valid PageConfig pageConfig);
/**
@@ -254,10 +290,13 @@ public interface IWeatherService {
*/
@GET
@Path("videos/latest")
@ApiOperation(value = "Returns the latest of weather videos.", tags = {Tags.DEFAULT, Tags.WEATHER})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather video list retrieved successfully.", response=WeatherVideo.class, responseContainer = "List"),
})
@Operation(summary = "Returns the latest of weather videos.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather video list retrieved successfully.",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = WeatherVideo.class))))
}
)
@PermitAll
Response getLatestVideos();
@@ -271,14 +310,17 @@ public interface IWeatherService {
*/
@GET
@Path("cities/{id: [0-9]+}/videos")
@ApiOperation(value = "Returns the all videos for the city.", tags = {Tags.DEFAULT, Tags.WEATHER})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather videos retrieved successfully.", response=WeatherVideoPage.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather videos not available."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "City does not exist.")
})
@Operation(summary = "Returns the all videos for the city.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather video page retrieved successfully.",
content = @Content(schema = @Schema(implementation = WeatherVideoPage.class))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "Weather videos not available."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "City does not exist."),
}
)
@PermitAll
Response getCityVideos(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id, @BeanParam @Valid PageConfig pageConfig);
Response getCityVideos(@Parameter(description = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id, @BeanParam @Valid PageConfig pageConfig);
/**
@@ -289,14 +331,17 @@ public interface IWeatherService {
*/
@GET
@Path("cities/{id: [0-9]+}/videos/latest")
@ApiOperation(value = "Returns the latest videos for the city.", tags = {Tags.DEFAULT, Tags.WEATHER})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Weather videos retrieved successfully.", response=WeatherVideo.class, responseContainer = "List"),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "Weather videos not available."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "City does not exist.")
})
@Operation(summary = "Returns the latest videos for the city.",
tags = { Tags.DEFAULT, Tags.WEATHER },
responses = {
@ApiResponse(responseCode = HttpStatus.OK, description = "Weather video list retrieved successfully.",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = WeatherVideo.class)))),
@ApiResponse(responseCode = HttpStatus.NO_CONTENT, description = "Weather videos not available."),
@ApiResponse(responseCode = HttpStatus.NOT_FOUND, description = "City does not exist."),
}
)
@PermitAll
Response getLatestCityVideos(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
Response getLatestCityVideos(@Parameter(description = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
@@ -1,14 +1,14 @@
package com.mowesta.api.weather;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Describes the weather condition at a particular point in time.
@@ -22,105 +22,105 @@ import io.swagger.annotations.ApiModelProperty;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description="Represents the weather condition at a particular point in time.")
@Schema(description="Represents the weather condition at a particular point in time.")
public class WeatherCondition {
/**
* The source of the condition.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The source of the condition.", required=true)
@Schema(description="The source of the condition.", requiredMode = RequiredMode.REQUIRED)
private WeatherSource source;
/**
* The time when the condition arries in Epoch milliseconds.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The time when the condition arrises in Epoch milliseconds.", required=true)
@Schema(description="The time when the condition arrises in Epoch milliseconds.", requiredMode = RequiredMode.REQUIRED)
private long time;
/**
* The forecast hour (as offset to the forecast time).
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The hour as an offset from the computation time.", required=true)
@Schema(description="The hour as an offset from the computation time.", requiredMode = RequiredMode.REQUIRED)
private int hour;
/**
* The forecast duration (in hours starting from the forecast hour).
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The duration of the condition in hours.", required=true)
@Schema(description="The duration of the condition in hours.", requiredMode = RequiredMode.REQUIRED)
private int duration;
/**
* The weather (interpretation) type.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The weather interpretation type describing the condition.", required=true)
@Schema(description="The weather interpretation type describing the condition.", requiredMode = RequiredMode.REQUIRED)
private WeatherType type;
/**
* The temperature in 2m above the ground in degree Celsius.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The temperature at two meters above the ground in degree centigrade.", required=true)
@Schema(description="The temperature at two meters above the ground in degree centigrade.", requiredMode = RequiredMode.REQUIRED)
private double temperature;
/**
* The wind direction 10 meter above the ground.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The wind direction at ten meters above the ground.", required=true)
@Schema(description="The wind direction at ten meters above the ground.", requiredMode = RequiredMode.REQUIRED)
private WindDirection windDirection;
/**
* The wind speed 10 meter above the ground.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The wind speed at ten meters above the ground in meters per second.", required=true)
@Schema(description="The wind speed at ten meters above the ground in meters per second.", requiredMode = RequiredMode.REQUIRED)
private double windSpeed;
/**
* The cloud cover in percent from 0 (no clouds) to 1 (just clouds).
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The cloud coverage in percent from 0 (no clouds) to 1 (totally clouded).", required=true)
@Schema(description="The cloud coverage in percent from 0 (no clouds) to 1 (totally clouded).", requiredMode = RequiredMode.REQUIRED)
private double cloudCoverage;
/**
* The depth of the clouds in percent from 0 to 1.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The cloud depth in percent.", required=true)
@Schema(description="The cloud depth in percent.", requiredMode = RequiredMode.REQUIRED)
private double cloudDepth;
/**
* The air pressure in hPa at the surface level.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The air pressure at the surface height in hPa.", required=true)
@Schema(description="The air pressure at the surface height in hPa.", requiredMode = RequiredMode.REQUIRED)
private double pressure;
/**
* The total amount of precipitation during the time frame.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The total precipitation in kg per square meter per hour during the duration.", required=true)
@Schema(description="The total precipitation in kg per square meter per hour during the duration.", requiredMode = RequiredMode.REQUIRED)
private double precipitation;
/**
* The snow height.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The show depth in meters.", required=true)
@Schema(description="The show depth in meters.", required=true)
private double snowDepth;
/**
* The relative humidity.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The relative humidity in percent at 2m above the surface.", required=true)
@Schema(description="The relative humidity in percent at 2m above the surface.", requiredMode = RequiredMode.REQUIRED)
private double humidity;
/**
@@ -3,17 +3,17 @@ package com.mowesta.api.weather;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.mowesta.api.Coordinate;
import com.mowesta.api.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Represents a forecast generated by a particular model for a particular place.
@@ -21,42 +21,42 @@ import io.swagger.annotations.ApiModelProperty;
* @author Marcus
*/
@XmlRootElement
@ApiModel(description = "Represents a weather forecast for a location.", parent = Entity.class)
@Schema(description = "Represents a weather forecast for a location.", allOf = Entity.class)
public class WeatherForecast extends Entity {
/**
* The coordinate to determine the place.
*/
@XmlElement(required = true)
@ApiModelProperty(value="The coordinate that determines the location.", required=true)
@Schema(description="The coordinate that determines the location.", requiredMode = RequiredMode.REQUIRED)
private Coordinate coordinate;
/**
* The source of the forecast.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The source of the forecast.", required=true)
@Schema(description="The source of the forecast.", requiredMode = RequiredMode.REQUIRED)
private WeatherSource source;
/**
* The surface height in meters above sea level.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The surface height at the location (in meters above sea level).", required=true)
@Schema(description="The surface height at the location (in meters above sea level).", requiredMode = RequiredMode.REQUIRED)
private double surfaceHeight;
/**
* The plant coverage in percent.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The plant coverage at the location (in percent).", required=true)
@Schema(description="The plant coverage at the location (in percent).", requiredMode = RequiredMode.REQUIRED)
private double plantCoverage;
/**
* The soil type.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The soil type at the location.", required=true)
@Schema(description="The soil type at the location.", requiredMode = RequiredMode.REQUIRED)
private SoilType soilType;
/**
@@ -65,7 +65,7 @@ public class WeatherForecast extends Entity {
@XmlElementWrapper
@XmlElement(name="condition")
@JsonProperty(value="conditions")
@ApiModelProperty(value="The weather conditions constituting the forecast.", required=true)
@Schema(description="The weather conditions constituting the forecast.", requiredMode = RequiredMode.REQUIRED)
private List<WeatherCondition> conditions = new ArrayList<>();
/**
@@ -1,12 +1,12 @@
package com.mowesta.api.weather;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.mowesta.api.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* A weather report of a particular station.
@@ -14,42 +14,42 @@ import io.swagger.annotations.ApiModelProperty;
* @author Marcus
*/
@XmlRootElement
@ApiModel(description = "Represents a weather report of a weather station.", parent = Entity.class)
@Schema(description = "Represents a weather report of a weather station.", allOf = Entity.class)
public class WeatherReport extends Entity {
/**
* The station that created the report.
*/
@XmlAttribute(required = false)
@ApiModelProperty(value="The id of the station.", required=false)
@XmlAttribute(required = true)
@Schema(description="The id of the station.", requiredMode = RequiredMode.REQUIRED)
private long station;
/**
* The time when the measurement was taken.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The measurement time in Epoch milliseconds.", required=true)
@Schema(description="The measurement time in Epoch milliseconds.", requiredMode = RequiredMode.REQUIRED)
private long time;
/**
* The temperature in 2m above the ground in degree Celsius.
*/
@XmlAttribute(required = false)
@ApiModelProperty(value="The temperature at two meters above the ground in degree centigrade.", required=false)
@Schema(description="The temperature at two meters above the ground in degree centigrade.", requiredMode = RequiredMode.NOT_REQUIRED)
private Double temperature;
/**
* The air pressure in hPa at the station's altitude.
*/
@XmlAttribute(required = false)
@ApiModelProperty(value="The air pressure at the station's altitude in hPa.", required=false)
@Schema(description="The air pressure at the station's altitude in hPa.", requiredMode = RequiredMode.NOT_REQUIRED)
private Double pressure;
/**
* The relative humidity measured at two meters above the ground.
*/
@XmlAttribute(required = false)
@ApiModelProperty(value="The relative humidity measured at two meters above the ground.", required=true)
@Schema(description="The relative humidity measured at two meters above the ground.", requiredMode = RequiredMode.NOT_REQUIRED)
private Double humidity;
/**
@@ -1,11 +1,11 @@
package com.mowesta.api.weather;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
import com.mowesta.api.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Represents a page of weather reports.
@@ -14,7 +14,7 @@ import io.swagger.annotations.ApiModel;
*/
@XmlRootElement
@XmlSeeAlso(WeatherReport.class)
@ApiModel(description = "Represents a page of weather reports.", parent = Page.class)
@Schema(description = "Represents a page of weather reports.", allOf = Page.class)
public class WeatherReportPage extends Page<WeatherReport> {
}
@@ -1,14 +1,14 @@
package com.mowesta.api.weather;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.mowesta.api.Coordinate;
import com.mowesta.api.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* A model for a weather station.
@@ -16,42 +16,42 @@ import io.swagger.annotations.ApiModelProperty;
* @author Marcus
*/
@XmlRootElement
@ApiModel(description = "Represents a weather station.", parent = Entity.class)
@Schema(description = "Represents a weather station.", allOf = Entity.class)
public class WeatherStation extends Entity {
/**
* The name of the station.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The name of the station.", required=true)
@Schema(description ="The name of the station.", requiredMode = RequiredMode.REQUIRED)
private String name;
/**
* The position of the station.
*/
@XmlElement(required = true)
@ApiModelProperty(value="The coordinate that determines the location.", required=true)
@Schema(description="The coordinate that determines the location.", requiredMode = RequiredMode.REQUIRED)
private Coordinate coordinate;
/**
* The altitude of the station.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The altitude of the station (in meters above sea level).", required=true)
@Schema(description="The altitude of the station (in meters above sea level).", requiredMode = RequiredMode.REQUIRED)
private double altitude;
/**
* The operator of the station.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The operator of the station.", required=true)
@Schema(description="The operator of the station.", requiredMode = RequiredMode.REQUIRED)
private StationOperator operator;
/**
* An external id used by the operator.
*/
@XmlAttribute(required = false)
@ApiModelProperty(value="An external id used by the operator.", required=false)
@Schema(description="An external id used by the operator.", requiredMode = RequiredMode.NOT_REQUIRED)
private String externalId;
/**
@@ -1,11 +1,11 @@
package com.mowesta.api.weather;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
import com.mowesta.api.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Represents a page of weather reports.
@@ -14,7 +14,7 @@ import io.swagger.annotations.ApiModel;
*/
@XmlRootElement
@XmlSeeAlso(WeatherStation.class)
@ApiModel(description = "Represents a page of weather stations.", parent = Page.class)
@Schema(description = "Represents a page of weather stations.", allOf = Page.class)
public class WeatherStationPage extends Page<WeatherStation> {
}
@@ -1,16 +1,16 @@
package com.mowesta.api.weather;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.mowesta.api.Coordinate;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
/**
* Represents a weather video.
@@ -24,7 +24,7 @@ import io.swagger.annotations.ApiModelProperty;
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
@ApiModel(description="Represents a weather video.")
@Schema(description="Represents a weather video.")
public class WeatherVideo {
/**
@@ -33,7 +33,7 @@ public class WeatherVideo {
* and the minimum of the longitude.
*/
@XmlElement(required = true)
@ApiModelProperty(value="The south west coordinate representing the bottom left corner of the video.", required=true)
@Schema(description="The south west coordinate representing the bottom left corner of the video.", requiredMode = RequiredMode.REQUIRED)
private Coordinate southWest;
/**
@@ -42,91 +42,91 @@ public class WeatherVideo {
* latitude.
*/
@XmlElement(required = true)
@ApiModelProperty(value="The north east coordinate representing the top right corner of the video.", required=true)
@Schema(description="The north east coordinate representing the top right corner of the video.", requiredMode = RequiredMode.REQUIRED)
private Coordinate northEast;
/**
* The type of data shown in the video.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The type of weather data contained in the video.", required=true)
@Schema(description="The type of weather data contained in the video.", requiredMode = RequiredMode.REQUIRED)
private VideoType type;
/**
* The data source for the video.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The type of weather data contained in the video.", required=true)
@Schema(description="The type of weather data contained in the video.", requiredMode = RequiredMode.REQUIRED)
private WeatherSource source;
/**
* The time of the prediction in Epoch milliseconds.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The time of the prediction in Epoch milliseconds.", required=true)
@Schema(description="The time of the prediction in Epoch milliseconds.", requiredMode = RequiredMode.REQUIRED)
private long time;
/**
* The start hour of the forecast.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The start hour of the forecast.", required=true)
@Schema(description="The start hour of the forecast.", requiredMode = RequiredMode.REQUIRED)
private int start;
/**
* The total duration of the forecast in hours.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value=" The total duration of the forecast in hours.", required=true)
@Schema(description=" The total duration of the forecast in hours.", requiredMode = RequiredMode.REQUIRED)
private int duration;
/**
* The number of frames per forecast hour.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The number of frames per forecast hour.", required=true)
@Schema(description="The number of frames per forecast hour.", requiredMode = RequiredMode.REQUIRED)
private int fph;
/**
* The number of frames per second of video time.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The number of frames per second of video time.", required=true)
@Schema(description="The number of frames per second of video time.", requiredMode = RequiredMode.REQUIRED)
private int fps;
/**
* The width of the video in pixels.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The width of the video in pixels.", required=true)
@Schema(description="The width of the video in pixels.", requiredMode = RequiredMode.REQUIRED)
private int width;
/**
* The height of the video in pixels.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The height of the video in pixels.", required=true)
@Schema(description="The height of the video in pixels.", requiredMode = RequiredMode.REQUIRED)
private int height;
/**
* The url to download the video.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The url to download the video.", required=true)
@Schema(description="The url to download the video.", requiredMode = RequiredMode.REQUIRED)
private String url;
/**
* The url of a preview image.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The url of a preview image.", required=true)
@Schema(description="The url of a preview image.", requiredMode = RequiredMode.REQUIRED)
private String preview;
/**
* The url of a preview image.
*/
@XmlAttribute(required = true)
@ApiModelProperty(value="The url of a scale image.", required=true)
@Schema(description ="The url of a scale image.", requiredMode = RequiredMode.REQUIRED)
private String scale;
@@ -1,11 +1,11 @@
package com.mowesta.api.weather;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSeeAlso;
import com.mowesta.api.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* Represents a page of weather videos.
@@ -14,7 +14,7 @@ import io.swagger.annotations.ApiModel;
*/
@XmlRootElement
@XmlSeeAlso(WeatherVideo.class)
@ApiModel(description = "Represents a page of weather videos.", parent = Page.class)
@Schema(description = "Represents a page of weather videos.", allOf = Page.class)
public class WeatherVideoPage extends Page<WeatherVideo> {
}
@@ -0,0 +1,44 @@
{
"info": {
"version": "1.0",
"title": "MoWeSta Service",
"description": "MoWeSta Service Api",
"termsOfService": "https://www.nes.uni-due.de",
"contact": {
"email": "marcus.handte@uni-due.de",
"name": "Universität Duisburg-Essen",
"url": "https://www.nes.uni-due.de"
},
"license": {
"url": "https://www.nes.uni-due.de",
"name": "Proprietary"
}
},
"openapi": "3.0.0",
"servers": [
{
"url": "/api",
"description": "Universität Duisburg-Essen"
}
],
"components": {
"securitySchemes": {
"admin" : {
"description" : "Operations requiring admin privileges.",
"type" : "http",
"scheme" : "basic"
},
"device" : {
"description" : "Operations requiring device privileges.",
"type" : "apiKey",
"in": "header",
"name": "Authorization"
},
"user" : {
"description" : "Operations requiring a valid user.",
"type" : "http",
"scheme" : "basic"
}
}
}
}
@@ -1,6 +0,0 @@
{
"admin" : {
"description" : "Operations requiring admin privileges.",
"type" : "basic"
}
}
@@ -1,8 +0,0 @@
{
"device" : {
"description" : "Operations requiring device privileges.",
"type" : "apiKey",
"in": "header",
"name": "Authorization"
}
}
@@ -1,6 +0,0 @@
{
"user" : {
"description" : "Operations requiring a valid user.",
"type" : "basic"
}
}
@@ -8,9 +8,9 @@ import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller;
import org.junit.Assert;
import org.junit.Test;
@@ -16,12 +16,12 @@ import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServlet;
@RequestScoped
public class AlexaServlet extends HttpServlet {
@@ -23,7 +23,7 @@ import java.util.Locale;
import java.util.Optional;
import java.util.ResourceBundle;
import javax.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaBuilder;
import static com.amazon.ask.request.Predicates.intentName;
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns = "http://xmlns.jcp.org/xml/ns/javaee"
<web-app xmlns = "https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd "
xsi:schemaLocation = "https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd "
version = "4.0">
<display-name>alexaservlet</display-name>
@@ -690,7 +690,6 @@ public class VideoEncoder {
@Override
protected void finalize() throws Throwable {
release();
super.finalize();
}
}
@@ -343,7 +343,6 @@ public class VideoInterpolator {
@Override
protected void finalize() throws Throwable {
release();
super.finalize();
}
+4 -4
View File
@@ -9,6 +9,7 @@ configurations {
dependencies {
api project(':common-api')
api project(':service-data')
api "org.mapstruct:mapstruct-jdk8:${mapstructVersion}"
api "org.infinispan:infinispan-query:${versionInfinispan}"
api "com.locoslab.library.geometry:geometry-wgs:${versionGeometry}"
@@ -18,7 +19,7 @@ dependencies {
compileOnly "com.fasterxml.jackson.core:jackson-databind:${versionJackson}"
compileOnly "org.hibernate:hibernate-search-orm:${versionHibernateSearch}"
compileOnly "org.hibernate.search:hibernate-search-mapper-orm-jakarta:${versionHibernateSearch}"
compileOnly "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
compileOnly "com.fasterxml.jackson.core:jackson-annotations:${versionJackson}"
compileOnly "org.mapstruct:mapstruct-processor:${mapstructVersion}"
@@ -26,13 +27,12 @@ dependencies {
testImplementation "org.infinispan:infinispan-core:${versionInfinispan}"
testImplementation "org.infinispan:infinispan-commons:${versionInfinispan}"
testImplementation "org.infinispan:infinispan-query:${versionInfinispan}"
testImplementation "org.hibernate:hibernate-search-orm:${versionHibernateSearch}"
testImplementation "org.hibernate.search:hibernate-search-mapper-orm-jakarta:${versionHibernateSearch}"
testImplementation "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
testImplementation "javax.xml.bind:jaxb-api:${versionJaxb}"
testImplementation "jakarta.xml.bind:jakarta.xml.bind-api:${versionJaxb}"
testImplementation "com.fasterxml.jackson.core:jackson-databind:${versionJackson}"
testImplementation "junit:junit:${versionJunit}"
testImplementation "org.picketbox:picketbox:${versionPicketbox}"
testImplementation "org.jboss.arquillian.junit:arquillian-junit-container:${versionArquillianJunit}"
testImplementation "org.wildfly.arquillian:wildfly-arquillian-container-managed:${versionArquillianContainer}"
@@ -8,21 +8,21 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NoResultException;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.NoResultException;
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Root;
import com.mowesta.api.PageConfig;
@@ -5,15 +5,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.Lob;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import javax.validation.constraints.NotNull;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.Lob;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Root;
import jakarta.validation.constraints.NotNull;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
@@ -22,11 +22,13 @@ import org.apache.lucene.search.SortField.Type;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.SortableField;
import org.hibernate.search.jpa.FullTextEntityManager;
import org.hibernate.search.jpa.FullTextQuery;
import org.hibernate.search.jpa.Search;
import org.hibernate.search.query.dsl.EntityContext;
import org.hibernate.search.query.dsl.QueryBuilder;
import org.hibernate.search.engine.search.predicate.SearchPredicate;
import org.hibernate.search.engine.search.predicate.spi.SearchPredicateBuilderFactory;
import org.hibernate.search.engine.search.query.SearchQuery;
import org.hibernate.search.engine.search.query.dsl.SearchQueryOptionsStep;
import org.hibernate.search.mapper.orm.Search;
import org.hibernate.search.mapper.orm.search.loading.dsl.SearchLoadingOptionsStep;
import org.hibernate.search.mapper.orm.session.SearchSession;
import com.mowesta.api.Coordinate;
import com.mowesta.api.Language;
@@ -260,8 +262,10 @@ public abstract class AbstractLocationEntity extends AbstractSpatialEntity {
* @return The count.
*/
public static int countAllByTerm(EntityManager em, Language language, String term) {
FullTextQuery query = createQueryByTerm(em, language, term);
return query.getResultSize();
// TODO: adapt
return 0;
// FullTextQuery query = createQueryByTerm(em, language, term);
// return query.getResultSize();
}
/**
@@ -277,13 +281,16 @@ public abstract class AbstractLocationEntity extends AbstractSpatialEntity {
@SuppressWarnings("unchecked")
public static List<AbstractLocationEntity> findAllByTerm(EntityManager em, PageConfig config,
Language language, String term) {
// TODO: fixme
return new ArrayList<>();
/*
FullTextQuery query = createQueryByTerm(em, language, term);
query.setSort(new Sort(SortField.FIELD_SCORE, new SortField("importance", Type.DOUBLE, true), new SortField("searchRank", Type.INT)));
query.setFirstResult(config.getOffset());
query.setMaxResults(config.getSize());
query.setProjection(FullTextQuery.OBJECT_CLASS, FullTextQuery.ID, FullTextQuery.DOCUMENT_ID, FullTextQuery.SCORE);
List<Object[]> projection = (List<Object[]>) query.getResultList();
return loadAll(em, projection, AbstractLocationEntity.class);
return loadAll(em, projection, AbstractLocationEntity.class);*/
}
@@ -296,15 +303,18 @@ public abstract class AbstractLocationEntity extends AbstractSpatialEntity {
* @param term The term to search.
* @return The query.
*/
private static FullTextQuery createQueryByTerm(EntityManager em, Language language, String term) {
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(em);
/* private static FullTextQuery createQueryByTerm(EntityManager em, Language language, String term) {
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(em);
QueryBuilder baseBuilder = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(AbstractLocationEntity.class).get();
Query q1 = createSubQuery(fullTextEntityManager, CityEntity.class, new String[]{"names", "state.names", "country.names"}, language, term);
Query q2 = createSubQuery(fullTextEntityManager, StateEntity.class, new String[]{"names", "country.names"}, language, term);
Query q3 = createSubQuery(fullTextEntityManager, CountryEntity.class, new String[]{"names"}, language, term);
Query query = baseBuilder.bool().should(q1).should(q2).should(q3).createQuery();
return fullTextEntityManager.createFullTextQuery(query, AbstractLocationEntity.class);
}
}*/
/**
* Creates a sub query for a particular entity type.
@@ -316,7 +326,7 @@ public abstract class AbstractLocationEntity extends AbstractSpatialEntity {
* @param term The term to search.
* @return The sub query to search the term.
*/
protected static Query createSubQuery(FullTextEntityManager tem, Class<? extends AbstractLocationEntity> cls, String[] text, Language language, String term) {
/* protected static <T extends AbstractLocationEntity> SearchPredicate createSubQuery(SearchPredicateBuilderFactory tem, Class<T> cls, String[] text, Language language, String term) {
String[] names = new String[] { "acronym", "local", null };
String[] analyzers = new String[] { "search-default", "search-default", null };
switch (language) {
@@ -341,6 +351,7 @@ public abstract class AbstractLocationEntity extends AbstractSpatialEntity {
analyzers[2] = "search-default";
break;
}
EntityContext context = tem.getSearchFactory().buildQueryBuilder().forEntity(cls);
String[] fields = new String[names.length * text.length];
for (int i = 0; i < text.length; i++) {
@@ -352,7 +363,7 @@ public abstract class AbstractLocationEntity extends AbstractSpatialEntity {
}
QueryBuilder builder = context.get();
return builder.keyword().onFields(fields).matching(term).createQuery();
}
}*/
/**
* Loads all location entites from a projection represented as an array consisting of (at least) object class and object id.
@@ -407,8 +418,7 @@ public abstract class AbstractLocationEntity extends AbstractSpatialEntity {
* @return The count.
*/
public static int findAllByRange(EntityManager em, Coordinate c1, Coordinate c2, Class<? extends AbstractLocationEntity> type) {
FullTextQuery query = createRangeQuery(em, c1, c2, type);
return query.getResultSize();
return (int)createRangeQuery(em, c1, c2, type).fetchTotalHitCount();
}
@@ -427,13 +437,8 @@ public abstract class AbstractLocationEntity extends AbstractSpatialEntity {
*/
@SuppressWarnings("unchecked")
public static <T extends AbstractLocationEntity> List<T> findAllByRange(EntityManager em, PageConfig config, Coordinate c1, Coordinate c2, Class<T> type) {
FullTextQuery query = createRangeQuery(em, c1, c2, type);
query.setSort(new Sort(SortField.FIELD_SCORE, new SortField("importance", Type.DOUBLE, true), new SortField("addressRank", Type.INT)));
query.setFirstResult(config.getOffset());
query.setMaxResults(config.getSize());
query.setProjection(FullTextQuery.OBJECT_CLASS, FullTextQuery.ID, FullTextQuery.DOCUMENT_ID, FullTextQuery.SCORE);
List<Object[]> projection = (List<Object[]>) query.getResultList();
return loadAll(em, projection, type);
SearchQueryOptionsStep<?, T, SearchLoadingOptionsStep, ?, ?> query= createRangeQuery(em, c1, c2, type);
return query.fetchHits(config.getOffset(), config.getSize());
}
/**
@@ -445,15 +450,16 @@ public abstract class AbstractLocationEntity extends AbstractSpatialEntity {
* @param type The type of objects.
* @return The query.
*/
private static <T extends AbstractLocationEntity> FullTextQuery createRangeQuery(EntityManager em, Coordinate c1, Coordinate c2, Class<T> type) {
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(em);
QueryBuilder builder = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(type).get();
Query minLat = builder.range().onField("coordinate.latitude").above(Math.min(c1.getLatitude(), c2.getLatitude())).createQuery();
Query maxLat = builder.range().onField("coordinate.latitude").below(Math.max(c1.getLatitude(), c2.getLatitude())).excludeLimit().createQuery();
Query minLon = builder.range().onField("coordinate.longitude").above(Math.min(c1.getLongitude(), c2.getLongitude())).createQuery();
Query maxLon = builder.range().onField("coordinate.longitude").below(Math.max(c1.getLongitude(), c2.getLongitude())).excludeLimit().createQuery();
Query query = builder.bool().must(minLat).must(maxLat).must(minLon).must(maxLon).createQuery();
return fullTextEntityManager.createFullTextQuery(query, type);
private static <T extends AbstractLocationEntity> SearchQueryOptionsStep<?, T, SearchLoadingOptionsStep, ?, ?> createRangeQuery(EntityManager em, Coordinate c1, Coordinate c2, Class<T> type) {
double tllat = Math.max(c1.getLatitude(), c2.getLatitude());
double tllon = Math.min(c1.getLongitude(), c2.getLongitude());
double brlat = Math.min(c1.getLatitude(), c2.getLatitude());
double brlon = Math.max(c1.getLongitude(), c2.getLongitude());
SearchSession session = Search.session(em);
return session.search(type).select(type).where((f, c) -> {
c.add(f.spatial().within().field("coordiante").boundingBox(tllat, tllon, brlat, brlon));
});
}
@@ -1,26 +1,19 @@
package com.mowesta.service.entity;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.validation.constraints.NotNull;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.validation.constraints.NotNull;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.SortableField;
import org.hibernate.search.annotations.Spatial;
import org.hibernate.search.annotations.SpatialMode;
import org.hibernate.search.jpa.FullTextEntityManager;
import org.hibernate.search.jpa.FullTextQuery;
import org.hibernate.search.jpa.Search;
import org.hibernate.search.query.dsl.QueryBuilder;
import org.hibernate.search.query.dsl.Unit;
import org.hibernate.search.spatial.DistanceSortField;
import org.hibernate.search.mapper.orm.Search;
import com.locoslab.library.geometry.wgs.HaversineDistance;
import com.mowesta.api.Coordinate;
/**
@@ -71,23 +64,20 @@ public abstract class AbstractSpatialEntity extends AbstractEntity {
* @param limit The maximum number to return or -1 to return all.
* @return The nearest (limit) forecasts from the coordinate that are at most (range) away.
*/
@SuppressWarnings("unchecked")
public static <E extends AbstractSpatialEntity> List<E> findByLocation(EntityManager em, Class<E> type, Coordinate location, int range, int limit) {
FullTextEntityManager manager = Search.getFullTextEntityManager(em);
QueryBuilder qb = manager.getSearchFactory().buildQueryBuilder().forEntity(type).get();
Query query = qb.spatial().onField("coordinate").within(range, Unit.KM)
.ofLatitude(location.getLatitude()).andLongitude(location.getLongitude())
.createQuery();
Sort order = new Sort(new DistanceSortField(location.getLatitude(), location.getLongitude(), "coordinate"));
List<E> result = new ArrayList<>();
FullTextQuery q = manager.createFullTextQuery(query, type).setSort(order);
if (limit >= 0) q = q.setMaxResults(limit);
for (Object o: q.getResultList()) {
if (type.isAssignableFrom(o.getClass())) {
result.add((E)o);
}
}
return result;
List<E> result = Search.session(em).search(type).selectEntity().where((f, c)-> {
c.add(f.spatial().within().field("coordinate").circle(location.getLatitude(), location.getLongitude(), range * 1000));
}).fetchAllHits();
result.sort((a, b) -> {
double ax = HaversineDistance.getDistance(a.getCoordinate().getLongitude(), a.getCoordinate().getLatitude(), location.getLongitude(), location.getLatitude());
double bx = HaversineDistance.getDistance(b.getCoordinate().getLongitude(), b.getCoordinate().getLatitude(), location.getLongitude(), location.getLatitude());
return Double.compare(ax, bx);
});
while (limit > 0 && result.size() > limit) {
result.remove(result.size() - 1);
}
return result;
}
}
@@ -2,12 +2,12 @@ package com.mowesta.service.entity;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import jakarta.persistence.EntityManager;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import com.mowesta.api.PageConfig;
@@ -1,34 +1,28 @@
package com.mowesta.service.entity;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.validation.constraints.NotNull;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.validation.constraints.NotNull;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.jpa.FullTextEntityManager;
import org.hibernate.search.jpa.FullTextQuery;
import org.hibernate.search.jpa.Search;
import org.hibernate.search.query.dsl.QueryBuilder;
import com.mowesta.api.Language;
import com.mowesta.api.PageConfig;
@@ -213,8 +207,10 @@ public class CityEntity extends AbstractLocationEntity {
* @return The count.
*/
public static int countByTerm(EntityManager em, Language language, String term) {
FullTextQuery query = createQueryByTerm(em, language, term);
return query.getResultSize();
// TODO: fixme
return 0;
// FullTextQuery query = createQueryByTerm(em, language, term);
// return query.getResultSize();
}
/**
@@ -229,13 +225,16 @@ public class CityEntity extends AbstractLocationEntity {
*/
@SuppressWarnings("unchecked")
public static List<CityEntity> findByTerm(EntityManager em, PageConfig config, Language language, String term) {
FullTextQuery query = createQueryByTerm(em, language, term);
// TODO: fixme
return new ArrayList<>();
/*FullTextQuery query = createQueryByTerm(em, language, term);
query.setSort(new Sort(SortField.FIELD_SCORE, new SortField("importance", SortField.Type.DOUBLE, true), new SortField("searchRank", SortField.Type.INT)));
query.setFirstResult(config.getOffset());
query.setMaxResults(config.getSize());
query.setProjection(FullTextQuery.OBJECT_CLASS, FullTextQuery.ID, FullTextQuery.DOCUMENT_ID, FullTextQuery.SCORE);
List<Object[]> projection = (List<Object[]>) query.getResultList();
return loadAll(em, projection, CityEntity.class);
return loadAll(em, projection, CityEntity.class);*/
}
@@ -248,11 +247,11 @@ public class CityEntity extends AbstractLocationEntity {
* @param term The term to search.
* @return The query.
*/
private static FullTextQuery createQueryByTerm(EntityManager em, Language language, String term) {
/* private static FullTextQuery createQueryByTerm(EntityManager em, Language language, String term) {
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(em);
Query q1 = createSubQuery(fullTextEntityManager, CityEntity.class, new String[]{"names", "state.names", "country.names"}, language, term);
return fullTextEntityManager.createFullTextQuery(q1, CityEntity.class);
}
}*/
/**
@@ -2,20 +2,20 @@ package com.mowesta.service.entity;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NoResultException;
import javax.persistence.Table;
import javax.persistence.TypedQuery;
import javax.persistence.UniqueConstraint;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.NamedQueries;
import jakarta.persistence.NamedQuery;
import jakarta.persistence.NoResultException;
import jakarta.persistence.Table;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.UniqueConstraint;
/**
* The entity that represents codes sent out to the user.
@@ -2,11 +2,11 @@ package com.mowesta.service.entity;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Index;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.Indexed;
@@ -1,19 +1,19 @@
package com.mowesta.service.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NoResultException;
import javax.persistence.Table;
import javax.persistence.TypedQuery;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.NamedQueries;
import jakarta.persistence.NamedQuery;
import jakarta.persistence.NoResultException;
import jakarta.persistence.Table;
import jakarta.persistence.TypedQuery;
import com.mowesta.api.device.OperatingSystem;
@@ -1,13 +1,13 @@
package com.mowesta.service.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
/**
* An entity to manage email addresses of users.
@@ -3,7 +3,7 @@ package com.mowesta.service.entity;
import java.util.Objects;
import java.util.StringJoiner;
import javax.persistence.Embeddable;
import jakarta.persistence.Embeddable;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Spatial;
@@ -1,9 +1,9 @@
package com.mowesta.service.entity;
import javax.persistence.Embeddable;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.validation.constraints.NotNull;
import jakarta.persistence.Embeddable;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.validation.constraints.NotNull;
import com.mowesta.api.location.LocationType;
@@ -1,8 +1,8 @@
package com.mowesta.service.entity;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.validation.constraints.NotNull;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.validation.constraints.NotNull;
import org.apache.lucene.analysis.core.LowerCaseFilterFactory;
import org.apache.lucene.analysis.de.GermanNormalizationFilterFactory;
@@ -2,19 +2,19 @@ package com.mowesta.service.entity;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Root;
import com.mowesta.api.TimeRange;
@@ -3,25 +3,25 @@ package com.mowesta.service.entity;
import java.util.List;
import java.util.Map;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.EnumType;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MapKeyColumn;
import javax.persistence.MapKeyEnumerated;
import javax.persistence.Table;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.validation.constraints.NotNull;
import jakarta.persistence.CollectionTable;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EnumType;
import jakarta.persistence.FetchType;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.MapKeyColumn;
import jakarta.persistence.MapKeyEnumerated;
import jakarta.persistence.Table;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.validation.constraints.NotNull;
import com.mowesta.api.PageConfig;
import com.mowesta.api.TimeRange;
@@ -2,18 +2,18 @@ package com.mowesta.service.entity;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NoResultException;
import javax.persistence.Table;
import javax.persistence.TypedQuery;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.NamedQueries;
import jakarta.persistence.NamedQuery;
import jakarta.persistence.NoResultException;
import jakarta.persistence.Table;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.UniqueConstraint;
import jakarta.validation.constraints.NotNull;
/**
* An entity to define user roles.
@@ -2,15 +2,15 @@ package com.mowesta.service.entity;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.Indexed;
@@ -3,30 +3,30 @@ package com.mowesta.service.entity;
import java.util.List;
import java.util.Set;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NoResultException;
import javax.persistence.OneToMany;
import javax.persistence.OrderColumn;
import javax.persistence.Table;
import javax.persistence.TypedQuery;
import javax.persistence.UniqueConstraint;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import jakarta.persistence.CollectionTable;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.FetchType;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.NamedQueries;
import jakarta.persistence.NamedQuery;
import jakarta.persistence.NoResultException;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OrderColumn;
import jakarta.persistence.Table;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import com.mowesta.api.PageConfig;
@@ -2,20 +2,20 @@ package com.mowesta.service.entity;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.Table;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.FetchType;
import jakarta.persistence.Index;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.NamedQueries;
import jakarta.persistence.Table;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
@@ -3,22 +3,22 @@ package com.mowesta.service.entity;
import java.util.List;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.NamedQueries;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.validation.constraints.NotNull;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.Index;
import jakarta.persistence.NamedQueries;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.validation.constraints.NotNull;
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.Field;
@@ -1,9 +1,9 @@
package com.mowesta.service.injection;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceProperty;
import jakarta.enterprise.inject.Produces;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import jakarta.persistence.PersistenceProperty;
/**
* The producers for data sources.
@@ -2,8 +2,8 @@ package com.mowesta.service.injection;
import java.util.logging.Logger;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import jakarta.enterprise.inject.Produces;
import jakarta.enterprise.inject.spi.InjectionPoint;
/**
* The producers for loggers.
@@ -8,8 +8,8 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;
/**
* The produces for predictions and video configurations.
@@ -1,8 +1,8 @@
package com.mowesta.service.injection;
import javax.annotation.Resource;
import javax.enterprise.inject.Produces;
import javax.mail.Session;
import jakarta.annotation.Resource;
import jakarta.enterprise.inject.Produces;
import jakarta.mail.Session;
/**
* Injection class for email session.
@@ -7,9 +7,9 @@ import java.lang.annotation.Target;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Qualifier;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;
import jakarta.inject.Qualifier;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -10,7 +10,7 @@ import com.mowesta.service.entity.DeviceEntity;
import com.mowesta.service.entity.EmailEntity;
import com.mowesta.service.entity.UserEntity;
import javax.persistence.EntityManager;
import jakarta.persistence.EntityManager;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -2,8 +2,8 @@ package com.mowesta.service.session;
import java.security.Principal;
import javax.annotation.Resource;
import javax.ejb.SessionContext;
import jakarta.annotation.Resource;
import jakarta.ejb.SessionContext;
import com.mowesta.service.entity.DeviceEntity;
import com.mowesta.service.entity.UserEntity;
@@ -8,8 +8,8 @@ import com.mowesta.service.conversion.Convert;
import com.mowesta.service.entity.AbstractEntity;
import com.mowesta.service.entity.OrderCriterion;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import jakarta.inject.Inject;
import jakarta.persistence.EntityManager;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
@@ -4,12 +4,12 @@ import java.util.HashSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.security.PermitAll;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import jakarta.annotation.security.PermitAll;
import jakarta.ejb.Stateless;
import jakarta.ejb.TransactionAttribute;
import jakarta.ejb.TransactionAttributeType;
import jakarta.inject.Inject;
import jakarta.persistence.EntityManager;
import com.mowesta.api.access.Roles;
import com.mowesta.service.crypto.SecureHash;
@@ -13,10 +13,10 @@ import com.mowesta.service.crypto.SecureToken;
import com.mowesta.service.crypto.TokenType;
import com.mowesta.service.entity.*;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.ejb.Stateless;
import jakarta.annotation.security.DeclareRoles;
import jakarta.annotation.security.PermitAll;
import jakarta.annotation.security.RolesAllowed;
import jakarta.ejb.Stateless;
/**
* A stateful session bean to manage devices.
@@ -186,7 +186,7 @@ public class DeviceSessionBean extends AbstractUserSpecificSessionBean {
*/
@RolesAllowed({ Roles.ADMIN })
public Device setDevice(long id, Device device) throws EntityNotFoundException {
DeviceEntity entity = em.find(DeviceEntity.class, new Long(id));
DeviceEntity entity = em.find(DeviceEntity.class, Long.valueOf(id));
if (entity == null)
throw new EntityNotFoundException(DeviceEntity.class, id, "Device not found.");
entity.setDeleted(device.isDeleted());
@@ -226,7 +226,7 @@ public class DeviceSessionBean extends AbstractUserSpecificSessionBean {
*/
@RolesAllowed({ Roles.ADMIN, Roles.USER })
public DeviceEntity getDeviceEntity(long id) throws EntityNotFoundException, EntityForbiddenException {
DeviceEntity device = em.find(DeviceEntity.class, new Long(id));
DeviceEntity device = em.find(DeviceEntity.class, Long.valueOf(id));
if (device == null)
throw new EntityNotFoundException(DeviceEntity.class, id, "Device not found.");
if (!sessionContext.isCallerInRole(Roles.ADMIN)) {
@@ -3,25 +3,25 @@ package com.mowesta.service.session;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.mail.Message;
import javax.mail.Message.RecipientType;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import jakarta.ejb.Stateless;
import jakarta.inject.Inject;
import jakarta.mail.Message;
import jakarta.mail.Message.RecipientType;
import jakarta.mail.MessagingException;
import jakarta.mail.Session;
import jakarta.mail.Transport;
import jakarta.mail.internet.AddressException;
import jakarta.mail.internet.InternetAddress;
import jakarta.mail.internet.MimeMessage;
import com.mowesta.service.template.EmailAssignment;
import com.mowesta.service.template.EmailMessage;
import com.mowesta.service.template.EmailTemplate;
/**
* The default email session bean that uses javax.mail to send
* The default email session bean that uses jakarta.mail to send
* emails.
*
* @author Marcus
@@ -4,20 +4,20 @@ import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.ejb.Asynchronous;
import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.SessionContext;
import javax.ejb.Singleton;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.transaction.Transactional.TxType;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import jakarta.ejb.Asynchronous;
import jakarta.ejb.ConcurrencyManagement;
import jakarta.ejb.ConcurrencyManagementType;
import jakarta.ejb.SessionContext;
import jakarta.ejb.Singleton;
import jakarta.ejb.TransactionAttribute;
import jakarta.ejb.TransactionAttributeType;
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import jakarta.transaction.Transactional.TxType;
import org.infinispan.Cache;
import org.infinispan.configuration.cache.Configuration;
@@ -7,9 +7,9 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.security.PermitAll;
import javax.ejb.Stateless;
import javax.inject.Inject;
import jakarta.annotation.security.PermitAll;
import jakarta.ejb.Stateless;
import jakarta.inject.Inject;
import com.mowesta.api.Coordinate;
import com.mowesta.api.PageConfig;
@@ -128,7 +128,7 @@ public class LocationSessionBean extends AbstractSessionBean {
*/
@PermitAll
public City getCity(long id, boolean filtered) throws EntityNotFoundException {
CityEntity city = em.find(CityEntity.class, new Long(id));
CityEntity city = em.find(CityEntity.class, Long.valueOf(id));
if (city == null || (filtered && city.isDeleted()))
throw new EntityNotFoundException(CityEntity.class, id, "City not found.");
return Convert.with(CityConverter.class).apply(city, filtered);
@@ -144,7 +144,7 @@ public class LocationSessionBean extends AbstractSessionBean {
*/
@PermitAll
public State getState(long id, boolean filtered) throws EntityNotFoundException {
StateEntity state = em.find(StateEntity.class, new Long(id));
StateEntity state = em.find(StateEntity.class, Long.valueOf(id));
if (state == null || (filtered && state.isDeleted()))
throw new EntityNotFoundException(StateEntity.class, id, "State not found.");
return Convert.with(StateConverter.class).apply(state, filtered);
@@ -160,7 +160,7 @@ public class LocationSessionBean extends AbstractSessionBean {
*/
@PermitAll
public Country getCountry(long id, boolean filtered) throws EntityNotFoundException {
CountryEntity country = em.find(CountryEntity.class, new Long(id));
CountryEntity country = em.find(CountryEntity.class, Long.valueOf(id));
if (country == null || (filtered && country.isDeleted()))
throw new EntityNotFoundException(CountryEntity.class, id, "Country not found.");
return Convert.with(CountryConverter.class).apply(country, filtered);
@@ -178,7 +178,7 @@ public class LocationSessionBean extends AbstractSessionBean {
@PermitAll
public long getLastModifiedCity(long id) {
long result = 0;
CityEntity city = em.find(CityEntity.class, new Long(id));
CityEntity city = em.find(CityEntity.class, Long.valueOf(id));
if (city == null)
return result;
if (city.getState() != null)
@@ -199,7 +199,7 @@ public class LocationSessionBean extends AbstractSessionBean {
@PermitAll
public long getLastModifiedState(long id) {
long result = 0;
StateEntity state = em.find(StateEntity.class, new Long(id));
StateEntity state = em.find(StateEntity.class, Long.valueOf(id));
if (state == null)
return result;
if (state.getCountry() != null)
@@ -217,7 +217,7 @@ public class LocationSessionBean extends AbstractSessionBean {
*/
@PermitAll
public long getLastModifiedCountry(long id) {
CountryEntity country = em.find(CountryEntity.class, new Long(id));
CountryEntity country = em.find(CountryEntity.class, Long.valueOf(id));
if (country == null) return 0;
else return country.getModificationTime();
}
@@ -258,7 +258,7 @@ public class LocationSessionBean extends AbstractSessionBean {
*/
@PermitAll
public String getCityBoundary(long id) throws EntityNotFoundException {
CityEntity city = em.find(CityEntity.class, new Long(id));
CityEntity city = em.find(CityEntity.class, Long.valueOf(id));
if (city == null)
throw new EntityNotFoundException(CityEntity.class, id, "City not found.");
return city.getBoundary();
@@ -274,7 +274,7 @@ public class LocationSessionBean extends AbstractSessionBean {
*/
@PermitAll
public String getStateBoundary(long id) throws EntityNotFoundException {
StateEntity state = em.find(StateEntity.class, new Long(id));
StateEntity state = em.find(StateEntity.class, Long.valueOf(id));
if (state == null)
throw new EntityNotFoundException(StateEntity.class, id, "State not found.");
return state.getBoundary();
@@ -290,7 +290,7 @@ public class LocationSessionBean extends AbstractSessionBean {
*/
@PermitAll
public String getCountryBoundary(long id) throws EntityNotFoundException {
CountryEntity country = em.find(CountryEntity.class, new Long(id));
CountryEntity country = em.find(CountryEntity.class, Long.valueOf(id));
if (country == null)
throw new EntityNotFoundException(CountryEntity.class, id, "Country not found.");
return country.getBoundary();
@@ -346,7 +346,7 @@ public class LocationSessionBean extends AbstractSessionBean {
*/
@PermitAll
public CityPage getStateCities(long id, PageConfig config, boolean filtered) throws EntityNotFoundException {
StateEntity state = em.find(StateEntity.class, new Long(id));
StateEntity state = em.find(StateEntity.class, Long.valueOf(id));
if (state == null || filtered && state.isDeleted())
throw new EntityNotFoundException(StateEntity.class, id, "State not found.");
return getLocationCities(state, config, filtered);
@@ -364,7 +364,7 @@ public class LocationSessionBean extends AbstractSessionBean {
*/
@PermitAll
public CityPage getCountryCities(long id, PageConfig config, boolean filtered) throws EntityNotFoundException {
CountryEntity country = em.find(CountryEntity.class, new Long(id));
CountryEntity country = em.find(CountryEntity.class, Long.valueOf(id));
if (country == null || filtered && country.isDeleted())
throw new EntityNotFoundException(CountryEntity.class, id, "Country not found.");
return getLocationCities(country, config, filtered);
@@ -10,14 +10,14 @@ import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Singleton;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.annotation.security.DeclareRoles;
import jakarta.annotation.security.PermitAll;
import jakarta.annotation.security.RolesAllowed;
import jakarta.ejb.ConcurrencyManagement;
import jakarta.ejb.ConcurrencyManagementType;
import jakarta.ejb.Singleton;
import com.mowesta.api.access.Roles;
import com.mowesta.api.log.LogMessage;

Some files were not shown because too many files have changed in this diff Show More