From 114dee4358f0c4ce94d693e8260816b517ccfb0b Mon Sep 17 00:00:00 2001 From: steven choi Date: Tue, 14 Nov 2023 10:14:48 +1100 Subject: [PATCH 1/2] #800 replace imageId to fileName --- .../au/org/ala/profile/api/ApiController.groovy | 16 ++++++++-------- .../org/ala/profile/hub/ProfileController.groovy | 8 ++++---- .../au/org/ala/profile/hub/UrlMappings.groovy | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/grails-app/controllers/au/org/ala/profile/api/ApiController.groovy b/grails-app/controllers/au/org/ala/profile/api/ApiController.groovy index b464416d..a7361628 100644 --- a/grails-app/controllers/au/org/ala/profile/api/ApiController.groovy +++ b/grails-app/controllers/au/org/ala/profile/api/ApiController.groovy @@ -549,10 +549,10 @@ class ApiController extends BaseController { } } - @Path("/api/opus/{opusId}/profile/{profileId}/image/{imageId}") + @Path("/api/opus/{opusId}/profile/{profileId}/image/{fileName}") @Operation( summary = "Get image associated with a profile", - operationId = "/api/opus/{opusId}/profile/{profileId}/image/{imageId}", + operationId = "/api/opus/{opusId}/profile/{profileId}/image/{fileName}", method = "GET", responses = [ @ApiResponse( @@ -587,10 +587,10 @@ class ApiController extends BaseController { in = ParameterIn.PATH, required = true, description = "Profile id - UUID or Scientific name"), - @Parameter(name = "imageId", + @Parameter(name = "fileName", in = ParameterIn.PATH, required = true, - description = "Image id - UUID"), + description = "fileName"), @Parameter(name = "type", in = ParameterIn.QUERY, required = true, @@ -623,10 +623,10 @@ class ApiController extends BaseController { forward controller: "profile", action: "getLocalImage" } - @Path("/api/opus/{opusId}/profile/{profileId}/image/thumbnail/{imageId}") + @Path("/api/opus/{opusId}/profile/{profileId}/image/thumbnail/{fileName}") @Operation( summary = "Get thumbnail image associated with a profile", - operationId = "/api/opus/{opusId}/profile/{profileId}/image/thumbnail/{imageId}", + operationId = "/api/opus/{opusId}/profile/{profileId}/image/thumbnail/{fileName}", method = "GET", responses = [ @ApiResponse( @@ -661,10 +661,10 @@ class ApiController extends BaseController { in = ParameterIn.PATH, required = true, description = "Profile id - UUID or Scientific name"), - @Parameter(name = "imageId", + @Parameter(name = "fileName", in = ParameterIn.PATH, required = true, - description = "Image id - UUID"), + description = "fileName"), @Parameter(name = "type", in = ParameterIn.QUERY, required = true, diff --git a/grails-app/controllers/au/org/ala/profile/hub/ProfileController.groovy b/grails-app/controllers/au/org/ala/profile/hub/ProfileController.groovy index 0168c43f..60708900 100644 --- a/grails-app/controllers/au/org/ala/profile/hub/ProfileController.groovy +++ b/grails-app/controllers/au/org/ala/profile/hub/ProfileController.groovy @@ -409,9 +409,9 @@ class ProfileController extends BaseController { ImageType type = params.type as ImageType //NB this imageId param already has the file extension on it, really the file name on disk if (type == ImageType.STAGED) { - displayLocalImage("${grailsApplication.config.image.staging.dir}/", params.opusId, params.profileId, params.imageId, true) + displayLocalImage("${grailsApplication.config.image.staging.dir}/", params.opusId, params.profileId, params.fileName, true) } else if (type == ImageType.PRIVATE) { - displayLocalImage("${grailsApplication.config.image.private.dir}/", params.opusId, params.profileId, params.imageId, true) + displayLocalImage("${grailsApplication.config.image.private.dir}/", params.opusId, params.profileId, params.fileName, true) } } catch (IllegalArgumentException e) { log.warn(e) @@ -428,9 +428,9 @@ class ProfileController extends BaseController { ImageType type = params.type as ImageType //NB this imageId param already has the file extension on it, really the file name on disk if (type == ImageType.STAGED) { - displayLocalImage("${grailsApplication.config.image.staging.dir}/", params.opusId, params.profileId, params.imageId, false) + displayLocalImage("${grailsApplication.config.image.staging.dir}/", params.opusId, params.profileId, params.fileName, false) } else if (type == ImageType.PRIVATE) { - displayLocalImage("${grailsApplication.config.image.private.dir}/", params.opusId, params.profileId, params.imageId, false) + displayLocalImage("${grailsApplication.config.image.private.dir}/", params.opusId, params.profileId, params.fileName, false) } } catch (IllegalArgumentException e) { log.warn(e) diff --git a/grails-app/controllers/au/org/ala/profile/hub/UrlMappings.groovy b/grails-app/controllers/au/org/ala/profile/hub/UrlMappings.groovy index aa65e764..fab17344 100644 --- a/grails-app/controllers/au/org/ala/profile/hub/UrlMappings.groovy +++ b/grails-app/controllers/au/org/ala/profile/hub/UrlMappings.groovy @@ -264,8 +264,8 @@ class UrlMappings { get "/opus/$opusId/profile" (version: "1.0", controller: "api", action: "getProfiles", namespace: "v1") get "/opus/$opusId/profile/$profileId" (version: "1.0", controller: "api", action: "get", namespace: "v1") get "/opus/$opusId/profile/$profileId/image" (version: "1.0", controller: "api", action: "getImages", namespace: "v1") - get "/opus/$opusId/profile/$profileId/image/$imageId" (version: "1.0", controller: "api", action: "getLocalImage", namespace: "v1") - get "/opus/$opusId/profile/$profileId/image/thumbnail/$imageId" (version: "1.0", controller: "api", action: "retrieveLocalThumbnailImage", namespace: "v1") + get "/opus/$opusId/profile/$profileId/image/$fileName" (version: "1.0", controller: "api", action: "getLocalImage", namespace: "v1") + get "/opus/$opusId/profile/$profileId/image/thumbnail/$fileName" (version: "1.0", controller: "api", action: "retrieveLocalThumbnailImage", namespace: "v1") get "/opus/$opusId/profile/$profileId/attribute/$attributeId" (version: "1.0", controller: "api", action: "getAttributes", namespace: "v1") get "/opus/$opusId/profile/$profileId/draft" (version: "1.0", controller: "api", action: "getDraftProfile", namespace: "v1") get "/opus" (version: "1.0", controller: "api", action: "getListCollections", namespace: "v1") From 415134c5b6a9d8718efd8a765ee679c8cfa8e101 Mon Sep 17 00:00:00 2001 From: steven choi Date: Tue, 14 Nov 2023 12:00:50 +1100 Subject: [PATCH 2/2] #785_2 fix --- .../au/org/ala/profile/api/ApiController.groovy | 2 ++ .../au/org/ala/profile/hub/ProfileController.groovy | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/grails-app/controllers/au/org/ala/profile/api/ApiController.groovy b/grails-app/controllers/au/org/ala/profile/api/ApiController.groovy index a7361628..d958a192 100644 --- a/grails-app/controllers/au/org/ala/profile/api/ApiController.groovy +++ b/grails-app/controllers/au/org/ala/profile/api/ApiController.groovy @@ -620,6 +620,7 @@ class ApiController extends BaseController { ) def getLocalImage() { + params.imageId = params.fileName forward controller: "profile", action: "getLocalImage" } @@ -694,6 +695,7 @@ class ApiController extends BaseController { ) def retrieveLocalThumbnailImage () { + params.imageId = params.fileName forward controller: "profile", action: "retrieveLocalThumbnailImage" } diff --git a/grails-app/controllers/au/org/ala/profile/hub/ProfileController.groovy b/grails-app/controllers/au/org/ala/profile/hub/ProfileController.groovy index 60708900..0168c43f 100644 --- a/grails-app/controllers/au/org/ala/profile/hub/ProfileController.groovy +++ b/grails-app/controllers/au/org/ala/profile/hub/ProfileController.groovy @@ -409,9 +409,9 @@ class ProfileController extends BaseController { ImageType type = params.type as ImageType //NB this imageId param already has the file extension on it, really the file name on disk if (type == ImageType.STAGED) { - displayLocalImage("${grailsApplication.config.image.staging.dir}/", params.opusId, params.profileId, params.fileName, true) + displayLocalImage("${grailsApplication.config.image.staging.dir}/", params.opusId, params.profileId, params.imageId, true) } else if (type == ImageType.PRIVATE) { - displayLocalImage("${grailsApplication.config.image.private.dir}/", params.opusId, params.profileId, params.fileName, true) + displayLocalImage("${grailsApplication.config.image.private.dir}/", params.opusId, params.profileId, params.imageId, true) } } catch (IllegalArgumentException e) { log.warn(e) @@ -428,9 +428,9 @@ class ProfileController extends BaseController { ImageType type = params.type as ImageType //NB this imageId param already has the file extension on it, really the file name on disk if (type == ImageType.STAGED) { - displayLocalImage("${grailsApplication.config.image.staging.dir}/", params.opusId, params.profileId, params.fileName, false) + displayLocalImage("${grailsApplication.config.image.staging.dir}/", params.opusId, params.profileId, params.imageId, false) } else if (type == ImageType.PRIVATE) { - displayLocalImage("${grailsApplication.config.image.private.dir}/", params.opusId, params.profileId, params.fileName, false) + displayLocalImage("${grailsApplication.config.image.private.dir}/", params.opusId, params.profileId, params.imageId, false) } } catch (IllegalArgumentException e) { log.warn(e)