Commit eb7c2f1659fea2a1b065c4d8a2eceeb630a16478

Authored by YevhenBondarenko
Committed by Andrew Shvayka
1 parent 872cc5ff

Feature/rest client (#2218)

* added methods from admin-controller, alarm-controller, asset-controller, audit-log-controller

* refactored rest client and added methods from auth controller

* added methods from component-descriptor-controller

* added methods from customer controller

* added methods from dashboard controller

* added methods from device controller

* refactored url pageLink params

* added methods from entity relation controller

* added methods from entity view controller

* refactored

* added methods from event controller

* added methods from rpc controller

* added methods from rule chain controller

* added methods from telemetry controller

* added methods from tenant controller

* added methods from user controller

* added methods from widgets bundle controller

* added methods from widget type controller

* created method refreshToken

* moved classes SecuritySettings, UserPasswordPolicy, ClaimRequest, UpdateMessage, to common module, and added "/api" to urls where this part was missing
... ... @@ -28,12 +28,12 @@ import org.thingsboard.server.common.data.AdminSettings;
28 28 import org.thingsboard.server.common.data.exception.ThingsboardException;
29 29 import org.thingsboard.server.common.data.id.TenantId;
30 30 import org.thingsboard.server.dao.settings.AdminSettingsService;
31   -import org.thingsboard.server.service.security.model.SecuritySettings;
  31 +import org.thingsboard.server.common.data.security.model.SecuritySettings;
32 32 import org.thingsboard.server.service.security.permission.Operation;
33 33 import org.thingsboard.server.service.security.permission.Resource;
34 34 import org.thingsboard.server.service.security.system.SystemSecurityService;
35 35 import org.thingsboard.server.service.update.UpdateService;
36   -import org.thingsboard.server.service.update.model.UpdateMessage;
  36 +import org.thingsboard.server.common.data.UpdateMessage;
37 37
38 38 @RestController
39 39 @RequestMapping("/api/admin")
... ...
... ... @@ -24,7 +24,6 @@ import org.springframework.http.HttpHeaders;
24 24 import org.springframework.http.HttpStatus;
25 25 import org.springframework.http.ResponseEntity;
26 26 import org.springframework.security.access.prepost.PreAuthorize;
27   -import org.springframework.security.core.Authentication;
28 27 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
29 28 import org.springframework.web.bind.annotation.RequestBody;
30 29 import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -43,14 +42,12 @@ import org.thingsboard.server.common.data.security.UserCredentials;
43 42 import org.thingsboard.server.dao.audit.AuditLogService;
44 43 import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRepository;
45 44 import org.thingsboard.server.service.security.auth.rest.RestAuthenticationDetails;
46   -import org.thingsboard.server.service.security.model.SecuritySettings;
  45 +import org.thingsboard.server.common.data.security.model.SecuritySettings;
47 46 import org.thingsboard.server.service.security.model.SecurityUser;
48   -import org.thingsboard.server.service.security.model.UserPasswordPolicy;
  47 +import org.thingsboard.server.common.data.security.model.UserPasswordPolicy;
49 48 import org.thingsboard.server.service.security.model.UserPrincipal;
50 49 import org.thingsboard.server.service.security.model.token.JwtToken;
51 50 import org.thingsboard.server.service.security.model.token.JwtTokenFactory;
52   -import org.thingsboard.server.service.security.permission.Operation;
53   -import org.thingsboard.server.service.security.permission.Resource;
54 51 import org.thingsboard.server.service.security.system.SystemSecurityService;
55 52 import ua_parser.Client;
56 53
... ...
... ... @@ -44,7 +44,7 @@ import org.thingsboard.server.common.data.id.TenantId;
44 44 import org.thingsboard.server.common.data.page.TextPageData;
45 45 import org.thingsboard.server.common.data.page.TextPageLink;
46 46 import org.thingsboard.server.common.data.security.DeviceCredentials;
47   -import org.thingsboard.server.controller.claim.data.ClaimRequest;
  47 +import org.thingsboard.server.common.data.ClaimRequest;
48 48 import org.thingsboard.server.dao.device.claim.ClaimResponse;
49 49 import org.thingsboard.server.dao.device.claim.ClaimResult;
50 50 import org.thingsboard.server.dao.exception.IncorrectParameterException;
... ...
... ... @@ -42,14 +42,13 @@ import org.thingsboard.server.common.data.User;
42 42 import org.thingsboard.server.common.data.exception.ThingsboardException;
43 43 import org.thingsboard.server.common.data.id.TenantId;
44 44 import org.thingsboard.server.common.data.security.UserCredentials;
45   -import org.thingsboard.server.dao.audit.AuditLogService;
46 45 import org.thingsboard.server.dao.exception.DataValidationException;
47 46 import org.thingsboard.server.dao.settings.AdminSettingsService;
48 47 import org.thingsboard.server.dao.user.UserService;
49 48 import org.thingsboard.server.dao.user.UserServiceImpl;
50 49 import org.thingsboard.server.service.security.exception.UserPasswordExpiredException;
51   -import org.thingsboard.server.service.security.model.SecuritySettings;
52   -import org.thingsboard.server.service.security.model.UserPasswordPolicy;
  50 +import org.thingsboard.server.common.data.security.model.SecuritySettings;
  51 +import org.thingsboard.server.common.data.security.model.UserPasswordPolicy;
53 52
54 53 import javax.annotation.Resource;
55 54 import java.util.ArrayList;
... ...
... ... @@ -19,7 +19,7 @@ import org.springframework.security.core.AuthenticationException;
19 19 import org.thingsboard.server.common.data.id.TenantId;
20 20 import org.thingsboard.server.common.data.security.UserCredentials;
21 21 import org.thingsboard.server.dao.exception.DataValidationException;
22   -import org.thingsboard.server.service.security.model.SecuritySettings;
  22 +import org.thingsboard.server.common.data.security.model.SecuritySettings;
23 23
24 24 public interface SystemSecurityService {
25 25
... ...
... ... @@ -22,7 +22,7 @@ import lombok.extern.slf4j.Slf4j;
22 22 import org.springframework.beans.factory.annotation.Value;
23 23 import org.springframework.stereotype.Service;
24 24 import org.springframework.web.client.RestTemplate;
25   -import org.thingsboard.server.service.update.model.UpdateMessage;
  25 +import org.thingsboard.server.common.data.UpdateMessage;
26 26
27 27 import javax.annotation.PostConstruct;
28 28 import javax.annotation.PreDestroy;
... ...
... ... @@ -15,7 +15,7 @@
15 15 */
16 16 package org.thingsboard.server.service.update;
17 17
18   -import org.thingsboard.server.service.update.model.UpdateMessage;
  18 +import org.thingsboard.server.common.data.UpdateMessage;
19 19
20 20 public interface UpdateService {
21 21
... ...
common/data/src/main/java/org/thingsboard/server/common/data/ClaimRequest.java renamed from application/src/main/java/org/thingsboard/server/controller/claim/data/ClaimRequest.java
... ... @@ -13,7 +13,7 @@
13 13 * See the License for the specific language governing permissions and
14 14 * limitations under the License.
15 15 */
16   -package org.thingsboard.server.controller.claim.data;
  16 +package org.thingsboard.server.common.data;
17 17
18 18 import lombok.Data;
19 19
... ...
common/data/src/main/java/org/thingsboard/server/common/data/UpdateMessage.java renamed from application/src/main/java/org/thingsboard/server/service/update/model/UpdateMessage.java
... ... @@ -13,7 +13,7 @@
13 13 * See the License for the specific language governing permissions and
14 14 * limitations under the License.
15 15 */
16   -package org.thingsboard.server.service.update.model;
  16 +package org.thingsboard.server.common.data;
17 17
18 18 import lombok.Data;
19 19
... ...
common/data/src/main/java/org/thingsboard/server/common/data/security/model/SecuritySettings.java renamed from application/src/main/java/org/thingsboard/server/service/security/model/SecuritySettings.java
... ... @@ -13,7 +13,7 @@
13 13 * See the License for the specific language governing permissions and
14 14 * limitations under the License.
15 15 */
16   -package org.thingsboard.server.service.security.model;
  16 +package org.thingsboard.server.common.data.security.model;
17 17
18 18 import lombok.Data;
19 19
... ...
common/data/src/main/java/org/thingsboard/server/common/data/security/model/UserPasswordPolicy.java renamed from application/src/main/java/org/thingsboard/server/service/security/model/UserPasswordPolicy.java
... ... @@ -13,7 +13,7 @@
13 13 * See the License for the specific language governing permissions and
14 14 * limitations under the License.
15 15 */
16   -package org.thingsboard.server.service.security.model;
  16 +package org.thingsboard.server.common.data.security.model;
17 17
18 18 import lombok.Data;
19 19
... ...
... ... @@ -31,6 +31,7 @@ import org.springframework.web.client.HttpClientErrorException;
31 31 import org.springframework.web.client.RestTemplate;
32 32 import org.springframework.web.context.request.async.DeferredResult;
33 33 import org.thingsboard.server.common.data.AdminSettings;
  34 +import org.thingsboard.server.common.data.ClaimRequest;
34 35 import org.thingsboard.server.common.data.Customer;
35 36 import org.thingsboard.server.common.data.Dashboard;
36 37 import org.thingsboard.server.common.data.DashboardInfo;
... ... @@ -39,6 +40,7 @@ import org.thingsboard.server.common.data.EntitySubtype;
39 40 import org.thingsboard.server.common.data.EntityView;
40 41 import org.thingsboard.server.common.data.Event;
41 42 import org.thingsboard.server.common.data.Tenant;
  43 +import org.thingsboard.server.common.data.UpdateMessage;
42 44 import org.thingsboard.server.common.data.User;
43 45 import org.thingsboard.server.common.data.alarm.Alarm;
44 46 import org.thingsboard.server.common.data.alarm.AlarmInfo;
... ... @@ -65,6 +67,8 @@ import org.thingsboard.server.common.data.rule.RuleChain;
65 67 import org.thingsboard.server.common.data.rule.RuleChainMetaData;
66 68 import org.thingsboard.server.common.data.security.DeviceCredentials;
67 69 import org.thingsboard.server.common.data.security.DeviceCredentialsType;
  70 +import org.thingsboard.server.common.data.security.model.SecuritySettings;
  71 +import org.thingsboard.server.common.data.security.model.UserPasswordPolicy;
68 72 import org.thingsboard.server.common.data.widget.WidgetType;
69 73 import org.thingsboard.server.common.data.widget.WidgetsBundle;
70 74
... ... @@ -85,6 +89,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
85 89 protected final RestTemplate restTemplate = new RestTemplate();
86 90 protected final String baseURL;
87 91 private String token;
  92 + private String refreshToken;
88 93
89 94 private final static String TIME_PAGE_LINK_URL_PARAMS = "limit={limit}&startTime={startTime}&endTime={endTime}&ascOrder={ascOrder}&offset={offset}";
90 95 private final static String TEXT_PAGE_LINK_URL_PARAMS = "limit={limit}&textSearch{textSearch}&idOffset={idOffset}&textOffset{textOffset}";
... ... @@ -93,7 +98,23 @@ public class RestClient implements ClientHttpRequestInterceptor {
93 98 public ClientHttpResponse intercept(HttpRequest request, byte[] bytes, ClientHttpRequestExecution execution) throws IOException {
94 99 HttpRequest wrapper = new HttpRequestWrapper(request);
95 100 wrapper.getHeaders().set(JWT_TOKEN_HEADER_PARAM, "Bearer " + token);
96   - return execution.execute(wrapper, bytes);
  101 + ClientHttpResponse response = execution.execute(wrapper, bytes);
  102 + if (response.getStatusCode() == HttpStatus.UNAUTHORIZED) {
  103 + synchronized (this) {
  104 + restTemplate.getInterceptors().remove(this);
  105 + refreshToken();
  106 + wrapper.getHeaders().set(JWT_TOKEN_HEADER_PARAM, "Bearer " + token);
  107 + return execution.execute(wrapper, bytes);
  108 + }
  109 + }
  110 + return response;
  111 + }
  112 +
  113 + public void refreshToken() {
  114 + Map<String, String> refreshTokenRequest = new HashMap<>();
  115 + refreshTokenRequest.put("refreshToken", refreshToken);
  116 + ResponseEntity<JsonNode> tokenInfo = restTemplate.postForEntity(baseURL + "/api/auth/token", refreshTokenRequest, JsonNode.class);
  117 + setTokenInfo(tokenInfo.getBody());
97 118 }
98 119
99 120 public void login(String username, String password) {
... ... @@ -101,8 +122,13 @@ public class RestClient implements ClientHttpRequestInterceptor {
101 122 loginRequest.put("username", username);
102 123 loginRequest.put("password", password);
103 124 ResponseEntity<JsonNode> tokenInfo = restTemplate.postForEntity(baseURL + "/api/auth/login", loginRequest, JsonNode.class);
104   - this.token = tokenInfo.getBody().get("token").asText();
105   - restTemplate.setInterceptors(Collections.singletonList(this));
  125 + setTokenInfo(tokenInfo.getBody());
  126 + }
  127 +
  128 + private void setTokenInfo(JsonNode tokenInfo) {
  129 + this.token = tokenInfo.get("token").asText();
  130 + this.refreshToken = tokenInfo.get("refreshToken").asText();
  131 + restTemplate.getInterceptors().add(this);
106 132 }
107 133
108 134 public Optional<Device> findDevice(String name) {
... ... @@ -289,28 +315,42 @@ public class RestClient implements ClientHttpRequestInterceptor {
289 315 }
290 316
291 317 public AdminSettings saveAdminSettings(AdminSettings adminSettings) {
292   - return restTemplate.postForEntity(baseURL + "/api/settings", adminSettings, AdminSettings.class).getBody();
  318 + return restTemplate.postForEntity(baseURL + "/api/admin/settings", adminSettings, AdminSettings.class).getBody();
293 319 }
294 320
295 321 public void sendTestMail(AdminSettings adminSettings) {
296   - restTemplate.postForEntity(baseURL + "/api/settings/testMail", adminSettings, AdminSettings.class);
297   - }
298   -
299   - //TODO:
300   -// @RequestMapping(value = "/securitySettings", method = RequestMethod.GET)
301   -// public SecuritySettings getSecuritySettings() {
302   -//
303   -// }
304   - //TODO:
305   -// @RequestMapping(value = "/securitySettings", method = RequestMethod.POST)
306   -// public SecuritySettings saveSecuritySettings(SecuritySettings securitySettings) {
307   -//
308   -// }
309   - //TODO:
310   -// @RequestMapping(value = "/updates", method = RequestMethod.GET)
311   -// public UpdateMessage checkUpdates() {
312   -//
313   -// }
  322 + restTemplate.postForEntity(baseURL + "/api/admin/settings/testMail", adminSettings, AdminSettings.class);
  323 + }
  324 +
  325 + public Optional<SecuritySettings> getSecuritySettings() {
  326 + try {
  327 + ResponseEntity<SecuritySettings> securitySettings = restTemplate.getForEntity(baseURL + "/api/admin/securitySettings", SecuritySettings.class);
  328 + return Optional.ofNullable(securitySettings.getBody());
  329 + } catch (HttpClientErrorException exception) {
  330 + if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
  331 + return Optional.empty();
  332 + } else {
  333 + throw exception;
  334 + }
  335 + }
  336 + }
  337 +
  338 + public SecuritySettings saveSecuritySettings(SecuritySettings securitySettings) {
  339 + return restTemplate.postForEntity(baseURL + "/api/admin/securitySettings", securitySettings, SecuritySettings.class).getBody();
  340 + }
  341 +
  342 + public Optional<UpdateMessage> checkUpdates() {
  343 + try {
  344 + ResponseEntity<UpdateMessage> updateMsg = restTemplate.getForEntity(baseURL + "/api/admin/updates", UpdateMessage.class);
  345 + return Optional.ofNullable(updateMsg.getBody());
  346 + } catch (HttpClientErrorException exception) {
  347 + if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
  348 + return Optional.empty();
  349 + } else {
  350 + throw exception;
  351 + }
  352 + }
  353 + }
314 354
315 355 public Optional<Alarm> getAlarmById(String alarmId) {
316 356 try {
... ... @@ -488,7 +528,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
488 528 addPageLinkToParam(params, pageLink);
489 529
490 530 ResponseEntity<TextPageData<Asset>> assets = restTemplate.exchange(
491   - baseURL + "/customer/{customerId}/assets?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
  531 + baseURL + "/api/customer/{customerId}/assets?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
492 532 HttpMethod.GET,
493 533 HttpEntity.EMPTY,
494 534 new ParameterizedTypeReference<TextPageData<Asset>>() {
... ... @@ -532,7 +572,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
532 572 addPageLinkToParam(params, pageLink);
533 573
534 574 ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange(
535   - baseURL + "/audit/logs/customer/{customerId}?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS,
  575 + baseURL + "/api/audit/logs/customer/{customerId}?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS,
536 576 HttpMethod.GET,
537 577 HttpEntity.EMPTY,
538 578 new ParameterizedTypeReference<TimePageData<AuditLog>>() {
... ... @@ -548,7 +588,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
548 588 addPageLinkToParam(params, pageLink);
549 589
550 590 ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange(
551   - baseURL + "/audit/logs/user/{userId}?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS,
  591 + baseURL + "/api/audit/logs/user/{userId}?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS,
552 592 HttpMethod.GET,
553 593 HttpEntity.EMPTY,
554 594 new ParameterizedTypeReference<TimePageData<AuditLog>>() {
... ... @@ -565,7 +605,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
565 605 addPageLinkToParam(params, pageLink);
566 606
567 607 ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange(
568   - baseURL + "/audit/logs/entity/{entityType}/{entityId}?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS,
  608 + baseURL + "/api/audit/logs/entity/{entityType}/{entityId}?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS,
569 609 HttpMethod.GET,
570 610 HttpEntity.EMPTY,
571 611 new ParameterizedTypeReference<TimePageData<AuditLog>>() {
... ... @@ -580,7 +620,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
580 620 addPageLinkToParam(params, pageLink);
581 621
582 622 ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange(
583   - baseURL + "/audit/logs?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS,
  623 + baseURL + "/api/audit/logs?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS,
584 624 HttpMethod.GET,
585 625 HttpEntity.EMPTY,
586 626 new ParameterizedTypeReference<TimePageData<AuditLog>>() {
... ... @@ -590,40 +630,47 @@ public class RestClient implements ClientHttpRequestInterceptor {
590 630 }
591 631
592 632 public Optional<User> getUser() {
593   - ResponseEntity<User> user = restTemplate.getForEntity(baseURL + "/auth/user", User.class);
  633 + ResponseEntity<User> user = restTemplate.getForEntity(baseURL + "/api/auth/user", User.class);
594 634 return Optional.ofNullable(user.getBody());
595 635 }
596 636
597 637 public void logout() {
598   - restTemplate.exchange(URI.create(baseURL + "/auth/logout"), HttpMethod.POST, HttpEntity.EMPTY, Object.class);
  638 + restTemplate.exchange(URI.create(baseURL + "/api/auth/logout"), HttpMethod.POST, HttpEntity.EMPTY, Object.class);
599 639 }
600 640
601 641 public void changePassword(JsonNode changePasswordRequest) {
602   - restTemplate.exchange(URI.create(baseURL + "/auth/changePassword"), HttpMethod.POST, new HttpEntity<>(changePasswordRequest), Object.class);
  642 + restTemplate.exchange(URI.create(baseURL + "/api/auth/changePassword"), HttpMethod.POST, new HttpEntity<>(changePasswordRequest), Object.class);
603 643 }
604 644
605   - //TODO:
606   -// @RequestMapping(value = "/noauth/userPasswordPolicy", method = RequestMethod.GET)
607   -// public UserPasswordPolicy getUserPasswordPolicy() {
608   -//
609   -// }
  645 + public Optional<UserPasswordPolicy> getUserPasswordPolicy() {
  646 + try {
  647 + ResponseEntity<UserPasswordPolicy> userPasswordPolicy = restTemplate.getForEntity(baseURL + "/api/noauth/userPasswordPolicy", UserPasswordPolicy.class);
  648 + return Optional.ofNullable(userPasswordPolicy.getBody());
  649 + } catch (HttpClientErrorException exception) {
  650 + if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
  651 + return Optional.empty();
  652 + } else {
  653 + throw exception;
  654 + }
  655 + }
  656 + }
610 657
611 658
612 659 public ResponseEntity<String> checkActivateToken(String activateToken) {
613   - return restTemplate.getForEntity(baseURL + "/noauth/activate?activateToken={activateToken}", String.class, activateToken);
  660 + return restTemplate.getForEntity(baseURL + "/api/noauth/activate?activateToken={activateToken}", String.class, activateToken);
614 661 }
615 662
616 663 public void requestResetPasswordByEmail(JsonNode resetPasswordByEmailRequest) {
617   - restTemplate.exchange(URI.create(baseURL + "/noauth/resetPasswordByEmail"), HttpMethod.POST, new HttpEntity<>(resetPasswordByEmailRequest), Object.class);
  664 + restTemplate.exchange(URI.create(baseURL + "/api/noauth/resetPasswordByEmail"), HttpMethod.POST, new HttpEntity<>(resetPasswordByEmailRequest), Object.class);
618 665 }
619 666
620 667 public ResponseEntity<String> checkResetToken(String resetToken) {
621   - return restTemplate.getForEntity(baseURL + "noauth/resetPassword?resetToken={resetToken}", String.class, resetToken);
  668 + return restTemplate.getForEntity(baseURL + "/api/noauth/resetPassword?resetToken={resetToken}", String.class, resetToken);
622 669 }
623 670
624 671 public Optional<JsonNode> activateUser(JsonNode activateRequest) {
625 672 try {
626   - ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/noauth/activate", activateRequest, JsonNode.class);
  673 + ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/api/noauth/activate", activateRequest, JsonNode.class);
627 674 return Optional.ofNullable(jsonNode.getBody());
628 675 } catch (HttpClientErrorException exception) {
629 676 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -636,7 +683,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
636 683
637 684 public Optional<JsonNode> resetPassword(JsonNode resetPasswordRequest) {
638 685 try {
639   - ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/noauth/resetPassword", resetPasswordRequest, JsonNode.class);
  686 + ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/api/noauth/resetPassword", resetPasswordRequest, JsonNode.class);
640 687 return Optional.ofNullable(jsonNode.getBody());
641 688 } catch (HttpClientErrorException exception) {
642 689 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -649,7 +696,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
649 696
650 697 public Optional<ComponentDescriptor> getComponentDescriptorByClazz(String componentDescriptorClazz) {
651 698 try {
652   - ResponseEntity<ComponentDescriptor> componentDescriptor = restTemplate.getForEntity(baseURL + "/component/{componentDescriptorClazz}", ComponentDescriptor.class);
  699 + ResponseEntity<ComponentDescriptor> componentDescriptor = restTemplate.getForEntity(baseURL + "/api/component/{componentDescriptorClazz}", ComponentDescriptor.class);
653 700 return Optional.ofNullable(componentDescriptor.getBody());
654 701 } catch (HttpClientErrorException exception) {
655 702 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -662,7 +709,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
662 709
663 710 public List<ComponentDescriptor> getComponentDescriptorsByType(String componentType) {
664 711 return restTemplate.exchange(
665   - baseURL + "/components?componentType={componentType}",
  712 + baseURL + "/api/components?componentType={componentType}",
666 713 HttpMethod.GET, HttpEntity.EMPTY,
667 714 new ParameterizedTypeReference<List<ComponentDescriptor>>() {
668 715 },
... ... @@ -671,7 +718,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
671 718
672 719 public List<ComponentDescriptor> getComponentDescriptorsByTypes(String[] componentTypes) {
673 720 return restTemplate.exchange(
674   - baseURL + "/components?componentTypes={componentTypes}",
  721 + baseURL + "/api/components?componentTypes={componentTypes}",
675 722 HttpMethod.GET,
676 723 HttpEntity.EMPTY,
677 724 new ParameterizedTypeReference<List<ComponentDescriptor>>() {
... ... @@ -681,7 +728,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
681 728
682 729 public Optional<Customer> getCustomerById(String customerId) {
683 730 try {
684   - ResponseEntity<Customer> customer = restTemplate.getForEntity(baseURL + "/customer/{customerId}", Customer.class, customerId);
  731 + ResponseEntity<Customer> customer = restTemplate.getForEntity(baseURL + "/api/customer/{customerId}", Customer.class, customerId);
685 732 return Optional.ofNullable(customer.getBody());
686 733 } catch (HttpClientErrorException exception) {
687 734 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -694,7 +741,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
694 741
695 742 public Optional<JsonNode> getShortCustomerInfoById(String customerId) {
696 743 try {
697   - ResponseEntity<JsonNode> customerInfo = restTemplate.getForEntity(baseURL + "/customer/{customerId}/shortInfo", JsonNode.class, customerId);
  744 + ResponseEntity<JsonNode> customerInfo = restTemplate.getForEntity(baseURL + "/api/customer/{customerId}/shortInfo", JsonNode.class, customerId);
698 745 return Optional.ofNullable(customerInfo.getBody());
699 746 } catch (HttpClientErrorException exception) {
700 747 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -706,15 +753,15 @@ public class RestClient implements ClientHttpRequestInterceptor {
706 753 }
707 754
708 755 public String getCustomerTitleById(String customerId) {
709   - return restTemplate.getForObject(baseURL + "/customer/{customerId}/title", String.class, customerId);
  756 + return restTemplate.getForObject(baseURL + "/api/customer/{customerId}/title", String.class, customerId);
710 757 }
711 758
712 759 public Customer saveCustomer(Customer customer) {
713   - return restTemplate.postForEntity(baseURL + "/customer", customer, Customer.class).getBody();
  760 + return restTemplate.postForEntity(baseURL + "/api/customer", customer, Customer.class).getBody();
714 761 }
715 762
716 763 public void deleteCustomer(String customerId) {
717   - restTemplate.delete(baseURL + "/customer/{customerId}", customerId);
  764 + restTemplate.delete(baseURL + "/api/customer/{customerId}", customerId);
718 765 }
719 766
720 767 public TextPageData<Customer> getCustomers(TextPageLink pageLink) {
... ... @@ -722,7 +769,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
722 769 addPageLinkToParam(params, pageLink);
723 770
724 771 ResponseEntity<TextPageData<Customer>> customer = restTemplate.exchange(
725   - baseURL + "/customers?" + TEXT_PAGE_LINK_URL_PARAMS,
  772 + baseURL + "/api/customers?" + TEXT_PAGE_LINK_URL_PARAMS,
726 773 HttpMethod.GET,
727 774 HttpEntity.EMPTY,
728 775 new ParameterizedTypeReference<TextPageData<Customer>>() {
... ... @@ -733,7 +780,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
733 780
734 781 public Optional<Customer> getTenantCustomer(String customerTitle) {
735 782 try {
736   - ResponseEntity<Customer> customer = restTemplate.getForEntity(baseURL + "/tenant/customers?customerTitle={customerTitle}", Customer.class, customerTitle);
  783 + ResponseEntity<Customer> customer = restTemplate.getForEntity(baseURL + "/api/tenant/customers?customerTitle={customerTitle}", Customer.class, customerTitle);
737 784 return Optional.ofNullable(customer.getBody());
738 785 } catch (HttpClientErrorException exception) {
739 786 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -745,16 +792,16 @@ public class RestClient implements ClientHttpRequestInterceptor {
745 792 }
746 793
747 794 public Long getServerTime() {
748   - return restTemplate.getForObject(baseURL + "/dashboard/serverTime", Long.class);
  795 + return restTemplate.getForObject(baseURL + "/api/dashboard/serverTime", Long.class);
749 796 }
750 797
751 798 public Long getMaxDatapointsLimit() {
752   - return restTemplate.getForObject(baseURL + "/dashboard/maxDatapointsLimit", Long.class);
  799 + return restTemplate.getForObject(baseURL + "/api/dashboard/maxDatapointsLimit", Long.class);
753 800 }
754 801
755 802 public Optional<DashboardInfo> getDashboardInfoById(String dashboardId) {
756 803 try {
757   - ResponseEntity<DashboardInfo> dashboardInfo = restTemplate.getForEntity(baseURL + "/dashboard/info/{dashboardId}", DashboardInfo.class, dashboardId);
  804 + ResponseEntity<DashboardInfo> dashboardInfo = restTemplate.getForEntity(baseURL + "/api/dashboard/info/{dashboardId}", DashboardInfo.class, dashboardId);
758 805 return Optional.ofNullable(dashboardInfo.getBody());
759 806 } catch (HttpClientErrorException exception) {
760 807 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -767,7 +814,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
767 814
768 815 public Optional<Dashboard> getDashboardById(String dashboardId) {
769 816 try {
770   - ResponseEntity<Dashboard> dashboard = restTemplate.getForEntity(baseURL + "/dashboard/{dashboardId}", Dashboard.class, dashboardId);
  817 + ResponseEntity<Dashboard> dashboard = restTemplate.getForEntity(baseURL + "/api/dashboard/{dashboardId}", Dashboard.class, dashboardId);
771 818 return Optional.ofNullable(dashboard.getBody());
772 819 } catch (HttpClientErrorException exception) {
773 820 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -779,16 +826,16 @@ public class RestClient implements ClientHttpRequestInterceptor {
779 826 }
780 827
781 828 public Dashboard saveDashboard(Dashboard dashboard) {
782   - return restTemplate.postForEntity(baseURL + "/dashboard", dashboard, Dashboard.class).getBody();
  829 + return restTemplate.postForEntity(baseURL + "/api/dashboard", dashboard, Dashboard.class).getBody();
783 830 }
784 831
785 832 public void deleteDashboard(String dashboardId) {
786   - restTemplate.delete(baseURL + "/dashboard/{dashboardId}", dashboardId);
  833 + restTemplate.delete(baseURL + "/api/dashboard/{dashboardId}", dashboardId);
787 834 }
788 835
789 836 public Optional<Dashboard> assignDashboardToCustomer(String customerId, String dashboardId) {
790 837 try {
791   - ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/customer/{customerId}/dashboard/{dashboardId}", null, Dashboard.class, customerId, dashboardId);
  838 + ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/dashboard/{dashboardId}", null, Dashboard.class, customerId, dashboardId);
792 839 return Optional.ofNullable(dashboard.getBody());
793 840 } catch (HttpClientErrorException exception) {
794 841 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -801,7 +848,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
801 848
802 849 public Optional<Dashboard> unassignDashboardFromCustomer(String customerId, String dashboardId) {
803 850 try {
804   - ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/customer/{customerId}/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, customerId, dashboardId);
  851 + ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/api/customer/{customerId}/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, customerId, dashboardId);
805 852 return Optional.ofNullable(dashboard.getBody());
806 853 } catch (HttpClientErrorException exception) {
807 854 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -814,7 +861,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
814 861
815 862 public Optional<Dashboard> updateDashboardCustomers(String dashboardId, String[] customerIds) {
816 863 try {
817   - ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/dashboard/{dashboardId}/customers", customerIds, Dashboard.class, dashboardId);
  864 + ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/dashboard/{dashboardId}/customers", customerIds, Dashboard.class, dashboardId);
818 865 return Optional.ofNullable(dashboard.getBody());
819 866 } catch (HttpClientErrorException exception) {
820 867 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -827,7 +874,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
827 874
828 875 public Optional<Dashboard> addDashboardCustomers(String dashboardId, String[] customerIds) {
829 876 try {
830   - ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/dashboard/{dashboardId}/customers/add", customerIds, Dashboard.class, dashboardId);
  877 + ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/dashboard/{dashboardId}/customers/add", customerIds, Dashboard.class, dashboardId);
831 878 return Optional.ofNullable(dashboard.getBody());
832 879 } catch (HttpClientErrorException exception) {
833 880 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -840,7 +887,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
840 887
841 888 public Optional<Dashboard> removeDashboardCustomers(String dashboardId, String[] customerIds) {
842 889 try {
843   - ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/dashboard/{dashboardId}/customers/remove", customerIds, Dashboard.class, dashboardId);
  890 + ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/dashboard/{dashboardId}/customers/remove", customerIds, Dashboard.class, dashboardId);
844 891 return Optional.ofNullable(dashboard.getBody());
845 892 } catch (HttpClientErrorException exception) {
846 893 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -853,7 +900,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
853 900
854 901 public Optional<Dashboard> assignDashboardToPublicCustomer(String dashboardId) {
855 902 try {
856   - ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/customer/public/dashboard/{dashboardId}", null, Dashboard.class, dashboardId);
  903 + ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/customer/public/dashboard/{dashboardId}", null, Dashboard.class, dashboardId);
857 904 return Optional.ofNullable(dashboard.getBody());
858 905 } catch (HttpClientErrorException exception) {
859 906 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -866,7 +913,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
866 913
867 914 public Optional<Dashboard> unassignDashboardFromPublicCustomer(String dashboardId) {
868 915 try {
869   - ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/customer/public/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, dashboardId);
  916 + ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/api/customer/public/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, dashboardId);
870 917 return Optional.ofNullable(dashboard.getBody());
871 918 } catch (HttpClientErrorException exception) {
872 919 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -882,7 +929,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
882 929 params.put("tenantId", tenantId);
883 930 addPageLinkToParam(params, pageLink);
884 931 return restTemplate.exchange(
885   - baseURL + "/tenant/{tenantId}/dashboards?" + TEXT_PAGE_LINK_URL_PARAMS,
  932 + baseURL + "/api/tenant/{tenantId}/dashboards?" + TEXT_PAGE_LINK_URL_PARAMS,
886 933 HttpMethod.GET, HttpEntity.EMPTY,
887 934 new ParameterizedTypeReference<TextPageData<DashboardInfo>>() {
888 935 },
... ... @@ -894,7 +941,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
894 941 Map<String, String> params = new HashMap<>();
895 942 addPageLinkToParam(params, pageLink);
896 943 return restTemplate.exchange(
897   - baseURL + "/tenant/dashboards?" + TEXT_PAGE_LINK_URL_PARAMS,
  944 + baseURL + "/api/tenant/dashboards?" + TEXT_PAGE_LINK_URL_PARAMS,
898 945 HttpMethod.GET, HttpEntity.EMPTY,
899 946 new ParameterizedTypeReference<TextPageData<DashboardInfo>>() {
900 947 },
... ... @@ -907,7 +954,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
907 954 params.put("customerId", customerId);
908 955 addPageLinkToParam(params, pageLink);
909 956 return restTemplate.exchange(
910   - baseURL + "/customer/{customerId}/dashboards?" + TEXT_PAGE_LINK_URL_PARAMS,
  957 + baseURL + "/api/customer/{customerId}/dashboards?" + TEXT_PAGE_LINK_URL_PARAMS,
911 958 HttpMethod.GET, HttpEntity.EMPTY,
912 959 new ParameterizedTypeReference<TimePageData<DashboardInfo>>() {
913 960 },
... ... @@ -917,7 +964,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
917 964
918 965 public Optional<Device> getDeviceById(String deviceId) {
919 966 try {
920   - ResponseEntity<Device> device = restTemplate.getForEntity(baseURL + "/device/{deviceId}", Device.class, deviceId);
  967 + ResponseEntity<Device> device = restTemplate.getForEntity(baseURL + "/api/device/{deviceId}", Device.class, deviceId);
921 968 return Optional.ofNullable(device.getBody());
922 969 } catch (HttpClientErrorException exception) {
923 970 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -929,16 +976,16 @@ public class RestClient implements ClientHttpRequestInterceptor {
929 976 }
930 977
931 978 public Device saveDevice(Device device) {
932   - return restTemplate.postForEntity(baseURL + "/device", device, Device.class).getBody();
  979 + return restTemplate.postForEntity(baseURL + "/api/device", device, Device.class).getBody();
933 980 }
934 981
935 982 public void deleteDevice(String deviceId) {
936   - restTemplate.delete(baseURL + "/device/{deviceId}", deviceId);
  983 + restTemplate.delete(baseURL + "/api/device/{deviceId}", deviceId);
937 984 }
938 985
939 986 public Optional<Device> assignDeviceToCustomer(String customerId, String deviceId) {
940 987 try {
941   - ResponseEntity<Device> device = restTemplate.postForEntity(baseURL + "/customer/{customerId}/device/{deviceId}", null, Device.class, customerId, deviceId);
  988 + ResponseEntity<Device> device = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/device/{deviceId}", null, Device.class, customerId, deviceId);
942 989 return Optional.ofNullable(device.getBody());
943 990 } catch (HttpClientErrorException exception) {
944 991 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -951,7 +998,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
951 998
952 999 public Optional<Device> unassignDeviceFromCustomer(String deviceId) {
953 1000 try {
954   - ResponseEntity<Device> device = restTemplate.exchange(baseURL + "/customer/device/{deviceId}", HttpMethod.DELETE, HttpEntity.EMPTY, Device.class, deviceId);
  1001 + ResponseEntity<Device> device = restTemplate.exchange(baseURL + "/api/customer/device/{deviceId}", HttpMethod.DELETE, HttpEntity.EMPTY, Device.class, deviceId);
955 1002 return Optional.ofNullable(device.getBody());
956 1003 } catch (HttpClientErrorException exception) {
957 1004 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -964,7 +1011,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
964 1011
965 1012 public Optional<Device> assignDeviceToPublicCustomer(String deviceId) {
966 1013 try {
967   - ResponseEntity<Device> device = restTemplate.postForEntity(baseURL + "/customer/public/device/{deviceId}", null, Device.class, deviceId);
  1014 + ResponseEntity<Device> device = restTemplate.postForEntity(baseURL + "/api/customer/public/device/{deviceId}", null, Device.class, deviceId);
968 1015 return Optional.ofNullable(device.getBody());
969 1016 } catch (HttpClientErrorException exception) {
970 1017 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -977,7 +1024,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
977 1024
978 1025 public Optional<DeviceCredentials> getDeviceCredentialsByDeviceId(String deviceId) {
979 1026 try {
980   - ResponseEntity<DeviceCredentials> deviceCredentials = restTemplate.getForEntity(baseURL + "/device/{deviceId}/credentials", DeviceCredentials.class, deviceId);
  1027 + ResponseEntity<DeviceCredentials> deviceCredentials = restTemplate.getForEntity(baseURL + "/api/device/{deviceId}/credentials", DeviceCredentials.class, deviceId);
981 1028 return Optional.ofNullable(deviceCredentials.getBody());
982 1029 } catch (HttpClientErrorException exception) {
983 1030 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -997,7 +1044,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
997 1044 params.put("type", type);
998 1045 addPageLinkToParam(params, pageLink);
999 1046 return restTemplate.exchange(
1000   - baseURL + "/tenant/devices?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
  1047 + baseURL + "/api/tenant/devices?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
1001 1048 HttpMethod.GET, HttpEntity.EMPTY,
1002 1049 new ParameterizedTypeReference<TextPageData<Device>>() {
1003 1050 },
... ... @@ -1007,7 +1054,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1007 1054
1008 1055 public Optional<Device> getTenantDevice(String deviceName) {
1009 1056 try {
1010   - ResponseEntity<Device> device = restTemplate.getForEntity(baseURL + "/tenant/devices?deviceName={deviceName}", Device.class, deviceName);
  1057 + ResponseEntity<Device> device = restTemplate.getForEntity(baseURL + "/api/tenant/devices?deviceName={deviceName}", Device.class, deviceName);
1011 1058 return Optional.ofNullable(device.getBody());
1012 1059 } catch (HttpClientErrorException exception) {
1013 1060 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1024,7 +1071,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1024 1071 params.put("type", type);
1025 1072 addPageLinkToParam(params, pageLink);
1026 1073 return restTemplate.exchange(
1027   - baseURL + "/customer/{customerId}/devices?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
  1074 + baseURL + "/api/customer/{customerId}/devices?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
1028 1075 HttpMethod.GET, HttpEntity.EMPTY,
1029 1076 new ParameterizedTypeReference<TextPageData<Device>>() {
1030 1077 },
... ... @@ -1033,7 +1080,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1033 1080 }
1034 1081
1035 1082 public List<Device> getDevicesByIds(String[] deviceIds) {
1036   - return restTemplate.exchange(baseURL + "/devices?deviceIds={deviceIds}",
  1083 + return restTemplate.exchange(baseURL + "/api/devices?deviceIds={deviceIds}",
1037 1084 HttpMethod.GET,
1038 1085 HttpEntity.EMPTY, new ParameterizedTypeReference<List<Device>>() {
1039 1086 },
... ... @@ -1042,7 +1089,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1042 1089
1043 1090 public List<Device> findByQuery(DeviceSearchQuery query) {
1044 1091 return restTemplate.exchange(
1045   - baseURL + "/devices",
  1092 + baseURL + "/api/devices",
1046 1093 HttpMethod.POST,
1047 1094 new HttpEntity<>(query),
1048 1095 new ParameterizedTypeReference<List<Device>>() {
... ... @@ -1051,23 +1098,26 @@ public class RestClient implements ClientHttpRequestInterceptor {
1051 1098
1052 1099 public List<EntitySubtype> getDeviceTypes() {
1053 1100 return restTemplate.exchange(
1054   - baseURL + "/devices",
  1101 + baseURL + "/api/devices",
1055 1102 HttpMethod.GET,
1056 1103 HttpEntity.EMPTY,
1057 1104 new ParameterizedTypeReference<List<EntitySubtype>>() {
1058 1105 }).getBody();
1059 1106 }
1060 1107
1061   - //TODO: ClaimRequest class
1062   -// @RequestMapping(value = "/customer/device/{deviceName}/claim", method = RequestMethod.POST)
1063   -// public DeferredResult<ResponseEntity> claimDevice(String deviceName, ClaimRequest claimRequest) {
1064   -// return restTemplate.exchange(baseURL + "/customer/device/{deviceName}/claim", HttpMethod.POST, new HttpEntity<>(claimRequest), new ParameterizedTypeReference<DeferredResult<ResponseEntity>>() {
1065   -// }, deviceName).getBody();
1066   -// }
  1108 + public DeferredResult<ResponseEntity> claimDevice(String deviceName, ClaimRequest claimRequest) {
  1109 + return restTemplate.exchange(
  1110 + baseURL + "/api/customer/device/{deviceName}/claim",
  1111 + HttpMethod.POST,
  1112 + new HttpEntity<>(claimRequest),
  1113 + new ParameterizedTypeReference<DeferredResult<ResponseEntity>>() {
  1114 + },
  1115 + deviceName).getBody();
  1116 + }
1067 1117
1068 1118 public DeferredResult<ResponseEntity> reClaimDevice(String deviceName) {
1069 1119 return restTemplate.exchange(
1070   - baseURL + "/customer/device/{deviceName}/claim",
  1120 + baseURL + "/api/customer/device/{deviceName}/claim",
1071 1121 HttpMethod.DELETE,
1072 1122 HttpEntity.EMPTY,
1073 1123 new ParameterizedTypeReference<DeferredResult<ResponseEntity>>() {
... ... @@ -1076,7 +1126,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1076 1126 }
1077 1127
1078 1128 public void saveRelation(EntityRelation relation) {
1079   - restTemplate.postForEntity(baseURL + "/relation", relation, Object.class);
  1129 + restTemplate.postForEntity(baseURL + "/api/relation", relation, Object.class);
1080 1130 }
1081 1131
1082 1132 public void deleteRelation(String fromId, String fromType, String relationType, String relationTypeGroup, String toId, String toType) {
... ... @@ -1087,11 +1137,11 @@ public class RestClient implements ClientHttpRequestInterceptor {
1087 1137 params.put("relationTypeGroup", relationTypeGroup);
1088 1138 params.put("toId", toId);
1089 1139 params.put("toType", toType);
1090   - restTemplate.delete(baseURL + "/relation?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}&toId={toId}&toType={toType}", params);
  1140 + restTemplate.delete(baseURL + "/api/relation?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}&toId={toId}&toType={toType}", params);
1091 1141 }
1092 1142
1093 1143 public void deleteRelations(String entityId, String entityType) {
1094   - restTemplate.delete(baseURL + "/relations?entityId={entityId}&entityType={entityType}", entityId, entityType);
  1144 + restTemplate.delete(baseURL + "/api/relations?entityId={entityId}&entityType={entityType}", entityId, entityType);
1095 1145 }
1096 1146
1097 1147 public Optional<EntityRelation> getRelation(String fromId, String fromType, String relationType, String relationTypeGroup, String toId, String toType) {
... ... @@ -1105,7 +1155,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1105 1155
1106 1156 try {
1107 1157 ResponseEntity<EntityRelation> entityRelation = restTemplate.getForEntity(
1108   - baseURL + "/relation?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}&toId={toId}&toType={toType}",
  1158 + baseURL + "/api/relation?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}&toId={toId}&toType={toType}",
1109 1159 EntityRelation.class,
1110 1160 params);
1111 1161 return Optional.ofNullable(entityRelation.getBody());
... ... @@ -1125,7 +1175,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1125 1175 params.put("relationTypeGroup", relationTypeGroup);
1126 1176
1127 1177 return restTemplate.exchange(
1128   - baseURL + "/relations?fromId={fromId}&fromType={fromType}&relationTypeGroup={relationTypeGroup}",
  1178 + baseURL + "/api/relations?fromId={fromId}&fromType={fromType}&relationTypeGroup={relationTypeGroup}",
1129 1179 HttpMethod.GET,
1130 1180 HttpEntity.EMPTY,
1131 1181 new ParameterizedTypeReference<List<EntityRelation>>() {
... ... @@ -1134,14 +1184,13 @@ public class RestClient implements ClientHttpRequestInterceptor {
1134 1184 }
1135 1185
1136 1186 public List<EntityRelationInfo> findInfoByFrom(String fromId, String fromType, String relationTypeGroup) {
1137   -
1138 1187 Map<String, String> params = new HashMap<>();
1139 1188 params.put("fromId", fromId);
1140 1189 params.put("fromType", fromType);
1141 1190 params.put("relationTypeGroup", relationTypeGroup);
1142 1191
1143 1192 return restTemplate.exchange(
1144   - baseURL + "/relations/info?fromId={fromId}&fromType={fromType}&relationTypeGroup={relationTypeGroup}",
  1193 + baseURL + "/api/relations/info?fromId={fromId}&fromType={fromType}&relationTypeGroup={relationTypeGroup}",
1145 1194 HttpMethod.GET,
1146 1195 HttpEntity.EMPTY,
1147 1196 new ParameterizedTypeReference<List<EntityRelationInfo>>() {
... ... @@ -1157,7 +1206,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1157 1206 params.put("relationTypeGroup", relationTypeGroup);
1158 1207
1159 1208 return restTemplate.exchange(
1160   - baseURL + "/relations?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}",
  1209 + baseURL + "/api/relations?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}",
1161 1210 HttpMethod.GET,
1162 1211 HttpEntity.EMPTY,
1163 1212 new ParameterizedTypeReference<List<EntityRelation>>() {
... ... @@ -1172,7 +1221,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1172 1221 params.put("relationTypeGroup", relationTypeGroup);
1173 1222
1174 1223 return restTemplate.exchange(
1175   - baseURL + "/relations?toId={toId}&toType={toType}&relationTypeGroup={relationTypeGroup}",
  1224 + baseURL + "/api/relations?toId={toId}&toType={toType}&relationTypeGroup={relationTypeGroup}",
1176 1225 HttpMethod.GET,
1177 1226 HttpEntity.EMPTY,
1178 1227 new ParameterizedTypeReference<List<EntityRelation>>() {
... ... @@ -1187,7 +1236,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1187 1236 params.put("relationTypeGroup", relationTypeGroup);
1188 1237
1189 1238 return restTemplate.exchange(
1190   - baseURL + "/relations?toId={toId}&toType={toType}&relationTypeGroup={relationTypeGroup}",
  1239 + baseURL + "/api/relations?toId={toId}&toType={toType}&relationTypeGroup={relationTypeGroup}",
1191 1240 HttpMethod.GET,
1192 1241 HttpEntity.EMPTY,
1193 1242 new ParameterizedTypeReference<List<EntityRelationInfo>>() {
... ... @@ -1203,7 +1252,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1203 1252 params.put("relationTypeGroup", relationTypeGroup);
1204 1253
1205 1254 return restTemplate.exchange(
1206   - baseURL + "/relations?toId={toId}&toType={toType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}",
  1255 + baseURL + "/api/relations?toId={toId}&toType={toType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}",
1207 1256 HttpMethod.GET,
1208 1257 HttpEntity.EMPTY,
1209 1258 new ParameterizedTypeReference<List<EntityRelation>>() {
... ... @@ -1213,7 +1262,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1213 1262
1214 1263 public List<EntityRelation> findByQuery(EntityRelationsQuery query) {
1215 1264 return restTemplate.exchange(
1216   - baseURL + "/relations",
  1265 + baseURL + "/api/relations",
1217 1266 HttpMethod.POST,
1218 1267 new HttpEntity<>(query),
1219 1268 new ParameterizedTypeReference<List<EntityRelation>>() {
... ... @@ -1222,7 +1271,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1222 1271
1223 1272 public List<EntityRelationInfo> findInfoByQuery(EntityRelationsQuery query) {
1224 1273 return restTemplate.exchange(
1225   - baseURL + "/relations",
  1274 + baseURL + "/api/relations",
1226 1275 HttpMethod.POST,
1227 1276 new HttpEntity<>(query),
1228 1277 new ParameterizedTypeReference<List<EntityRelationInfo>>() {
... ... @@ -1231,7 +1280,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1231 1280
1232 1281 public Optional<EntityView> getEntityViewById(String entityViewId) {
1233 1282 try {
1234   - ResponseEntity<EntityView> entityView = restTemplate.getForEntity(baseURL + "/entityView/{entityViewId}", EntityView.class, entityViewId);
  1283 + ResponseEntity<EntityView> entityView = restTemplate.getForEntity(baseURL + "/api/entityView/{entityViewId}", EntityView.class, entityViewId);
1235 1284 return Optional.ofNullable(entityView.getBody());
1236 1285 } catch (HttpClientErrorException exception) {
1237 1286 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1243,16 +1292,16 @@ public class RestClient implements ClientHttpRequestInterceptor {
1243 1292 }
1244 1293
1245 1294 public EntityView saveEntityView(EntityView entityView) {
1246   - return restTemplate.postForEntity(baseURL + "entityView", entityView, EntityView.class).getBody();
  1295 + return restTemplate.postForEntity(baseURL + "/api/entityView", entityView, EntityView.class).getBody();
1247 1296 }
1248 1297
1249 1298 public void deleteEntityView(String entityViewId) {
1250   - restTemplate.delete(baseURL + "/entityView/{entityViewId}", entityViewId);
  1299 + restTemplate.delete(baseURL + "/api/entityView/{entityViewId}", entityViewId);
1251 1300 }
1252 1301
1253 1302 public Optional<EntityView> getTenantEntityView(String entityViewName) {
1254 1303 try {
1255   - ResponseEntity<EntityView> entityView = restTemplate.getForEntity(baseURL + "/tenant/entityViews?entityViewName={entityViewName}", EntityView.class, entityViewName);
  1304 + ResponseEntity<EntityView> entityView = restTemplate.getForEntity(baseURL + "/api/tenant/entityViews?entityViewName={entityViewName}", EntityView.class, entityViewName);
1256 1305 return Optional.ofNullable(entityView.getBody());
1257 1306 } catch (HttpClientErrorException exception) {
1258 1307 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1265,7 +1314,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1265 1314
1266 1315 public Optional<EntityView> assignEntityViewToCustomer(String customerId, String entityViewId) {
1267 1316 try {
1268   - ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "/customer/{customerId}/entityView/{entityViewId}", null, EntityView.class, customerId, entityViewId);
  1317 + ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/entityView/{entityViewId}", null, EntityView.class, customerId, entityViewId);
1269 1318 return Optional.ofNullable(entityView.getBody());
1270 1319 } catch (HttpClientErrorException exception) {
1271 1320 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1279,7 +1328,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1279 1328 public Optional<EntityView> unassignEntityViewFromCustomer(String entityViewId) {
1280 1329 try {
1281 1330 ResponseEntity<EntityView> entityView = restTemplate.exchange(
1282   - baseURL + "/customer/entityView/{entityViewId}",
  1331 + baseURL + "/api/customer/entityView/{entityViewId}",
1283 1332 HttpMethod.DELETE,
1284 1333 HttpEntity.EMPTY,
1285 1334 EntityView.class, entityViewId);
... ... @@ -1299,7 +1348,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1299 1348 params.put("type", type);
1300 1349 addPageLinkToParam(params, pageLink);
1301 1350 return restTemplate.exchange(
1302   - baseURL + "/customer/{customerId}/entityViews?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
  1351 + baseURL + "/api/customer/{customerId}/entityViews?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
1303 1352 HttpMethod.GET,
1304 1353 HttpEntity.EMPTY,
1305 1354 new ParameterizedTypeReference<TextPageData<EntityView>>() {
... ... @@ -1312,7 +1361,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1312 1361 params.put("type", type);
1313 1362 addPageLinkToParam(params, pageLink);
1314 1363 return restTemplate.exchange(
1315   - baseURL + "/tenant/entityViews?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
  1364 + baseURL + "/api/tenant/entityViews?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
1316 1365 HttpMethod.GET,
1317 1366 HttpEntity.EMPTY,
1318 1367 new ParameterizedTypeReference<TextPageData<EntityView>>() {
... ... @@ -1321,18 +1370,18 @@ public class RestClient implements ClientHttpRequestInterceptor {
1321 1370 }
1322 1371
1323 1372 public List<EntityView> findByQuery(EntityViewSearchQuery query) {
1324   - return restTemplate.exchange(baseURL + "/entityViews", HttpMethod.POST, new HttpEntity<>(query), new ParameterizedTypeReference<List<EntityView>>() {
  1373 + return restTemplate.exchange(baseURL + "/api/entityViews", HttpMethod.POST, new HttpEntity<>(query), new ParameterizedTypeReference<List<EntityView>>() {
1325 1374 }).getBody();
1326 1375 }
1327 1376
1328 1377 public List<EntitySubtype> getEntityViewTypes() {
1329   - return restTemplate.exchange(baseURL + "/entityView/types", HttpMethod.GET, HttpEntity.EMPTY, new ParameterizedTypeReference<List<EntitySubtype>>() {
  1378 + return restTemplate.exchange(baseURL + "/api/entityView/types", HttpMethod.GET, HttpEntity.EMPTY, new ParameterizedTypeReference<List<EntitySubtype>>() {
1330 1379 }).getBody();
1331 1380 }
1332 1381
1333 1382 public Optional<EntityView> assignEntityViewToPublicCustomer(String entityViewId) {
1334 1383 try {
1335   - ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "customer/public/entityView/{entityViewId}", null, EntityView.class, entityViewId);
  1384 + ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "/api/customer/public/entityView/{entityViewId}", null, EntityView.class, entityViewId);
1336 1385 return Optional.ofNullable(entityView.getBody());
1337 1386 } catch (HttpClientErrorException exception) {
1338 1387 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1352,7 +1401,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1352 1401 addPageLinkToParam(params, pageLink);
1353 1402
1354 1403 return restTemplate.exchange(
1355   - baseURL + "/events/{entityType}/{entityId}/{eventType}?tenantId={tenantId}&" + TIME_PAGE_LINK_URL_PARAMS,
  1404 + baseURL + "/api/events/{entityType}/{entityId}/{eventType}?tenantId={tenantId}&" + TIME_PAGE_LINK_URL_PARAMS,
1356 1405 HttpMethod.GET,
1357 1406 HttpEntity.EMPTY,
1358 1407 new ParameterizedTypeReference<TimePageData<Event>>() {
... ... @@ -1368,7 +1417,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1368 1417 addPageLinkToParam(params, pageLink);
1369 1418
1370 1419 return restTemplate.exchange(
1371   - baseURL + "/events/{entityType}/{entityId}?tenantId={tenantId}&" + TIME_PAGE_LINK_URL_PARAMS,
  1420 + baseURL + "/api/events/{entityType}/{entityId}?tenantId={tenantId}&" + TIME_PAGE_LINK_URL_PARAMS,
1372 1421 HttpMethod.GET,
1373 1422 HttpEntity.EMPTY,
1374 1423 new ParameterizedTypeReference<TimePageData<Event>>() {
... ... @@ -1398,7 +1447,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1398 1447
1399 1448 public Optional<RuleChain> getRuleChainById(String ruleChainId) {
1400 1449 try {
1401   - ResponseEntity<RuleChain> ruleChain = restTemplate.getForEntity(baseURL + "/ruleChain/{ruleChainId}", RuleChain.class, ruleChainId);
  1450 + ResponseEntity<RuleChain> ruleChain = restTemplate.getForEntity(baseURL + "/api/ruleChain/{ruleChainId}", RuleChain.class, ruleChainId);
1402 1451 return Optional.ofNullable(ruleChain.getBody());
1403 1452 } catch (HttpClientErrorException exception) {
1404 1453 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1411,7 +1460,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1411 1460
1412 1461 public Optional<RuleChainMetaData> getRuleChainMetaData(String ruleChainId) {
1413 1462 try {
1414   - ResponseEntity<RuleChainMetaData> ruleChainMetaData = restTemplate.getForEntity(baseURL + "/ruleChain/{ruleChainId}/metadata", RuleChainMetaData.class, ruleChainId);
  1463 + ResponseEntity<RuleChainMetaData> ruleChainMetaData = restTemplate.getForEntity(baseURL + "/api/ruleChain/{ruleChainId}/metadata", RuleChainMetaData.class, ruleChainId);
1415 1464 return Optional.ofNullable(ruleChainMetaData.getBody());
1416 1465 } catch (HttpClientErrorException exception) {
1417 1466 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1423,12 +1472,12 @@ public class RestClient implements ClientHttpRequestInterceptor {
1423 1472 }
1424 1473
1425 1474 public RuleChain saveRuleChain(RuleChain ruleChain) {
1426   - return restTemplate.postForEntity(baseURL + "/ruleChain", ruleChain, RuleChain.class).getBody();
  1475 + return restTemplate.postForEntity(baseURL + "/api/ruleChain", ruleChain, RuleChain.class).getBody();
1427 1476 }
1428 1477
1429 1478 public Optional<RuleChain> setRootRuleChain(String ruleChainId) {
1430 1479 try {
1431   - ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/ruleChain/{ruleChainId}/root", null, RuleChain.class, ruleChainId);
  1480 + ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/api/ruleChain/{ruleChainId}/root", null, RuleChain.class, ruleChainId);
1432 1481 return Optional.ofNullable(ruleChain.getBody());
1433 1482 } catch (HttpClientErrorException exception) {
1434 1483 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1440,14 +1489,14 @@ public class RestClient implements ClientHttpRequestInterceptor {
1440 1489 }
1441 1490
1442 1491 public RuleChainMetaData saveRuleChainMetaData(RuleChainMetaData ruleChainMetaData) {
1443   - return restTemplate.postForEntity(baseURL + "/ruleChain/metadata", ruleChainMetaData, RuleChainMetaData.class).getBody();
  1492 + return restTemplate.postForEntity(baseURL + "/api/ruleChain/metadata", ruleChainMetaData, RuleChainMetaData.class).getBody();
1444 1493 }
1445 1494
1446 1495 public TextPageData<RuleChain> getRuleChains(TextPageLink pageLink) {
1447 1496 Map<String, String> params = new HashMap<>();
1448 1497 addPageLinkToParam(params, pageLink);
1449 1498 return restTemplate.exchange(
1450   - baseURL + "/ruleChains" + TEXT_PAGE_LINK_URL_PARAMS,
  1499 + baseURL + "/api/ruleChains" + TEXT_PAGE_LINK_URL_PARAMS,
1451 1500 HttpMethod.GET,
1452 1501 HttpEntity.EMPTY,
1453 1502 new ParameterizedTypeReference<TextPageData<RuleChain>>() {
... ... @@ -1456,12 +1505,12 @@ public class RestClient implements ClientHttpRequestInterceptor {
1456 1505 }
1457 1506
1458 1507 public void deleteRuleChain(String ruleChainId) {
1459   - restTemplate.delete(baseURL + "/ruleChain/{ruleChainId}", ruleChainId);
  1508 + restTemplate.delete(baseURL + "/api/ruleChain/{ruleChainId}", ruleChainId);
1460 1509 }
1461 1510
1462 1511 public Optional<JsonNode> getLatestRuleNodeDebugInput(String ruleNodeId) {
1463 1512 try {
1464   - ResponseEntity<JsonNode> jsonNode = restTemplate.getForEntity(baseURL + "/ruleNode/{ruleNodeId}/debugIn", JsonNode.class, ruleNodeId);
  1513 + ResponseEntity<JsonNode> jsonNode = restTemplate.getForEntity(baseURL + "/api/ruleNode/{ruleNodeId}/debugIn", JsonNode.class, ruleNodeId);
1465 1514 return Optional.ofNullable(jsonNode.getBody());
1466 1515 } catch (HttpClientErrorException exception) {
1467 1516 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1474,7 +1523,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1474 1523
1475 1524 public Optional<JsonNode> testScript(JsonNode inputParams) {
1476 1525 try {
1477   - ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/ruleChain/testScript", inputParams, JsonNode.class);
  1526 + ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/api/ruleChain/testScript", inputParams, JsonNode.class);
1478 1527 return Optional.ofNullable(jsonNode.getBody());
1479 1528 } catch (HttpClientErrorException exception) {
1480 1529 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1689,7 +1738,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1689 1738
1690 1739 public Optional<Tenant> getTenantById(String tenantId) {
1691 1740 try {
1692   - ResponseEntity<Tenant> tenant = restTemplate.getForEntity(baseURL + "/tenant/{tenantId}", Tenant.class, tenantId);
  1741 + ResponseEntity<Tenant> tenant = restTemplate.getForEntity(baseURL + "/api/tenant/{tenantId}", Tenant.class, tenantId);
1693 1742 return Optional.ofNullable(tenant.getBody());
1694 1743 } catch (HttpClientErrorException exception) {
1695 1744 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1701,11 +1750,11 @@ public class RestClient implements ClientHttpRequestInterceptor {
1701 1750 }
1702 1751
1703 1752 public Tenant saveTenant(Tenant tenant) {
1704   - return restTemplate.postForEntity(baseURL + "/tenant", tenant, Tenant.class).getBody();
  1753 + return restTemplate.postForEntity(baseURL + "/api/tenant", tenant, Tenant.class).getBody();
1705 1754 }
1706 1755
1707 1756 public void deleteTenant(String tenantId) {
1708   - restTemplate.delete(baseURL + "/tenant/{tenantId}", tenantId);
  1757 + restTemplate.delete(baseURL + "/api/tenant/{tenantId}", tenantId);
1709 1758 }
1710 1759
1711 1760 public TextPageData<Tenant> getTenants(TextPageLink pageLink) {
... ... @@ -1722,7 +1771,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1722 1771
1723 1772 public Optional<User> getUserById(String userId) {
1724 1773 try {
1725   - ResponseEntity<User> user = restTemplate.getForEntity(baseURL + "/user/{userId}", User.class, userId);
  1774 + ResponseEntity<User> user = restTemplate.getForEntity(baseURL + "/api/user/{userId}", User.class, userId);
1726 1775 return Optional.ofNullable(user.getBody());
1727 1776 } catch (HttpClientErrorException exception) {
1728 1777 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1734,12 +1783,12 @@ public class RestClient implements ClientHttpRequestInterceptor {
1734 1783 }
1735 1784
1736 1785 public Boolean isUserTokenAccessEnabled() {
1737   - return restTemplate.getForEntity(baseURL + "/user/tokenAccessEnabled", Boolean.class).getBody();
  1786 + return restTemplate.getForEntity(baseURL + "/api/user/tokenAccessEnabled", Boolean.class).getBody();
1738 1787 }
1739 1788
1740 1789 public Optional<JsonNode> getUserToken(String userId) {
1741 1790 try {
1742   - ResponseEntity<JsonNode> userToken = restTemplate.getForEntity(baseURL + "/user/{userId}/token", JsonNode.class, userId);
  1791 + ResponseEntity<JsonNode> userToken = restTemplate.getForEntity(baseURL + "/api/user/{userId}/token", JsonNode.class, userId);
1743 1792 return Optional.ofNullable(userToken.getBody());
1744 1793 } catch (HttpClientErrorException exception) {
1745 1794 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1751,16 +1800,16 @@ public class RestClient implements ClientHttpRequestInterceptor {
1751 1800 }
1752 1801
1753 1802 public User saveUser(User user, boolean sendActivationMail) {
1754   - return restTemplate.postForEntity(baseURL + "/user?sendActivationMail={sendActivationMail}", user, User.class, sendActivationMail).getBody();
  1803 + return restTemplate.postForEntity(baseURL + "/api/user?sendActivationMail={sendActivationMail}", user, User.class, sendActivationMail).getBody();
1755 1804 }
1756 1805
1757 1806 public void sendActivationEmail(String email) {
1758   - restTemplate.postForEntity(baseURL + "/user/sendActivationMail?email={email}", null, Object.class, email);
  1807 + restTemplate.postForEntity(baseURL + "/api/user/sendActivationMail?email={email}", null, Object.class, email);
1759 1808 }
1760 1809
1761 1810 public Optional<String> getActivationLink(String userId) {
1762 1811 try {
1763   - ResponseEntity<String> activationLink = restTemplate.getForEntity(baseURL + "/user/{userId}/activationLink", String.class, userId);
  1812 + ResponseEntity<String> activationLink = restTemplate.getForEntity(baseURL + "/api/user/{userId}/activationLink", String.class, userId);
1764 1813 return Optional.ofNullable(activationLink.getBody());
1765 1814 } catch (HttpClientErrorException exception) {
1766 1815 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1772,7 +1821,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1772 1821 }
1773 1822
1774 1823 public void deleteUser(String userId) {
1775   - restTemplate.delete(baseURL + "/user/{userId}", userId);
  1824 + restTemplate.delete(baseURL + "/api/user/{userId}", userId);
1776 1825 }
1777 1826
1778 1827 // @RequestMapping(value = "/tenant/{tenantId}/users", params = {"limit"}, method = RequestMethod.GET)
... ... @@ -1796,7 +1845,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1796 1845 addPageLinkToParam(params, pageLink);
1797 1846
1798 1847 return restTemplate.exchange(
1799   - baseURL + "/customer/{customerId}/users?" + TEXT_PAGE_LINK_URL_PARAMS,
  1848 + baseURL + "/api/customer/{customerId}/users?" + TEXT_PAGE_LINK_URL_PARAMS,
1800 1849 HttpMethod.GET,
1801 1850 HttpEntity.EMPTY,
1802 1851 new ParameterizedTypeReference<TextPageData<User>>() {
... ... @@ -1806,7 +1855,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1806 1855
1807 1856 public void setUserCredentialsEnabled(String userId, boolean userCredentialsEnabled) {
1808 1857 restTemplate.postForEntity(
1809   - baseURL + "/user/{userId}/userCredentialsEnabled?serCredentialsEnabled={serCredentialsEnabled}",
  1858 + baseURL + "/api/user/{userId}/userCredentialsEnabled?serCredentialsEnabled={serCredentialsEnabled}",
1810 1859 null,
1811 1860 Object.class,
1812 1861 userId,
... ... @@ -1816,7 +1865,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1816 1865 public Optional<WidgetsBundle> getWidgetsBundleById(String widgetsBundleId) {
1817 1866 try {
1818 1867 ResponseEntity<WidgetsBundle> widgetsBundle =
1819   - restTemplate.getForEntity(baseURL + "/widgetsBundle/{widgetsBundleId}", WidgetsBundle.class, widgetsBundleId);
  1868 + restTemplate.getForEntity(baseURL + "/api/widgetsBundle/{widgetsBundleId}", WidgetsBundle.class, widgetsBundleId);
1820 1869 return Optional.ofNullable(widgetsBundle.getBody());
1821 1870 } catch (HttpClientErrorException exception) {
1822 1871 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1828,18 +1877,18 @@ public class RestClient implements ClientHttpRequestInterceptor {
1828 1877 }
1829 1878
1830 1879 public WidgetsBundle saveWidgetsBundle(WidgetsBundle widgetsBundle) {
1831   - return restTemplate.postForEntity(baseURL + "/widgetsBundle", widgetsBundle, WidgetsBundle.class).getBody();
  1880 + return restTemplate.postForEntity(baseURL + "/api/widgetsBundle", widgetsBundle, WidgetsBundle.class).getBody();
1832 1881 }
1833 1882
1834 1883 public void deleteWidgetsBundle(String widgetsBundleId) {
1835   - restTemplate.delete(baseURL + "/widgetsBundle/{widgetsBundleId}", widgetsBundleId);
  1884 + restTemplate.delete(baseURL + "/api/widgetsBundle/{widgetsBundleId}", widgetsBundleId);
1836 1885 }
1837 1886
1838 1887 public TextPageData<WidgetsBundle> getWidgetsBundles(TextPageLink pageLink) {
1839 1888 Map<String, String> params = new HashMap<>();
1840 1889 addPageLinkToParam(params, pageLink);
1841 1890 return restTemplate.exchange(
1842   - baseURL + "/widgetsBundles?" + TEXT_PAGE_LINK_URL_PARAMS,
  1891 + baseURL + "/api/widgetsBundles?" + TEXT_PAGE_LINK_URL_PARAMS,
1843 1892 HttpMethod.GET,
1844 1893 HttpEntity.EMPTY,
1845 1894 new ParameterizedTypeReference<TextPageData<WidgetsBundle>>() {
... ... @@ -1848,7 +1897,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1848 1897
1849 1898 public List<WidgetsBundle> getWidgetsBundles() {
1850 1899 return restTemplate.exchange(
1851   - baseURL + "/widgetsBundles",
  1900 + baseURL + "/api/widgetsBundles",
1852 1901 HttpMethod.GET,
1853 1902 HttpEntity.EMPTY,
1854 1903 new ParameterizedTypeReference<List<WidgetsBundle>>() {
... ... @@ -1858,7 +1907,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1858 1907 public Optional<WidgetType> getWidgetTypeById(String widgetTypeId) {
1859 1908 try {
1860 1909 ResponseEntity<WidgetType> widgetType =
1861   - restTemplate.getForEntity(baseURL + "/widgetType/{widgetTypeId}", WidgetType.class, widgetTypeId);
  1910 + restTemplate.getForEntity(baseURL + "/api/widgetType/{widgetTypeId}", WidgetType.class, widgetTypeId);
1862 1911 return Optional.ofNullable(widgetType.getBody());
1863 1912 } catch (HttpClientErrorException exception) {
1864 1913 if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
... ... @@ -1870,16 +1919,16 @@ public class RestClient implements ClientHttpRequestInterceptor {
1870 1919 }
1871 1920
1872 1921 public WidgetType saveWidgetType(WidgetType widgetType) {
1873   - return restTemplate.postForEntity(baseURL + "/widgetType", widgetType, WidgetType.class).getBody();
  1922 + return restTemplate.postForEntity(baseURL + "/api/widgetType", widgetType, WidgetType.class).getBody();
1874 1923 }
1875 1924
1876 1925 public void deleteWidgetType(String widgetTypeId) {
1877   - restTemplate.delete(baseURL + "/widgetType/{widgetTypeId}", widgetTypeId);
  1926 + restTemplate.delete(baseURL + "/api/widgetType/{widgetTypeId}", widgetTypeId);
1878 1927 }
1879 1928
1880 1929 public List<WidgetType> getBundleWidgetTypes(boolean isSystem, String bundleAlias) {
1881 1930 return restTemplate.exchange(
1882   - baseURL + "/widgetTypes?isSystem={isSystem}&bundleAlias={bundleAlias}",
  1931 + baseURL + "/api/widgetTypes?isSystem={isSystem}&bundleAlias={bundleAlias}",
1883 1932 HttpMethod.GET,
1884 1933 HttpEntity.EMPTY,
1885 1934 new ParameterizedTypeReference<List<WidgetType>>() {
... ... @@ -1892,7 +1941,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
1892 1941 try {
1893 1942 ResponseEntity<WidgetType> widgetType =
1894 1943 restTemplate.getForEntity(
1895   - baseURL + "/widgetType?isSystem={isSystem}&bundleAlias={bundleAlias}&alias={alias}",
  1944 + baseURL + "/api/widgetType?isSystem={isSystem}&bundleAlias={bundleAlias}&alias={alias}",
1896 1945 WidgetType.class,
1897 1946 isSystem,
1898 1947 bundleAlias,
... ...