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
This commit is contained in:
YevhenBondarenko 2019-11-29 13:48:31 +02:00 committed by Andrew Shvayka
parent 872cc5fff6
commit eb7c2f1659
12 changed files with 204 additions and 159 deletions

View File

@ -28,12 +28,12 @@ import org.thingsboard.server.common.data.AdminSettings;
import org.thingsboard.server.common.data.exception.ThingsboardException; import org.thingsboard.server.common.data.exception.ThingsboardException;
import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.dao.settings.AdminSettingsService; import org.thingsboard.server.dao.settings.AdminSettingsService;
import org.thingsboard.server.service.security.model.SecuritySettings; import org.thingsboard.server.common.data.security.model.SecuritySettings;
import org.thingsboard.server.service.security.permission.Operation; import org.thingsboard.server.service.security.permission.Operation;
import org.thingsboard.server.service.security.permission.Resource; import org.thingsboard.server.service.security.permission.Resource;
import org.thingsboard.server.service.security.system.SystemSecurityService; import org.thingsboard.server.service.security.system.SystemSecurityService;
import org.thingsboard.server.service.update.UpdateService; import org.thingsboard.server.service.update.UpdateService;
import org.thingsboard.server.service.update.model.UpdateMessage; import org.thingsboard.server.common.data.UpdateMessage;
@RestController @RestController
@RequestMapping("/api/admin") @RequestMapping("/api/admin")

View File

@ -24,7 +24,6 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -43,14 +42,12 @@ import org.thingsboard.server.common.data.security.UserCredentials;
import org.thingsboard.server.dao.audit.AuditLogService; import org.thingsboard.server.dao.audit.AuditLogService;
import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRepository; import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRepository;
import org.thingsboard.server.service.security.auth.rest.RestAuthenticationDetails; import org.thingsboard.server.service.security.auth.rest.RestAuthenticationDetails;
import org.thingsboard.server.service.security.model.SecuritySettings; import org.thingsboard.server.common.data.security.model.SecuritySettings;
import org.thingsboard.server.service.security.model.SecurityUser; import org.thingsboard.server.service.security.model.SecurityUser;
import org.thingsboard.server.service.security.model.UserPasswordPolicy; import org.thingsboard.server.common.data.security.model.UserPasswordPolicy;
import org.thingsboard.server.service.security.model.UserPrincipal; import org.thingsboard.server.service.security.model.UserPrincipal;
import org.thingsboard.server.service.security.model.token.JwtToken; import org.thingsboard.server.service.security.model.token.JwtToken;
import org.thingsboard.server.service.security.model.token.JwtTokenFactory; import org.thingsboard.server.service.security.model.token.JwtTokenFactory;
import org.thingsboard.server.service.security.permission.Operation;
import org.thingsboard.server.service.security.permission.Resource;
import org.thingsboard.server.service.security.system.SystemSecurityService; import org.thingsboard.server.service.security.system.SystemSecurityService;
import ua_parser.Client; import ua_parser.Client;

View File

@ -44,7 +44,7 @@ import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.page.TextPageData; import org.thingsboard.server.common.data.page.TextPageData;
import org.thingsboard.server.common.data.page.TextPageLink; import org.thingsboard.server.common.data.page.TextPageLink;
import org.thingsboard.server.common.data.security.DeviceCredentials; import org.thingsboard.server.common.data.security.DeviceCredentials;
import org.thingsboard.server.controller.claim.data.ClaimRequest; import org.thingsboard.server.common.data.ClaimRequest;
import org.thingsboard.server.dao.device.claim.ClaimResponse; import org.thingsboard.server.dao.device.claim.ClaimResponse;
import org.thingsboard.server.dao.device.claim.ClaimResult; import org.thingsboard.server.dao.device.claim.ClaimResult;
import org.thingsboard.server.dao.exception.IncorrectParameterException; import org.thingsboard.server.dao.exception.IncorrectParameterException;

View File

