diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/Main.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/Main.java index ace6645..42d247f 100644 --- a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/Main.java +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/Main.java @@ -15,6 +15,10 @@ */ package de.hsos.ecs.richwps.wpsmonitor.client; +import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientCreateException; +import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientException; +import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientWpsProcessNotFoundException; +import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientWpsNotFoundException; import de.hsos.ecs.richwps.wpsmonitor.client.resource.WpsMetricResource; import de.hsos.ecs.richwps.wpsmonitor.client.resource.WpsProcessResource; import de.hsos.ecs.richwps.wpsmonitor.client.resource.WpsResource; @@ -24,42 +28,99 @@ import java.util.logging.Logger; /** + * This is a simple Code Demonstration of the WpsMontiorClient. This Code also + * serves as a TestCode. To use this Code as a Test you must registred the WPS + * "http://localhost:8080/wps/WebProcessingService" and the Process + * "SimpleBuffer" in the WPSMonitor or simply change the static members below. + * + * Make sure the monitor is started and avaible (see the monitorUrl static + * Member). * * @author Florian Vogelpohl */ public class Main { + private static URL monitorUrl; + private static URL registredWpsUrl; + private static URL nonExistsWpsUrl; + private static String registredWpsProcess; + private static String nonExistsWpsProcess; + + static { + try { + monitorUrl = new URL("http://localhost:1111/"); + registredWpsUrl = new URL("http://localhost:8080/wps/WebProcessingService"); + nonExistsWpsUrl = new URL("http://example.com/this/wps/should/not/be/exists"); + registredWpsProcess = "SimpleBuffer"; + nonExistsWpsProcess = "AnyProcessWhichShouldNotExists"; + } catch (MalformedURLException ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public void listWps(final WpsMonitorClient client) throws WpsMonitorClientException { + for (final WpsResource wps : client.getAllWps()) { + System.out.println(wps); + } + } + + public void wpsNotFound(final WpsMonitorClient client) throws WpsMonitorClientException { + try { + client.getWps(nonExistsWpsUrl); + } catch (WpsMonitorClientWpsNotFoundException ex) { + System.out.println(ex); + } + } + + public void wpsNotFound2(final WpsMonitorClient client) throws WpsMonitorClientException { + try { + client.getWpsProcess(nonExistsWpsUrl, registredWpsProcess); + } catch (WpsMonitorClientWpsNotFoundException ex) { + System.out.println(ex); + } + } + + public void wpsProcessNotFound(final WpsMonitorClient client) throws WpsMonitorClientException { + try { + client.getWpsProcess(registredWpsUrl, nonExistsWpsProcess); + } catch (WpsMonitorClientWpsProcessNotFoundException ex) { + System.out.println(ex); + } + } + + public void findWpsProcess(final WpsMonitorClient client) throws WpsMonitorClientException { + WpsProcessResource wpsProcess = client.getWpsProcess(registredWpsUrl, registredWpsProcess); + + System.out.println("Wps Process:"); + System.out.println(wpsProcess.toString()); + System.out.println("Metrics:"); + + for (final WpsMetricResource metric : wpsProcess.getMetricsAsList()) { + System.out.println(metric.toString()); + } + } + public static void main(String[] args) { try { - WpsMonitorClient wpsMonitorClient = new WpsMonitorClientFactory().create(new URL("http://localhost:1111/")); - - System.out.println("List of WPS are available in the Monitor"); - System.out.println("----"); - - for (final WpsResource wpsResource : wpsMonitorClient.getAllWps()) { - System.out.println(wpsResource); - } - - System.out.println("----"); - - WpsResource pickup = wpsMonitorClient.getWps(new URL("http://localhost:8080/wps/WebProcessingService")); - - if (pickup != null) { - WpsProcessResource wpsProcess = wpsMonitorClient.getWpsProcess(pickup, "Blubb"); - - if (wpsProcess != null) { - System.out.println("Metrics"); - - for(WpsMetricResource r : wpsProcess.getMetricsAsList()) { - System.out.println(r); - } - } else { - System.out.println("Can't demonstrate the getProcessMetrics method, because there are no WpsProcess with the name \"Blubb\" are registrated in the Monitor"); - } - } else { - System.out.println("Can't demonstrate the metrics method, because there are no WPS registrated in the Monitor."); - } - } catch (MalformedURLException | WpsMonitorClientException | WpsMonitorClientCreateException ex) { + WpsMonitorClient wpsMonitorClient = new WpsMonitorClientFactory().create(monitorUrl); + + Main main = new Main(); + System.out.println("List WPS:"); + main.listWps(wpsMonitorClient); + + System.out.println("WPS Not Found:"); + main.wpsNotFound(wpsMonitorClient); + + System.out.println("WPS also Not Found:"); + main.wpsNotFound2(wpsMonitorClient); + + System.out.println("WPS Process not found but the WPS endpoint is registred:"); + main.wpsProcessNotFound(wpsMonitorClient); + + System.out.println("Show a registred WPS Process and the Metrics:"); + main.findWpsProcess(wpsMonitorClient); + + } catch (WpsMonitorClientException | WpsMonitorClientCreateException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClient.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClient.java index f3d2f9c..501487d 100644 --- a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClient.java +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClient.java @@ -15,6 +15,7 @@ */ package de.hsos.ecs.richwps.wpsmonitor.client; +import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientException; import de.hsos.ecs.richwps.wpsmonitor.client.resource.WpsProcessResource; import de.hsos.ecs.richwps.wpsmonitor.client.resource.WpsResource; import java.net.URL; diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientFactory.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientFactory.java index 7d9910d..63a6c69 100644 --- a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientFactory.java +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientFactory.java @@ -15,6 +15,7 @@ */ package de.hsos.ecs.richwps.wpsmonitor.client; +import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientCreateException; import com.google.gson.Gson; import de.hsos.ecs.richwps.wpsmonitor.client.http.HttpException; import de.hsos.ecs.richwps.wpsmonitor.client.http.WpsMonitorRequester; diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientImpl.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientImpl.java index 9413fa9..c621b54 100644 --- a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientImpl.java +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientImpl.java @@ -15,6 +15,9 @@ */ package de.hsos.ecs.richwps.wpsmonitor.client; +import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientException; +import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientWpsProcessNotFoundException; +import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientWpsNotFoundException; import de.hsos.ecs.richwps.wpsmonitor.client.http.HttpException; import de.hsos.ecs.richwps.wpsmonitor.client.http.WpsMonitorRequester; import de.hsos.ecs.richwps.wpsmonitor.client.resource.WpsProcessResource; @@ -71,7 +74,7 @@ private void initContext(final Boolean refresh) throws HttpException { List wpsList = requester.getWpsList(); for (final WpsEntity entity : wpsList) { - wpsContext.put(entity.getUri(), ResourceConverter.WpsEntityToResource(entity)); + wpsContext.put(entity.getEndpoint(), ResourceConverter.WpsEntityToResource(entity)); } } } @@ -100,7 +103,13 @@ public WpsProcessResource getWpsProcess(final WpsResource wpsResource, final Str public WpsProcessResource getWpsProcess(final WpsResource wpsResource, final String wpsProcessIdentifier, final Integer consider) throws WpsMonitorClientException { try { - return requester.getProcess(wpsResource, wpsProcessIdentifier, consider); + WpsProcessResource process = requester.getProcess(wpsResource, wpsProcessIdentifier, consider); + + if(process == null) { + throw new WpsMonitorClientWpsProcessNotFoundException(wpsProcessIdentifier, wpsResource.getWpsEndPoint()); + } + + return process; } catch (HttpException ex) { throw new WpsMonitorClientException("Can't Request Process metrics.", ex); } @@ -120,7 +129,11 @@ public WpsResource getWps(final URL wpsEndPoint, final Boolean forceRefresh) try { initContext(forceRefresh); WpsResource result = wpsContext.get(wpsEndPoint); - + + if(result == null) { + throw new WpsMonitorClientWpsNotFoundException(wpsEndPoint); + } + return result; } catch (HttpException ex) { throw new WpsMonitorClientException("Can't initalize WpsContent.", ex); @@ -140,7 +153,7 @@ public List getAllWps(final Boolean forceRefresh) initContext(forceRefresh); return new ArrayList<>(wpsContext.values()); } catch (HttpException ex) { - throw new WpsMonitorClientException("Can't request List of WPS.", ex); + throw new WpsMonitorClientException("Can't request List of WPS. Maybe the Monitor is offline (used endpoint: " + monitorEndpoint.toString() + ")", ex); } } diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientCreateException.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientCreateException.java similarity index 93% rename from client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientCreateException.java rename to client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientCreateException.java index 136f88c..9299d85 100644 --- a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientCreateException.java +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientCreateException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package de.hsos.ecs.richwps.wpsmonitor.client; +package de.hsos.ecs.richwps.wpsmonitor.client.exception; /** * diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientException.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientException.java similarity index 95% rename from client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientException.java rename to client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientException.java index eb8ec89..091fa84 100644 --- a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/WpsMonitorClientException.java +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package de.hsos.ecs.richwps.wpsmonitor.client; +package de.hsos.ecs.richwps.wpsmonitor.client.exception; /** * WpsMonitorClientException capsule any Exceptions, e.g. HttpException. diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientWpsNotFoundException.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientWpsNotFoundException.java new file mode 100644 index 0000000..0ae5c79 --- /dev/null +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientWpsNotFoundException.java @@ -0,0 +1,20 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package de.hsos.ecs.richwps.wpsmonitor.client.exception; + +import java.net.URL; + +/** + * + * @author Florian Vogelpohl + */ +public class WpsMonitorClientWpsNotFoundException extends WpsMonitorClientException { + + public WpsMonitorClientWpsNotFoundException(final URL wpsEndpoint) { + super("The WPS \"" + wpsEndpoint.toString() + "\" was not found within the WPSMonitor."); + } + +} diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientWpsProcessNotFoundException.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientWpsProcessNotFoundException.java new file mode 100644 index 0000000..f437953 --- /dev/null +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientWpsProcessNotFoundException.java @@ -0,0 +1,20 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package de.hsos.ecs.richwps.wpsmonitor.client.exception; + +import java.net.URL; + +/** + * + * @author Florian Vogelpohl + */ +public class WpsMonitorClientWpsProcessNotFoundException extends WpsMonitorClientException { + + public WpsMonitorClientWpsProcessNotFoundException(final String processIdentifier, final URL wpsEndpoint) { + super("The Process \"" + processIdentifier + "\" of WPS \"" + wpsEndpoint.toString() + "\" was not found within the WPSMonitor."); + } + +} diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/http/WpsMonitorJsonRequester.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/http/WpsMonitorJsonRequester.java index dc5cc32..a7c6f40 100644 --- a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/http/WpsMonitorJsonRequester.java +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/http/WpsMonitorJsonRequester.java @@ -35,7 +35,6 @@ public class WpsMonitorJsonRequester { private final static String MEASUREMENT_RESOURCE = "measurement"; private final static String WPS_RESOURCE = "wps"; private final static String WPS_PROCESS_RESOURCE = "process"; - private final static String DISPLAY_OPTION = "display"; private final static String COUNT_OPTION = "count"; public static String getJson(final URL endPoint) throws HttpException { @@ -46,7 +45,9 @@ public static String getJson(final URL endPoint) throws HttpException { connection.setRequestMethod(REQUEST_METHOD); connection.setRequestProperty("Accept", MIME_TYPE); - if (connection.getResponseCode() != 200) { + if(connection.getResponseCode() == 404) { + return null; + } else if (connection.getResponseCode() != 200) { throw new HttpException("Request failed: HTTP Error Code was: " + connection.getResponseCode()); } @@ -70,20 +71,18 @@ public static String getJson(final URL endPoint) throws HttpException { return result; } - public static URL buildWpsProcessMetricsURL(final URL monitorEndpoint, final String wpsIdentifier, + public static URL buildWpsProcessMetricsURL(final URL monitorEndpoint, final Long wpsId, final String wpsProcessIdentifier, final Integer count) throws HttpException { try { String buildUrl = concatUrlStr(new String[] { WPS_RESOURCE, - wpsIdentifier, + wpsId.toString(), WPS_PROCESS_RESOURCE, wpsProcessIdentifier, COUNT_OPTION, - count.toString(), - DISPLAY_OPTION, - "metric" + count.toString() }); return new URL(monitorEndpoint, buildUrl); diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/http/WpsMonitorRequester.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/http/WpsMonitorRequester.java index 2cf1a98..6370af8 100644 --- a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/http/WpsMonitorRequester.java +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/http/WpsMonitorRequester.java @@ -48,29 +48,39 @@ public WpsMonitorRequester(final URL monitorEndpoint, final Gson gson) throws Ht this.monitorEndpoint = monitorEndpoint; this.gson = gson; - this.wpsUrl = WpsMonitorJsonRequester.buildWpsURL(monitorEndpoint); + this.wpsUrl = buildWpsUrl(); } public List getWpsList() throws HttpException { - String wpsListJson = WpsMonitorJsonRequester.getJson(wpsUrl); - + String wpsListJson = getJson(wpsUrl); + return gson.fromJson(wpsListJson, new TypeToken>() { }.getType()); } - + public WpsProcessResource getProcess(final WpsResource wpsResource, final String wpsProcessIdentifier, final Integer considerMeasuredValue) throws HttpException { + Validate.notNull(wpsResource, "wpsResource"); + Validate.notNull(wpsProcessIdentifier, "wpsProcessIdentifier"); + Validate.notNull(considerMeasuredValue, "considerMeasuredValue"); + /* Build REST endpoint URL and get the JSON Data */ - URL processURL = WpsMonitorJsonRequester.buildWpsProcessMetricsURL(monitorEndpoint, - wpsResource.getWpsIdentifier(), wpsProcessIdentifier, considerMeasuredValue); - String metricJson = WpsMonitorJsonRequester.getJson(processURL); - - /* Restore object structure */ - Map> fromJson = gson.fromJson(metricJson, new TypeToken>>() { - }.getType()); - Map metrics = getMetrics(fromJson); + URL processURL = buildWpsProcessMetricsUrl(wpsResource.getWpsId(), wpsProcessIdentifier, considerMeasuredValue); + String metricJson = getJson(processURL); + + WpsProcessResource result = null; + + if (metricJson != null && !metricJson.isEmpty()) { + + /* Restore object structure */ + Map> fromJson = gson.fromJson(metricJson, new TypeToken>>() { + }.getType()); + Map metrics = getMetrics(fromJson); + + result = new WpsProcessResource(wpsResource, wpsProcessIdentifier, metrics); + } /* Return new WpsProcessResource instance */ - return new WpsProcessResource(wpsResource, wpsProcessIdentifier, metrics); + return result; } private Map getMetrics(final Map> metricsMap) { @@ -91,4 +101,19 @@ public URL getMonitorEndpoint() { public Gson getGson() { return gson; } + + /* + * Encapsulate Static helpers + */ + private String getJson(final URL endpoint) throws HttpException { + return WpsMonitorJsonRequester.getJson(endpoint); + } + + private URL buildWpsUrl() throws HttpException { + return WpsMonitorJsonRequester.buildWpsURL(monitorEndpoint); + } + + private URL buildWpsProcessMetricsUrl(final Long wpsId, final String processIdentifier, final Integer considerMeasuredValue) throws HttpException { + return WpsMonitorJsonRequester.buildWpsProcessMetricsURL(monitorEndpoint, wpsId, processIdentifier, considerMeasuredValue); + } } diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/resource/WpsProcessResource.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/resource/WpsProcessResource.java index 7f6d1f0..e07b5b4 100644 --- a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/resource/WpsProcessResource.java +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/resource/WpsProcessResource.java @@ -59,4 +59,9 @@ public List getMetricsAsList() { public WpsResource getWpsResource() { return wpsResource; } + + @Override + public String toString() { + return "WpsProcessResource{" + "wpsResource=" + wpsResource + ", processIdentifier=" + processIdentifier + ", metrics=" + metrics + '}'; + } } diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/resource/WpsResource.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/resource/WpsResource.java index d443a57..a80db4b 100644 --- a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/resource/WpsResource.java +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/resource/WpsResource.java @@ -26,31 +26,30 @@ public class WpsResource { private final URL wpsEndPoint; - private final String wpsIdentifier; + private final Long wpsId; /** * Creates a new WpsResource instance. The WpsIdentifier String is used by * the WpsMonitor internally. * * @param wpsEndPoint URL of the WPS-Server - * @param wpsIdentifier WPS Identifier which is used by the WpsMonitor - * internally and must be registred by each entry in the Monitor. It's not - * necessary for the use of the WpsMonitor Client. + * @param wpsId WPS Id which is used by the WpsMonitor + * internally. */ - public WpsResource(final URL wpsEndPoint, final String wpsIdentifier) { + public WpsResource(final URL wpsEndPoint, final Long wpsId) { Validate.notNull(wpsEndPoint); - Validate.notNull(wpsIdentifier); - Validate.notEmpty(wpsIdentifier); + Validate.notNull(wpsId); this.wpsEndPoint = wpsEndPoint; - this.wpsIdentifier = wpsIdentifier; + this.wpsId = wpsId; } public URL getWpsEndPoint() { return wpsEndPoint; } - public String getWpsIdentifier() { - return wpsIdentifier; + public Long getWpsId() { + return wpsId; } + } diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/resource/converter/ResourceConverter.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/resource/converter/ResourceConverter.java index 53230f0..81d6012 100644 --- a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/resource/converter/ResourceConverter.java +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/client/resource/converter/ResourceConverter.java @@ -26,6 +26,6 @@ public class ResourceConverter { public static WpsResource WpsEntityToResource(final WpsEntity entity) { - return new WpsResource(entity.getUri(), entity.getIdentifier()); + return new WpsResource(entity.getEndpoint(), entity.getId()); } } diff --git a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/data/entity/WpsEntity.java b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/data/entity/WpsEntity.java index 88a5389..69d8b1e 100644 --- a/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/data/entity/WpsEntity.java +++ b/client/src/main/java/de/hsos/ecs/richwps/wpsmonitor/data/entity/WpsEntity.java @@ -21,7 +21,6 @@ import java.net.URL; import java.util.Objects; - /** * Entity for WPS. * @@ -31,41 +30,30 @@ public class WpsEntity implements Serializable { private static final long serialVersionUID = 1L; private Long id; - private String identifier; - private URL route; + private URL endpoint; public WpsEntity() { } - public WpsEntity(String identifier, URL route) { - this.identifier = identifier; - this.route = route; - } - - public WpsEntity(String identifier, String route) throws MalformedURLException, URISyntaxException { - this.identifier = identifier; - this.setUri(route); + public WpsEntity(final URL endpoint) { + this.endpoint = endpoint; } - public String getIdentifier() { - return identifier; + public WpsEntity(final String endpoint) throws MalformedURLException, URISyntaxException { + this.setEndpoint(endpoint); } - public void setIdentifier(String identifier) { - this.identifier = identifier; + public URL getEndpoint() { + return endpoint; } - public URL getUri() { - return route; + public void setEndpoint(final URL route) { + this.endpoint = route; } - public void setUri(URL route) { - this.route = route; - } - - public final void setUri(String route) throws MalformedURLException, URISyntaxException { - this.route = new URL(route);; + public final void setEndpoint(final String route) throws MalformedURLException, URISyntaxException { + this.endpoint = new URL(route); } @Override @@ -76,7 +64,7 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -91,12 +79,13 @@ public Long getId() { return id; } - public void setId(Long id) { + public void setId(final Long id) { this.id = id; } @Override public String toString() { - return "WpsEntity{" + "identifier=" + identifier + ", route=" + route + '}'; + return "WpsEntity{" + "id=" + id + ", route=" + endpoint + '}'; } + }