-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/#777 #783
Feature/#777 #783
Changes from 3 commits
69b4660
9cb4074
734f254
7109714
9f28e22
d6e3c9d
ce5f56d
b446fc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ import au.org.ala.plugins.openapi.Path | |
type = SecuritySchemeType.HTTP, | ||
scheme = "bearer" | ||
) | ||
@RequireApiKey() | ||
|
||
class ApiController extends BaseController { | ||
static namespace = "v1" | ||
static allowedSortFields = ['scientificNameLower', 'lastUpdated', 'dateCreated'] | ||
|
@@ -34,6 +34,7 @@ class ApiController extends BaseController { | |
MapService mapService | ||
ApiService apiService | ||
|
||
@RequireApiKey() | ||
@Path("/api/opus/{opusId}") | ||
@Operation( | ||
summary = "Get collection (opus) details", | ||
|
@@ -106,6 +107,41 @@ class ApiController extends BaseController { | |
} | ||
} | ||
|
||
@Path("/api/opus/list") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename to |
||
@Operation( | ||
summary = "Get all collection (opus) details", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps better to reword it to |
||
operationId = "/api/opus/list", | ||
method = "GET", | ||
responses = [ | ||
@ApiResponse( | ||
responseCode = "200", | ||
content = @Content( | ||
mediaType = "application/json", | ||
array = @ArraySchema( | ||
schema = @Schema( | ||
implementation = OpusResponse.class | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace with CollectionList since OpusResponse has a lost more properties than what is returned by this API. |
||
) | ||
) | ||
) | ||
), | ||
@ApiResponse(responseCode = "400", | ||
description = "opusId is a required parameter"), | ||
@ApiResponse(responseCode = "403", | ||
description = "You do not have the necessary permissions to perform this action."), | ||
@ApiResponse(responseCode = "405", | ||
description = "An unexpected error has occurred while processing your request."), | ||
@ApiResponse(responseCode = "404", | ||
description = "Collection not found"), | ||
@ApiResponse(responseCode = "500", | ||
description = "An unexpected error has occurred while processing your request.") | ||
] | ||
) | ||
def getListCollections () { | ||
List opus = profileService.getOpusList() as List | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reuse |
||
render opus as JSON | ||
} | ||
|
||
@RequireApiKey() | ||
@Path("/api/opus/{opusId}/profile") | ||
@Operation( | ||
summary = "List profiles in a collection", | ||
|
@@ -245,6 +281,7 @@ class ApiController extends BaseController { | |
} | ||
} | ||
|
||
@RequireApiKey() | ||
@Path("/api/opus/{opusId}/profile/{profileId}") | ||
@Operation( | ||
summary = "Get a profile in a collection", | ||
|
@@ -333,6 +370,7 @@ class ApiController extends BaseController { | |
} | ||
} | ||
|
||
@RequireApiKey() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove. applies to other implementations. |
||
@Path("/api/opus/{opusId}/profile/{profileId}/draft") | ||
@Operation( | ||
summary = "Get a draft profile in a collection", | ||
|
@@ -416,6 +454,7 @@ class ApiController extends BaseController { | |
} | ||
} | ||
|
||
@RequireApiKey() | ||
@Path("/api/opus/{opusId}/profile/{profileId}/image") | ||
@Operation( | ||
summary = "Get images associated with a profile", | ||
|
@@ -510,6 +549,7 @@ class ApiController extends BaseController { | |
} | ||
} | ||
|
||
@RequireApiKey() | ||
@Path("/api/opus/{opusId}/profile/{profileId}/attribute/{attributeId}") | ||
@Operation( | ||
summary = "Get attributes of a profile in a collection", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,8 @@ class ApiInterceptor { | |
Class controllerClass = controller?.clazz | ||
def method = controllerClass?.getMethod(actionName, [] as Class[]) | ||
|
||
if (method.name == "getListCollections") return true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should not escape api interceptor logic. |
||
|
||
if (authorization) { | ||
if (params.opusId && (opus = profileService.getOpus(params.opusId))) { | ||
params.isOpusPrivate = opus.privateCollection | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -263,6 +263,7 @@ class UrlMappings { | |
get "/opus/$opusId/profile/$profileId/image" (version: "1.0", controller: "api", action: "getImages", 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/list" (version: "1.0", controller: "api", action: "getListCollections", namespace: "v1") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be |
||
} | ||
|
||
"/openapi/$action?/$id?(.$format)?"(controller: "openApi") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,11 @@ class ProfileService { | |
webServiceWrapperService.get("${grailsApplication.config.profile.service.url}/opus/${encPath(opusId)}", [:], ContentType.APPLICATION_JSON, true, false, getCustomHeaderWithUserId())?.resp | ||
} | ||
|
||
def getOpusList() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment above. |
||
webServiceWrapperService.get("${grailsApplication.config.profile.service.url}/opus/list", [:], ContentType.APPLICATION_JSON, false, false, null)?.resp | ||
} | ||
|
||
|
||
def updateOpus(String opusId, Map json) { | ||
webService.post("${grailsApplication.config.profile.service.url}/opus/${encPath(opusId)}", json, [:], ContentType.APPLICATION_JSON, true, false, getCustomHeaderWithUserId()) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is requireapikey required? Similarly other below actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previous ApiController class had @RequireApiKey. so I put it into all method except api/opus/list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep security standard for all actions.