Skip to content

Commit

Permalink
Additional settings for the REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
bpross-52n committed Oct 1, 2020
1 parent 42f4235 commit 0fddefa
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 11 deletions.
18 changes: 17 additions & 1 deletion rest/src/main/java/org/n52/javaps/rest/ApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,28 @@
*/
package org.n52.javaps.rest;

import java.net.URI;

import org.n52.faroe.Validation;
import org.n52.faroe.annotation.Configurable;
import org.n52.faroe.annotation.Setting;
import org.n52.javaps.rest.settings.RestSettingsConstants;
import org.springframework.stereotype.Controller;

@Controller
@Configurable
public class ApiController implements Api {

private URI apiURI;

@Setting(RestSettingsConstants.API_URI)
public void setDescription(URI apiURI) {
Validation.notNull("apiURI", apiURI);
this.apiURI = apiURI;
}

@Override
public String api() {
return "redirect:https://app.swaggerhub.com/apis/geoprocessing/WPS/1.0-draft";
return "redirect:" + apiURI;
}
}
31 changes: 21 additions & 10 deletions rest/src/main/java/org/n52/javaps/rest/LandingPageApiImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,29 @@
*/
package org.n52.javaps.rest;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;

import org.n52.faroe.Validation;
import org.n52.faroe.annotation.Configurable;
import org.n52.faroe.annotation.Setting;
import org.n52.iceland.service.ServiceSettings;
import org.n52.javaps.rest.model.Link;
import org.n52.javaps.rest.model.LandingPage;
import org.n52.javaps.rest.model.Link;
import org.n52.javaps.rest.settings.RestSettingsConstants;
import org.springframework.stereotype.Controller;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;

/**
* Home redirection to swagger api documentation
* Landing page
*/
@Controller
@Configurable
public class LandingPageApiImpl implements LandingPageApi {

private String serviceURL;
private String title;
private String description;

@Setting(ServiceSettings.SERVICE_URL)
public void setServiceURL(URI serviceURL) {
Expand All @@ -47,12 +50,20 @@ public void setServiceURL(URI serviceURL) {
this.serviceURL = url.replace("/service", BASE_URL);
}

@Override
public LandingPage landingPage() {
@Setting(RestSettingsConstants.TITLE)
public void setTitle(String title) {
Validation.notNull("title", title);
this.title = title;
}

String title = "52°North draft OGC API - Processes";
@Setting(RestSettingsConstants.DESCRIPTION)
public void setDescription(String description) {
Validation.notNull("description", description);
this.description = description;
}

String description = "52°North draft OGC API - Processes, powered by javaPS";
@Override
public LandingPage landingPage() {

List<Link> links = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
public class RestSettingsConstants {

public static final String ENABLE_JOB_LIST_EXTENSION = "rest.enable.joblist.extension";
public static final String TITLE = "rest.title";
public static final String DESCRIPTION = "rest.description";
public static final String API_URI = "rest.api.uri";

}
27 changes: 27 additions & 0 deletions webapp/src/main/resources/settings/settings-rest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,31 @@
<property name="defaultValue" value="false" />
</bean>

<bean class="org.n52.faroe.settings.StringSettingDefinition">
<property name="key" value="rest.title" />
<property name="title" value="REST title" />
<property name="description" value="The title of the REST landingpage" />
<property name="order" value="6.0" />
<property name="group" ref="restSettingDefinitionGroup" />
<property name="defaultValue" value="52°North draft OGC API - Processes" />
</bean>

<bean class="org.n52.faroe.settings.StringSettingDefinition">
<property name="key" value="rest.description" />
<property name="title" value="Rest description" />
<property name="description" value="The description of the REST landingpage" />
<property name="order" value="6.0" />
<property name="group" ref="restSettingDefinitionGroup" />
<property name="defaultValue" value="52°North draft OGC API - Processes, powered by javaPS" />
</bean>

<bean class="org.n52.faroe.settings.UriSettingDefinition">
<property name="key" value="rest.api.uri" />
<property name="title" value="API URI" />
<property name="description" value="The URI of the API. A calll to /api will redirect to this URI" />
<property name="order" value="6.0" />
<property name="group" ref="restSettingDefinitionGroup" />
<property name="defaultValue" value="https://app.swaggerhub.com/apis/geoprocessing/WPS/1.0-draft" />
</bean>

</beans>
12 changes: 12 additions & 0 deletions webapp/src/main/webapp/WEB-INF/config/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@
"rest.enable.joblist.extension" : {
"type" : "boolean",
"value" : false
},
"rest.title" : {
"type" : "string",
"value" : "52\u00B0North draft OGC API - Processes"
},
"rest.description" : {
"type" : "string",
"value" : "52\u00B0North draft OGC API - Processes, powered by javaPS"
},
"rest.api.uri" : {
"type" : "uri",
"value" : "https://app.swaggerhub.com/apiproxy/schema/file/apis/geoprocessing/WPS/1.0-draft.4?format=json"
}
}
}

0 comments on commit 0fddefa

Please sign in to comment.