|
|
|
@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.web.bind.annotation.RequestPart; |
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
@ -49,6 +50,8 @@ import org.thingsboard.server.service.security.permission.Resource; |
|
|
|
|
|
|
|
import java.nio.ByteBuffer; |
|
|
|
|
|
|
|
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; |
|
|
|
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE; |
|
|
|
import static org.thingsboard.server.controller.ControllerConstants.DEVICE_PROFILE_ID_PARAM_DESCRIPTION; |
|
|
|
import static org.thingsboard.server.controller.ControllerConstants.OTA_PACKAGE_CHECKSUM_ALGORITHM_ALLOWABLE_VALUES; |
|
|
|
import static org.thingsboard.server.controller.ControllerConstants.OTA_PACKAGE_DESCRIPTION; |
|
|
|
@ -105,7 +108,7 @@ public class OtaPackageController extends BaseController { |
|
|
|
@ApiOperation(value = "Get OTA Package Info (getOtaPackageInfoById)", |
|
|
|
notes = "Fetch the OTA Package Info object based on the provided OTA Package Id. " + |
|
|
|
OTA_PACKAGE_INFO_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH, |
|
|
|
produces = "application/json") |
|
|
|
produces = APPLICATION_JSON_VALUE) |
|
|
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
|
@RequestMapping(value = "/otaPackage/info/{otaPackageId}", method = RequestMethod.GET) |
|
|
|
@ResponseBody |
|
|
|
@ -123,7 +126,7 @@ public class OtaPackageController extends BaseController { |
|
|
|
@ApiOperation(value = "Get OTA Package (getOtaPackageById)", |
|
|
|
notes = "Fetch the OTA Package object based on the provided OTA Package Id. " + |
|
|
|
"The server checks that the OTA Package is owned by the same tenant. " + OTA_PACKAGE_DESCRIPTION + TENANT_AUTHORITY_PARAGRAPH, |
|
|
|
produces = "application/json") |
|
|
|
produces = APPLICATION_JSON_VALUE) |
|
|
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|
|
|
@RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.GET) |
|
|
|
@ResponseBody |
|
|
|
@ -144,8 +147,8 @@ public class OtaPackageController extends BaseController { |
|
|
|
"Specify existing OTA Package id to update the OTA Package Info. " + |
|
|
|
"Referencing non-existing OTA Package Id will cause 'Not Found' error. " + |
|
|
|
"\n\nOTA Package combination of the title with the version is unique in the scope of tenant. " + TENANT_AUTHORITY_PARAGRAPH, |
|
|
|
produces = "application/json", |
|
|
|
consumes = "application/json") |
|
|
|
produces = APPLICATION_JSON_VALUE, |
|
|
|
consumes = APPLICATION_JSON_VALUE) |
|
|
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|
|
|
@RequestMapping(value = "/otaPackage", method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ -168,9 +171,10 @@ public class OtaPackageController extends BaseController { |
|
|
|
|
|
|
|
@ApiOperation(value = "Save OTA Package data (saveOtaPackageData)", |
|
|
|
notes = "Update the OTA Package. Adds the date to the existing OTA Package Info" + TENANT_AUTHORITY_PARAGRAPH, |
|
|
|
produces = "application/json") |
|
|
|
produces = APPLICATION_JSON_VALUE, |
|
|
|
consumes = MULTIPART_FORM_DATA_VALUE) |
|
|
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|
|
|
@RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.POST) |
|
|
|
@RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.POST, consumes = MULTIPART_FORM_DATA_VALUE) |
|
|
|
@ResponseBody |
|
|
|
public OtaPackageInfo saveOtaPackageData(@ApiParam(value = OTA_PACKAGE_ID_PARAM_DESCRIPTION) |
|
|
|
@PathVariable(OTA_PACKAGE_ID) String strOtaPackageId, |
|
|
|
@ -179,7 +183,7 @@ public class OtaPackageController extends BaseController { |
|
|
|
@ApiParam(value = "OTA Package checksum algorithm.", allowableValues = OTA_PACKAGE_CHECKSUM_ALGORITHM_ALLOWABLE_VALUES) |
|
|
|
@RequestParam(CHECKSUM_ALGORITHM) String checksumAlgorithmStr, |
|
|
|
@ApiParam(value = "OTA Package data.") |
|
|
|
@RequestBody MultipartFile file) throws ThingsboardException { |
|
|
|
@RequestPart MultipartFile file) throws ThingsboardException { |
|
|
|
checkParameter(OTA_PACKAGE_ID, strOtaPackageId); |
|
|
|
checkParameter(CHECKSUM_ALGORITHM, checksumAlgorithmStr); |
|
|
|
try { |
|
|
|
@ -221,7 +225,7 @@ public class OtaPackageController extends BaseController { |
|
|
|
@ApiOperation(value = "Get OTA Package Infos (getOtaPackages)", |
|
|
|
notes = "Returns a page of OTA Package Info objects owned by tenant. " + |
|
|
|
PAGE_DATA_PARAMETERS + OTA_PACKAGE_INFO_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH, |
|
|
|
produces = "application/json") |
|
|
|
produces = APPLICATION_JSON_VALUE) |
|
|
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
|
@RequestMapping(value = "/otaPackages", method = RequestMethod.GET) |
|
|
|
@ResponseBody |
|
|
|
@ -246,7 +250,7 @@ public class OtaPackageController extends BaseController { |
|
|
|
@ApiOperation(value = "Get OTA Package Infos (getOtaPackages)", |
|
|
|
notes = "Returns a page of OTA Package Info objects owned by tenant. " + |
|
|
|
PAGE_DATA_PARAMETERS + OTA_PACKAGE_INFO_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH, |
|
|
|
produces = "application/json") |
|
|
|
produces = APPLICATION_JSON_VALUE) |
|
|
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
|
@RequestMapping(value = "/otaPackages/{deviceProfileId}/{type}", method = RequestMethod.GET) |
|
|
|
@ResponseBody |
|
|
|
@ -278,7 +282,7 @@ public class OtaPackageController extends BaseController { |
|
|
|
@ApiOperation(value = "Delete OTA Package (deleteOtaPackage)", |
|
|
|
notes = "Deletes the OTA Package. Referencing non-existing OTA Package Id will cause an error. " + |
|
|
|
"Can't delete the OTA Package if it is referenced by existing devices or device profile." + TENANT_AUTHORITY_PARAGRAPH, |
|
|
|
produces = "application/json") |
|
|
|
produces = APPLICATION_JSON_VALUE) |
|
|
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|
|
|
@RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.DELETE) |
|
|
|
@ResponseBody |
|
|
|
|