Merge branch 'DEVELOP_BE' of ssh://172.18.22.160:29418/Dropwizard/Microservices/mics-home-service into DEVELOP_BE
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..120a6d2
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,284 @@
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License 2.0 which is available at
+http://www.eclipse.org/legal/epl-2.0, or the Apache Software License
+2.0 which is available at https://www.apache.org/licenses/LICENSE-2.0.
+
+_______________________________________________________________________
+Eclipse Public License - v 2.0
+
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+ PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
+ OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+ a) in the case of the initial Contributor, the initial content
+ Distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+ i) changes to the Program, and
+ ii) additions to the Program;
+ where such changes and/or additions to the Program originate from
+ and are Distributed by that particular Contributor. A Contribution
+ "originates" from a Contributor if it was added to the Program by
+ such Contributor itself or anyone acting on such Contributor's behalf.
+ Contributions do not include changes or additions to the Program that
+ are not Modified Works.
+
+"Contributor" means any person or entity that Distributes the Program.
+
+"Licensed Patents" mean patent claims licensable by a Contributor which
+are necessarily infringed by the use or sale of its Contribution alone
+or when combined with the Program.
+
+"Program" means the Contributions Distributed in accordance with this
+Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement
+or any Secondary License (as applicable), including Contributors.
+
+"Derivative Works" shall mean any work, whether in Source Code or other
+form, that is based on (or derived from) the Program and for which the
+editorial revisions, annotations, elaborations, or other modifications
+represent, as a whole, an original work of authorship.
+
+"Modified Works" shall mean any work in Source Code or other form that
+results from an addition to, deletion from, or modification of the
+contents of the Program, including, for purposes of clarity any new file
+in Source Code form that contains any contents of the Program. Modified
+Works shall not include works that contain only declarations,
+interfaces, types, classes, structures, or files of the Program solely
+in each case in order to link to, bind by name, or subclass the Program
+or Modified Works thereof.
+
+"Distribute" means the acts of a) distributing or b) making available
+in any manner that enables the transfer of a copy.
+
+"Source Code" means the form of a Program preferred for making
+modifications, including but not limited to software source code,
+documentation source, and configuration files.
+
+"Secondary License" means either the GNU General Public License,
+Version 2.0, or any later versions of that license, including any
+exceptions or additional permissions as identified by the initial
+Contributor.
+
+2. GRANT OF RIGHTS
+
+ a) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free copyright
+ license to reproduce, prepare Derivative Works of, publicly display,
+ publicly perform, Distribute and sublicense the Contribution of such
+ Contributor, if any, and such Derivative Works.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free patent
+ license under Licensed Patents to make, use, sell, offer to sell,
+ import and otherwise transfer the Contribution of such Contributor,
+ if any, in Source Code or other form. This patent license shall
+ apply to the combination of the Contribution and the Program if, at
+ the time the Contribution is added by the Contributor, such addition
+ of the Contribution causes such combination to be covered by the
+ Licensed Patents. The patent license shall not apply to any other
+ combinations which include the Contribution. No hardware per se is
+ licensed hereunder.
+
+ c) Recipient understands that although each Contributor grants the
+ licenses to its Contributions set forth herein, no assurances are
+ provided by any Contributor that the Program does not infringe the
+ patent or other intellectual property rights of any other entity.
+ Each Contributor disclaims any liability to Recipient for claims
+ brought by any other entity based on infringement of intellectual
+ property rights or otherwise. As a condition to exercising the
+ rights and licenses granted hereunder, each Recipient hereby
+ assumes sole responsibility to secure any other intellectual
+ property rights needed, if any. For example, if a third party
+ patent license is required to allow Recipient to Distribute the
+ Program, it is Recipient's responsibility to acquire that license
+ before distributing the Program.
+
+ d) Each Contributor represents that to its knowledge it has
+ sufficient copyright rights in its Contribution, if any, to grant
+ the copyright license set forth in this Agreement.
+
+ e) Notwithstanding the terms of any Secondary License, no
+ Contributor makes additional grants to any Recipient (other than
+ those set forth in this Agreement) as a result of such Recipient's
+ receipt of the Program under the terms of a Secondary License
+ (if permitted under the terms of Section 3).
+
+3. REQUIREMENTS
+
+3.1 If a Contributor Distributes the Program in any form, then:
+
+ a) the Program must also be made available as Source Code, in
+ accordance with section 3.2, and the Contributor must accompany
+ the Program with a statement that the Source Code for the Program
+ is available under this Agreement, and informs Recipients how to
+ obtain it in a reasonable manner on or through a medium customarily
+ used for software exchange; and
+
+ b) the Contributor may Distribute the Program under a license
+ different than this Agreement, provided that such license:
+ i) effectively disclaims on behalf of all other Contributors all
+ warranties and conditions, express and implied, including
+ warranties or conditions of title and non-infringement, and
+ implied warranties or conditions of merchantability and fitness
+ for a particular purpose;
+
+ ii) effectively excludes on behalf of all other Contributors all
+ liability for damages, including direct, indirect, special,
+ incidental and consequential damages, such as lost profits;
+
+ iii) does not attempt to limit or alter the recipients' rights
+ in the Source Code under section 3.2; and
+
+ iv) requires any subsequent distribution of the Program by any
+ party to be under a license that satisfies the requirements
+ of this section 3.
+
+3.2 When the Program is Distributed as Source Code:
+
+ a) it must be made available under this Agreement, or if the
+ Program (i) is combined with other material in a separate file or
+ files made available under a Secondary License, and (ii) the initial
+ Contributor attached to the Source Code the notice described in
+ Exhibit A of this Agreement, then the Program may be made available
+ under the terms of such Secondary Licenses, and
+
+ b) a copy of this Agreement must be included with each copy of
+ the Program.
+
+3.3 Contributors may not remove or alter any copyright, patent,
+trademark, attribution notices, disclaimers of warranty, or limitations
+of liability ("notices") contained within the Program from any copy of
+the Program which they Distribute, provided that Contributors may add
+their own appropriate notices.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities
+with respect to end users, business partners and the like. While this
+license is intended to facilitate the commercial use of the Program,
+the Contributor who includes the Program in a commercial product
+offering should do so in a manner which does not create potential
+liability for other Contributors. Therefore, if a Contributor includes
+the Program in a commercial product offering, such Contributor
+("Commercial Contributor") hereby agrees to defend and indemnify every
+other Contributor ("Indemnified Contributor") against any losses,
+damages and costs (collectively "Losses") arising from claims, lawsuits
+and other legal actions brought by a third party against the Indemnified
+Contributor to the extent caused by the acts or omissions of such
+Commercial Contributor in connection with its distribution of the Program
+in a commercial product offering. The obligations in this section do not
+apply to any claims or Losses relating to any actual or alleged
+intellectual property infringement. In order to qualify, an Indemnified
+Contributor must: a) promptly notify the Commercial Contributor in
+writing of such claim, and b) allow the Commercial Contributor to control,
+and cooperate with the Commercial Contributor in, the defense and any
+related settlement negotiations. The Indemnified Contributor may
+participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those performance
+claims and warranties, and if a court requires any other Contributor to
+pay any damages as a result, the Commercial Contributor must pay
+those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
+PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
+BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
+IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
+TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE. Each Recipient is solely responsible for determining the
+appropriateness of using and distributing the Program and assumes all
+risks associated with its exercise of rights under this Agreement,
+including but not limited to the risks and costs of program errors,
+compliance with applicable laws, damage to or loss of data, programs
+or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
+PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
+SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
+PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
+EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further
+action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the
+Program itself (excluding combinations of the Program with other software
+or hardware) infringes such Recipient's patent(s), then such Recipient's
+rights granted under Section 2(b) shall terminate as of the date such
+litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of
+time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use
+and distribution of the Program as soon as reasonably practicable.
+However, Recipient's obligations under this Agreement and any licenses
+granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement,
+but in order to avoid inconsistency the Agreement is copyrighted and
+may only be modified in the following manner. The Agreement Steward
+reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement
+Steward has the right to modify this Agreement. The Eclipse Foundation
+is the initial Agreement Steward. The Eclipse Foundation may assign the
+responsibility to serve as the Agreement Steward to a suitable separate
+entity. Each new version of the Agreement will be given a distinguishing
+version number. The Program (including Contributions) may always be
+Distributed subject to the version of the Agreement under which it was
+received. In addition, after a new version of the Agreement is published,
+Contributor may elect to Distribute the Program (including its
+Contributions) under the new version.
+
+Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
+receives no rights or licenses to the intellectual property of any
+Contributor under this Agreement, whether expressly, by implication,
+estoppel or otherwise. All rights in the Program not expressly granted
+under this Agreement are reserved. Nothing in this Agreement is intended
+to be enforceable by any entity that is not a Contributor or Recipient.
+No third-party beneficiary rights are created under this Agreement.
+
+Exhibit A - Form of Secondary Licenses Notice
+
+"This Source Code may also be made available under the following
+Secondary Licenses when the conditions for such availability set forth
+in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
+version(s), and exceptions or additional permissions here}."
+
+ Simply including a copy of this Agreement, including this Exhibit A
+ is not sufficient to license the Source Code under Secondary Licenses.
+
+ If it is not possible or desirable to put the notice in a particular
+ file, then You may include the notice in a location (such as a LICENSE
+ file in a relevant directory) where a recipient would be likely to
+ look for such a notice.
+
+ You may add additional accurate notices of copyright ownership.
+
diff --git a/pom.xml b/pom.xml
index e2b8674..c2bfd5b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>pta.de</groupId>
+ <groupId>org.eclipse.openk</groupId>
<artifactId>mics-home-service</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
diff --git a/src/main/java/de/pta/mics/home/common/Globals.java b/src/main/java/de/pta/mics/home/common/Globals.java
deleted file mode 100644
index 73558f3..0000000
--- a/src/main/java/de/pta/mics/home/common/Globals.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package de.pta.mics.home.common;
-
-
-public final class Globals {
- public static final String HEADER_JSON_UTF8 = "application/json; charset=utf-8";
-
- private Globals() {}
-}
diff --git a/src/main/java/de/pta/mics/home/common/HttpStatusException.java b/src/main/java/de/pta/mics/home/common/HttpStatusException.java
deleted file mode 100644
index 78a3e22..0000000
--- a/src/main/java/de/pta/mics/home/common/HttpStatusException.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package de.pta.mics.home.common;
-
-public class HttpStatusException extends Exception {
- private final int httpStatus;
-
- public HttpStatusException( int httpStatus ) {
- this.httpStatus = httpStatus;
- }
-
- public int getHttpStatus() {
- return httpStatus;
- }
-}
diff --git a/src/main/java/de/pta/mics/home/common/JsonGeneratorBase.java b/src/main/java/de/pta/mics/home/common/JsonGeneratorBase.java
deleted file mode 100644
index d1cadee..0000000
--- a/src/main/java/de/pta/mics/home/common/JsonGeneratorBase.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package de.pta.mics.home.common;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import java.util.Date;
-
-public class JsonGeneratorBase {
- private JsonGeneratorBase() {}
- public static Gson getGson() {
- return new GsonBuilder()
- .registerTypeAdapter(Date.class, new GsonUTCDateAdapter())
- .disableHtmlEscaping()
- .create();
- }
-}
diff --git a/src/main/java/de/pta/mics/home/common/NotificationStatus.java b/src/main/java/de/pta/mics/home/common/NotificationStatus.java
deleted file mode 100644
index 7b49d2f..0000000
--- a/src/main/java/de/pta/mics/home/common/NotificationStatus.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package de.pta.mics.home.common;
-
-public enum NotificationStatus {
-
- UNKNOWN(0, "unknown"),
- OPEN(1, "open"),
- INPROGRESS(2, "inprogress"),
- FINISHED(3, "finished"),
- CLOSED(4, "closed");
-
- public final int id;
- public final String statusName;
-
- NotificationStatus(int id, String name) {
- this.id = id;
- this.statusName = name;
- }
-}
diff --git a/src/main/java/de/pta/mics/home/common/util/JsonGeneratorBase.java b/src/main/java/de/pta/mics/home/common/util/JsonGeneratorBase.java
deleted file mode 100644
index 2ff149f..0000000
--- a/src/main/java/de/pta/mics/home/common/util/JsonGeneratorBase.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package de.pta.mics.home.common.util;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import de.pta.mics.home.common.GsonUTCDateAdapter;
-
-import java.util.Date;
-
-public class JsonGeneratorBase {
- private JsonGeneratorBase() {}
- public static Gson getGson() {
- return new GsonBuilder()
- .registerTypeAdapter(Date.class, new GsonUTCDateAdapter())
- .disableHtmlEscaping()
- .create();
- }
-}
diff --git a/src/main/java/de/pta/mics/home/common/util/ResourceLoaderBase.java b/src/main/java/de/pta/mics/home/common/util/ResourceLoaderBase.java
deleted file mode 100644
index e340198..0000000
--- a/src/main/java/de/pta/mics/home/common/util/ResourceLoaderBase.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package de.pta.mics.home.common.util;
-
-import java.io.InputStream;
-import java.io.StringWriter;
-import org.apache.commons.io.IOUtils;
-
-public class ResourceLoaderBase {
- private String stream2String(InputStream is) {
- StringWriter writer = new StringWriter();
- try {
- IOUtils.copy(is, writer, "UTF-8");
- } catch (Exception e) { // NOSONAR
- return "";
- }
- return writer.toString();
-
-
- }
-
- public String loadStringFromResource(String filename) {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- InputStream jsonstream = classLoader.getResourceAsStream(filename);
- return stream2String(jsonstream);
- }
-}
diff --git a/src/main/java/de/pta/mics/home/controller/BackendController.java b/src/main/java/de/pta/mics/home/controller/BackendController.java
deleted file mode 100644
index a8df9be..0000000
--- a/src/main/java/de/pta/mics/home/controller/BackendController.java
+++ /dev/null
@@ -1,27 +0,0 @@
-
-package de.pta.mics.home.controller;
-
-import org.apache.log4j.Logger;
-import de.pta.mics.home.viewmodel.VersionInfo;
-
-public class BackendController {
-
- private static final Logger LOGGER = Logger.getLogger(BackendController.class.getName());
-
- public VersionInfo getVersionInfo() {
- LOGGER.info("getVersionInfo is called");
-
- try {
- return getVersionInfoImpl(getClass().getPackage().getImplementationVersion());
- } finally {
- LOGGER.info("getVersionInfo is finished");
- }
- }
-
- private VersionInfo getVersionInfoImpl(String pomVersion) {
- VersionInfo vi = new VersionInfo();
- vi.setBackendVersion(pomVersion);
-
- return vi;
- }
-}
diff --git a/src/main/java/de/pta/mics/home/controller/CentralProxy.java b/src/main/java/de/pta/mics/home/controller/CentralProxy.java
deleted file mode 100644
index 8eb038f..0000000
--- a/src/main/java/de/pta/mics/home/controller/CentralProxy.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package de.pta.mics.home.controller;
-
-import de.pta.mics.home.common.HttpStatusException;
-import de.pta.mics.home.communication.RestServiceWrapper;
-
-public class CentralProxy {
- private final String url;
-
- public CentralProxy( String url ) {
- this.url = url;
- }
-
- public String getServerDistribution( String clusterName ) throws HttpStatusException {
- RestServiceWrapper w = new RestServiceWrapper( url, false );
- return w.performGetRequest(url + "/serviceDistribution/" + clusterName );
- }
-
- public String getHealthState( String healthStateExtraPath, String protocol, String host, String port ) throws HttpStatusException {
- RestServiceWrapper w = new RestServiceWrapper( url, false );
- return w.performGetRequest(protocol + "://" + host + ":" + port + "/" + healthStateExtraPath );
- }
-}
diff --git a/src/main/java/de/pta/mics/home/rest/BackendRestService.java b/src/main/java/de/pta/mics/home/rest/BackendRestService.java
deleted file mode 100644
index 644d49a..0000000
--- a/src/main/java/de/pta/mics/home/rest/BackendRestService.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package de.pta.mics.home.rest;
-
-import de.pta.mics.home.common.JsonGeneratorBase;
-import de.pta.mics.home.controller.BackendController;
-import de.pta.mics.home.controller.CentralProxy;
-import de.pta.mics.home.controller.ResponseBuilderWrapper;
-import org.apache.http.HttpStatus;
-import org.apache.log4j.Logger;
-import de.pta.mics.home.common.BackendConfig;
-import de.pta.mics.home.common.HttpStatusException;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Response;
-
-
-@Path("/mics/home")
-public class BackendRestService {
- private static final Logger logger = Logger.getLogger(BackendRestService.class.getName());
-
- @GET
- @Path("/versionInfo/")
- @Produces("application/json")
- public Response getVersionInfo() {
- String vstring = JsonGeneratorBase.getGson().toJson(
- new BackendController().getVersionInfo() );
- try {
- return ResponseBuilderWrapper.INSTANCE.buildOKResponse(vstring);
- } catch (HttpStatusException e) {
- return responseFromException(e);
- }
- }
-
- @GET
- @Path("/myServerDistribution/")
- @Produces("application/json")
- public Response getMyServerDistribution() {
- try {
- BackendConfig bc = BackendConfig.getInstance();
- CentralProxy central = new CentralProxy(bc.getMicsCentralURL());
- return ResponseBuilderWrapper.INSTANCE.buildOKResponse(
- central.getServerDistribution(bc.getMicsDistributionCluster()));
- }
- catch (Exception e) {
- return responseFromException(e);
- }
- }
-
- @GET
- @Path("/healthState/{protocol}/{host}/{port}")
- @Produces("application/json")
- public Response getHealthState( @PathParam("protocol") String protocol, @PathParam("host") String host , @PathParam("port") String port ) {
- try {
- BackendConfig bc = BackendConfig.getInstance();
- CentralProxy central = new CentralProxy(bc.getMicsCentralURL());
- return ResponseBuilderWrapper.INSTANCE.buildOKResponse(
- central.getHealthState(bc.getMicsHealthStateExtraPath(), protocol, host, port));
- }
- catch (Exception e) {
- return responseFromException(e);
- }
- }
-
-
- private Response responseFromException(Exception e) {
- int errcode;
-
- if (e instanceof HttpStatusException) {
- logger.error("Caught BackendException", e);
- errcode = ((HttpStatusException) e).getHttpStatus();
- return Response.status(errcode).build();
- } else {
- logger.error("Unexpected exception", e);
- return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).build();
- }
- }
-}
diff --git a/src/main/java/de/pta/mics/home/rest/RestServiceConfiguration.java b/src/main/java/de/pta/mics/home/rest/RestServiceConfiguration.java
deleted file mode 100644
index 1c4493d..0000000
--- a/src/main/java/de/pta/mics/home/rest/RestServiceConfiguration.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package de.pta.mics.home.rest;
-
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class RestServiceConfiguration extends javax.ws.rs.core.Application {
- public RestServiceConfiguration() {
- // Standard Contstructor needed
- }
-
- @Override
- public Set<Class<?>> getClasses() {
- Set<Class<?>> restServicesClasses = new HashSet<>();
- restServicesClasses.add(BackendRestService.class);
- return restServicesClasses;
- }
-}
diff --git a/src/main/java/de/pta/mics/home/viewmodel/ErrorReturn.java b/src/main/java/de/pta/mics/home/viewmodel/ErrorReturn.java
deleted file mode 100644
index 5965878..0000000
--- a/src/main/java/de/pta/mics/home/viewmodel/ErrorReturn.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package de.pta.mics.home.viewmodel;
-
-import java.io.Serializable;
-
-public class ErrorReturn implements Serializable {
- private static final long serialVersionUID = -1841112315318005840L;
-
- private String errorText;
- private int errorCode;
-
- public String getErrorText() {
- return errorText;
- }
- public void setErrorText(String errorText) {
- this.errorText = errorText;
- }
- public int getErrorCode() {
- return errorCode;
- }
- public void setErrorCode(int errorCode) {
- this.errorCode = errorCode;
- }
-}
diff --git a/src/main/java/de/pta/mics/home/viewmodel/VersionInfo.java b/src/main/java/de/pta/mics/home/viewmodel/VersionInfo.java
deleted file mode 100644
index 959f84a..0000000
--- a/src/main/java/de/pta/mics/home/viewmodel/VersionInfo.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package de.pta.mics.home.viewmodel;
-
-public class VersionInfo {
- private String backendVersion;
-
- public String getBackendVersion() {
- return backendVersion;
- }
-
- public void setBackendVersion(String backendVersion) {
- this.backendVersion = backendVersion;
- }
-}
diff --git a/src/main/java/de/pta/mics/home/common/BackendConfig.java b/src/main/java/org/eclipse/openk/mics/home/common/BackendConfig.java
similarity index 64%
rename from src/main/java/de/pta/mics/home/common/BackendConfig.java
rename to src/main/java/org/eclipse/openk/mics/home/common/BackendConfig.java
index 0d4530a..0b6d1ff 100644
--- a/src/main/java/de/pta/mics/home/common/BackendConfig.java
+++ b/src/main/java/org/eclipse/openk/mics/home/common/BackendConfig.java
@@ -1,6 +1,18 @@
-package de.pta.mics.home.common;
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
-import de.pta.mics.home.common.util.ResourceLoaderBase;
+package org.eclipse.openk.mics.home.common;
+
+import org.eclipse.openk.mics.home.common.util.ResourceLoaderBase;
public class BackendConfig {
@@ -10,6 +22,7 @@
private String micsCentralURL;
private String micsDistributionCluster;
private String micsHealthStateExtraPath;
+ private boolean micsCentralIsHttps;
private static BackendConfig instance;
@@ -42,6 +55,10 @@
return micsHealthStateExtraPath;
}
+ public boolean isMicsCentralIsHttps() {
+ return micsCentralIsHttps;
+ }
+
public static String getConfigFileName() {
return configFileName;
}
diff --git a/src/main/java/org/eclipse/openk/mics/home/common/Globals.java b/src/main/java/org/eclipse/openk/mics/home/common/Globals.java
new file mode 100644
index 0000000..7825e3b
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/common/Globals.java
@@ -0,0 +1,20 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common;
+
+
+public final class Globals {
+ public static final String HEADER_JSON_UTF8 = "application/json; charset=utf-8";
+
+ private Globals() {}
+}
diff --git a/src/main/java/de/pta/mics/home/common/GsonUTCDateAdapter.java b/src/main/java/org/eclipse/openk/mics/home/common/GsonUTCDateAdapter.java
similarity index 75%
rename from src/main/java/de/pta/mics/home/common/GsonUTCDateAdapter.java
rename to src/main/java/org/eclipse/openk/mics/home/common/GsonUTCDateAdapter.java
index 8387bcc..6d97eb8 100644
--- a/src/main/java/de/pta/mics/home/common/GsonUTCDateAdapter.java
+++ b/src/main/java/org/eclipse/openk/mics/home/common/GsonUTCDateAdapter.java
@@ -1,4 +1,16 @@
-package de.pta.mics.home.common;
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
diff --git a/src/main/java/org/eclipse/openk/mics/home/common/HttpStatusException.java b/src/main/java/org/eclipse/openk/mics/home/common/HttpStatusException.java
new file mode 100644
index 0000000..ebda9be
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/common/HttpStatusException.java
@@ -0,0 +1,25 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common;
+
+public class HttpStatusException extends Exception {
+ private final int httpStatus;
+
+ public HttpStatusException( int httpStatus ) {
+ this.httpStatus = httpStatus;
+ }
+
+ public int getHttpStatus() {
+ return httpStatus;
+ }
+}
diff --git a/src/main/java/de/pta/mics/home/common/InitBackendConfig.java b/src/main/java/org/eclipse/openk/mics/home/common/InitBackendConfig.java
similarity index 74%
rename from src/main/java/de/pta/mics/home/common/InitBackendConfig.java
rename to src/main/java/org/eclipse/openk/mics/home/common/InitBackendConfig.java
index c5f3bdc..a592581 100644
--- a/src/main/java/de/pta/mics/home/common/InitBackendConfig.java
+++ b/src/main/java/org/eclipse/openk/mics/home/common/InitBackendConfig.java
@@ -1,4 +1,16 @@
-package de.pta.mics.home.common;
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common;
import org.apache.log4j.Logger;
diff --git a/src/main/java/org/eclipse/openk/mics/home/common/JsonGeneratorBase.java b/src/main/java/org/eclipse/openk/mics/home/common/JsonGeneratorBase.java
new file mode 100644
index 0000000..ab6cb01
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/common/JsonGeneratorBase.java
@@ -0,0 +1,27 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import java.util.Date;
+
+public class JsonGeneratorBase {
+ private JsonGeneratorBase() {}
+ public static Gson getGson() {
+ return new GsonBuilder()
+ .registerTypeAdapter(Date.class, new GsonUTCDateAdapter())
+ .disableHtmlEscaping()
+ .create();
+ }
+}
diff --git a/src/main/java/org/eclipse/openk/mics/home/common/NotificationStatus.java b/src/main/java/org/eclipse/openk/mics/home/common/NotificationStatus.java
new file mode 100644
index 0000000..fcd4834
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/common/NotificationStatus.java
@@ -0,0 +1,30 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common;
+
+public enum NotificationStatus {
+
+ UNKNOWN(0, "unknown"),
+ OPEN(1, "open"),
+ INPROGRESS(2, "inprogress"),
+ FINISHED(3, "finished"),
+ CLOSED(4, "closed");
+
+ public final int id;
+ public final String statusName;
+
+ NotificationStatus(int id, String name) {
+ this.id = id;
+ this.statusName = name;
+ }
+}
diff --git a/src/main/java/org/eclipse/openk/mics/home/common/util/JsonGeneratorBase.java b/src/main/java/org/eclipse/openk/mics/home/common/util/JsonGeneratorBase.java
new file mode 100644
index 0000000..b181d8a
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/common/util/JsonGeneratorBase.java
@@ -0,0 +1,29 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common.util;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.eclipse.openk.mics.home.common.GsonUTCDateAdapter;
+
+import java.util.Date;
+
+public class JsonGeneratorBase {
+ private JsonGeneratorBase() {}
+ public static Gson getGson() {
+ return new GsonBuilder()
+ .registerTypeAdapter(Date.class, new GsonUTCDateAdapter())
+ .disableHtmlEscaping()
+ .create();
+ }
+}
diff --git a/src/main/java/de/pta/mics/home/common/util/LoggerUtil.java b/src/main/java/org/eclipse/openk/mics/home/common/util/LoggerUtil.java
similarity index 83%
rename from src/main/java/de/pta/mics/home/common/util/LoggerUtil.java
rename to src/main/java/org/eclipse/openk/mics/home/common/util/LoggerUtil.java
index a7c902e..616726c 100644
--- a/src/main/java/de/pta/mics/home/common/util/LoggerUtil.java
+++ b/src/main/java/org/eclipse/openk/mics/home/common/util/LoggerUtil.java
@@ -1,4 +1,16 @@
-package de.pta.mics.home.common.util;
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common.util;
import java.io.IOException;
import javax.servlet.ServletContext;
diff --git a/src/main/java/org/eclipse/openk/mics/home/common/util/ResourceLoaderBase.java b/src/main/java/org/eclipse/openk/mics/home/common/util/ResourceLoaderBase.java
new file mode 100644
index 0000000..9ec0c82
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/common/util/ResourceLoaderBase.java
@@ -0,0 +1,37 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common.util;
+
+import java.io.InputStream;
+import java.io.StringWriter;
+import org.apache.commons.io.IOUtils;
+
+public class ResourceLoaderBase {
+ private String stream2String(InputStream is) {
+ StringWriter writer = new StringWriter();
+ try {
+ IOUtils.copy(is, writer, "UTF-8");
+ } catch (Exception e) { // NOSONAR
+ return "";
+ }
+ return writer.toString();
+
+
+ }
+
+ public String loadStringFromResource(String filename) {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ InputStream jsonstream = classLoader.getResourceAsStream(filename);
+ return stream2String(jsonstream);
+ }
+}
diff --git a/src/main/java/de/pta/mics/home/communication/RestServiceWrapper.java b/src/main/java/org/eclipse/openk/mics/home/communication/RestServiceWrapper.java
similarity index 79%
rename from src/main/java/de/pta/mics/home/communication/RestServiceWrapper.java
rename to src/main/java/org/eclipse/openk/mics/home/communication/RestServiceWrapper.java
index f473238..68af238 100644
--- a/src/main/java/de/pta/mics/home/communication/RestServiceWrapper.java
+++ b/src/main/java/org/eclipse/openk/mics/home/communication/RestServiceWrapper.java
@@ -1,6 +1,18 @@
-package de.pta.mics.home.communication;
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
-import de.pta.mics.home.common.HttpStatusException;
+package org.eclipse.openk.mics.home.communication;
+
+import org.eclipse.openk.mics.home.common.HttpStatusException;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpGet;
@@ -14,9 +26,10 @@
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
-import de.pta.mics.home.common.Globals;
+import org.eclipse.openk.mics.home.common.Globals;
+import javax.ws.rs.core.Response;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -54,7 +67,7 @@
return createJson(response);
}
- public String performPostRequest(String restFunctionWithParams, String data) throws HttpStatusException {
+ public Response performPostRequestWithResponse(String restFunctionWithParams, String data) throws HttpStatusException {
String completeRequest = baseURL + "/" + restFunctionWithParams;
// create HTTP Client
@@ -78,7 +91,13 @@
LOGGER.warn(errtext, e);
throw new HttpStatusException(HttpStatus.SC_SERVICE_UNAVAILABLE);
}
- return createJson(response);
+ String ent = createJson(response);
+
+ Response.ResponseBuilder rb = Response.status(response.getStatusLine().getStatusCode());
+ if (ent != null) {
+ rb.entity(ent);
+ }
+ return rb.build();
}
private CloseableHttpClient createHttpsClient() throws HttpStatusException {
diff --git a/src/main/java/org/eclipse/openk/mics/home/controller/BackendController.java b/src/main/java/org/eclipse/openk/mics/home/controller/BackendController.java
new file mode 100644
index 0000000..faf0cf8
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/controller/BackendController.java
@@ -0,0 +1,39 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+
+package org.eclipse.openk.mics.home.controller;
+
+import org.apache.log4j.Logger;
+import org.eclipse.openk.mics.home.viewmodel.VersionInfo;
+
+public class BackendController {
+
+ private static final Logger LOGGER = Logger.getLogger(BackendController.class.getName());
+
+ public VersionInfo getVersionInfo() {
+ LOGGER.info("getVersionInfo is called");
+
+ try {
+ return getVersionInfoImpl(getClass().getPackage().getImplementationVersion());
+ } finally {
+ LOGGER.info("getVersionInfo is finished");
+ }
+ }
+
+ private VersionInfo getVersionInfoImpl(String pomVersion) {
+ VersionInfo vi = new VersionInfo();
+ vi.setBackendVersion(pomVersion);
+
+ return vi;
+ }
+}
diff --git a/src/main/java/org/eclipse/openk/mics/home/controller/CentralProxy.java b/src/main/java/org/eclipse/openk/mics/home/controller/CentralProxy.java
new file mode 100644
index 0000000..60853e4
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/controller/CentralProxy.java
@@ -0,0 +1,35 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.controller;
+
+import org.eclipse.openk.mics.home.common.HttpStatusException;
+import org.eclipse.openk.mics.home.communication.RestServiceWrapper;
+
+public class CentralProxy {
+ private final String url;
+ private final RestServiceWrapper restServiceWrapper;
+
+ public CentralProxy( String url ) {
+ this.url = url;
+ this.restServiceWrapper = new RestServiceWrapper( url, false );
+ }
+
+ public String getServerDistribution( String clusterName ) throws HttpStatusException {
+ return restServiceWrapper.performGetRequest(url + "/serviceDistribution/" + clusterName );
+ }
+
+ public String getHealthState( String healthStateExtraPath, String protocol, String host, String port ) throws HttpStatusException {
+ return restServiceWrapper.performGetRequest(protocol + "://" + host + ":" + port + "/" + healthStateExtraPath );
+ }
+
+}
diff --git a/src/main/java/de/pta/mics/home/controller/ResponseBuilderWrapper.java b/src/main/java/org/eclipse/openk/mics/home/controller/ResponseBuilderWrapper.java
similarity index 73%
rename from src/main/java/de/pta/mics/home/controller/ResponseBuilderWrapper.java
rename to src/main/java/org/eclipse/openk/mics/home/controller/ResponseBuilderWrapper.java
index c887035..f921e4d 100644
--- a/src/main/java/de/pta/mics/home/controller/ResponseBuilderWrapper.java
+++ b/src/main/java/org/eclipse/openk/mics/home/controller/ResponseBuilderWrapper.java
@@ -1,7 +1,19 @@
-package de.pta.mics.home.controller;
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.controller;
import org.apache.http.HttpStatus;
-import de.pta.mics.home.common.HttpStatusException;
+import org.eclipse.openk.mics.home.common.HttpStatusException;
import javax.ws.rs.core.Response;
diff --git a/src/main/java/org/eclipse/openk/mics/home/rest/BackendRestService.java b/src/main/java/org/eclipse/openk/mics/home/rest/BackendRestService.java
new file mode 100644
index 0000000..69f6263
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/rest/BackendRestService.java
@@ -0,0 +1,109 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.rest;
+
+import org.eclipse.openk.mics.home.common.JsonGeneratorBase;
+import org.eclipse.openk.mics.home.communication.RestServiceWrapper;
+import org.eclipse.openk.mics.home.controller.BackendController;
+import org.eclipse.openk.mics.home.controller.CentralProxy;
+import org.eclipse.openk.mics.home.controller.ResponseBuilderWrapper;
+import org.apache.http.HttpStatus;
+import org.apache.log4j.Logger;
+import org.eclipse.openk.mics.home.common.BackendConfig;
+import org.eclipse.openk.mics.home.common.HttpStatusException;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+
+
+@Path("/mics/home")
+public class BackendRestService {
+ private static final Logger logger = Logger.getLogger(BackendRestService.class.getName());
+
+ @GET
+ @Path("/versionInfo/")
+ @Produces("application/json")
+ public Response getVersionInfo() {
+ String vstring = JsonGeneratorBase.getGson().toJson(
+ new BackendController().getVersionInfo() );
+ try {
+ return ResponseBuilderWrapper.INSTANCE.buildOKResponse(vstring);
+ } catch (HttpStatusException e) {
+ return responseFromException(e);
+ }
+ }
+
+ @GET
+ @Path("/myServerDistribution/")
+ @Produces("application/json")
+ public Response getMyServerDistribution() {
+ try {
+ BackendConfig bc = BackendConfig.getInstance();
+ CentralProxy central = new CentralProxy(bc.getMicsCentralURL());
+ return ResponseBuilderWrapper.INSTANCE.buildOKResponse(
+ central.getServerDistribution(bc.getMicsDistributionCluster()));
+ }
+ catch (Exception e) {
+ return responseFromException(e);
+ }
+ }
+
+ @GET
+ @Path("/healthState/{protocol}/{host}/{port}")
+ @Produces("application/json")
+ public Response getHealthState( @PathParam("protocol") String protocol, @PathParam("host") String host , @PathParam("port") String port ) {
+ try {
+ BackendConfig bc = BackendConfig.getInstance();
+ CentralProxy central = new CentralProxy(bc.getMicsCentralURL());
+ return ResponseBuilderWrapper.INSTANCE.buildOKResponse(
+ central.getHealthState(bc.getMicsHealthStateExtraPath(), protocol, host, port));
+ }
+ catch (Exception e) {
+ return responseFromException(e);
+ }
+ }
+
+ @POST
+ @Path("/dispatch/")
+ @Produces("application/json")
+ public Response dispatch( String envelope ) {
+ try {
+ BackendConfig bc = BackendConfig.getInstance();
+ RestServiceWrapper restServiceWrapper = new RestServiceWrapper(bc.getMicsCentralURL(), bc.isMicsCentralIsHttps());
+ return restServiceWrapper.performPostRequestWithResponse(createDispatchURL(), envelope);
+ }
+ catch( Exception e) {
+ return responseFromException(e);
+
+ }
+ }
+
+ private String createDispatchURL() {
+ BackendConfig bc = BackendConfig.getInstance();
+ return "dispatch/"+bc.getMicsDistributionCluster();
+ }
+
+
+ private Response responseFromException(Exception e) {
+ int errcode;
+
+ if (e instanceof HttpStatusException) {
+ logger.error("Caught BackendException", e);
+ errcode = ((HttpStatusException) e).getHttpStatus();
+ return Response.status(errcode).build();
+ } else {
+ logger.error("Unexpected exception", e);
+ return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).build();
+ }
+ }
+}
diff --git a/src/main/java/org/eclipse/openk/mics/home/rest/RestServiceConfiguration.java b/src/main/java/org/eclipse/openk/mics/home/rest/RestServiceConfiguration.java
new file mode 100644
index 0000000..a829a6d
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/rest/RestServiceConfiguration.java
@@ -0,0 +1,30 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.rest;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class RestServiceConfiguration extends javax.ws.rs.core.Application {
+ public RestServiceConfiguration() {
+ // Standard Contstructor needed
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> restServicesClasses = new HashSet<>();
+ restServicesClasses.add(BackendRestService.class);
+ return restServicesClasses;
+ }
+}
diff --git a/src/main/java/org/eclipse/openk/mics/home/viewmodel/ErrorReturn.java b/src/main/java/org/eclipse/openk/mics/home/viewmodel/ErrorReturn.java
new file mode 100644
index 0000000..470926a
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/viewmodel/ErrorReturn.java
@@ -0,0 +1,35 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.viewmodel;
+
+import java.io.Serializable;
+
+public class ErrorReturn implements Serializable {
+ private static final long serialVersionUID = -1841112315318005840L;
+
+ private String errorText;
+ private int errorCode;
+
+ public String getErrorText() {
+ return errorText;
+ }
+ public void setErrorText(String errorText) {
+ this.errorText = errorText;
+ }
+ public int getErrorCode() {
+ return errorCode;
+ }
+ public void setErrorCode(int errorCode) {
+ this.errorCode = errorCode;
+ }
+}
diff --git a/src/main/java/org/eclipse/openk/mics/home/viewmodel/ServiceRequestEnvelope.java b/src/main/java/org/eclipse/openk/mics/home/viewmodel/ServiceRequestEnvelope.java
new file mode 100644
index 0000000..022a412
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/viewmodel/ServiceRequestEnvelope.java
@@ -0,0 +1,105 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.viewmodel;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class ServiceRequestEnvelope {
+ public static class HttpHeader {
+ private String attribute;
+ private String value;
+
+ public String getAttribute() {
+ return attribute;
+ }
+
+ public void setAttribute(String attribute) {
+ this.attribute = attribute;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+
+ private String serviceName;
+ private boolean isHttps;
+ private String method;
+ private String uriFragment;
+ private String payload;
+ private HttpHeader[] headers;
+
+ @JsonProperty
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ @JsonProperty
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ @JsonProperty
+ public boolean isHttps() {
+ return isHttps;
+ }
+
+ @JsonProperty
+ public void setHttps(boolean https) {
+ isHttps = https;
+ }
+
+ @JsonProperty
+ public String getMethod() {
+ return method;
+ }
+
+ @JsonProperty
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+ @JsonProperty
+ public String getUriFragment() {
+ return uriFragment;
+ }
+
+ @JsonProperty
+ public void setUriFragment(String uriFragment) {
+ this.uriFragment = uriFragment;
+ }
+
+ @JsonProperty
+ public String getPayload() {
+ return payload;
+ }
+
+ @JsonProperty
+ public void setPayload(String payload) {
+ this.payload = payload;
+ }
+
+ @JsonProperty
+ public HttpHeader[] getHeaders() {
+ return headers;
+ }
+
+ @JsonProperty
+ public void setHeaders(HttpHeader[] headers) {
+ this.headers = headers;
+ }
+}
diff --git a/src/main/java/org/eclipse/openk/mics/home/viewmodel/VersionInfo.java b/src/main/java/org/eclipse/openk/mics/home/viewmodel/VersionInfo.java
new file mode 100644
index 0000000..b353fc5
--- /dev/null
+++ b/src/main/java/org/eclipse/openk/mics/home/viewmodel/VersionInfo.java
@@ -0,0 +1,25 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.viewmodel;
+
+public class VersionInfo {
+ private String backendVersion;
+
+ public String getBackendVersion() {
+ return backendVersion;
+ }
+
+ public void setBackendVersion(String backendVersion) {
+ this.backendVersion = backendVersion;
+ }
+}
diff --git a/src/main/resources/backendConfigCustom.json b/src/main/resources/backendConfigCustom.json
index 5d4e7f1..498bd18 100644
--- a/src/main/resources/backendConfigCustom.json
+++ b/src/main/resources/backendConfigCustom.json
@@ -1,5 +1,6 @@
{
"micsDistributionCluster" : "elogbook.openK",
"micsCentralURL" : "http://localhost:9010/mics/central",
- "micsHealthStateExtraPath" : "healthcheck?pretty=true"
+ "micsHealthStateExtraPath" : "healthcheck?pretty=true",
+ "micsCentralIsHttps" : false
}
diff --git a/src/main/resources/backendConfigDevLocal.json b/src/main/resources/backendConfigDevLocal.json
index 5d4e7f1..498bd18 100644
--- a/src/main/resources/backendConfigDevLocal.json
+++ b/src/main/resources/backendConfigDevLocal.json
@@ -1,5 +1,6 @@
{
"micsDistributionCluster" : "elogbook.openK",
"micsCentralURL" : "http://localhost:9010/mics/central",
- "micsHealthStateExtraPath" : "healthcheck?pretty=true"
+ "micsHealthStateExtraPath" : "healthcheck?pretty=true",
+ "micsCentralIsHttps" : false
}
diff --git a/src/main/resources/backendConfigDevServer.json b/src/main/resources/backendConfigDevServer.json
index 8a5d25b..51774fc 100644
--- a/src/main/resources/backendConfigDevServer.json
+++ b/src/main/resources/backendConfigDevServer.json
@@ -1,5 +1,6 @@
{
"micsDistributionCluster" : "elogbook.openK",
"micsCentralURL" : "http://172.18.22.160:9010/mics/central",
- "micsHealthStateExtraPath" : "healthcheck?pretty=true"
+ "micsHealthStateExtraPath" : "healthcheck?pretty=true",
+ "micsCentralIsHttps" : false
}
diff --git a/src/main/resources/backendConfigDocker.json b/src/main/resources/backendConfigDocker.json
index f1f63e1..d762016 100644
--- a/src/main/resources/backendConfigDocker.json
+++ b/src/main/resources/backendConfigDocker.json
@@ -1,5 +1,6 @@
{
"micsDistributionCluster" : "elogbook.openK",
"micsCentralURL" : "http://172.25.0.54:9010/mics/central",
- "micsHealthStateExtraPath" : "healthcheck?pretty=true"
+ "micsHealthStateExtraPath" : "healthcheck?pretty=true",
+ "micsCentralIsHttps" : false
}
diff --git a/src/main/resources/backendConfigProduction.json b/src/main/resources/backendConfigProduction.json
index aeb4d00..c5096ed 100644
--- a/src/main/resources/backendConfigProduction.json
+++ b/src/main/resources/backendConfigProduction.json
@@ -1,5 +1,6 @@
{
"micsDistributionCluster" : "elogbook.openK",
"micsCentralURL" : "http://localhost:9010/mics/central",
- "micsHealthStateExtraPath" : "healthcheck?pretty=true"
+ "micsHealthStateExtraPath" : "healthcheck?pretty=true",
+ "micsCentralIsHttps" : false
}
\ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index 3fd3172..c12695b 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -26,7 +26,7 @@
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
- <param-value>de.pta.mics.home.rest.RestServiceConfiguration</param-value>
+ <param-value>org.eclipse.openk.mics.home.rest.RestServiceConfiguration</param-value>
</init-param>
</servlet>
@@ -37,7 +37,7 @@
<servlet>
<servlet-name>log4j-init</servlet-name>
- <servlet-class>de.pta.mics.home.common.util.LoggerUtil</servlet-class>
+ <servlet-class>org.eclipse.openk.mics.home.common.util.LoggerUtil</servlet-class>
<init-param>
<param-name>log4j-init-file</param-name>
<param-value>WEB-INF/logger.xml</param-value>
@@ -47,7 +47,7 @@
<servlet>
<servlet-name>InitBackendConfig</servlet-name>
- <servlet-class>de.pta.mics.home.common.InitBackendConfig</servlet-class>
+ <servlet-class>org.eclipse.openk.mics.home.common.InitBackendConfig</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
diff --git a/src/test/java/de/pta/mics/home/common/BackendConfigTest.java b/src/test/java/de/pta/mics/home/common/BackendConfigTest.java
deleted file mode 100644
index a209a55..0000000
--- a/src/test/java/de/pta/mics/home/common/BackendConfigTest.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package de.pta.mics.home.common;
-
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class BackendConfigTest {
- @Test
- public void testConfig() {
- BackendConfig bc = BackendConfig.getInstance();
- assertEquals( bc.getMicsCentralURL(), "http://localhost:9010/mics/central" );
- assertEquals( bc.getMicsDistributionCluster(), "elogbook.openK");
- assertEquals( bc.getMicsHealthStateExtraPath(), "healthcheck?pretty=true" );
- BackendConfig.setConfigFileName("backendConfigProduction.json");
- assertEquals( BackendConfig.getConfigFileName(), "backendConfigProduction.json");
- }
-}
diff --git a/src/test/java/de/pta/mics/home/common/HttpStatusExceptionTest.java b/src/test/java/de/pta/mics/home/common/HttpStatusExceptionTest.java
deleted file mode 100644
index 141c721..0000000
--- a/src/test/java/de/pta/mics/home/common/HttpStatusExceptionTest.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package de.pta.mics.home.common;
-
-import org.apache.http.HttpStatus;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class HttpStatusExceptionTest {
- @Test
- public void testAll() {
- HttpStatusException hse = new HttpStatusException( 200 );
- assertEquals( hse.getHttpStatus(), HttpStatus.SC_OK );
- }
-}
diff --git a/src/test/java/de/pta/mics/home/common/NotificationStatusTest.java b/src/test/java/de/pta/mics/home/common/NotificationStatusTest.java
deleted file mode 100644
index 5ecf746..0000000
--- a/src/test/java/de/pta/mics/home/common/NotificationStatusTest.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package de.pta.mics.home.common;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class NotificationStatusTest {
-
- @Test
- public void createNotificationStatus() throws Exception {
-
- assertEquals(0, NotificationStatus.UNKNOWN.id);
- assertEquals(1, NotificationStatus.OPEN.id);
- assertEquals(2, NotificationStatus.INPROGRESS.id);
- assertEquals(3, NotificationStatus.FINISHED.id);
- assertEquals(4, NotificationStatus.CLOSED.id);
-
- }
-
-}
diff --git a/src/test/java/de/pta/mics/home/common/util/ResourceLoaderBaseTest.java b/src/test/java/de/pta/mics/home/common/util/ResourceLoaderBaseTest.java
deleted file mode 100644
index e555d7a..0000000
--- a/src/test/java/de/pta/mics/home/common/util/ResourceLoaderBaseTest.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package de.pta.mics.home.common.util;
-
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class ResourceLoaderBaseTest {
- @Test
- public void testloadStringFromResourceError() {
- ResourceLoaderBase rlb = new ResourceLoaderBase();
- String str = rlb.loadStringFromResource("UNKNOWN_FILE");
- assertEquals(str, "");
- }
-}
diff --git a/src/test/java/de/pta/mics/home/controller/CentralProxyTest.java b/src/test/java/de/pta/mics/home/controller/CentralProxyTest.java
deleted file mode 100644
index aec27fa..0000000
--- a/src/test/java/de/pta/mics/home/controller/CentralProxyTest.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package de.pta.mics.home.controller;
-
-import org.junit.Test;
-
-public class CentralProxyTest {
-
- @Test
- public void testConstructor() {
- CentralProxy cp = new CentralProxy("TEST_URL");
- }
-}
diff --git a/src/test/java/de/pta/mics/home/controller/ResponseBuilderWrapperTest.java b/src/test/java/de/pta/mics/home/controller/ResponseBuilderWrapperTest.java
deleted file mode 100644
index 53b4652..0000000
--- a/src/test/java/de/pta/mics/home/controller/ResponseBuilderWrapperTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package de.pta.mics.home.controller;
-
-
-import org.apache.http.HttpStatus;
-import de.pta.mics.home.common.HttpStatusException;
-import org.junit.Test;
-
-import javax.ws.rs.core.Response;
-
-import static org.junit.Assert.assertEquals;
-
-
-public class ResponseBuilderWrapperTest {
- @Test
- public void testGetResponseBuilder() throws HttpStatusException {
- String json = "{ 'ret' : 'OK' }";
- Response.ResponseBuilder rb = ResponseBuilderWrapper.INSTANCE.getResponseBuilder( json );
- Response resp = rb.build();
- assertEquals(resp.getStatus(), HttpStatus.SC_OK );
- }
-
- @Test
- public void testBuildOkResponse() throws HttpStatusException {
- String json = "{ 'test' : 'Value' }";
- Response resp = ResponseBuilderWrapper.INSTANCE.buildOKResponse( json );
- assertEquals( resp.getStatus(), HttpStatus.SC_OK );
-
- }
-}
diff --git a/src/test/java/de/pta/mics/home/viewmodel/ErrorReturnTest.java b/src/test/java/de/pta/mics/home/viewmodel/ErrorReturnTest.java
deleted file mode 100644
index 31f5f77..0000000
--- a/src/test/java/de/pta/mics/home/viewmodel/ErrorReturnTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package de.pta.mics.home.viewmodel;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import de.pta.mics.home.common.JsonGeneratorBase;
-import de.pta.mics.home.common.util.ResourceLoaderBase;
-import org.junit.Test;
-
-public class ErrorReturnTest extends ResourceLoaderBase {
- // IMPORTANT TEST!!!
- // Make sure, our Interface produces a DEFINED Json!
- // Changes in the interface will HOPEFULLY crash here!!!
-
- @Test
- public void TestStructureAgainstJson() {
- String json = super.loadStringFromResource("testErrorReturn.json");
- ErrorReturn errRet = JsonGeneratorBase.getGson().fromJson(json, ErrorReturn.class);
- assertFalse(errRet.getErrorText().isEmpty());
- assertEquals(errRet.getErrorCode(), 999);
- }
-
- @Test
- public void TestSetters() {
- ErrorReturn errRet = new ErrorReturn();
- errRet.setErrorCode(1);
- errRet.setErrorText("bla bla");
- }
-
-}
diff --git a/src/test/java/de/pta/mics/home/viewmodel/VersionInfoTest.java b/src/test/java/de/pta/mics/home/viewmodel/VersionInfoTest.java
deleted file mode 100644
index 16eee61..0000000
--- a/src/test/java/de/pta/mics/home/viewmodel/VersionInfoTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package de.pta.mics.home.viewmodel;
-
-
-import static org.junit.Assert.assertTrue;
-
-import de.pta.mics.home.common.JsonGeneratorBase;
-import de.pta.mics.home.common.util.ResourceLoaderBase;
-import org.junit.Test;
-
-public class VersionInfoTest extends ResourceLoaderBase {
- // IMPORTANT TEST!!!
- // Make sure, our Interface produces a DEFINED Json!
- // Changes in the interface will HOPEFULLY crash here!!!
-
- @Test
- public void testStructureAgainstJson() {
- String json = super.loadStringFromResource("VersionInfo.json");
- VersionInfo vi = JsonGeneratorBase.getGson().fromJson(json, VersionInfo.class);
-
- assertTrue(vi.getBackendVersion().equals("0x.0x.xx"));
- }
-
- @Test
- public void testSetters() {
- VersionInfo vi = new VersionInfo();
- vi.setBackendVersion("222");
- }
-
-}
diff --git a/src/test/java/org/eclipse/openk/mics/home/common/BackendConfigTest.java b/src/test/java/org/eclipse/openk/mics/home/common/BackendConfigTest.java
new file mode 100644
index 0000000..16d9254
--- /dev/null
+++ b/src/test/java/org/eclipse/openk/mics/home/common/BackendConfigTest.java
@@ -0,0 +1,31 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class BackendConfigTest {
+ @Test
+ public void testConfig() {
+ BackendConfig bc = BackendConfig.getInstance();
+ assertEquals( bc.getMicsCentralURL(), "http://localhost:9010/mics/central" );
+ assertEquals( bc.getMicsDistributionCluster(), "elogbook.openK");
+ assertEquals( bc.getMicsHealthStateExtraPath(), "healthcheck?pretty=true" );
+ BackendConfig.setConfigFileName("backendConfigProduction.json");
+ assertEquals( BackendConfig.getConfigFileName(), "backendConfigProduction.json");
+ assertEquals( false, BackendConfig.getInstance().isMicsCentralIsHttps());
+ }
+}
diff --git a/src/test/java/org/eclipse/openk/mics/home/common/HttpStatusExceptionTest.java b/src/test/java/org/eclipse/openk/mics/home/common/HttpStatusExceptionTest.java
new file mode 100644
index 0000000..664e987
--- /dev/null
+++ b/src/test/java/org/eclipse/openk/mics/home/common/HttpStatusExceptionTest.java
@@ -0,0 +1,26 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common;
+
+import org.apache.http.HttpStatus;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class HttpStatusExceptionTest {
+ @Test
+ public void testAll() {
+ HttpStatusException hse = new HttpStatusException( 200 );
+ assertEquals( hse.getHttpStatus(), HttpStatus.SC_OK );
+ }
+}
diff --git a/src/test/java/de/pta/mics/home/common/InitBackendConfigTest.java b/src/test/java/org/eclipse/openk/mics/home/common/InitBackendConfigTest.java
similarity index 65%
rename from src/test/java/de/pta/mics/home/common/InitBackendConfigTest.java
rename to src/test/java/org/eclipse/openk/mics/home/common/InitBackendConfigTest.java
index 81768bf..fbc0e97 100644
--- a/src/test/java/de/pta/mics/home/common/InitBackendConfigTest.java
+++ b/src/test/java/org/eclipse/openk/mics/home/common/InitBackendConfigTest.java
@@ -1,4 +1,16 @@
-package de.pta.mics.home.common;
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common;
import org.junit.Test;
import org.powermock.reflect.Whitebox;
diff --git a/src/test/java/org/eclipse/openk/mics/home/common/NotificationStatusTest.java b/src/test/java/org/eclipse/openk/mics/home/common/NotificationStatusTest.java
new file mode 100644
index 0000000..e6fb159
--- /dev/null
+++ b/src/test/java/org/eclipse/openk/mics/home/common/NotificationStatusTest.java
@@ -0,0 +1,32 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class NotificationStatusTest {
+
+ @Test
+ public void createNotificationStatus() throws Exception {
+
+ assertEquals(0, NotificationStatus.UNKNOWN.id);
+ assertEquals(1, NotificationStatus.OPEN.id);
+ assertEquals(2, NotificationStatus.INPROGRESS.id);
+ assertEquals(3, NotificationStatus.FINISHED.id);
+ assertEquals(4, NotificationStatus.CLOSED.id);
+
+ }
+
+}
diff --git a/src/test/java/de/pta/mics/home/common/util/JsonGeneratorBaseTest.java b/src/test/java/org/eclipse/openk/mics/home/common/util/JsonGeneratorBaseTest.java
similarity index 75%
rename from src/test/java/de/pta/mics/home/common/util/JsonGeneratorBaseTest.java
rename to src/test/java/org/eclipse/openk/mics/home/common/util/JsonGeneratorBaseTest.java
index 9ed5500..83ce19d 100644
--- a/src/test/java/de/pta/mics/home/common/util/JsonGeneratorBaseTest.java
+++ b/src/test/java/org/eclipse/openk/mics/home/common/util/JsonGeneratorBaseTest.java
@@ -1,4 +1,16 @@
-package de.pta.mics.home.common.util;
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common.util;
import org.junit.Test;
import org.powermock.reflect.Whitebox;
diff --git a/src/test/java/org/eclipse/openk/mics/home/common/util/ResourceLoaderBaseTest.java b/src/test/java/org/eclipse/openk/mics/home/common/util/ResourceLoaderBaseTest.java
new file mode 100644
index 0000000..ebdb533
--- /dev/null
+++ b/src/test/java/org/eclipse/openk/mics/home/common/util/ResourceLoaderBaseTest.java
@@ -0,0 +1,27 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.common.util;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class ResourceLoaderBaseTest {
+ @Test
+ public void testloadStringFromResourceError() {
+ ResourceLoaderBase rlb = new ResourceLoaderBase();
+ String str = rlb.loadStringFromResource("UNKNOWN_FILE");
+ assertEquals(str, "");
+ }
+}
diff --git a/src/test/java/org/eclipse/openk/mics/home/controller/CentralProxyTest.java b/src/test/java/org/eclipse/openk/mics/home/controller/CentralProxyTest.java
new file mode 100644
index 0000000..64d1d7f
--- /dev/null
+++ b/src/test/java/org/eclipse/openk/mics/home/controller/CentralProxyTest.java
@@ -0,0 +1,40 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.controller;
+
+import org.eclipse.openk.mics.home.common.HttpStatusException;
+import org.eclipse.openk.mics.home.communication.RestServiceWrapper;
+import org.easymock.EasyMock;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+import static org.easymock.EasyMock.anyString;
+import static org.junit.Assert.assertEquals;
+
+public class CentralProxyTest {
+
+ @Test
+ public void testAll() throws HttpStatusException {
+ RestServiceWrapper rsw = EasyMock.createMock(RestServiceWrapper.class);
+ EasyMock.expect(rsw.performGetRequest(anyString())).andReturn("fine").anyTimes();
+ EasyMock.replay(rsw);
+ EasyMock.verify(rsw);
+ CentralProxy cp = new CentralProxy("TEST_URL");
+
+ Whitebox.setInternalState(cp, "restServiceWrapper", rsw);
+
+ assertEquals( "fine", cp.getHealthState("/abs",
+ "https", "123.456.789.0", "4711"));
+ assertEquals( "fine", cp.getServerDistribution("klausDasCluster"));
+ }
+}
diff --git a/src/test/java/org/eclipse/openk/mics/home/controller/ResponseBuilderWrapperTest.java b/src/test/java/org/eclipse/openk/mics/home/controller/ResponseBuilderWrapperTest.java
new file mode 100644
index 0000000..c168498
--- /dev/null
+++ b/src/test/java/org/eclipse/openk/mics/home/controller/ResponseBuilderWrapperTest.java
@@ -0,0 +1,41 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.controller;
+
+
+import org.apache.http.HttpStatus;
+import org.eclipse.openk.mics.home.common.HttpStatusException;
+import org.junit.Test;
+
+import javax.ws.rs.core.Response;
+
+import static org.junit.Assert.assertEquals;
+
+
+public class ResponseBuilderWrapperTest {
+ @Test
+ public void testGetResponseBuilder() throws HttpStatusException {
+ String json = "{ 'ret' : 'OK' }";
+ Response.ResponseBuilder rb = ResponseBuilderWrapper.INSTANCE.getResponseBuilder( json );
+ Response resp = rb.build();
+ assertEquals(resp.getStatus(), HttpStatus.SC_OK );
+ }
+
+ @Test
+ public void testBuildOkResponse() throws HttpStatusException {
+ String json = "{ 'test' : 'Value' }";
+ Response resp = ResponseBuilderWrapper.INSTANCE.buildOKResponse( json );
+ assertEquals( resp.getStatus(), HttpStatus.SC_OK );
+
+ }
+}
diff --git a/src/test/java/org/eclipse/openk/mics/home/viewmodel/ErrorReturnTest.java b/src/test/java/org/eclipse/openk/mics/home/viewmodel/ErrorReturnTest.java
new file mode 100644
index 0000000..6ac0ada
--- /dev/null
+++ b/src/test/java/org/eclipse/openk/mics/home/viewmodel/ErrorReturnTest.java
@@ -0,0 +1,42 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.viewmodel;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import org.eclipse.openk.mics.home.common.JsonGeneratorBase;
+import org.eclipse.openk.mics.home.common.util.ResourceLoaderBase;
+import org.junit.Test;
+
+public class ErrorReturnTest extends ResourceLoaderBase {
+ // IMPORTANT TEST!!!
+ // Make sure, our Interface produces a DEFINED Json!
+ // Changes in the interface will HOPEFULLY crash here!!!
+
+ @Test
+ public void TestStructureAgainstJson() {
+ String json = super.loadStringFromResource("testErrorReturn.json");
+ ErrorReturn errRet = JsonGeneratorBase.getGson().fromJson(json, ErrorReturn.class);
+ assertFalse(errRet.getErrorText().isEmpty());
+ assertEquals(errRet.getErrorCode(), 999);
+ }
+
+ @Test
+ public void TestSetters() {
+ ErrorReturn errRet = new ErrorReturn();
+ errRet.setErrorCode(1);
+ errRet.setErrorText("bla bla");
+ }
+
+}
diff --git a/src/test/java/org/eclipse/openk/mics/home/viewmodel/ServiceRequestEnvelopeTest.java b/src/test/java/org/eclipse/openk/mics/home/viewmodel/ServiceRequestEnvelopeTest.java
new file mode 100644
index 0000000..23a9fe7
--- /dev/null
+++ b/src/test/java/org/eclipse/openk/mics/home/viewmodel/ServiceRequestEnvelopeTest.java
@@ -0,0 +1,50 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.viewmodel;
+
+
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class ServiceRequestEnvelopeTest {
+
+ @Test
+ public void testPojo() {
+ final String payload = "Testme Accurate";
+ ServiceRequestEnvelope env = new ServiceRequestEnvelope();
+ env.setHttps(true);
+ env.setMethod("POST");
+ env.setUriFragment("Fraggel");
+ env.setServiceName("Salve");
+
+ ServiceRequestEnvelope.HttpHeader[] headers = new ServiceRequestEnvelope.HttpHeader[2];
+ headers[0] = new ServiceRequestEnvelope.HttpHeader();
+ headers[0].setAttribute("1stAttr");
+ headers[0].setValue("1stValue");
+ headers[1] = new ServiceRequestEnvelope.HttpHeader();
+ headers[1].setAttribute("2ndAttr");
+ headers[1].setValue("2ndValue");
+ env.setHeaders(headers);
+
+ assertEquals(true, env.isHttps());
+ assertEquals("POST", env.getMethod());
+ env.setPayload(payload);
+ assertEquals(payload, env.getPayload());
+ assertEquals("Fraggel", env.getUriFragment());
+ assertEquals("Salve", env.getServiceName());
+ assertEquals(2, env.getHeaders().length);
+ assertEquals("2ndAttr", env.getHeaders()[1].getAttribute());
+ assertEquals("1stValue", env.getHeaders()[0].getValue());
+ }
+}
diff --git a/src/test/java/org/eclipse/openk/mics/home/viewmodel/VersionInfoTest.java b/src/test/java/org/eclipse/openk/mics/home/viewmodel/VersionInfoTest.java
new file mode 100644
index 0000000..8e41e0a
--- /dev/null
+++ b/src/test/java/org/eclipse/openk/mics/home/viewmodel/VersionInfoTest.java
@@ -0,0 +1,41 @@
+/**
+******************************************************************************
+* Copyright © 2018 PTA GmbH.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+*
+* http://www.eclipse.org/legal/epl-v10.html
+*
+******************************************************************************
+*/
+
+package org.eclipse.openk.mics.home.viewmodel;
+
+
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.openk.mics.home.common.JsonGeneratorBase;
+import org.eclipse.openk.mics.home.common.util.ResourceLoaderBase;
+import org.junit.Test;
+
+public class VersionInfoTest extends ResourceLoaderBase {
+ // IMPORTANT TEST!!!
+ // Make sure, our Interface produces a DEFINED Json!
+ // Changes in the interface will HOPEFULLY crash here!!!
+
+ @Test
+ public void testStructureAgainstJson() {
+ String json = super.loadStringFromResource("VersionInfo.json");
+ VersionInfo vi = JsonGeneratorBase.getGson().fromJson(json, VersionInfo.class);
+
+ assertTrue(vi.getBackendVersion().equals("0x.0x.xx"));
+ }
+
+ @Test
+ public void testSetters() {
+ VersionInfo vi = new VersionInfo();
+ vi.setBackendVersion("222");
+ }
+
+}
diff --git a/src/test/resources/serviceRequestEnvelope.json b/src/test/resources/serviceRequestEnvelope.json
new file mode 100644
index 0000000..9722f58
--- /dev/null
+++ b/src/test/resources/serviceRequestEnvelope.json
@@ -0,0 +1,17 @@
+{
+ "serviceName": "auth-n-auth.mics",
+ "isHttps": false,
+ "method": "GET",
+ "uriFragment": "versionInfo",
+ "payload": "eyAiYmFja2VuZFZlcnNpb24iOiAiMC4xLjMtU05BUFNIT1QifQ==",
+ "headers": [
+ {
+ "attribute": "Content-Type",
+ "value": "application/json"
+ },
+ {
+ "attribute": "accept",
+ "value": "application/json"
+ }
+ ]
+}
\ No newline at end of file