CPD Results

The following document contains the results of PMD's CPD 7.27.0.

Duplications

File Line
org/tailormap/api/controller/LayerAttachedUploadsController.java 87
org/tailormap/api/controller/UploadsController.java 56
if (!uploadsService.checkIfModifiedSince(id, request.getDateHeader("If-Modified-Since"))) {
      return ResponseEntity.status(NOT_MODIFIED).build();
    }
    // TODO this would fail when we have added a LEGEND upload to a layer description, because the category would be
    //  wrong, since the frontend generating the url does not know the category of the upload, so it is likely to
    //  always use LAYER_ATTACHED_FILE.
    Upload upload = uploadRepository
        .findWithContentByIdAndCategory(id, category)
        .orElseThrow(() -> new ResponseStatusException(NOT_FOUND));

    return ResponseEntity.ok()
        .header("Content-Type", upload.getMimeType())
        .header(UploadsService.DESCRIPTION_HEADER_NAME, upload.getDescription())
        .lastModified(upload.getLastModified().toInstant())
        .contentLength(upload.getContentLength())
        .cacheControl(CacheControl.noCache().cachePublic())
        .body(upload.getContent());
  }
File Line
org/tailormap/api/controller/admin/AttributeStatisticsAdminController.java 36
org/tailormap/api/controller/admin/UniqueValuesAdminController.java 42
public AttributeStatisticsAdminController(
      FeatureTypeRepository featureTypeRepository, FeatureSourceFactoryHelper featureSourceFactoryHelper) {
    this.featureTypeRepository = featureTypeRepository;
    this.featureSourceFactoryHelper = featureSourceFactoryHelper;
  }

  @ExceptionHandler({ResponseStatusException.class})
  public ResponseEntity<?> handleException(ResponseStatusException ex) {
    // wrap the exception in a proper json response
    return ResponseEntity.status(ex.getStatusCode())
        .contentType(MediaType.APPLICATION_JSON)
        .body(new ErrorResponse()
            .message(
                ex.getReason() != null
                    ? ex.getReason()
                    : ex.getBody().getTitle())
            .code(ex.getStatusCode().value()));
  }

  /**
   * Retrieve attribute statistics for a feature type.
   *
   * @param featureTypeId the feature type id for which to retrieve statistics
   * @param attributeName the name of the attribute
   * @param filter an optional CQL filter to apply to the features before calculating statistics
   * @return @return the calculated statistics; fields may be null when not applicable or when no features match
   * @throws ResponseStatusException if the feature type or attribute does not exist, or if a bad request was
   *     submitted
   */
  @Operation(