|
|
1
|
+package org.thingsboard.server.controller;
|
|
|
2
|
+
|
|
|
3
|
+import com.google.common.base.Function;
|
|
|
4
|
+import com.google.common.util.concurrent.FutureCallback;
|
|
|
5
|
+import com.google.common.util.concurrent.Futures;
|
|
|
6
|
+import com.google.common.util.concurrent.ListenableFuture;
|
|
|
7
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
8
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
9
|
+import org.springframework.http.HttpStatus;
|
|
|
10
|
+import org.springframework.http.ResponseEntity;
|
|
|
11
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
12
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
13
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
14
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
15
|
+import org.springframework.web.bind.annotation.ResponseStatus;
|
|
|
16
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
17
|
+import org.springframework.web.context.request.async.DeferredResult;
|
|
|
18
|
+import org.thingsboard.server.actors.plugin.ValidationResult;
|
|
|
19
|
+import org.thingsboard.server.common.data.DataConstants;
|
|
|
20
|
+import org.thingsboard.server.common.data.Device;
|
|
|
21
|
+import org.thingsboard.server.common.data.id.DeviceId;
|
|
|
22
|
+import org.thingsboard.server.common.data.id.EntityId;
|
|
|
23
|
+import org.thingsboard.server.common.data.id.EntityIdFactory;
|
|
|
24
|
+import org.thingsboard.server.common.data.kv.AttributeKvEntry;
|
|
|
25
|
+import org.thingsboard.server.common.data.kv.KvEntry;
|
|
|
26
|
+import org.thingsboard.server.dao.attributes.AttributesService;
|
|
|
27
|
+import org.thingsboard.server.dao.timeseries.TimeseriesService;
|
|
|
28
|
+import org.thingsboard.server.exception.ThingsboardException;
|
|
|
29
|
+import org.thingsboard.server.extensions.api.exception.ToErrorResponseEntity;
|
|
|
30
|
+import org.thingsboard.server.extensions.api.plugins.PluginConstants;
|
|
|
31
|
+import org.thingsboard.server.service.security.model.SecurityUser;
|
|
|
32
|
+
|
|
|
33
|
+import javax.annotation.Nullable;
|
|
|
34
|
+import javax.annotation.PreDestroy;
|
|
|
35
|
+import java.util.ArrayList;
|
|
|
36
|
+import java.util.List;
|
|
|
37
|
+import java.util.concurrent.ExecutorService;
|
|
|
38
|
+import java.util.concurrent.Executors;
|
|
|
39
|
+import java.util.stream.Collectors;
|
|
|
40
|
+
|
|
|
41
|
+/**
|
|
|
42
|
+ * Created by ashvayka on 22.03.18.
|
|
|
43
|
+ */
|
|
|
44
|
+@RestController
|
|
|
45
|
+@RequestMapping(PluginConstants.TELEMETRY_URL_PREFIX)
|
|
|
46
|
+@Slf4j
|
|
|
47
|
+public class TelemetryController extends BaseController {
|
|
|
48
|
+
|
|
|
49
|
+ public static final String CUSTOMER_USER_IS_NOT_ALLOWED_TO_PERFORM_THIS_OPERATION = "Customer user is not allowed to perform this operation!";
|
|
|
50
|
+ public static final String SYSTEM_ADMINISTRATOR_IS_NOT_ALLOWED_TO_PERFORM_THIS_OPERATION = "System administrator is not allowed to perform this operation!";
|
|
|
51
|
+ public static final String DEVICE_WITH_REQUESTED_ID_NOT_FOUND = "Device with requested id wasn't found!";
|
|
|
52
|
+
|
|
|
53
|
+ @Autowired
|
|
|
54
|
+ private AttributesService attributesService;
|
|
|
55
|
+
|
|
|
56
|
+ @Autowired
|
|
|
57
|
+ private TimeseriesService tsService;
|
|
|
58
|
+
|
|
|
59
|
+ private ExecutorService executor;
|
|
|
60
|
+
|
|
|
61
|
+ public void initExecutor() {
|
|
|
62
|
+ executor = Executors.newSingleThreadExecutor();
|
|
|
63
|
+ }
|
|
|
64
|
+
|
|
|
65
|
+ @PreDestroy
|
|
|
66
|
+ public void shutdownExecutor() {
|
|
|
67
|
+ if (executor != null) {
|
|
|
68
|
+ executor.shutdownNow();
|
|
|
69
|
+ }
|
|
|
70
|
+ }
|
|
|
71
|
+
|
|
|
72
|
+ @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
|
|
73
|
+ @RequestMapping(value = "/{entityType}/{entityId}/keys/ATTRIBUTES", method = RequestMethod.GET)
|
|
|
74
|
+ @ResponseStatus(value = HttpStatus.OK)
|
|
|
75
|
+ public DeferredResult<ResponseEntity> getAttributeKeys(
|
|
|
76
|
+ @PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr) throws ThingsboardException {
|
|
|
77
|
+ DeferredResult<ResponseEntity> response = new DeferredResult<ResponseEntity>();
|
|
|
78
|
+ EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr);
|
|
|
79
|
+
|
|
|
80
|
+ validate(getCurrentUser(), entityId, new ValidationCallback(response,
|
|
|
81
|
+ new FutureCallback<DeferredResult<ResponseEntity>>() {
|
|
|
82
|
+ @Override
|
|
|
83
|
+ public void onSuccess(@Nullable DeferredResult<ResponseEntity> result) {
|
|
|
84
|
+ List<ListenableFuture<List<AttributeKvEntry>>> futures = new ArrayList<>();
|
|
|
85
|
+ for (String scope : DataConstants.allScopes()) {
|
|
|
86
|
+ futures.add(attributesService.findAll(entityId, scope));
|
|
|
87
|
+ }
|
|
|
88
|
+
|
|
|
89
|
+ ListenableFuture<List<AttributeKvEntry>> future = Futures.transform(Futures.successfulAsList(futures),
|
|
|
90
|
+ (Function<? super List<List<AttributeKvEntry>>, ? extends List<AttributeKvEntry>>) input -> {
|
|
|
91
|
+ List<AttributeKvEntry> tmp = new ArrayList<>();
|
|
|
92
|
+ if (input != null) {
|
|
|
93
|
+ input.forEach(tmp::addAll);
|
|
|
94
|
+ }
|
|
|
95
|
+ return tmp;
|
|
|
96
|
+ }, executor);
|
|
|
97
|
+
|
|
|
98
|
+ Futures.addCallback(future, getAttributeKeysPluginCallback(result));
|
|
|
99
|
+ }
|
|
|
100
|
+
|
|
|
101
|
+ @Override
|
|
|
102
|
+ public void onFailure(Throwable t) {
|
|
|
103
|
+ handleError(t, response, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
104
|
+ }
|
|
|
105
|
+ }));
|
|
|
106
|
+
|
|
|
107
|
+ return response;
|
|
|
108
|
+ }
|
|
|
109
|
+
|
|
|
110
|
+ @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
|
|
111
|
+ @RequestMapping(value = "/{entityType}/{entityId}/keys/ATTRIBUTES/{scope}", method = RequestMethod.GET)
|
|
|
112
|
+ @ResponseStatus(value = HttpStatus.OK)
|
|
|
113
|
+ public DeferredResult<ResponseEntity> getAttributeKeysByScope() {
|
|
|
114
|
+ return null;
|
|
|
115
|
+ }
|
|
|
116
|
+
|
|
|
117
|
+ @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
|
|
118
|
+ @RequestMapping(value = "/{entityType}/{entityId}/values/ATTRIBUTES", method = RequestMethod.GET)
|
|
|
119
|
+ @ResponseStatus(value = HttpStatus.OK)
|
|
|
120
|
+ public DeferredResult<ResponseEntity> getAttributeValues() {
|
|
|
121
|
+ return null;
|
|
|
122
|
+ }
|
|
|
123
|
+
|
|
|
124
|
+ @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
|
|
125
|
+ @RequestMapping(value = "/{entityType}/{entityId}/values/ATTRIBUTES", method = RequestMethod.GET)
|
|
|
126
|
+ @ResponseStatus(value = HttpStatus.OK)
|
|
|
127
|
+ public DeferredResult<ResponseEntity> getAttributeValuesByScope() {
|
|
|
128
|
+ return null;
|
|
|
129
|
+ }
|
|
|
130
|
+
|
|
|
131
|
+ private FutureCallback<List<AttributeKvEntry>> getAttributeKeysPluginCallback(final DeferredResult<ResponseEntity> response) {
|
|
|
132
|
+ return new FutureCallback<List<AttributeKvEntry>>() {
|
|
|
133
|
+
|
|
|
134
|
+ @Override
|
|
|
135
|
+ public void onSuccess(List<AttributeKvEntry> attributes) {
|
|
|
136
|
+ List<String> keys = attributes.stream().map(KvEntry::getKey).collect(Collectors.toList());
|
|
|
137
|
+ response.setResult(new ResponseEntity<>(keys, HttpStatus.OK));
|
|
|
138
|
+ }
|
|
|
139
|
+
|
|
|
140
|
+ @Override
|
|
|
141
|
+ public void onFailure(Throwable e) {
|
|
|
142
|
+ log.error("Failed to fetch attributes", e);
|
|
|
143
|
+ handleError(e, response, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
144
|
+ }
|
|
|
145
|
+ };
|
|
|
146
|
+ }
|
|
|
147
|
+
|
|
|
148
|
+ private void handleError(Throwable e, final DeferredResult<ResponseEntity> response, HttpStatus defaultErrorStatus) {
|
|
|
149
|
+ ResponseEntity responseEntity;
|
|
|
150
|
+ if (e != null && e instanceof ToErrorResponseEntity) {
|
|
|
151
|
+ responseEntity = ((ToErrorResponseEntity) e).toErrorResponseEntity();
|
|
|
152
|
+ } else if (e != null && e instanceof IllegalArgumentException) {
|
|
|
153
|
+ responseEntity = new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
|
|
|
154
|
+ } else {
|
|
|
155
|
+ responseEntity = new ResponseEntity<>(defaultErrorStatus);
|
|
|
156
|
+ }
|
|
|
157
|
+ response.setResult(responseEntity);
|
|
|
158
|
+ }
|
|
|
159
|
+
|
|
|
160
|
+ private void validate(SecurityUser currentUser, EntityId entityId, ValidationCallback callback) {
|
|
|
161
|
+ switch (entityId.getEntityType()) {
|
|
|
162
|
+ case DEVICE:
|
|
|
163
|
+ validateDevice(currentUser, entityId, callback);
|
|
|
164
|
+ return;
|
|
|
165
|
+// case ASSET:
|
|
|
166
|
+// validateAsset(ctx, entityId, callback);
|
|
|
167
|
+// return;
|
|
|
168
|
+// case RULE:
|
|
|
169
|
+// validateRule(ctx, entityId, callback);
|
|
|
170
|
+// return;
|
|
|
171
|
+// case RULE_CHAIN:
|
|
|
172
|
+// validateRuleChain(ctx, entityId, callback);
|
|
|
173
|
+// return;
|
|
|
174
|
+// case PLUGIN:
|
|
|
175
|
+// validatePlugin(ctx, entityId, callback);
|
|
|
176
|
+// return;
|
|
|
177
|
+// case CUSTOMER:
|
|
|
178
|
+// validateCustomer(ctx, entityId, callback);
|
|
|
179
|
+// return;
|
|
|
180
|
+// case TENANT:
|
|
|
181
|
+// validateTenant(ctx, entityId, callback);
|
|
|
182
|
+// return;
|
|
|
183
|
+ default:
|
|
|
184
|
+ //TODO: add support of other entities
|
|
|
185
|
+ throw new IllegalStateException("Not Implemented!");
|
|
|
186
|
+ }
|
|
|
187
|
+ }
|
|
|
188
|
+
|
|
|
189
|
+ private void validateDevice(final SecurityUser currentUser, EntityId entityId, ValidationCallback callback) {
|
|
|
190
|
+ if (currentUser.isSystemAdmin()) {
|
|
|
191
|
+ callback.onSuccess(ValidationResult.accessDenied(SYSTEM_ADMINISTRATOR_IS_NOT_ALLOWED_TO_PERFORM_THIS_OPERATION));
|
|
|
192
|
+ } else {
|
|
|
193
|
+ ListenableFuture<Device> deviceFuture = deviceService.findDeviceByIdAsync(new DeviceId(entityId.getId()));
|
|
|
194
|
+ Futures.addCallback(deviceFuture, getCallback(callback, device -> {
|
|
|
195
|
+ if (device == null) {
|
|
|
196
|
+ return ValidationResult.entityNotFound(DEVICE_WITH_REQUESTED_ID_NOT_FOUND);
|
|
|
197
|
+ } else {
|
|
|
198
|
+ if (!device.getTenantId().equals(currentUser.getTenantId())) {
|
|
|
199
|
+ return ValidationResult.accessDenied("Device doesn't belong to the current Tenant!");
|
|
|
200
|
+ } else if (currentUser.isCustomerUser() && !device.getCustomerId().equals(currentUser.getCustomerId())) {
|
|
|
201
|
+ return ValidationResult.accessDenied("Device doesn't belong to the current Customer!");
|
|
|
202
|
+ } else {
|
|
|
203
|
+ return ValidationResult.ok();
|
|
|
204
|
+ }
|
|
|
205
|
+ }
|
|
|
206
|
+ }));
|
|
|
207
|
+ }
|
|
|
208
|
+ }
|
|
|
209
|
+
|
|
|
210
|
+ private <T> FutureCallback<T> getCallback(ValidationCallback callback, Function<T, ValidationResult> transformer) {
|
|
|
211
|
+ return new FutureCallback<T>() {
|
|
|
212
|
+ @Override
|
|
|
213
|
+ public void onSuccess(@Nullable T result) {
|
|
|
214
|
+ callback.onSuccess(transformer.apply(result));
|
|
|
215
|
+ }
|
|
|
216
|
+
|
|
|
217
|
+ @Override
|
|
|
218
|
+ public void onFailure(Throwable t) {
|
|
|
219
|
+ callback.onFailure(t);
|
|
|
220
|
+ }
|
|
|
221
|
+ };
|
|
|
222
|
+ }
|
|
|
223
|
+//
|
|
|
224
|
+// private void validateAsset(final PluginApiCallSecurityContext ctx, EntityId entityId, ValidationCallback callback) {
|
|
|
225
|
+// if (ctx.isSystemAdmin()) {
|
|
|
226
|
+// callback.onSuccess(this, ValidationResult.accessDenied(SYSTEM_ADMINISTRATOR_IS_NOT_ALLOWED_TO_PERFORM_THIS_OPERATION));
|
|
|
227
|
+// } else {
|
|
|
228
|
+// ListenableFuture<Asset> assetFuture = pluginCtx.assetService.findAssetByIdAsync(new AssetId(entityId.getId()));
|
|
|
229
|
+// Futures.addCallback(assetFuture, getCallback(callback, asset -> {
|
|
|
230
|
+// if (asset == null) {
|
|
|
231
|
+// return ValidationResult.entityNotFound("Asset with requested id wasn't found!");
|
|
|
232
|
+// } else {
|
|
|
233
|
+// if (!asset.getTenantId().equals(ctx.getTenantId())) {
|
|
|
234
|
+// return ValidationResult.accessDenied("Asset doesn't belong to the current Tenant!");
|
|
|
235
|
+// } else if (ctx.isCustomerUser() && !asset.getCustomerId().equals(ctx.getCustomerId())) {
|
|
|
236
|
+// return ValidationResult.accessDenied("Asset doesn't belong to the current Customer!");
|
|
|
237
|
+// } else {
|
|
|
238
|
+// return ValidationResult.ok();
|
|
|
239
|
+// }
|
|
|
240
|
+// }
|
|
|
241
|
+// }));
|
|
|
242
|
+// }
|
|
|
243
|
+// }
|
|
|
244
|
+//
|
|
|
245
|
+// private void validateRule(final PluginApiCallSecurityContext ctx, EntityId entityId, ValidationCallback callback) {
|
|
|
246
|
+// if (ctx.isCustomerUser()) {
|
|
|
247
|
+// callback.onSuccess(this, ValidationResult.accessDenied(CUSTOMER_USER_IS_NOT_ALLOWED_TO_PERFORM_THIS_OPERATION));
|
|
|
248
|
+// } else {
|
|
|
249
|
+// ListenableFuture<RuleMetaData> ruleFuture = pluginCtx.ruleService.findRuleByIdAsync(new RuleId(entityId.getId()));
|
|
|
250
|
+// Futures.addCallback(ruleFuture, getCallback(callback, rule -> {
|
|
|
251
|
+// if (rule == null) {
|
|
|
252
|
+// return ValidationResult.entityNotFound("Rule with requested id wasn't found!");
|
|
|
253
|
+// } else {
|
|
|
254
|
+// if (ctx.isTenantAdmin() && !rule.getTenantId().equals(ctx.getTenantId())) {
|
|
|
255
|
+// return ValidationResult.accessDenied("Rule doesn't belong to the current Tenant!");
|
|
|
256
|
+// } else if (ctx.isSystemAdmin() && !rule.getTenantId().isNullUid()) {
|
|
|
257
|
+// return ValidationResult.accessDenied("Rule is not in system scope!");
|
|
|
258
|
+// } else {
|
|
|
259
|
+// return ValidationResult.ok();
|
|
|
260
|
+// }
|
|
|
261
|
+// }
|
|
|
262
|
+// }));
|
|
|
263
|
+// }
|
|
|
264
|
+// }
|
|
|
265
|
+//
|
|
|
266
|
+// private void validateRuleChain(final PluginApiCallSecurityContext ctx, EntityId entityId, ValidationCallback callback) {
|
|
|
267
|
+// if (ctx.isCustomerUser()) {
|
|
|
268
|
+// callback.onSuccess(this, ValidationResult.accessDenied(CUSTOMER_USER_IS_NOT_ALLOWED_TO_PERFORM_THIS_OPERATION));
|
|
|
269
|
+// } else {
|
|
|
270
|
+// ListenableFuture<RuleChain> ruleChainFuture = pluginCtx.ruleChainService.findRuleChainByIdAsync(new RuleChainId(entityId.getId()));
|
|
|
271
|
+// Futures.addCallback(ruleChainFuture, getCallback(callback, ruleChain -> {
|
|
|
272
|
+// if (ruleChain == null) {
|
|
|
273
|
+// return ValidationResult.entityNotFound("Rule chain with requested id wasn't found!");
|
|
|
274
|
+// } else {
|
|
|
275
|
+// if (ctx.isTenantAdmin() && !ruleChain.getTenantId().equals(ctx.getTenantId())) {
|
|
|
276
|
+// return ValidationResult.accessDenied("Rule chain doesn't belong to the current Tenant!");
|
|
|
277
|
+// } else if (ctx.isSystemAdmin() && !ruleChain.getTenantId().isNullUid()) {
|
|
|
278
|
+// return ValidationResult.accessDenied("Rule chain is not in system scope!");
|
|
|
279
|
+// } else {
|
|
|
280
|
+// return ValidationResult.ok();
|
|
|
281
|
+// }
|
|
|
282
|
+// }
|
|
|
283
|
+// }));
|
|
|
284
|
+// }
|
|
|
285
|
+// }
|
|
|
286
|
+//
|
|
|
287
|
+//
|
|
|
288
|
+// private void validatePlugin(final PluginApiCallSecurityContext ctx, EntityId entityId, ValidationCallback callback) {
|
|
|
289
|
+// if (ctx.isCustomerUser()) {
|
|
|
290
|
+// callback.onSuccess(this, ValidationResult.accessDenied(CUSTOMER_USER_IS_NOT_ALLOWED_TO_PERFORM_THIS_OPERATION));
|
|
|
291
|
+// } else {
|
|
|
292
|
+// ListenableFuture<PluginMetaData> pluginFuture = pluginCtx.pluginService.findPluginByIdAsync(new PluginId(entityId.getId()));
|
|
|
293
|
+// Futures.addCallback(pluginFuture, getCallback(callback, plugin -> {
|
|
|
294
|
+// if (plugin == null) {
|
|
|
295
|
+// return ValidationResult.entityNotFound("Plugin with requested id wasn't found!");
|
|
|
296
|
+// } else {
|
|
|
297
|
+// if (ctx.isTenantAdmin() && !plugin.getTenantId().equals(ctx.getTenantId())) {
|
|
|
298
|
+// return ValidationResult.accessDenied("Plugin doesn't belong to the current Tenant!");
|
|
|
299
|
+// } else if (ctx.isSystemAdmin() && !plugin.getTenantId().isNullUid()) {
|
|
|
300
|
+// return ValidationResult.accessDenied("Plugin is not in system scope!");
|
|
|
301
|
+// } else {
|
|
|
302
|
+// return ValidationResult.ok();
|
|
|
303
|
+// }
|
|
|
304
|
+// }
|
|
|
305
|
+// }));
|
|
|
306
|
+// }
|
|
|
307
|
+// }
|
|
|
308
|
+//
|
|
|
309
|
+// private void validateCustomer(final PluginApiCallSecurityContext ctx, EntityId entityId, ValidationCallback callback) {
|
|
|
310
|
+// if (ctx.isSystemAdmin()) {
|
|
|
311
|
+// callback.onSuccess(this, ValidationResult.accessDenied(SYSTEM_ADMINISTRATOR_IS_NOT_ALLOWED_TO_PERFORM_THIS_OPERATION));
|
|
|
312
|
+// } else {
|
|
|
313
|
+// ListenableFuture<Customer> customerFuture = pluginCtx.customerService.findCustomerByIdAsync(new CustomerId(entityId.getId()));
|
|
|
314
|
+// Futures.addCallback(customerFuture, getCallback(callback, customer -> {
|
|
|
315
|
+// if (customer == null) {
|
|
|
316
|
+// return ValidationResult.entityNotFound("Customer with requested id wasn't found!");
|
|
|
317
|
+// } else {
|
|
|
318
|
+// if (!customer.getTenantId().equals(ctx.getTenantId())) {
|
|
|
319
|
+// return ValidationResult.accessDenied("Customer doesn't belong to the current Tenant!");
|
|
|
320
|
+// } else if (ctx.isCustomerUser() && !customer.getId().equals(ctx.getCustomerId())) {
|
|
|
321
|
+// return ValidationResult.accessDenied("Customer doesn't relate to the currently authorized customer user!");
|
|
|
322
|
+// } else {
|
|
|
323
|
+// return ValidationResult.ok();
|
|
|
324
|
+// }
|
|
|
325
|
+// }
|
|
|
326
|
+// }));
|
|
|
327
|
+// }
|
|
|
328
|
+// }
|
|
|
329
|
+//
|
|
|
330
|
+// private void validateTenant(final PluginApiCallSecurityContext ctx, EntityId entityId, ValidationCallback callback) {
|
|
|
331
|
+// if (ctx.isCustomerUser()) {
|
|
|
332
|
+// callback.onSuccess(this, ValidationResult.accessDenied(CUSTOMER_USER_IS_NOT_ALLOWED_TO_PERFORM_THIS_OPERATION));
|
|
|
333
|
+// } else if (ctx.isSystemAdmin()) {
|
|
|
334
|
+// callback.onSuccess(this, ValidationResult.ok());
|
|
|
335
|
+// } else {
|
|
|
336
|
+// ListenableFuture<Tenant> tenantFuture = pluginCtx.tenantService.findTenantByIdAsync(new TenantId(entityId.getId()));
|
|
|
337
|
+// Futures.addCallback(tenantFuture, getCallback(callback, tenant -> {
|
|
|
338
|
+// if (tenant == null) {
|
|
|
339
|
+// return ValidationResult.entityNotFound("Tenant with requested id wasn't found!");
|
|
|
340
|
+// } else if (!tenant.getId().equals(ctx.getTenantId())) {
|
|
|
341
|
+// return ValidationResult.accessDenied("Tenant doesn't relate to the currently authorized user!");
|
|
|
342
|
+// } else {
|
|
|
343
|
+// return ValidationResult.ok();
|
|
|
344
|
+// }
|
|
|
345
|
+// }));
|
|
|
346
|
+// }
|
|
|
347
|
+// }
|
|
|
348
|
+
|
|
|
349
|
+
|
|
|
350
|
+} |