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