upd
This commit is contained in:
parent
808a384165
commit
5861520542
@ -158,12 +158,8 @@ public class AdminController extends BaseController {
|
||||
@RequestMapping(value = "/jwtSettings", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public JwtSettings getJwtSettings() throws ThingsboardException {
|
||||
try {
|
||||
accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.READ);
|
||||
return checkNotNull(jwtSettingsService.getJwtSettings());
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Update JWT Settings (saveJwtSettings)",
|
||||
@ -175,14 +171,10 @@ public class AdminController extends BaseController {
|
||||
public JwtPair saveJwtSettings(
|
||||
@ApiParam(value = "A JSON value representing the JWT Settings.")
|
||||
@RequestBody JwtSettings jwtSettings) throws ThingsboardException {
|
||||
try {
|
||||
SecurityUser securityUser = getCurrentUser();
|
||||
accessControlService.checkPermission(securityUser, Resource.ADMIN_SETTINGS, Operation.WRITE);
|
||||
checkNotNull(jwtSettingsService.saveJwtSettings(jwtSettings));
|
||||
return tokenFactory.createTokenPair(securityUser);
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Send test email (sendTestMail)",
|
||||
|
||||
@ -78,12 +78,8 @@ public class AssetProfileController extends BaseController {
|
||||
@ApiParam(value = ASSET_PROFILE_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable(ASSET_PROFILE_ID) String strAssetProfileId) throws ThingsboardException {
|
||||
checkParameter(ASSET_PROFILE_ID, strAssetProfileId);
|
||||
try {
|
||||
AssetProfileId assetProfileId = new AssetProfileId(toUUID(strAssetProfileId));
|
||||
return checkAssetProfileId(assetProfileId, Operation.READ);
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Get Asset Profile Info (getAssetProfileInfoById)",
|
||||
@ -97,12 +93,8 @@ public class AssetProfileController extends BaseController {
|
||||
@ApiParam(value = ASSET_PROFILE_ID_PARAM_DESCRIPTION)
|
||||
@PathVariable(ASSET_PROFILE_ID) String strAssetProfileId) throws ThingsboardException {
|
||||
checkParameter(ASSET_PROFILE_ID, strAssetProfileId);
|
||||
try {
|
||||
AssetProfileId assetProfileId = new AssetProfileId(toUUID(strAssetProfileId));
|
||||
return new AssetProfileInfo(checkAssetProfileId(assetProfileId, Operation.READ));
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Get Default Asset Profile (getDefaultAssetProfileInfo)",
|
||||
@ -113,11 +105,7 @@ public class AssetProfileController extends BaseController {
|
||||
@RequestMapping(value = "/assetProfileInfo/default", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public AssetProfileInfo getDefaultAssetProfileInfo() throws ThingsboardException {
|
||||
try {
|
||||
return checkNotNull(assetProfileService.findDefaultAssetProfileInfo(getTenantId()));
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Create Or Update Asset Profile (saveAssetProfile)",
|
||||
@ -191,12 +179,8 @@ public class AssetProfileController extends BaseController {
|
||||
@RequestParam(required = false) String sortProperty,
|
||||
@ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
||||
try {
|
||||
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
|
||||
return checkNotNull(assetProfileService.findAssetProfiles(getTenantId(), pageLink));
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Get Asset Profile infos (getAssetProfileInfos)",
|
||||
@ -217,11 +201,7 @@ public class AssetProfileController extends BaseController {
|
||||
@RequestParam(required = false) String sortProperty,
|
||||
@ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
||||
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
||||
try {
|
||||
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
|
||||
return checkNotNull(assetProfileService.findAssetProfileInfos(getTenantId(), pageLink));
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,19 +465,7 @@ public class EdgeController extends BaseController {
|
||||
try {
|
||||
accessControlService.checkPermission(user, Resource.EDGE, Operation.READ, edge.getId(), edge);
|
||||
return true;
|
||||
} final DeferredResult<ResponseEntity> response = new DeferredResult<>();
|
||||
if (isEdgesEnabled()) {
|
||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||
edgeId = checkNotNull(edgeId);
|
||||
SecurityUser user = getCurrentUser();
|
||||
TenantId tenantId = user.getTenantId();
|
||||
ToEdgeSyncRequest request = new ToEdgeSyncRequest(UUID.randomUUID(), tenantId, edgeId);
|
||||
edgeRpcService.processSyncRequest(request, fromEdgeSyncResponse -> reply(response, fromEdgeSyncResponse));
|
||||
} else {
|
||||
throw new ThingsboardException("Edges support disabled", ThingsboardErrorCode.GENERAL);
|
||||
}
|
||||
return response;
|
||||
catch (ThingsboardException e) {
|
||||
} catch (ThingsboardException e) {
|
||||
return false;
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.thingsboard.server.controller;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@ -372,7 +373,7 @@ public class RuleChainController extends BaseController {
|
||||
@ApiParam(value = "Script language: JS or TBEL")
|
||||
@RequestParam(required = false) ScriptLanguage scriptLang,
|
||||
@ApiParam(value = "Test JS request. See API call description above.")
|
||||
@RequestBody JsonNode inputParams) throws ThingsboardException {
|
||||
@RequestBody JsonNode inputParams) throws ThingsboardException, JsonProcessingException {
|
||||
String script = inputParams.get("script").asText();
|
||||
String scriptType = inputParams.get("scriptType").asText();
|
||||
JsonNode argNamesJson = inputParams.get("argNames");
|
||||
|
||||
@ -114,11 +114,7 @@ public class DefaultSmsService implements SmsService {
|
||||
@Override
|
||||
public void sendTestSms(TestSmsRequest testSmsRequest) throws ThingsboardException {
|
||||
SmsSender testSmsSender;
|
||||
try {
|
||||
testSmsSender = this.smsSenderFactory.createSmsSender(testSmsRequest.getProviderConfiguration());
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
}
|
||||
this.sendSms(testSmsSender, testSmsRequest.getNumberTo(), testSmsRequest.getMessage());
|
||||
testSmsSender.destroy();
|
||||
}
|
||||
@ -129,11 +125,7 @@ public class DefaultSmsService implements SmsService {
|
||||
}
|
||||
|
||||
private int sendSms(SmsSender smsSender, String numberTo, String message) throws ThingsboardException {
|
||||
try {
|
||||
return smsSender.sendSms(numberTo, message);
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private ThingsboardException handleException(Exception exception) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user