Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Fixed constraint violation serialization on client

Christian Bauer53715831f3e2
diff --git a/client/src/main/java/org/openremote/app/client/admin/users/edit/AdminUserEditActivity.java b/client/src/main/java/org/openremote/app/client/admin/users/edit/AdminUserEditActivity.java
index a5f3b363c..70f34f0e7 100644
--- a/client/src/main/java/org/openremote/app/client/admin/users/edit/AdminUserEditActivity.java
+++ b/client/src/main/java/org/openremote/app/client/admin/users/edit/AdminUserEditActivity.java
@@ -229,11 +229,11 @@ public class AdminUserEditActivity
if (password == null)
return;
if (!password.equals(passwordControl)) {
- validationErrorHandler.accept(new ConstraintViolation[]{
- new ConstraintViolation(
- ConstraintViolation.Type.FIELD, "password", environment.getMessages().passwordsMustMatch()
- )
- });
+ ConstraintViolation violation = new ConstraintViolation();
+ violation.setConstraintType(ConstraintViolation.Type.FIELD);
+ violation.setPath("password");
+ violation.setMessage(environment.getMessages().passwordsMustMatch());
+ validationErrorHandler.accept(new ConstraintViolation[]{violation});
return;
}
Credential credential = new Credential(password, false);
diff --git a/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.java b/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.java
index cbfec5b4c..42bd3d8f9 100644
--- a/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.java
+++ b/client/src/main/java/org/openremote/app/client/assets/asset/AssetEditActivity.java
@@ -150,8 +150,6 @@ public class AssetEditActivity
asset.setName("My New Asset");
asset.setRealmId(environment.getApp().getTenant().getId());
asset.setTenantDisplayName(environment.getApp().getTenant().getDisplayName());
- JsUtil.log(asset);
-
asset.setType(AssetType.THING);
}
diff --git a/client/src/main/java/org/openremote/app/client/rest/RequestService.java b/client/src/main/java/org/openremote/app/client/rest/RequestService.java
index 99e53712f..3f00d065f 100644
--- a/client/src/main/java/org/openremote/app/client/rest/RequestService.java
+++ b/client/src/main/java/org/openremote/app/client/rest/RequestService.java
@@ -26,9 +26,8 @@ import elemental2.core.Global;
import jsinterop.annotations.JsIgnore;
import jsinterop.annotations.JsType;
import jsinterop.base.Any;
+import jsinterop.base.Js;
import org.openremote.app.client.util.JsUtil;
-import org.openremote.model.asset.Asset;
-import org.openremote.model.asset.AssetQuery;
import org.openremote.model.http.*;
import org.openremote.model.interop.BiConsumer;
import org.openremote.model.interop.Consumer;
@@ -42,23 +41,31 @@ import java.util.stream.Collectors;
import java.util.stream.DoubleStream;
import static com.google.gwt.http.client.Response.*;
-import static org.openremote.model.http.ConstraintViolationReport.VIOLATION_EXCEPTION_HEADER;
+import static org.openremote.model.http.BadRequestException.VIOLATION_EXCEPTION_HEADER;
@JsType
public class RequestService {
private static final Logger LOG = Logger.getLogger(RequestService.class.getName());
- double ANY_STATUS_CODE = -1;
+ public static final double ANY_STATUS_CODE = -1;
// This consumer gets request params, sets credentials to authorize the request, then calls the given runnable
final protected BiConsumer<RequestParams, Runnable> requestAuthorizer;
+ final protected Runnable beforeRequest;
+
+ final protected Runnable afterRequest;
+
final protected Function<String, ConstraintViolationReport> constraintViolationReader;
public RequestService(BiConsumer<RequestParams, Runnable> requestAuthorizer,
+ Runnable beforeRequest,
+ Runnable afterRequest,
Function<String, ConstraintViolationReport> constraintViolationReader) {
this.requestAuthorizer = requestAuthorizer;
+ this.beforeRequest = beforeRequest;
+ this.afterRequest = afterRequest;
this.constraintViolationReader = constraintViolationReader;
}
@@ -151,9 +158,17 @@ public class RequestService {
Consumer<OUT> onResponse,
Consumer<RequestException> onException) {
+ if (beforeRequest != null) {
+ beforeRequest.run();
+ }
+
RequestParams<IN, OUT> requestParams = new RequestParams<>(
(responseCode, request, responseText) -> {
+ if (afterRequest != null) {
+ afterRequest.run();
+ }
+
if (responseCode == 0) {
onException.accept(new NoResponseException(0));
return;
@@ -165,7 +180,7 @@ public class RequestService {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Received 400 status with constraint violation report: " + responseText);
}
- ConstraintViolationReport report = getConstraintViolationReport(responseText);
+ ConstraintViolationReport report = constraintViolationReader.apply(responseText);
onException.accept(new BadRequestException(SC_BAD_REQUEST, report));
} else {
if (LOG.isLoggable(Level.FINE)) {
@@ -229,8 +244,4 @@ public class RequestService {
requestAuthorizer.accept(requestParams, () -> onRequest.accept(requestParams));
}
}
-
- protected ConstraintViolationReport getConstraintViolationReport(String responseText) {
- return constraintViolationReader.apply(responseText);
- }
}
diff --git a/client/src/main/webapp/src/or-app/or-app-security.html b/client/src/main/webapp/src/or-app/or-app-security.html
index e683a4cbb..10ac6d828 100644
--- a/client/src/main/webapp/src/or-app/or-app-security.html
+++ b/client/src/main/webapp/src/or-app/or-app-security.html
@@ -309,6 +309,7 @@
}
serviceUrl = serviceUrl + "?Auth-Realm=" + this.realm;
if (this.keycloak) {
+ // TODO Should use keycloak.updateToken()?
serviceUrl = serviceUrl + "&Authorization=Bearer " + this.keycloak.token;
} else {
serviceUrl = serviceUrl + "&Authorization=Basic " + window.btoa(this.user + ":" + this.basicAuthPassword);
diff --git a/client/src/main/webapp/src/or-app/or-app.html b/client/src/main/webapp/src/or-app/or-app.html
index 5f045c754..546ffd470 100644
--- a/client/src/main/webapp/src/or-app/or-app.html
+++ b/client/src/main/webapp/src/or-app/or-app.html
@@ -62,11 +62,11 @@
display: none;
}
+ /* Example how to style slotted children
#slots ::slotted(*) {
- /* TODO Example how to style slotted children
border: 1px solid var(--theme-red);
- */
}
+ */
</style>
<div id="loader"></div>
@@ -374,7 +374,7 @@
// Disable login/token refresh
this.set("login", false);
- // TODO Close websocket?
+ this.disconnectEventService();
// Hide the slots
this.$.slots.style.display = "none";
@@ -429,8 +429,9 @@
(requestParams, onComplete) => {
this.getSecurity().authorizeRequestParams(requestParams, onComplete);
},
+ this.showLoader.bind(this),
+ this.hideLoader.bind(this),
(constraintViolationReportJson) => {
- // TODO Anything else for constraint violation handling?
return JSON.parse(constraintViolationReportJson);
}
// TODO We should give a default error handler to RequestService
@@ -459,8 +460,7 @@
// Close explicitly on unload/refresh of page, otherwise close code will be 1001
window.addEventListener("beforeunload", () => {
console.log("Page unloaded, closing event service connection");
- // TODO Should also cancel all subscriptions with the server
- this.webSocket.close();
+ this.disconnectEventService();
});
};
@@ -493,6 +493,15 @@
});
}
+ disconnectEventService() {
+ if (this.webSocket && this.webSocket.readyState === this.webSocket.OPEN) {
+ console.log("Closing WebSocket");
+
+ // TODO Should also cancel all subscriptions with the server!
+ this.webSocket.close();
+ }
+ }
+
loadTenantDetails(onComplete) {
if (!this.login) {
onComplete();
@@ -508,9 +517,7 @@
onComplete();
},
(exception) => {
- // TODO Exception handler, or see above for default error handler in RequestService
- console.log("### GOT EXCEPTION");
- console.dir(exception);
+ this.set("error", exception);
}
);
}
diff --git a/client/src/main/webapp/src/or-app/or-style.html b/client/src/main/webapp/src/or-app/or-style.html
index 7d72b498e..e3d09ec0f 100644
--- a/client/src/main/webapp/src/or-app/or-style.html
+++ b/client/src/main/webapp/src/or-app/or-style.html
@@ -34,15 +34,6 @@
outline: 0;
}
- .scrollable {
- overflow: auto;
- }
-
- scrollable div {
- -webkit-flex-shrink: 0;
- flex-shrink: 0;
- }
-
.or-Viewport {
width: 100%;
height: 100vh;
@@ -597,6 +588,16 @@
margin: 0.4em;
}
+ .or-FormMessages,
+ .or-Toast {
+ font-size: smaller;
+ font-weight: 600;
+ padding: 0.8em;
+ border-radius: 0.25em;
+ -webkit-box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);
+ -moz-box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);
+ box-shadow: 1px 1px 4px -1px rgba(0, 0, 0, 0.9);
+ }
.or-FormMessages,
.or-Toast {
font-size: smaller;
diff --git a/client/src/main/webapp/src/or-asset-list/or-asset-list.html b/client/src/main/webapp/src/or-asset-list/or-asset-list.html
index 02e7e5272..bc972e4d1 100644
--- a/client/src/main/webapp/src/or-asset-list/or-asset-list.html
+++ b/client/src/main/webapp/src/or-asset-list/or-asset-list.html
@@ -53,7 +53,7 @@
return e instanceof HTMLTemplateElement;
});
if (!assetTemplate) {
- throw "Missing item <template> as child of asset list";
+ openremote.INSTANCE.set("error", "Missing item <template> as child of asset list");
}
this.set("assetTemplate", assetTemplate);
}
@@ -88,9 +88,7 @@
this.set("assets", response);
},
(exception) => {
- // TODO Exception handler
- console.log("### GOT EXCEPTION");
- console.dir(exception);
+ openremote.INSTANCE.set("error", exception);
}
);
}
@@ -101,6 +99,10 @@
this.shadowRoot.host.removeChild(item);
});
+ if (!this.assetTemplate) {
+ return;
+ }
+
// For each asset, create a new item element and append the template, then append to host element
for (let asset of assets) {
let item = document.createElement("or-asset-list-item");
diff --git a/deployment/manager/consoles/customerA/index.html b/deployment/manager/consoles/customerA/index.html
index a5a74579f..6ded59ad7 100644
--- a/deployment/manager/consoles/customerA/index.html
+++ b/deployment/manager/consoles/customerA/index.html
@@ -73,7 +73,7 @@
<or-toast></or-toast>
<!-- ############## Required: One <or-app> should wrap your frontend, you can enforce login/authentication ############## -->
-<or-app login tenant-realm="customerA" timeout="10">
+<or-app login tenant-realm="customerA">
<!-- You can use your own styles or the OpenRemote styles and theme -->
<a href="#" class="myAppHeadline">
@@ -99,9 +99,8 @@
</p>
</div>
- <!-- Switch to horizontal layout but flex vertical first and take as much vertical
- space as needed, and allow children to scroll if content doesn't fit -->
- <div class="flex layout horizontal scrollable">
+ <!-- Switch to horizontal layout but flex vertical first and take as much vertical space as needed -->
+ <div class="flex layout horizontal">
<!-- Flex and take as much horizontal space as possible -->
<div class="flex layout vertical">
@@ -141,7 +140,7 @@
</div>
<!-- Flex and take as much horizontal space as possible, show scrollbars if content doesn't fit. -->
- <div class="flex or-MainContent scrollable">
+ <div class="flex or-MainContent scroll">
<!-- Execute AssetQuery and subscribe for attribute changes -->
<or-asset type="room" id="blabla">
diff --git a/manager/src/main/java/org/openremote/manager/security/TenantResourceImpl.java b/manager/src/main/java/org/openremote/manager/security/TenantResourceImpl.java
index d30c3b062..7c386f290 100644
--- a/manager/src/main/java/org/openremote/manager/security/TenantResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/security/TenantResourceImpl.java
@@ -40,7 +40,7 @@ import java.util.logging.Logger;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static org.openremote.model.Constants.MASTER_REALM;
-import static org.openremote.model.http.ConstraintViolationReport.VIOLATION_EXCEPTION_HEADER;
+import static org.openremote.model.http.BadRequestException.VIOLATION_EXCEPTION_HEADER;
public class TenantResourceImpl extends ManagerWebResource implements TenantResource {
@@ -163,10 +163,10 @@ public class TenantResourceImpl extends ManagerWebResource implements TenantReso
ResourceBundle validationMessages = getContainer().getService(I18NService.class).getValidationMessages();
List<ConstraintViolation> violations = new ArrayList<>();
- violations.add(new ConstraintViolation(
- ConstraintViolation.Type.PARAMETER,
- validationMessages.getString("Tenant.masterDeleted")
- ));
+ ConstraintViolation violation = new ConstraintViolation();
+ violation.setConstraintType(ConstraintViolation.Type.PARAMETER);
+ violation.setMessage(validationMessages.getString("Tenant.masterDeleted"));
+ violations.add(violation);
ConstraintViolationReport report = new ConstraintViolationReport();
report.setParameterViolations(violations.toArray(new ConstraintViolation[violations.size()]));
return report;
@@ -180,19 +180,17 @@ public class TenantResourceImpl extends ManagerWebResource implements TenantReso
List<ConstraintViolation> violations = new ArrayList<>();
if (tenant.getEnabled() == null || !tenant.getEnabled()) {
- ConstraintViolation violation = new ConstraintViolation(
- ConstraintViolation.Type.PARAMETER,
- "Tenant.enabled",
- validationMessages.getString("Tenant.masterDisabled")
- );
+ ConstraintViolation violation = new ConstraintViolation();
+ violation.setConstraintType(ConstraintViolation.Type.PARAMETER);
+ violation.setPath("Tenant.enabled");
+ violation.setMessage(validationMessages.getString("Tenant.masterDisabled"));
violations.add(violation);
}
if (tenant.getRealm() == null || !tenant.getRealm().equals(MASTER_REALM)) {
- ConstraintViolation violation = new ConstraintViolation(
- ConstraintViolation.Type.PARAMETER,
- "Tenant.realm",
- validationMessages.getString("Tenant.masterRealmChanged")
- );
+ ConstraintViolation violation = new ConstraintViolation();
+ violation.setConstraintType(ConstraintViolation.Type.PARAMETER);
+ violation.setPath("Tenant.realm");
+ violation.setMessage(validationMessages.getString("Tenant.masterRealmChanged"));
violations.add(violation);
}
if (violations.size() > 0) {
diff --git a/manager/src/main/java/org/openremote/manager/security/UserResourceImpl.java b/manager/src/main/java/org/openremote/manager/security/UserResourceImpl.java
index 73d12a163..9b796386f 100644
--- a/manager/src/main/java/org/openremote/manager/security/UserResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/security/UserResourceImpl.java
@@ -41,7 +41,7 @@ import java.util.ResourceBundle;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
import static org.openremote.model.Constants.MASTER_REALM;
-import static org.openremote.model.http.ConstraintViolationReport.VIOLATION_EXCEPTION_HEADER;
+import static org.openremote.model.http.BadRequestException.VIOLATION_EXCEPTION_HEADER;
public class UserResourceImpl extends ManagerWebResource implements UserResource {
@@ -210,10 +210,10 @@ public class UserResourceImpl extends ManagerWebResource implements UserResource
ResourceBundle validationMessages = getContainer().getService(I18NService.class).getValidationMessages();
List<ConstraintViolation> violations = new ArrayList<>();
- violations.add(new ConstraintViolation(
- ConstraintViolation.Type.PARAMETER,
- validationMessages.getString("User.masterAdminDeleted")
- ));
+ ConstraintViolation violation = new ConstraintViolation();
+ violation.setConstraintType(ConstraintViolation.Type.PARAMETER);
+ violation.setMessage(validationMessages.getString("User.masterAdminDeleted"));
+ violations.add(violation);
ConstraintViolationReport report = new ConstraintViolationReport();
report.setParameterViolations(violations.toArray(new ConstraintViolation[violations.size()]));
return report;
@@ -231,11 +231,10 @@ public class UserResourceImpl extends ManagerWebResource implements UserResource
List<ConstraintViolation> violations = new ArrayList<>();
if (user.getEnabled() == null || !user.getEnabled()) {
- ConstraintViolation violation = new ConstraintViolation(
- ConstraintViolation.Type.PARAMETER,
- "User.enabled",
- validationMessages.getString("User.masterAdminDisabled")
- );
+ ConstraintViolation violation = new ConstraintViolation();
+ violation.setConstraintType(ConstraintViolation.Type.PARAMETER);
+ violation.setPath("User.enabled");
+ violation.setMessage(validationMessages.getString("User.masterAdminDisabled"));
violations.add(violation);
}
if (violations.size() > 0) {
diff --git a/model/src/main/java/org/openremote/model/http/BadRequestException.java b/model/src/main/java/org/openremote/model/http/BadRequestException.java
index 345386aba..74f31d407 100644
--- a/model/src/main/java/org/openremote/model/http/BadRequestException.java
+++ b/model/src/main/java/org/openremote/model/http/BadRequestException.java
@@ -24,6 +24,8 @@ import jsinterop.annotations.JsType;
@JsType
public class BadRequestException extends RequestException {
+ public static final String VIOLATION_EXCEPTION_HEADER = "validation-exception";
+
protected ConstraintViolationReport constraintViolationReport;
public BadRequestException(int statusCode, ConstraintViolationReport constraintViolationReport) {
diff --git a/model/src/main/java/org/openremote/model/http/ConstraintViolation.java b/model/src/main/java/org/openremote/model/http/ConstraintViolation.java
index 20d39f065..ebaa4da1d 100644
--- a/model/src/main/java/org/openremote/model/http/ConstraintViolation.java
+++ b/model/src/main/java/org/openremote/model/http/ConstraintViolation.java
@@ -19,72 +19,69 @@
*/
package org.openremote.model.http;
-import jsinterop.annotations.JsIgnore;
-import jsinterop.annotations.JsType;
+import jsinterop.annotations.*;
-import java.io.Serializable;
-
-@JsType
-public class ConstraintViolation implements Serializable {
+@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
+public class ConstraintViolation {
@JsType
public enum Type {CLASS, FIELD, PROPERTY, PARAMETER, RETURN_VALUE}
+ @JsProperty
protected Type constraintType;
- protected String path;
- protected String message;
- protected String value;
- @JsIgnore
- private ConstraintViolation() {
- this(null, null);
- }
+ @JsProperty
+ protected String path;
- public ConstraintViolation(Type constraintType, String path, String message) {
- this.constraintType = constraintType;
- this.path = path;
- this.message = message;
- }
+ @JsProperty
+ protected String message;
- @JsIgnore
- public ConstraintViolation(Type constraintType, String message) {
- this(constraintType, null, message);
- }
+ @JsProperty
+ protected String value;
- public Type getConstraintType() {
+ @JsOverlay
+ final public Type getConstraintType() {
return constraintType;
}
- public void setConstraintType(Type constraintType) {
+ @JsOverlay
+ final public void setConstraintType(Type constraintType) {
this.constraintType = constraintType;
}
- public String getPath() {
+ @JsOverlay
+ final public String getPath() {
return path;
}
- public void setPath(String path) {
+ @JsOverlay
+ final public void setPath(String path) {
this.path = path;
}
- public String getMessage() {
+ @JsOverlay
+ final public String getMessage() {
return message;
}
- public void setMessage(String message) {
+ @JsOverlay
+ final public void setMessage(String message) {
this.message = message;
}
- public String getValue() {
+ @JsOverlay
+ final public String getValue() {
return value;
}
- public void setValue(String value) {
+ @JsOverlay
+ final public void setValue(String value) {
this.value = value;
}
+ @JsOverlay
@Override
- public String toString() {
+ final public String toString() {
return getClass().getSimpleName() + "{" +
"constraintType=" + constraintType +
", path='" + path + '\'' +
diff --git a/model/src/main/java/org/openremote/model/http/ConstraintViolationReport.java b/model/src/main/java/org/openremote/model/http/ConstraintViolationReport.java
index 98dc013eb..b0ace67e7 100644
--- a/model/src/main/java/org/openremote/model/http/ConstraintViolationReport.java
+++ b/model/src/main/java/org/openremote/model/http/ConstraintViolationReport.java
@@ -19,73 +19,95 @@
*/
package org.openremote.model.http;
-import jsinterop.annotations.JsType;
+import jsinterop.annotations.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-@JsType
-public class ConstraintViolationReport implements java.io.Serializable {
-
- public static final String VIOLATION_EXCEPTION_HEADER = "validation-exception";
+@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
+public class ConstraintViolationReport {
+ @JsProperty
protected String exception;
- protected ConstraintViolation[] fieldViolations = new ConstraintViolation[0];
- protected ConstraintViolation[] propertyViolations = new ConstraintViolation[0];
- protected ConstraintViolation[] classViolations = new ConstraintViolation[0];
- protected ConstraintViolation[] parameterViolations = new ConstraintViolation[0];
- protected ConstraintViolation[] returnValueViolations = new ConstraintViolation[0];
- public String getException() {
+ @JsProperty
+ protected ConstraintViolation[] fieldViolations;
+
+ @JsProperty
+ protected ConstraintViolation[] propertyViolations;
+
+ @JsProperty
+ protected ConstraintViolation[] classViolations;
+
+ @JsProperty
+ protected ConstraintViolation[] parameterViolations;
+
+ @JsProperty
+ protected ConstraintViolation[] returnValueViolations;
+
+ @JsOverlay
+ final public String getException() {
return exception;
}
- public void setException(String exception) {
+ @JsOverlay
+ final public void setException(String exception) {
this.exception = exception;
}
- public ConstraintViolation[] getFieldViolations() {
- return fieldViolations;
+ @JsOverlay
+ final public ConstraintViolation[] getFieldViolations() {
+ return fieldViolations != null ? fieldViolations : new ConstraintViolation[0];
}
- public void setFieldViolations(ConstraintViolation[] fieldViolations) {
+ @JsOverlay
+ final public void setFieldViolations(ConstraintViolation[] fieldViolations) {
this.fieldViolations = fieldViolations;
}
- public ConstraintViolation[] getPropertyViolations() {
- return propertyViolations;
+ @JsOverlay
+ final public ConstraintViolation[] getPropertyViolations() {
+ return propertyViolations != null ? propertyViolations : new ConstraintViolation[0];
}
- public void setPropertyViolations(ConstraintViolation[] propertyViolations) {
+ @JsOverlay
+ final public void setPropertyViolations(ConstraintViolation[] propertyViolations) {
this.propertyViolations = propertyViolations;
}
- public ConstraintViolation[] getClassViolations() {
- return classViolations;
+ @JsOverlay
+ final public ConstraintViolation[] getClassViolations() {
+ return classViolations != null ? classViolations : new ConstraintViolation[0];
}
- public void setClassViolations(ConstraintViolation[] classViolations) {
+ @JsOverlay
+ final public void setClassViolations(ConstraintViolation[] classViolations) {
this.classViolations = classViolations;
}
- public ConstraintViolation[] getParameterViolations() {
- return parameterViolations;
+ @JsOverlay
+ final public ConstraintViolation[] getParameterViolations() {
+ return parameterViolations != null ? parameterViolations : new ConstraintViolation[0];
}
- public void setParameterViolations(ConstraintViolation[] parameterViolations) {
+ @JsOverlay
+ final public void setParameterViolations(ConstraintViolation[] parameterViolations) {
this.parameterViolations = parameterViolations;
}
- public ConstraintViolation[] getReturnValueViolations() {
- return returnValueViolations;
+ @JsOverlay
+ final public ConstraintViolation[] getReturnValueViolations() {
+ return returnValueViolations != null ? returnValueViolations : new ConstraintViolation[0];
}
- public void setReturnValueViolations(ConstraintViolation[] returnValueViolations) {
+ @JsOverlay
+ final public void setReturnValueViolations(ConstraintViolation[] returnValueViolations) {
this.returnValueViolations = returnValueViolations;
}
- public boolean hasViolations() {
+ @JsOverlay
+ final public boolean hasViolations() {
return getFieldViolations().length > 0
|| getPropertyViolations().length > 0
|| getClassViolations().length > 0
@@ -93,7 +115,8 @@ public class ConstraintViolationReport implements java.io.Serializable {
|| getReturnValueViolations().length > 0;
}
- public ConstraintViolation[] getAllViolations() {
+ @JsOverlay
+ final public ConstraintViolation[] getAllViolations() {
List<ConstraintViolation> violations = new ArrayList<>();
violations.addAll(Arrays.asList(getFieldViolations()));
violations.addAll(Arrays.asList(getPropertyViolations()));
@@ -103,15 +126,4 @@ public class ConstraintViolationReport implements java.io.Serializable {
return violations.toArray(new ConstraintViolation[violations.size()]);
}
- @Override
- public String toString() {
- return getClass().getSimpleName() + "{" +
- "exception='" + exception + '\'' +
- ", fieldViolations=" + Arrays.toString(fieldViolations) +
- ", propertyViolations=" + Arrays.toString(propertyViolations) +
- ", classViolations=" + Arrays.toString(classViolations) +
- ", parameterViolations=" + Arrays.toString(parameterViolations) +
- ", returnValueViolations=" + Arrays.toString(returnValueViolations) +
- '}';
- }
}
\ No newline at end of file
diff --git a/model/src/main/java/org/openremote/model/http/RequestException.java b/model/src/main/java/org/openremote/model/http/RequestException.java
index df07ff211..77fa5fbe9 100644
--- a/model/src/main/java/org/openremote/model/http/RequestException.java
+++ b/model/src/main/java/org/openremote/model/http/RequestException.java
@@ -50,4 +50,11 @@ public class RequestException extends RuntimeException {
public double getStatusCode() {
return statusCode;
}
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "{" +
+ "statusCode=" + statusCode +
+ '}';
+ }
}
diff --git a/model/src/main/java/org/openremote/model/http/UnexpectedStatusRequestException.java b/model/src/main/java/org/openremote/model/http/UnexpectedStatusRequestException.java
index 8b7bf06d4..60f6a93a4 100644
--- a/model/src/main/java/org/openremote/model/http/UnexpectedStatusRequestException.java
+++ b/model/src/main/java/org/openremote/model/http/UnexpectedStatusRequestException.java
@@ -21,6 +21,8 @@ package org.openremote.model.http;
import jsinterop.annotations.JsType;
+import java.util.Arrays;
+
@JsType
public class UnexpectedStatusRequestException extends RequestException {
@@ -34,4 +36,12 @@ public class UnexpectedStatusRequestException extends RequestException {
public double[] getExpectedStatusCodes() {
return expectedStatusCodes;
}
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "{" +
+ "expectedStatusCodes=" + Arrays.toString(expectedStatusCodes) +
+ ", statusCode=" + statusCode +
+ '}';
+ }
}
diff --git a/test/src/main/groovy/org/openremote/test/TestOpenRemoteApp.java b/test/src/main/groovy/org/openremote/test/TestOpenRemoteApp.java
index 3aaf17f4f..2d815c431 100644
--- a/test/src/main/groovy/org/openremote/test/TestOpenRemoteApp.java
+++ b/test/src/main/groovy/org/openremote/test/TestOpenRemoteApp.java
@@ -42,8 +42,15 @@ public class TestOpenRemoteApp extends OpenRemoteApp {
public TestOpenRemoteApp(KeycloakDeployment keycloakDeployment, Tenant tenant, Closure<String> accessTokenClosure) {
this.security = new TestAppSecurity(keycloakDeployment, accessTokenClosure);
this.tenant = tenant;
+
ClientObjectMapper<ConstraintViolationReport> constraintViolationReportMapper = new ClientObjectMapper<>(Container.JSON, ConstraintViolationReport.class);
- this.requestService = new RequestService(security::authorizeRequestParams, constraintViolationReportMapper::read);
+
+ this.requestService = new RequestService(
+ security::authorizeRequestParams,
+ () -> {},
+ () -> {},
+ constraintViolationReportMapper::read
+ );
}
@Override