@ -42,14 +42,13 @@ import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.exception.ThingsboardException; import org.thingsboard.server.common.data.exception.ThingsboardException;
import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.security.UserCredentials; import org.thingsboard.server.common.data.security.UserCredentials;
import org.thingsboard.server.dao.audit.AuditLogService;
import org.thingsboard.server.dao.exception.DataValidationException; import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.settings.AdminSettingsService; import org.thingsboard.server.dao.settings.AdminSettingsService;
import org.thingsboard.server.dao.user.UserService; import org.thingsboard.server.dao.user.UserService;
import org.thingsboard.server.dao.user.UserServiceImpl; import org.thingsboard.server.dao.user.UserServiceImpl;
import org.thingsboard.server.service.security.exception.UserPasswordExpiredException; import org.thingsboard.server.service.security.exception.UserPasswordExpiredException;
import org.thingsboard.server.service.security.model.SecuritySettings; import org.thingsboard.server.common.data.security.model.SecuritySettings;
import org.thingsboard.server.service.security.model.UserPasswordPolicy; import org.thingsboard.server.common.data.security.model.UserPasswordPolicy;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -19,7 +19,7 @@ import org.springframework.security.core.AuthenticationException;
import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.security.UserCredentials; import org.thingsboard.server.common.data.security.UserCredentials;
import org.thingsboard.server.dao.exception.DataValidationException; import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.service.security.model.SecuritySettings; import org.thingsboard.server.common.data.security.model.SecuritySettings;
public interface SystemSecurityService { public interface SystemSecurityService {

View File

@ -22,7 +22,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.thingsboard.server.service.update.model.UpdateMessage; import org.thingsboard.server.common.data.UpdateMessage;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;

View File

@ -15,7 +15,7 @@
*/ */
package org.thingsboard.server.service.update; package org.thingsboard.server.service.update;
import org.thingsboard.server.service.update.model.UpdateMessage; import org.thingsboard.server.common.data.UpdateMessage;
public interface UpdateService { public interface UpdateService {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.thingsboard.server.controller.claim.data; package org.thingsboard.server.common.data;
import lombok.Data; import lombok.Data;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.thingsboard.server.service.update.model; package org.thingsboard.server.common.data;
import lombok.Data; import lombok.Data;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.thingsboard.server.service.security.model; package org.thingsboard.server.common.data.security.model;
import lombok.Data; import lombok.Data;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.thingsboard.server.service.security.model; package org.thingsboard.server.common.data.security.model;
import lombok.Data; import lombok.Data;

View File

@ -31,6 +31,7 @@ import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
import org.thingsboard.server.common.data.AdminSettings; import org.thingsboard.server.common.data.AdminSettings;
import org.thingsboard.server.common.data.ClaimRequest;
import org.thingsboard.server.common.data.Customer; import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.Dashboard; import org.thingsboard.server.common.data.Dashboard;
import org.thingsboard.server.common.data.DashboardInfo; import org.thingsboard.server.common.data.DashboardInfo;
@ -39,6 +40,7 @@ import org.thingsboard.server.common.data.EntitySubtype;
import org.thingsboard.server.common.data.EntityView; import org.thingsboard.server.common.data.EntityView;
import org.thingsboard.server.common.data.Event; import org.thingsboard.server.common.data.Event;
import org.thingsboard.server.common.data.Tenant; import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.UpdateMessage;
import org.thingsboard.server.common.data.User; import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.alarm.Alarm; import org.thingsboard.server.common.data.alarm.Alarm;
import org.thingsboard.server.common.data.alarm.AlarmInfo; import org.thingsboard.server.common.data.alarm.AlarmInfo;
@ -65,6 +67,8 @@ import org.thingsboard.server.common.data.rule.RuleChain;
import org.thingsboard.server.common.data.rule.RuleChainMetaData; import org.thingsboard.server.common.data.rule.RuleChainMetaData;
import org.thingsboard.server.common.data.security.DeviceCredentials; import org.thingsboard.server.common.data.security.DeviceCredentials;
import org.thingsboard.server.common.data.security.DeviceCredentialsType; import org.thingsboard.server.common.data.security.DeviceCredentialsType;
import org.thingsboard.server.common.data.security.model.SecuritySettings;
import org.thingsboard.server.common.data.security.model.UserPasswordPolicy;
import org.thingsboard.server.common.data.widget.WidgetType; import org.thingsboard.server.common.data.widget.WidgetType;
import org.thingsboard.server.common.data.widget.WidgetsBundle; import org.thingsboard.server.common.data.widget.WidgetsBundle;
@ -85,6 +89,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
protected final RestTemplate restTemplate = new RestTemplate(); protected final RestTemplate restTemplate = new RestTemplate();
protected final String baseURL; protected final String baseURL;
private String token; private String token;
private String refreshToken;
private final static String TIME_PAGE_LINK_URL_PARAMS = "limit={limit}&startTime={startTime}&endTime={endTime}&ascOrder={ascOrder}&offset={offset}"; private final static String TIME_PAGE_LINK_URL_PARAMS = "limit={limit}&startTime={startTime}&endTime={endTime}&ascOrder={ascOrder}&offset={offset}";
private final static String TEXT_PAGE_LINK_URL_PARAMS = "limit={limit}&textSearch{textSearch}&idOffset={idOffset}&textOffset{textOffset}"; private final static String TEXT_PAGE_LINK_URL_PARAMS = "limit={limit}&textSearch{textSearch}&idOffset={idOffset}&textOffset{textOffset}";
@ -93,16 +98,37 @@ public class RestClient implements ClientHttpRequestInterceptor {
public ClientHttpResponse intercept(HttpRequest request, byte[] bytes, ClientHttpRequestExecution execution) throws IOException { public ClientHttpResponse intercept(HttpRequest request, byte[] bytes, ClientHttpRequestExecution execution) throws IOException {
HttpRequest wrapper = new HttpRequestWrapper(request); HttpRequest wrapper = new HttpRequestWrapper(request);
wrapper.getHeaders().set(JWT_TOKEN_HEADER_PARAM, "Bearer " + token); wrapper.getHeaders().set(JWT_TOKEN_HEADER_PARAM, "Bearer " + token);
ClientHttpResponse response = execution.execute(wrapper, bytes);
if (response.getStatusCode() == HttpStatus.UNAUTHORIZED) {
synchronized (this) {
restTemplate.getInterceptors().remove(this);
refreshToken();
wrapper.getHeaders().set(JWT_TOKEN_HEADER_PARAM, "Bearer " + token);
return execution.execute(wrapper, bytes); return execution.execute(wrapper, bytes);
} }
}
return response;
}
public void refreshToken() {
Map<String, String> refreshTokenRequest = new HashMap<>();
refreshTokenRequest.put("refreshToken", refreshToken);
ResponseEntity<JsonNode> tokenInfo = restTemplate.postForEntity(baseURL + "/api/auth/token", refreshTokenRequest, JsonNode.class);
setTokenInfo(tokenInfo.getBody());
}
public void login(String username, String password) { public void login(String username, String password) {
Map<String, String> loginRequest = new HashMap<>(); Map<String, String> loginRequest = new HashMap<>();
loginRequest.put("username", username); loginRequest.put("username", username);
loginRequest.put("password", password); loginRequest.put("password", password);
ResponseEntity<JsonNode> tokenInfo = restTemplate.postForEntity(baseURL + "/api/auth/login", loginRequest, JsonNode.class); ResponseEntity<JsonNode> tokenInfo = restTemplate.postForEntity(baseURL + "/api/auth/login", loginRequest, JsonNode.class);
this.token = tokenInfo.getBody().get("token").asText(); setTokenInfo(tokenInfo.getBody());
restTemplate.setInterceptors(Collections.singletonList(this)); }
private void setTokenInfo(JsonNode tokenInfo) {
this.token = tokenInfo.get("token").asText();
this.refreshToken = tokenInfo.get("refreshToken").asText();
restTemplate.getInterceptors().add(this);
} }
public Optional<Device> findDevice(String name) { public Optional<Device> findDevice(String name) {
@ -289,28 +315,42 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public AdminSettings saveAdminSettings(AdminSettings adminSettings) { public AdminSettings saveAdminSettings(AdminSettings adminSettings) {
return restTemplate.postForEntity(baseURL + "/api/settings", adminSettings, AdminSettings.class).getBody(); return restTemplate.postForEntity(baseURL + "/api/admin/settings", adminSettings, AdminSettings.class).getBody();
} }
public void sendTestMail(AdminSettings adminSettings) { public void sendTestMail(AdminSettings adminSettings) {
restTemplate.postForEntity(baseURL + "/api/settings/testMail", adminSettings, AdminSettings.class); restTemplate.postForEntity(baseURL + "/api/admin/settings/testMail", adminSettings, AdminSettings.class);
} }
//TODO: public Optional<SecuritySettings> getSecuritySettings() {
// @RequestMapping(value = "/securitySettings", method = RequestMethod.GET) try {
// public SecuritySettings getSecuritySettings() { ResponseEntity<SecuritySettings> securitySettings = restTemplate.getForEntity(baseURL + "/api/admin/securitySettings", SecuritySettings.class);
// return Optional.ofNullable(securitySettings.getBody());
// } } catch (HttpClientErrorException exception) {
//TODO: if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
// @RequestMapping(value = "/securitySettings", method = RequestMethod.POST) return Optional.empty();
// public SecuritySettings saveSecuritySettings(SecuritySettings securitySettings) { } else {
// throw exception;
// } }
//TODO: }
// @RequestMapping(value = "/updates", method = RequestMethod.GET) }
// public UpdateMessage checkUpdates() {
// public SecuritySettings saveSecuritySettings(SecuritySettings securitySettings) {
// } return restTemplate.postForEntity(baseURL + "/api/admin/securitySettings", securitySettings, SecuritySettings.class).getBody();
}
public Optional<UpdateMessage> checkUpdates() {
try {
ResponseEntity<UpdateMessage> updateMsg = restTemplate.getForEntity(baseURL + "/api/admin/updates", UpdateMessage.class);
return Optional.ofNullable(updateMsg.getBody());
} catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
return Optional.empty();
} else {
throw exception;
}
}
}
public Optional<Alarm> getAlarmById(String alarmId) { public Optional<Alarm> getAlarmById(String alarmId) {
try { try {
@ -488,7 +528,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
ResponseEntity<TextPageData<Asset>> assets = restTemplate.exchange( ResponseEntity<TextPageData<Asset>> assets = restTemplate.exchange(
baseURL + "/customer/{customerId}/assets?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS, baseURL + "/api/customer/{customerId}/assets?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TextPageData<Asset>>() { new ParameterizedTypeReference<TextPageData<Asset>>() {
@ -532,7 +572,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange( ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange(
baseURL + "/audit/logs/customer/{customerId}?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS, baseURL + "/api/audit/logs/customer/{customerId}?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TimePageData<AuditLog>>() { new ParameterizedTypeReference<TimePageData<AuditLog>>() {
@ -548,7 +588,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange( ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange(
baseURL + "/audit/logs/user/{userId}?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS, baseURL + "/api/audit/logs/user/{userId}?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TimePageData<AuditLog>>() { new ParameterizedTypeReference<TimePageData<AuditLog>>() {
@ -565,7 +605,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange( ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange(
baseURL + "/audit/logs/entity/{entityType}/{entityId}?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS, baseURL + "/api/audit/logs/entity/{entityType}/{entityId}?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TimePageData<AuditLog>>() { new ParameterizedTypeReference<TimePageData<AuditLog>>() {
@ -580,7 +620,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange( ResponseEntity<TimePageData<AuditLog>> auditLog = restTemplate.exchange(
baseURL + "/audit/logs?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS, baseURL + "/api/audit/logs?actionTypes={actionTypes}&" + TIME_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TimePageData<AuditLog>>() { new ParameterizedTypeReference<TimePageData<AuditLog>>() {
@ -590,40 +630,47 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public Optional<User> getUser() { public Optional<User> getUser() {
ResponseEntity<User> user = restTemplate.getForEntity(baseURL + "/auth/user", User.class); ResponseEntity<User> user = restTemplate.getForEntity(baseURL + "/api/auth/user", User.class);
return Optional.ofNullable(user.getBody()); return Optional.ofNullable(user.getBody());
} }
public void logout() { public void logout() {
restTemplate.exchange(URI.create(baseURL + "/auth/logout"), HttpMethod.POST, HttpEntity.EMPTY, Object.class); restTemplate.exchange(URI.create(baseURL + "/api/auth/logout"), HttpMethod.POST, HttpEntity.EMPTY, Object.class);
} }
public void changePassword(JsonNode changePasswordRequest) { public void changePassword(JsonNode changePasswordRequest) {
restTemplate.exchange(URI.create(baseURL + "/auth/changePassword"), HttpMethod.POST, new HttpEntity<>(changePasswordRequest), Object.class); restTemplate.exchange(URI.create(baseURL + "/api/auth/changePassword"), HttpMethod.POST, new HttpEntity<>(changePasswordRequest), Object.class);
} }
//TODO: public Optional<UserPasswordPolicy> getUserPasswordPolicy() {
// @RequestMapping(value = "/noauth/userPasswordPolicy", method = RequestMethod.GET) try {
// public UserPasswordPolicy getUserPasswordPolicy() { ResponseEntity<UserPasswordPolicy> userPasswordPolicy = restTemplate.getForEntity(baseURL + "/api/noauth/userPasswordPolicy", UserPasswordPolicy.class);
// return Optional.ofNullable(userPasswordPolicy.getBody());
// } } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
return Optional.empty();
} else {
throw exception;
}
}
}
public ResponseEntity<String> checkActivateToken(String activateToken) { public ResponseEntity<String> checkActivateToken(String activateToken) {
return restTemplate.getForEntity(baseURL + "/noauth/activate?activateToken={activateToken}", String.class, activateToken); return restTemplate.getForEntity(baseURL + "/api/noauth/activate?activateToken={activateToken}", String.class, activateToken);
} }
public void requestResetPasswordByEmail(JsonNode resetPasswordByEmailRequest) { public void requestResetPasswordByEmail(JsonNode resetPasswordByEmailRequest) {
restTemplate.exchange(URI.create(baseURL + "/noauth/resetPasswordByEmail"), HttpMethod.POST, new HttpEntity<>(resetPasswordByEmailRequest), Object.class); restTemplate.exchange(URI.create(baseURL + "/api/noauth/resetPasswordByEmail"), HttpMethod.POST, new HttpEntity<>(resetPasswordByEmailRequest), Object.class);
} }
public ResponseEntity<String> checkResetToken(String resetToken) { public ResponseEntity<String> checkResetToken(String resetToken) {
return restTemplate.getForEntity(baseURL + "noauth/resetPassword?resetToken={resetToken}", String.class, resetToken); return restTemplate.getForEntity(baseURL + "/api/noauth/resetPassword?resetToken={resetToken}", String.class, resetToken);
} }
public Optional<JsonNode> activateUser(JsonNode activateRequest) { public Optional<JsonNode> activateUser(JsonNode activateRequest) {
try { try {
ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/noauth/activate", activateRequest, JsonNode.class); ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/api/noauth/activate", activateRequest, JsonNode.class);
return Optional.ofNullable(jsonNode.getBody()); return Optional.ofNullable(jsonNode.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -636,7 +683,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<JsonNode> resetPassword(JsonNode resetPasswordRequest) { public Optional<JsonNode> resetPassword(JsonNode resetPasswordRequest) {
try { try {
ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/noauth/resetPassword", resetPasswordRequest, JsonNode.class); ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/api/noauth/resetPassword", resetPasswordRequest, JsonNode.class);
return Optional.ofNullable(jsonNode.getBody()); return Optional.ofNullable(jsonNode.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -649,7 +696,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<ComponentDescriptor> getComponentDescriptorByClazz(String componentDescriptorClazz) { public Optional<ComponentDescriptor> getComponentDescriptorByClazz(String componentDescriptorClazz) {
try { try {
ResponseEntity<ComponentDescriptor> componentDescriptor = restTemplate.getForEntity(baseURL + "/component/{componentDescriptorClazz}", ComponentDescriptor.class); ResponseEntity<ComponentDescriptor> componentDescriptor = restTemplate.getForEntity(baseURL + "/api/component/{componentDescriptorClazz}", ComponentDescriptor.class);
return Optional.ofNullable(componentDescriptor.getBody()); return Optional.ofNullable(componentDescriptor.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -662,7 +709,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public List<ComponentDescriptor> getComponentDescriptorsByType(String componentType) { public List<ComponentDescriptor> getComponentDescriptorsByType(String componentType) {
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/components?componentType={componentType}", baseURL + "/api/components?componentType={componentType}",
HttpMethod.GET, HttpEntity.EMPTY, HttpMethod.GET, HttpEntity.EMPTY,
new ParameterizedTypeReference<List<ComponentDescriptor>>() { new ParameterizedTypeReference<List<ComponentDescriptor>>() {
}, },
@ -671,7 +718,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public List<ComponentDescriptor> getComponentDescriptorsByTypes(String[] componentTypes) { public List<ComponentDescriptor> getComponentDescriptorsByTypes(String[] componentTypes) {
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/components?componentTypes={componentTypes}", baseURL + "/api/components?componentTypes={componentTypes}",
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<List<ComponentDescriptor>>() { new ParameterizedTypeReference<List<ComponentDescriptor>>() {
@ -681,7 +728,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Customer> getCustomerById(String customerId) { public Optional<Customer> getCustomerById(String customerId) {
try { try {
ResponseEntity<Customer> customer = restTemplate.getForEntity(baseURL + "/customer/{customerId}", Customer.class, customerId); ResponseEntity<Customer> customer = restTemplate.getForEntity(baseURL + "/api/customer/{customerId}", Customer.class, customerId);
return Optional.ofNullable(customer.getBody()); return Optional.ofNullable(customer.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -694,7 +741,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<JsonNode> getShortCustomerInfoById(String customerId) { public Optional<JsonNode> getShortCustomerInfoById(String customerId) {
try { try {
ResponseEntity<JsonNode> customerInfo = restTemplate.getForEntity(baseURL + "/customer/{customerId}/shortInfo", JsonNode.class, customerId); ResponseEntity<JsonNode> customerInfo = restTemplate.getForEntity(baseURL + "/api/customer/{customerId}/shortInfo", JsonNode.class, customerId);
return Optional.ofNullable(customerInfo.getBody()); return Optional.ofNullable(customerInfo.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -706,15 +753,15 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public String getCustomerTitleById(String customerId) { public String getCustomerTitleById(String customerId) {
return restTemplate.getForObject(baseURL + "/customer/{customerId}/title", String.class, customerId); return restTemplate.getForObject(baseURL + "/api/customer/{customerId}/title", String.class, customerId);
} }
public Customer saveCustomer(Customer customer) { public Customer saveCustomer(Customer customer) {
return restTemplate.postForEntity(baseURL + "/customer", customer, Customer.class).getBody(); return restTemplate.postForEntity(baseURL + "/api/customer", customer, Customer.class).getBody();
} }
public void deleteCustomer(String customerId) { public void deleteCustomer(String customerId) {
restTemplate.delete(baseURL + "/customer/{customerId}", customerId); restTemplate.delete(baseURL + "/api/customer/{customerId}", customerId);
} }
public TextPageData<Customer> getCustomers(TextPageLink pageLink) { public TextPageData<Customer> getCustomers(TextPageLink pageLink) {
@ -722,7 +769,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
ResponseEntity<TextPageData<Customer>> customer = restTemplate.exchange( ResponseEntity<TextPageData<Customer>> customer = restTemplate.exchange(
baseURL + "/customers?" + TEXT_PAGE_LINK_URL_PARAMS, baseURL + "/api/customers?" + TEXT_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TextPageData<Customer>>() { new ParameterizedTypeReference<TextPageData<Customer>>() {
@ -733,7 +780,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Customer> getTenantCustomer(String customerTitle) { public Optional<Customer> getTenantCustomer(String customerTitle) {
try { try {
ResponseEntity<Customer> customer = restTemplate.getForEntity(baseURL + "/tenant/customers?customerTitle={customerTitle}", Customer.class, customerTitle); ResponseEntity<Customer> customer = restTemplate.getForEntity(baseURL + "/api/tenant/customers?customerTitle={customerTitle}", Customer.class, customerTitle);
return Optional.ofNullable(customer.getBody()); return Optional.ofNullable(customer.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -745,16 +792,16 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public Long getServerTime() { public Long getServerTime() {
return restTemplate.getForObject(baseURL + "/dashboard/serverTime", Long.class); return restTemplate.getForObject(baseURL + "/api/dashboard/serverTime", Long.class);
} }
public Long getMaxDatapointsLimit() { public Long getMaxDatapointsLimit() {
return restTemplate.getForObject(baseURL + "/dashboard/maxDatapointsLimit", Long.class); return restTemplate.getForObject(baseURL + "/api/dashboard/maxDatapointsLimit", Long.class);
} }
public Optional<DashboardInfo> getDashboardInfoById(String dashboardId) { public Optional<DashboardInfo> getDashboardInfoById(String dashboardId) {
try { try {
ResponseEntity<DashboardInfo> dashboardInfo = restTemplate.getForEntity(baseURL + "/dashboard/info/{dashboardId}", DashboardInfo.class, dashboardId); ResponseEntity<DashboardInfo> dashboardInfo = restTemplate.getForEntity(baseURL + "/api/dashboard/info/{dashboardId}", DashboardInfo.class, dashboardId);
return Optional.ofNullable(dashboardInfo.getBody()); return Optional.ofNullable(dashboardInfo.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -767,7 +814,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Dashboard> getDashboardById(String dashboardId) { public Optional<Dashboard> getDashboardById(String dashboardId) {
try { try {
ResponseEntity<Dashboard> dashboard = restTemplate.getForEntity(baseURL + "/dashboard/{dashboardId}", Dashboard.class, dashboardId); ResponseEntity<Dashboard> dashboard = restTemplate.getForEntity(baseURL + "/api/dashboard/{dashboardId}", Dashboard.class, dashboardId);
return Optional.ofNullable(dashboard.getBody()); return Optional.ofNullable(dashboard.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -779,16 +826,16 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public Dashboard saveDashboard(Dashboard dashboard) { public Dashboard saveDashboard(Dashboard dashboard) {
return restTemplate.postForEntity(baseURL + "/dashboard", dashboard, Dashboard.class).getBody(); return restTemplate.postForEntity(baseURL + "/api/dashboard", dashboard, Dashboard.class).getBody();
} }
public void deleteDashboard(String dashboardId) { public void deleteDashboard(String dashboardId) {
restTemplate.delete(baseURL + "/dashboard/{dashboardId}", dashboardId); restTemplate.delete(baseURL + "/api/dashboard/{dashboardId}", dashboardId);
} }
public Optional<Dashboard> assignDashboardToCustomer(String customerId, String dashboardId) { public Optional<Dashboard> assignDashboardToCustomer(String customerId, String dashboardId) {
try { try {
ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/customer/{customerId}/dashboard/{dashboardId}", null, Dashboard.class, customerId, dashboardId); ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/dashboard/{dashboardId}", null, Dashboard.class, customerId, dashboardId);
return Optional.ofNullable(dashboard.getBody()); return Optional.ofNullable(dashboard.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -801,7 +848,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Dashboard> unassignDashboardFromCustomer(String customerId, String dashboardId) { public Optional<Dashboard> unassignDashboardFromCustomer(String customerId, String dashboardId) {
try { try {
ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/customer/{customerId}/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, customerId, dashboardId); ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/api/customer/{customerId}/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, customerId, dashboardId);
return Optional.ofNullable(dashboard.getBody()); return Optional.ofNullable(dashboard.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -814,7 +861,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Dashboard> updateDashboardCustomers(String dashboardId, String[] customerIds) { public Optional<Dashboard> updateDashboardCustomers(String dashboardId, String[] customerIds) {
try { try {
ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/dashboard/{dashboardId}/customers", customerIds, Dashboard.class, dashboardId); ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/dashboard/{dashboardId}/customers", customerIds, Dashboard.class, dashboardId);
return Optional.ofNullable(dashboard.getBody()); return Optional.ofNullable(dashboard.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -827,7 +874,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Dashboard> addDashboardCustomers(String dashboardId, String[] customerIds) { public Optional<Dashboard> addDashboardCustomers(String dashboardId, String[] customerIds) {
try { try {
ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/dashboard/{dashboardId}/customers/add", customerIds, Dashboard.class, dashboardId); ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/dashboard/{dashboardId}/customers/add", customerIds, Dashboard.class, dashboardId);
return Optional.ofNullable(dashboard.getBody()); return Optional.ofNullable(dashboard.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -840,7 +887,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Dashboard> removeDashboardCustomers(String dashboardId, String[] customerIds) { public Optional<Dashboard> removeDashboardCustomers(String dashboardId, String[] customerIds) {
try { try {
ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/dashboard/{dashboardId}/customers/remove", customerIds, Dashboard.class, dashboardId); ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/dashboard/{dashboardId}/customers/remove", customerIds, Dashboard.class, dashboardId);
return Optional.ofNullable(dashboard.getBody()); return Optional.ofNullable(dashboard.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -853,7 +900,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Dashboard> assignDashboardToPublicCustomer(String dashboardId) { public Optional<Dashboard> assignDashboardToPublicCustomer(String dashboardId) {
try { try {
ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/customer/public/dashboard/{dashboardId}", null, Dashboard.class, dashboardId); ResponseEntity<Dashboard> dashboard = restTemplate.postForEntity(baseURL + "/api/customer/public/dashboard/{dashboardId}", null, Dashboard.class, dashboardId);
return Optional.ofNullable(dashboard.getBody()); return Optional.ofNullable(dashboard.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -866,7 +913,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Dashboard> unassignDashboardFromPublicCustomer(String dashboardId) { public Optional<Dashboard> unassignDashboardFromPublicCustomer(String dashboardId) {
try { try {
ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/customer/public/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, dashboardId); ResponseEntity<Dashboard> dashboard = restTemplate.exchange(baseURL + "/api/customer/public/dashboard/{dashboardId}", HttpMethod.DELETE, HttpEntity.EMPTY, Dashboard.class, dashboardId);
return Optional.ofNullable(dashboard.getBody()); return Optional.ofNullable(dashboard.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -882,7 +929,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
params.put("tenantId", tenantId); params.put("tenantId", tenantId);
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/tenant/{tenantId}/dashboards?" + TEXT_PAGE_LINK_URL_PARAMS, baseURL + "/api/tenant/{tenantId}/dashboards?" + TEXT_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpEntity.EMPTY, HttpMethod.GET, HttpEntity.EMPTY,
new ParameterizedTypeReference<TextPageData<DashboardInfo>>() { new ParameterizedTypeReference<TextPageData<DashboardInfo>>() {
}, },
@ -894,7 +941,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/tenant/dashboards?" + TEXT_PAGE_LINK_URL_PARAMS, baseURL + "/api/tenant/dashboards?" + TEXT_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpEntity.EMPTY, HttpMethod.GET, HttpEntity.EMPTY,
new ParameterizedTypeReference<TextPageData<DashboardInfo>>() { new ParameterizedTypeReference<TextPageData<DashboardInfo>>() {
}, },
@ -907,7 +954,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
params.put("customerId", customerId); params.put("customerId", customerId);
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/customer/{customerId}/dashboards?" + TEXT_PAGE_LINK_URL_PARAMS, baseURL + "/api/customer/{customerId}/dashboards?" + TEXT_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpEntity.EMPTY, HttpMethod.GET, HttpEntity.EMPTY,
new ParameterizedTypeReference<TimePageData<DashboardInfo>>() { new ParameterizedTypeReference<TimePageData<DashboardInfo>>() {
}, },
@ -917,7 +964,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Device> getDeviceById(String deviceId) { public Optional<Device> getDeviceById(String deviceId) {
try { try {
ResponseEntity<Device> device = restTemplate.getForEntity(baseURL + "/device/{deviceId}", Device.class, deviceId); ResponseEntity<Device> device = restTemplate.getForEntity(baseURL + "/api/device/{deviceId}", Device.class, deviceId);
return Optional.ofNullable(device.getBody()); return Optional.ofNullable(device.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -929,16 +976,16 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public Device saveDevice(Device device) { public Device saveDevice(Device device) {
return restTemplate.postForEntity(baseURL + "/device", device, Device.class).getBody(); return restTemplate.postForEntity(baseURL + "/api/device", device, Device.class).getBody();
} }
public void deleteDevice(String deviceId) { public void deleteDevice(String deviceId) {
restTemplate.delete(baseURL + "/device/{deviceId}", deviceId); restTemplate.delete(baseURL + "/api/device/{deviceId}", deviceId);
} }
public Optional<Device> assignDeviceToCustomer(String customerId, String deviceId) { public Optional<Device> assignDeviceToCustomer(String customerId, String deviceId) {
try { try {
ResponseEntity<Device> device = restTemplate.postForEntity(baseURL + "/customer/{customerId}/device/{deviceId}", null, Device.class, customerId, deviceId); ResponseEntity<Device> device = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/device/{deviceId}", null, Device.class, customerId, deviceId);
return Optional.ofNullable(device.getBody()); return Optional.ofNullable(device.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -951,7 +998,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Device> unassignDeviceFromCustomer(String deviceId) { public Optional<Device> unassignDeviceFromCustomer(String deviceId) {
try { try {
ResponseEntity<Device> device = restTemplate.exchange(baseURL + "/customer/device/{deviceId}", HttpMethod.DELETE, HttpEntity.EMPTY, Device.class, deviceId); ResponseEntity<Device> device = restTemplate.exchange(baseURL + "/api/customer/device/{deviceId}", HttpMethod.DELETE, HttpEntity.EMPTY, Device.class, deviceId);
return Optional.ofNullable(device.getBody()); return Optional.ofNullable(device.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -964,7 +1011,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Device> assignDeviceToPublicCustomer(String deviceId) { public Optional<Device> assignDeviceToPublicCustomer(String deviceId) {
try { try {
ResponseEntity<Device> device = restTemplate.postForEntity(baseURL + "/customer/public/device/{deviceId}", null, Device.class, deviceId); ResponseEntity<Device> device = restTemplate.postForEntity(baseURL + "/api/customer/public/device/{deviceId}", null, Device.class, deviceId);
return Optional.ofNullable(device.getBody()); return Optional.ofNullable(device.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -977,7 +1024,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<DeviceCredentials> getDeviceCredentialsByDeviceId(String deviceId) { public Optional<DeviceCredentials> getDeviceCredentialsByDeviceId(String deviceId) {
try { try {
ResponseEntity<DeviceCredentials> deviceCredentials = restTemplate.getForEntity(baseURL + "/device/{deviceId}/credentials", DeviceCredentials.class, deviceId); ResponseEntity<DeviceCredentials> deviceCredentials = restTemplate.getForEntity(baseURL + "/api/device/{deviceId}/credentials", DeviceCredentials.class, deviceId);
return Optional.ofNullable(deviceCredentials.getBody()); return Optional.ofNullable(deviceCredentials.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -997,7 +1044,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
params.put("type", type); params.put("type", type);
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/tenant/devices?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS, baseURL + "/api/tenant/devices?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpEntity.EMPTY, HttpMethod.GET, HttpEntity.EMPTY,
new ParameterizedTypeReference<TextPageData<Device>>() { new ParameterizedTypeReference<TextPageData<Device>>() {
}, },
@ -1007,7 +1054,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Device> getTenantDevice(String deviceName) { public Optional<Device> getTenantDevice(String deviceName) {
try { try {
ResponseEntity<Device> device = restTemplate.getForEntity(baseURL + "/tenant/devices?deviceName={deviceName}", Device.class, deviceName); ResponseEntity<Device> device = restTemplate.getForEntity(baseURL + "/api/tenant/devices?deviceName={deviceName}", Device.class, deviceName);
return Optional.ofNullable(device.getBody()); return Optional.ofNullable(device.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1024,7 +1071,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
params.put("type", type); params.put("type", type);
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/customer/{customerId}/devices?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS, baseURL + "/api/customer/{customerId}/devices?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpEntity.EMPTY, HttpMethod.GET, HttpEntity.EMPTY,
new ParameterizedTypeReference<TextPageData<Device>>() { new ParameterizedTypeReference<TextPageData<Device>>() {
}, },
@ -1033,7 +1080,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public List<Device> getDevicesByIds(String[] deviceIds) { public List<Device> getDevicesByIds(String[] deviceIds) {
return restTemplate.exchange(baseURL + "/devices?deviceIds={deviceIds}", return restTemplate.exchange(baseURL + "/api/devices?deviceIds={deviceIds}",
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, new ParameterizedTypeReference<List<Device>>() { HttpEntity.EMPTY, new ParameterizedTypeReference<List<Device>>() {
}, },
@ -1042,7 +1089,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public List<Device> findByQuery(DeviceSearchQuery query) { public List<Device> findByQuery(DeviceSearchQuery query) {
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/devices", baseURL + "/api/devices",
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(query), new HttpEntity<>(query),
new ParameterizedTypeReference<List<Device>>() { new ParameterizedTypeReference<List<Device>>() {
@ -1051,23 +1098,26 @@ public class RestClient implements ClientHttpRequestInterceptor {
public List<EntitySubtype> getDeviceTypes() { public List<EntitySubtype> getDeviceTypes() {
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/devices", baseURL + "/api/devices",
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<List<EntitySubtype>>() { new ParameterizedTypeReference<List<EntitySubtype>>() {
}).getBody(); }).getBody();
} }
//TODO: ClaimRequest class public DeferredResult<ResponseEntity> claimDevice(String deviceName, ClaimRequest claimRequest) {
// @RequestMapping(value = "/customer/device/{deviceName}/claim", method = RequestMethod.POST) return restTemplate.exchange(
// public DeferredResult<ResponseEntity> claimDevice(String deviceName, ClaimRequest claimRequest) { baseURL + "/api/customer/device/{deviceName}/claim",
// return restTemplate.exchange(baseURL + "/customer/device/{deviceName}/claim", HttpMethod.POST, new HttpEntity<>(claimRequest), new ParameterizedTypeReference<DeferredResult<ResponseEntity>>() { HttpMethod.POST,
// }, deviceName).getBody(); new HttpEntity<>(claimRequest),
// } new ParameterizedTypeReference<DeferredResult<ResponseEntity>>() {
},
deviceName).getBody();
}
public DeferredResult<ResponseEntity> reClaimDevice(String deviceName) { public DeferredResult<ResponseEntity> reClaimDevice(String deviceName) {
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/customer/device/{deviceName}/claim", baseURL + "/api/customer/device/{deviceName}/claim",
HttpMethod.DELETE, HttpMethod.DELETE,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<DeferredResult<ResponseEntity>>() { new ParameterizedTypeReference<DeferredResult<ResponseEntity>>() {
@ -1076,7 +1126,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public void saveRelation(EntityRelation relation) { public void saveRelation(EntityRelation relation) {
restTemplate.postForEntity(baseURL + "/relation", relation, Object.class); restTemplate.postForEntity(baseURL + "/api/relation", relation, Object.class);
} }
public void deleteRelation(String fromId, String fromType, String relationType, String relationTypeGroup, String toId, String toType) { public void deleteRelation(String fromId, String fromType, String relationType, String relationTypeGroup, String toId, String toType) {
@ -1087,11 +1137,11 @@ public class RestClient implements ClientHttpRequestInterceptor {
params.put("relationTypeGroup", relationTypeGroup); params.put("relationTypeGroup", relationTypeGroup);
params.put("toId", toId); params.put("toId", toId);
params.put("toType", toType); params.put("toType", toType);
restTemplate.delete(baseURL + "/relation?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}&toId={toId}&toType={toType}", params); restTemplate.delete(baseURL + "/api/relation?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}&toId={toId}&toType={toType}", params);
} }
public void deleteRelations(String entityId, String entityType) { public void deleteRelations(String entityId, String entityType) {
restTemplate.delete(baseURL + "/relations?entityId={entityId}&entityType={entityType}", entityId, entityType); restTemplate.delete(baseURL + "/api/relations?entityId={entityId}&entityType={entityType}", entityId, entityType);
} }
public Optional<EntityRelation> getRelation(String fromId, String fromType, String relationType, String relationTypeGroup, String toId, String toType) { 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 {
try { try {
ResponseEntity<EntityRelation> entityRelation = restTemplate.getForEntity( ResponseEntity<EntityRelation> entityRelation = restTemplate.getForEntity(
baseURL + "/relation?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}&toId={toId}&toType={toType}", baseURL + "/api/relation?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}&toId={toId}&toType={toType}",
EntityRelation.class, EntityRelation.class,
params); params);
return Optional.ofNullable(entityRelation.getBody()); return Optional.ofNullable(entityRelation.getBody());
@ -1125,7 +1175,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
params.put("relationTypeGroup", relationTypeGroup); params.put("relationTypeGroup", relationTypeGroup);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/relations?fromId={fromId}&fromType={fromType}&relationTypeGroup={relationTypeGroup}", baseURL + "/api/relations?fromId={fromId}&fromType={fromType}&relationTypeGroup={relationTypeGroup}",
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<List<EntityRelation>>() { new ParameterizedTypeReference<List<EntityRelation>>() {
@ -1134,14 +1184,13 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public List<EntityRelationInfo> findInfoByFrom(String fromId, String fromType, String relationTypeGroup) { public List<EntityRelationInfo> findInfoByFrom(String fromId, String fromType, String relationTypeGroup) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put("fromId", fromId); params.put("fromId", fromId);
params.put("fromType", fromType); params.put("fromType", fromType);
params.put("relationTypeGroup", relationTypeGroup); params.put("relationTypeGroup", relationTypeGroup);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/relations/info?fromId={fromId}&fromType={fromType}&relationTypeGroup={relationTypeGroup}", baseURL + "/api/relations/info?fromId={fromId}&fromType={fromType}&relationTypeGroup={relationTypeGroup}",
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<List<EntityRelationInfo>>() { new ParameterizedTypeReference<List<EntityRelationInfo>>() {
@ -1157,7 +1206,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
params.put("relationTypeGroup", relationTypeGroup); params.put("relationTypeGroup", relationTypeGroup);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/relations?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}", baseURL + "/api/relations?fromId={fromId}&fromType={fromType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}",
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<List<EntityRelation>>() { new ParameterizedTypeReference<List<EntityRelation>>() {
@ -1172,7 +1221,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
params.put("relationTypeGroup", relationTypeGroup); params.put("relationTypeGroup", relationTypeGroup);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/relations?toId={toId}&toType={toType}&relationTypeGroup={relationTypeGroup}", baseURL + "/api/relations?toId={toId}&toType={toType}&relationTypeGroup={relationTypeGroup}",
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<List<EntityRelation>>() { new ParameterizedTypeReference<List<EntityRelation>>() {
@ -1187,7 +1236,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
params.put("relationTypeGroup", relationTypeGroup); params.put("relationTypeGroup", relationTypeGroup);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/relations?toId={toId}&toType={toType}&relationTypeGroup={relationTypeGroup}", baseURL + "/api/relations?toId={toId}&toType={toType}&relationTypeGroup={relationTypeGroup}",
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<List<EntityRelationInfo>>() { new ParameterizedTypeReference<List<EntityRelationInfo>>() {
@ -1203,7 +1252,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
params.put("relationTypeGroup", relationTypeGroup); params.put("relationTypeGroup", relationTypeGroup);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/relations?toId={toId}&toType={toType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}", baseURL + "/api/relations?toId={toId}&toType={toType}&relationType={relationType}&relationTypeGroup={relationTypeGroup}",
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<List<EntityRelation>>() { new ParameterizedTypeReference<List<EntityRelation>>() {
@ -1213,7 +1262,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public List<EntityRelation> findByQuery(EntityRelationsQuery query) { public List<EntityRelation> findByQuery(EntityRelationsQuery query) {
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/relations", baseURL + "/api/relations",
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(query), new HttpEntity<>(query),
new ParameterizedTypeReference<List<EntityRelation>>() { new ParameterizedTypeReference<List<EntityRelation>>() {
@ -1222,7 +1271,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public List<EntityRelationInfo> findInfoByQuery(EntityRelationsQuery query) { public List<EntityRelationInfo> findInfoByQuery(EntityRelationsQuery query) {
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/relations", baseURL + "/api/relations",
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(query), new HttpEntity<>(query),
new ParameterizedTypeReference<List<EntityRelationInfo>>() { new ParameterizedTypeReference<List<EntityRelationInfo>>() {
@ -1231,7 +1280,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<EntityView> getEntityViewById(String entityViewId) { public Optional<EntityView> getEntityViewById(String entityViewId) {
try { try {
ResponseEntity<EntityView> entityView = restTemplate.getForEntity(baseURL + "/entityView/{entityViewId}", EntityView.class, entityViewId); ResponseEntity<EntityView> entityView = restTemplate.getForEntity(baseURL + "/api/entityView/{entityViewId}", EntityView.class, entityViewId);
return Optional.ofNullable(entityView.getBody()); return Optional.ofNullable(entityView.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1243,16 +1292,16 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public EntityView saveEntityView(EntityView entityView) { public EntityView saveEntityView(EntityView entityView) {
return restTemplate.postForEntity(baseURL + "entityView", entityView, EntityView.class).getBody(); return restTemplate.postForEntity(baseURL + "/api/entityView", entityView, EntityView.class).getBody();
} }
public void deleteEntityView(String entityViewId) { public void deleteEntityView(String entityViewId) {
restTemplate.delete(baseURL + "/entityView/{entityViewId}", entityViewId); restTemplate.delete(baseURL + "/api/entityView/{entityViewId}", entityViewId);
} }
public Optional<EntityView> getTenantEntityView(String entityViewName) { public Optional<EntityView> getTenantEntityView(String entityViewName) {
try { try {
ResponseEntity<EntityView> entityView = restTemplate.getForEntity(baseURL + "/tenant/entityViews?entityViewName={entityViewName}", EntityView.class, entityViewName); ResponseEntity<EntityView> entityView = restTemplate.getForEntity(baseURL + "/api/tenant/entityViews?entityViewName={entityViewName}", EntityView.class, entityViewName);
return Optional.ofNullable(entityView.getBody()); return Optional.ofNullable(entityView.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1265,7 +1314,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<EntityView> assignEntityViewToCustomer(String customerId, String entityViewId) { public Optional<EntityView> assignEntityViewToCustomer(String customerId, String entityViewId) {
try { try {
ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "/customer/{customerId}/entityView/{entityViewId}", null, EntityView.class, customerId, entityViewId); ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/entityView/{entityViewId}", null, EntityView.class, customerId, entityViewId);
return Optional.ofNullable(entityView.getBody()); return Optional.ofNullable(entityView.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1279,7 +1328,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<EntityView> unassignEntityViewFromCustomer(String entityViewId) { public Optional<EntityView> unassignEntityViewFromCustomer(String entityViewId) {
try { try {
ResponseEntity<EntityView> entityView = restTemplate.exchange( ResponseEntity<EntityView> entityView = restTemplate.exchange(
baseURL + "/customer/entityView/{entityViewId}", baseURL + "/api/customer/entityView/{entityViewId}",
HttpMethod.DELETE, HttpMethod.DELETE,
HttpEntity.EMPTY, HttpEntity.EMPTY,
EntityView.class, entityViewId); EntityView.class, entityViewId);
@ -1299,7 +1348,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
params.put("type", type); params.put("type", type);
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/customer/{customerId}/entityViews?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS, baseURL + "/api/customer/{customerId}/entityViews?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TextPageData<EntityView>>() { new ParameterizedTypeReference<TextPageData<EntityView>>() {
@ -1312,7 +1361,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
params.put("type", type); params.put("type", type);
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/tenant/entityViews?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS, baseURL + "/api/tenant/entityViews?type={type}&" + TEXT_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TextPageData<EntityView>>() { new ParameterizedTypeReference<TextPageData<EntityView>>() {
@ -1321,18 +1370,18 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public List<EntityView> findByQuery(EntityViewSearchQuery query) { public List<EntityView> findByQuery(EntityViewSearchQuery query) {
return restTemplate.exchange(baseURL + "/entityViews", HttpMethod.POST, new HttpEntity<>(query), new ParameterizedTypeReference<List<EntityView>>() { return restTemplate.exchange(baseURL + "/api/entityViews", HttpMethod.POST, new HttpEntity<>(query), new ParameterizedTypeReference<List<EntityView>>() {
}).getBody(); }).getBody();
} }
public List<EntitySubtype> getEntityViewTypes() { public List<EntitySubtype> getEntityViewTypes() {
return restTemplate.exchange(baseURL + "/entityView/types", HttpMethod.GET, HttpEntity.EMPTY, new ParameterizedTypeReference<List<EntitySubtype>>() { return restTemplate.exchange(baseURL + "/api/entityView/types", HttpMethod.GET, HttpEntity.EMPTY, new ParameterizedTypeReference<List<EntitySubtype>>() {
}).getBody(); }).getBody();
} }
public Optional<EntityView> assignEntityViewToPublicCustomer(String entityViewId) { public Optional<EntityView> assignEntityViewToPublicCustomer(String entityViewId) {
try { try {
ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "customer/public/entityView/{entityViewId}", null, EntityView.class, entityViewId); ResponseEntity<EntityView> entityView = restTemplate.postForEntity(baseURL + "/api/customer/public/entityView/{entityViewId}", null, EntityView.class, entityViewId);
return Optional.ofNullable(entityView.getBody()); return Optional.ofNullable(entityView.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1352,7 +1401,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/events/{entityType}/{entityId}/{eventType}?tenantId={tenantId}&" + TIME_PAGE_LINK_URL_PARAMS, baseURL + "/api/events/{entityType}/{entityId}/{eventType}?tenantId={tenantId}&" + TIME_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TimePageData<Event>>() { new ParameterizedTypeReference<TimePageData<Event>>() {
@ -1368,7 +1417,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/events/{entityType}/{entityId}?tenantId={tenantId}&" + TIME_PAGE_LINK_URL_PARAMS, baseURL + "/api/events/{entityType}/{entityId}?tenantId={tenantId}&" + TIME_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TimePageData<Event>>() { new ParameterizedTypeReference<TimePageData<Event>>() {
@ -1398,7 +1447,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<RuleChain> getRuleChainById(String ruleChainId) { public Optional<RuleChain> getRuleChainById(String ruleChainId) {
try { try {
ResponseEntity<RuleChain> ruleChain = restTemplate.getForEntity(baseURL + "/ruleChain/{ruleChainId}", RuleChain.class, ruleChainId); ResponseEntity<RuleChain> ruleChain = restTemplate.getForEntity(baseURL + "/api/ruleChain/{ruleChainId}", RuleChain.class, ruleChainId);
return Optional.ofNullable(ruleChain.getBody()); return Optional.ofNullable(ruleChain.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1411,7 +1460,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<RuleChainMetaData> getRuleChainMetaData(String ruleChainId) { public Optional<RuleChainMetaData> getRuleChainMetaData(String ruleChainId) {
try { try {
ResponseEntity<RuleChainMetaData> ruleChainMetaData = restTemplate.getForEntity(baseURL + "/ruleChain/{ruleChainId}/metadata", RuleChainMetaData.class, ruleChainId); ResponseEntity<RuleChainMetaData> ruleChainMetaData = restTemplate.getForEntity(baseURL + "/api/ruleChain/{ruleChainId}/metadata", RuleChainMetaData.class, ruleChainId);
return Optional.ofNullable(ruleChainMetaData.getBody()); return Optional.ofNullable(ruleChainMetaData.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1423,12 +1472,12 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public RuleChain saveRuleChain(RuleChain ruleChain) { public RuleChain saveRuleChain(RuleChain ruleChain) {
return restTemplate.postForEntity(baseURL + "/ruleChain", ruleChain, RuleChain.class).getBody(); return restTemplate.postForEntity(baseURL + "/api/ruleChain", ruleChain, RuleChain.class).getBody();
} }
public Optional<RuleChain> setRootRuleChain(String ruleChainId) { public Optional<RuleChain> setRootRuleChain(String ruleChainId) {
try { try {
ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/ruleChain/{ruleChainId}/root", null, RuleChain.class, ruleChainId); ResponseEntity<RuleChain> ruleChain = restTemplate.postForEntity(baseURL + "/api/ruleChain/{ruleChainId}/root", null, RuleChain.class, ruleChainId);
return Optional.ofNullable(ruleChain.getBody()); return Optional.ofNullable(ruleChain.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1440,14 +1489,14 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public RuleChainMetaData saveRuleChainMetaData(RuleChainMetaData ruleChainMetaData) { public RuleChainMetaData saveRuleChainMetaData(RuleChainMetaData ruleChainMetaData) {
return restTemplate.postForEntity(baseURL + "/ruleChain/metadata", ruleChainMetaData, RuleChainMetaData.class).getBody(); return restTemplate.postForEntity(baseURL + "/api/ruleChain/metadata", ruleChainMetaData, RuleChainMetaData.class).getBody();
} }
public TextPageData<RuleChain> getRuleChains(TextPageLink pageLink) { public TextPageData<RuleChain> getRuleChains(TextPageLink pageLink) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/ruleChains" + TEXT_PAGE_LINK_URL_PARAMS, baseURL + "/api/ruleChains" + TEXT_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TextPageData<RuleChain>>() { new ParameterizedTypeReference<TextPageData<RuleChain>>() {
@ -1456,12 +1505,12 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public void deleteRuleChain(String ruleChainId) { public void deleteRuleChain(String ruleChainId) {
restTemplate.delete(baseURL + "/ruleChain/{ruleChainId}", ruleChainId); restTemplate.delete(baseURL + "/api/ruleChain/{ruleChainId}", ruleChainId);
} }
public Optional<JsonNode> getLatestRuleNodeDebugInput(String ruleNodeId) { public Optional<JsonNode> getLatestRuleNodeDebugInput(String ruleNodeId) {
try { try {
ResponseEntity<JsonNode> jsonNode = restTemplate.getForEntity(baseURL + "/ruleNode/{ruleNodeId}/debugIn", JsonNode.class, ruleNodeId); ResponseEntity<JsonNode> jsonNode = restTemplate.getForEntity(baseURL + "/api/ruleNode/{ruleNodeId}/debugIn", JsonNode.class, ruleNodeId);
return Optional.ofNullable(jsonNode.getBody()); return Optional.ofNullable(jsonNode.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1474,7 +1523,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<JsonNode> testScript(JsonNode inputParams) { public Optional<JsonNode> testScript(JsonNode inputParams) {
try { try {
ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/ruleChain/testScript", inputParams, JsonNode.class); ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/api/ruleChain/testScript", inputParams, JsonNode.class);
return Optional.ofNullable(jsonNode.getBody()); return Optional.ofNullable(jsonNode.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1689,7 +1738,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<Tenant> getTenantById(String tenantId) { public Optional<Tenant> getTenantById(String tenantId) {
try { try {
ResponseEntity<Tenant> tenant = restTemplate.getForEntity(baseURL + "/tenant/{tenantId}", Tenant.class, tenantId); ResponseEntity<Tenant> tenant = restTemplate.getForEntity(baseURL + "/api/tenant/{tenantId}", Tenant.class, tenantId);
return Optional.ofNullable(tenant.getBody()); return Optional.ofNullable(tenant.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1701,11 +1750,11 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public Tenant saveTenant(Tenant tenant) { public Tenant saveTenant(Tenant tenant) {
return restTemplate.postForEntity(baseURL + "/tenant", tenant, Tenant.class).getBody(); return restTemplate.postForEntity(baseURL + "/api/tenant", tenant, Tenant.class).getBody();
} }
public void deleteTenant(String tenantId) { public void deleteTenant(String tenantId) {
restTemplate.delete(baseURL + "/tenant/{tenantId}", tenantId); restTemplate.delete(baseURL + "/api/tenant/{tenantId}", tenantId);
} }
public TextPageData<Tenant> getTenants(TextPageLink pageLink) { public TextPageData<Tenant> getTenants(TextPageLink pageLink) {
@ -1722,7 +1771,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<User> getUserById(String userId) { public Optional<User> getUserById(String userId) {
try { try {
ResponseEntity<User> user = restTemplate.getForEntity(baseURL + "/user/{userId}", User.class, userId); ResponseEntity<User> user = restTemplate.getForEntity(baseURL + "/api/user/{userId}", User.class, userId);
return Optional.ofNullable(user.getBody()); return Optional.ofNullable(user.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1734,12 +1783,12 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public Boolean isUserTokenAccessEnabled() { public Boolean isUserTokenAccessEnabled() {
return restTemplate.getForEntity(baseURL + "/user/tokenAccessEnabled", Boolean.class).getBody(); return restTemplate.getForEntity(baseURL + "/api/user/tokenAccessEnabled", Boolean.class).getBody();
} }
public Optional<JsonNode> getUserToken(String userId) { public Optional<JsonNode> getUserToken(String userId) {
try { try {
ResponseEntity<JsonNode> userToken = restTemplate.getForEntity(baseURL + "/user/{userId}/token", JsonNode.class, userId); ResponseEntity<JsonNode> userToken = restTemplate.getForEntity(baseURL + "/api/user/{userId}/token", JsonNode.class, userId);
return Optional.ofNullable(userToken.getBody()); return Optional.ofNullable(userToken.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1751,16 +1800,16 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public User saveUser(User user, boolean sendActivationMail) { public User saveUser(User user, boolean sendActivationMail) {
return restTemplate.postForEntity(baseURL + "/user?sendActivationMail={sendActivationMail}", user, User.class, sendActivationMail).getBody(); return restTemplate.postForEntity(baseURL + "/api/user?sendActivationMail={sendActivationMail}", user, User.class, sendActivationMail).getBody();
} }
public void sendActivationEmail(String email) { public void sendActivationEmail(String email) {
restTemplate.postForEntity(baseURL + "/user/sendActivationMail?email={email}", null, Object.class, email); restTemplate.postForEntity(baseURL + "/api/user/sendActivationMail?email={email}", null, Object.class, email);
} }
public Optional<String> getActivationLink(String userId) { public Optional<String> getActivationLink(String userId) {
try { try {
ResponseEntity<String> activationLink = restTemplate.getForEntity(baseURL + "/user/{userId}/activationLink", String.class, userId); ResponseEntity<String> activationLink = restTemplate.getForEntity(baseURL + "/api/user/{userId}/activationLink", String.class, userId);
return Optional.ofNullable(activationLink.getBody()); return Optional.ofNullable(activationLink.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1772,7 +1821,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public void deleteUser(String userId) { public void deleteUser(String userId) {
restTemplate.delete(baseURL + "/user/{userId}", userId); restTemplate.delete(baseURL + "/api/user/{userId}", userId);
} }
// @RequestMapping(value = "/tenant/{tenantId}/users", params = {"limit"}, method = RequestMethod.GET) // @RequestMapping(value = "/tenant/{tenantId}/users", params = {"limit"}, method = RequestMethod.GET)
@ -1796,7 +1845,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/customer/{customerId}/users?" + TEXT_PAGE_LINK_URL_PARAMS, baseURL + "/api/customer/{customerId}/users?" + TEXT_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TextPageData<User>>() { new ParameterizedTypeReference<TextPageData<User>>() {
@ -1806,7 +1855,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public void setUserCredentialsEnabled(String userId, boolean userCredentialsEnabled) { public void setUserCredentialsEnabled(String userId, boolean userCredentialsEnabled) {
restTemplate.postForEntity( restTemplate.postForEntity(
baseURL + "/user/{userId}/userCredentialsEnabled?serCredentialsEnabled={serCredentialsEnabled}", baseURL + "/api/user/{userId}/userCredentialsEnabled?serCredentialsEnabled={serCredentialsEnabled}",
null, null,
Object.class, Object.class,
userId, userId,
@ -1816,7 +1865,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<WidgetsBundle> getWidgetsBundleById(String widgetsBundleId) { public Optional<WidgetsBundle> getWidgetsBundleById(String widgetsBundleId) {
try { try {
ResponseEntity<WidgetsBundle> widgetsBundle = ResponseEntity<WidgetsBundle> widgetsBundle =
restTemplate.getForEntity(baseURL + "/widgetsBundle/{widgetsBundleId}", WidgetsBundle.class, widgetsBundleId); restTemplate.getForEntity(baseURL + "/api/widgetsBundle/{widgetsBundleId}", WidgetsBundle.class, widgetsBundleId);
return Optional.ofNullable(widgetsBundle.getBody()); return Optional.ofNullable(widgetsBundle.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1828,18 +1877,18 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public WidgetsBundle saveWidgetsBundle(WidgetsBundle widgetsBundle) { public WidgetsBundle saveWidgetsBundle(WidgetsBundle widgetsBundle) {
return restTemplate.postForEntity(baseURL + "/widgetsBundle", widgetsBundle, WidgetsBundle.class).getBody(); return restTemplate.postForEntity(baseURL + "/api/widgetsBundle", widgetsBundle, WidgetsBundle.class).getBody();
} }
public void deleteWidgetsBundle(String widgetsBundleId) { public void deleteWidgetsBundle(String widgetsBundleId) {
restTemplate.delete(baseURL + "/widgetsBundle/{widgetsBundleId}", widgetsBundleId); restTemplate.delete(baseURL + "/api/widgetsBundle/{widgetsBundleId}", widgetsBundleId);
} }
public TextPageData<WidgetsBundle> getWidgetsBundles(TextPageLink pageLink) { public TextPageData<WidgetsBundle> getWidgetsBundles(TextPageLink pageLink) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
addPageLinkToParam(params, pageLink); addPageLinkToParam(params, pageLink);
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/widgetsBundles?" + TEXT_PAGE_LINK_URL_PARAMS, baseURL + "/api/widgetsBundles?" + TEXT_PAGE_LINK_URL_PARAMS,
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<TextPageData<WidgetsBundle>>() { new ParameterizedTypeReference<TextPageData<WidgetsBundle>>() {
@ -1848,7 +1897,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public List<WidgetsBundle> getWidgetsBundles() { public List<WidgetsBundle> getWidgetsBundles() {
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/widgetsBundles", baseURL + "/api/widgetsBundles",
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<List<WidgetsBundle>>() { new ParameterizedTypeReference<List<WidgetsBundle>>() {
@ -1858,7 +1907,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
public Optional<WidgetType> getWidgetTypeById(String widgetTypeId) { public Optional<WidgetType> getWidgetTypeById(String widgetTypeId) {
try { try {
ResponseEntity<WidgetType> widgetType = ResponseEntity<WidgetType> widgetType =
restTemplate.getForEntity(baseURL + "/widgetType/{widgetTypeId}", WidgetType.class, widgetTypeId); restTemplate.getForEntity(baseURL + "/api/widgetType/{widgetTypeId}", WidgetType.class, widgetTypeId);
return Optional.ofNullable(widgetType.getBody()); return Optional.ofNullable(widgetType.getBody());
} catch (HttpClientErrorException exception) { } catch (HttpClientErrorException exception) {
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
@ -1870,16 +1919,16 @@ public class RestClient implements ClientHttpRequestInterceptor {
} }
public WidgetType saveWidgetType(WidgetType widgetType) { public WidgetType saveWidgetType(WidgetType widgetType) {
return restTemplate.postForEntity(baseURL + "/widgetType", widgetType, WidgetType.class).getBody(); return restTemplate.postForEntity(baseURL + "/api/widgetType", widgetType, WidgetType.class).getBody();
} }
public void deleteWidgetType(String widgetTypeId) { public void deleteWidgetType(String widgetTypeId) {
restTemplate.delete(baseURL + "/widgetType/{widgetTypeId}", widgetTypeId); restTemplate.delete(baseURL + "/api/widgetType/{widgetTypeId}", widgetTypeId);
} }
public List<WidgetType> getBundleWidgetTypes(boolean isSystem, String bundleAlias) { public List<WidgetType> getBundleWidgetTypes(boolean isSystem, String bundleAlias) {
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/widgetTypes?isSystem={isSystem}&bundleAlias={bundleAlias}", baseURL + "/api/widgetTypes?isSystem={isSystem}&bundleAlias={bundleAlias}",
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<List<WidgetType>>() { new ParameterizedTypeReference<List<WidgetType>>() {
@ -1892,7 +1941,7 @@ public class RestClient implements ClientHttpRequestInterceptor {
try { try {
ResponseEntity<WidgetType> widgetType = ResponseEntity<WidgetType> widgetType =
restTemplate.getForEntity( restTemplate.getForEntity(
baseURL + "/widgetType?isSystem={isSystem}&bundleAlias={bundleAlias}&alias={alias}", baseURL + "/api/widgetType?isSystem={isSystem}&bundleAlias={bundleAlias}&alias={alias}",
WidgetType.class, WidgetType.class,
isSystem, isSystem,
bundleAlias, bundleAlias,