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:
  • Constructor Details

  • 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

      @FrameworkGetMapping("/{id}") @Policy(permissionRoots="IMPORT") public Import getImport(@PathVariable String id, @ContextOperation(READ) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • 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

      @FrameworkPostMapping("/{id}/cancel") @Policy(permissionRoots="IMPORT") public org.springframework.http.ResponseEntity<Object> cancelImport(@PathVariable("id") String importId, @ContextOperation(UPDATE) com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • 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)
      See Also:
    • getUserFriendlyFilenameForImport

      protected String getUserFriendlyFilenameForImport(Import metadata)
    • 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 for downloadErrorsReport(String, ContextInfo, HttpServletResponse) must be StreamingResponseBody, or Spring will not use the StreamingResponseBodyReturnValueHandler, 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 thrown ImportEndpoint.IneligibleForErrorsReportException
      Returns:
      an ApiError response body
    • logDebug

      protected void logDebug(Exception ex, org.springframework.web.context.request.WebRequest request)
    • getImportManager

      protected ImportManager getImportManager()
    • getImportService

      protected ImportService<Import> getImportService()
    • getErrorsReportService

      protected ErrorsReportService getErrorsReportService()
    • getBatchItemCompletionService

      protected BatchItemCompletionService<BatchItemCompletion> getBatchItemCompletionService()
    • getStorage

      protected StorageService getStorage()
    • getImportSpecificationService

      protected ImportSpecificationService getImportSpecificationService()