Class ImportEndpoint
java.lang.Object
com.broadleafcommerce.dataimport.web.endpoint.ImportEndpoint
@FrameworkRestController
@FrameworkMapping("/imports")
@DataRouteByExample(Import.class)
public class ImportEndpoint
extends Object
Endpoint for generally applicable operations on imports.
- Author:
- Phillip Verheyden (phillipuniverse)
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Exception thrown bydownloadErrorsReport(String, ContextInfo, HttpServletResponse)
when an import does not satisfy the conditions ofErrorsReportService.isEligibleForErrorsDownload(Import)
. -
Constructor Summary
ConstructorDescriptionImportEndpoint
(ImportManager importManager, ImportService<Import> importService, ErrorsReportService errorsReportService, BatchItemCompletionService<BatchItemCompletion> batchItemCompletionService, StorageService storage, ImportSpecificationService importSpecificationService) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Object>
cancelImport
(String importId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody>
downloadErrorsReport
(String importId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, javax.servlet.http.HttpServletResponse response) org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody>
downloadOriginalFile
(String importId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, javax.servlet.http.HttpServletResponse response) protected BatchItemCompletionService<BatchItemCompletion>
protected ErrorsReportService
protected ImportManager
protected ImportService<Import>
protected ImportSpecificationService
org.springframework.data.domain.Page<BatchItemCompletion>
getItemCompletions
(String importId, org.springframework.data.domain.Pageable pageable, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) getSpecifications
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected StorageService
protected String
getUserFriendlyFilenameForImport
(Import metadata) org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError>
handleErrorsReportException
(Exception ex, org.springframework.web.context.request.WebRequest request) org.springframework.http.ResponseEntity<ImportValidationApiError>
handleImportValidationException
(ImportValidationException ex, org.springframework.web.context.request.WebRequest request) org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError>
handleIneligibleForErrorsReportException
(Exception ex, org.springframework.web.context.request.WebRequest request) Custom exception and exception handler to produce this response.org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError>
handleInvalidUploadRequest
(Exception ex, org.springframework.web.context.request.WebRequest request) org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError>
handleReadImportFileException
(Exception ex, org.springframework.web.context.request.WebRequest request) protected void
org.springframework.data.domain.Page<Import>
readSystemImports
(Boolean isActive, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) start
(ImportRequest request, org.springframework.web.multipart.MultipartFile file, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
Constructor Details
-
ImportEndpoint
public ImportEndpoint(ImportManager importManager, ImportService<Import> importService, ErrorsReportService errorsReportService, BatchItemCompletionService<BatchItemCompletion> batchItemCompletionService, StorageService storage, ImportSpecificationService importSpecificationService)
-
-
Method Details
-
start
@FrameworkPostMapping("/start") @Policy(permissionRoots="IMPORT") public Import start(@RequestPart("request") ImportRequest request, @RequestPart("data") org.springframework.web.multipart.MultipartFile file, @ContextOperation(CREATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
readSystemImports
@FrameworkGetMapping @Policy(permissionRoots="IMPORT") public org.springframework.data.domain.Page<Import> readSystemImports(@RequestParam(value="isActive",required=false) @Nullable Boolean isActive, @PageableDefault(size=50) org.springframework.data.domain.Pageable pageable, @ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getSpecifications
@FrameworkGetMapping("/specifications") @Policy(permissionRoots="IMPORT") public List<ImportSpecificationResponse> getSpecifications(@ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getImport
-
getItemCompletions
@FrameworkGetMapping("/{id}/completed-items") @Policy(permissionRoots="IMPORT") public org.springframework.data.domain.Page<BatchItemCompletion> getItemCompletions(@PathVariable("id") String importId, @PageableDefault(size=50) org.springframework.data.domain.Pageable pageable, cz.jirutka.rsql.parser.ast.Node filters, @ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
cancelImport
-
downloadErrorsReport
@FrameworkGetMapping("/{id}/errors") @Policy(permissionRoots="DOWNLOAD_IMPORT_ERRORS", operationTypes=READ) public org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody> downloadErrorsReport(@PathVariable("id") String importId, @ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, javax.servlet.http.HttpServletResponse response) -
getUserFriendlyFilenameForImport
-
downloadOriginalFile
@FrameworkGetMapping("/{id}/original") @Policy(permissionRoots="DOWNLOAD_ORIGINAL_IMPORT_FILE", operationTypes=READ) public org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody> downloadOriginalFile(@PathVariable("id") String importId, @ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, javax.servlet.http.HttpServletResponse response) -
handleInvalidUploadRequest
@ExceptionHandler({org.springframework.web.multipart.MultipartException.class,org.springframework.web.multipart.MaxUploadSizeExceededException.class}) public org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> handleInvalidUploadRequest(Exception ex, org.springframework.web.context.request.WebRequest request) -
handleImportValidationException
@ExceptionHandler(ImportValidationException.class) public org.springframework.http.ResponseEntity<ImportValidationApiError> handleImportValidationException(ImportValidationException ex, org.springframework.web.context.request.WebRequest request) -
handleReadImportFileException
@ExceptionHandler(ReadOriginalImportFileException.class) public org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> handleReadImportFileException(Exception ex, org.springframework.web.context.request.WebRequest request) -
handleErrorsReportException
@ExceptionHandler(ErrorsReportException.class) public org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> handleErrorsReportException(Exception ex, org.springframework.web.context.request.WebRequest request) -
handleIneligibleForErrorsReportException
@ExceptionHandler(IneligibleForErrorsReportException.class) public org.springframework.http.ResponseEntity<com.broadleafcommerce.common.error.ApiError> handleIneligibleForErrorsReportException(Exception ex, org.springframework.web.context.request.WebRequest request) Custom exception and exception handler to produce this response. This is because the method return type fordownloadErrorsReport(String, ContextInfo, HttpServletResponse)
must beStreamingResponseBody
, or Spring will not use theStreamingResponseBodyReturnValueHandler
, and the endpoint will return a 406 in the "ok" case.Separating this error response into an exception handler allows the return type of the original method to remain the same.
- Parameters:
ex
- the thrownImportEndpoint.IneligibleForErrorsReportException
- Returns:
- an ApiError response body
-
logDebug
-
getImportManager
-
getImportService
-
getErrorsReportService
-
getBatchItemCompletionService
-
getStorage
-
getImportSpecificationService
-