@RequestMapping(value="/{typeId}/apps/{appId}/import", method = RequestMethod.GET)
public @ResponseBody RestResponse<String> importScan(@PathVariable("appId") int appId) {
log.info("Processing request for scan import.");
RemoteProviderApplication remoteProviderApplication = remoteProviderApplicationService.load(appId);
if (remoteProviderApplication == null || remoteProviderApplication.getApplication() == null) {
return RestResponse.failure("The requested application wasn't found.");
}
if (remoteProviderApplication.getApplication().getId() == null ||
remoteProviderApplication.getApplication().getOrganization() == null ||
remoteProviderApplication.getApplication().getOrganization().getId() == null ||
!PermissionUtils.isAuthorized(Permission.CAN_UPLOAD_SCANS,
remoteProviderApplication.getApplication().getOrganization().getId(),
remoteProviderApplication.getApplication().getId())) {
return RestResponse.failure("You don't have permission to do that.");
}
remoteProviderTypeService.decryptCredentials(
remoteProviderApplication.getRemoteProviderType());
ResponseCode response = remoteProviderTypeService.importScansForApplication(remoteProviderApplication);
if (response.equals(ResponseCode.SUCCESS)) {
return RestResponse.success("Do the redirect");