|
|
@ -15,8 +15,11 @@ |
|
|
*/ |
|
|
*/ |
|
|
package org.thingsboard.server.controller; |
|
|
package org.thingsboard.server.controller; |
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
import com.google.common.util.concurrent.ListenableFuture; |
|
|
import com.google.common.util.concurrent.ListenableFuture; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.http.HttpStatus; |
|
|
import org.springframework.http.HttpStatus; |
|
|
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
import org.springframework.web.bind.annotation.PathVariable; |
|
|
import org.springframework.web.bind.annotation.PathVariable; |
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
@ -59,6 +62,7 @@ import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@RestController |
|
|
@RestController |
|
|
@TbCoreComponent |
|
|
@TbCoreComponent |
|
|
|
|
|
@Slf4j |
|
|
@RequestMapping("/api") |
|
|
@RequestMapping("/api") |
|
|
public class EdgeController extends BaseController { |
|
|
public class EdgeController extends BaseController { |
|
|
|
|
|
|
|
|
@ -544,27 +548,6 @@ public class EdgeController extends BaseController { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST) |
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
public Object checkInstance(@RequestBody Object request) throws ThingsboardException { |
|
|
|
|
|
try { |
|
|
|
|
|
return edgeService.checkInstance(request); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/license/activateInstance", params = {"licenseSecret", "releaseDate"}, method = RequestMethod.POST) |
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
public Object activateInstance(@RequestParam String licenseSecret, |
|
|
|
|
|
@RequestParam String releaseDate) throws ThingsboardException { |
|
|
|
|
|
try { |
|
|
|
|
|
return edgeService.activateInstance(licenseSecret, releaseDate); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')") |
|
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')") |
|
|
@RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET) |
|
|
@RequestMapping(value = "/edge/missingToRelatedRuleChains/{edgeId}", method = RequestMethod.GET) |
|
|
@ResponseBody |
|
|
@ResponseBody |
|
|
@ -583,4 +566,29 @@ public class EdgeController extends BaseController { |
|
|
private void cleanUpLicenseKey(Edge edge) { |
|
|
private void cleanUpLicenseKey(Edge edge) { |
|
|
edge.setEdgeLicenseKey(null); |
|
|
edge.setEdgeLicenseKey(null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/license/checkInstance", method = RequestMethod.POST) |
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
public ResponseEntity<JsonNode> checkInstance(@RequestBody JsonNode request) throws ThingsboardException { |
|
|
|
|
|
log.debug("Checking instance [{}]", request); |
|
|
|
|
|
try { |
|
|
|
|
|
return edgeService.checkInstance(request); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("Error occurred: [{}]", e.getMessage(), e); |
|
|
|
|
|
throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/license/activateInstance", params = {"licenseSecret", "releaseDate"}, method = RequestMethod.POST) |
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
public ResponseEntity<JsonNode> activateInstance(@RequestParam String licenseSecret, |
|
|
|
|
|
@RequestParam String releaseDate) throws ThingsboardException { |
|
|
|
|
|
log.debug("Activating instance [{}], [{}]", licenseSecret, releaseDate); |
|
|
|
|
|
try { |
|
|
|
|
|
return edgeService.activateInstance(licenseSecret, releaseDate); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("Error occurred: [{}]", e.getMessage(), e); |
|
|
|
|
|
throw new ThingsboardException(e, ThingsboardErrorCode.SUBSCRIPTION_VIOLATION); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|