Skip to content

Commit

Permalink
Updated image metadata endpoint to include opusId
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-brinkman committed Dec 11, 2023
1 parent df8031e commit a87c340
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
profileHubVersion=4.2
profileHubVersion=4.2.1-SNAPSHOT
grailsVersion=5.2.4
grailsGradlePluginVersion=5.2.3
groovyVersion=3.0.11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ profileEditor.directive('imageUpload', function ($browser, $http, config) {
$scope.metadata.created = util.formatLocalDate($scope.metadata.created);
$cacheFactory.get('$http').removeAll();

profileService.saveImageMetadata($scope.image.imageId, $scope.metadata).then(function(data) {
profileService.saveImageMetadata($scope.opusId, $scope.image.imageId, $scope.metadata).then(function(data) {
if (angular.isDefined($scope.callbackHandler)) {
$scope.callbackHandler(data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,12 +586,12 @@ profileEditor.service('profileService', function ($http, util, $cacheFactory, co
return util.toStandardPromise(future);
},

saveImageMetadata: function(imageId, data) {
saveImageMetadata: function(opusId, imageId, data) {
$log.debug("Saving image metadata: " + imageId);
var future = null;
if (imageId) {
if (opusId && imageId) {
future = enqueue(function() {
return $http.post(util.contextRoot() + "/image/" + imageId + "/metadata", data)
return $http.post(util.contextRoot() + "/opus/" + opusId + "/image/" + imageId + "/metadata", data)
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ class ProfileController extends BaseController {
@Secured(role = ROLE_PROFILE_EDITOR)
def updateLocalImageMetadata() {
def metadata = request.getJSON()
if (!params.imageId || !metadata) {
badRequest "imageId or metadata is required"
if (!params.opusId || !params.imageId || !metadata) {
badRequest "opusId, imageId and metadata is required"
} else {
handle imageService.updateLocalImageMetadata(params.imageId, metadata)
handle imageService.updateLocalImageMetadata(params.opusId, params.imageId, metadata)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class UrlMappings {

"/opus/$opusId/statistics" controller: "statistics", action: [GET: "index"]
"/opus/$opusId/image/$filename" controller: "opus", action: [GET: "downloadImage", DELETE: "deleteImage"]
"/opus/$opusId/image/$imageId/metadata" controller: "profile", action: [POST: "updateLocalImageMetadata"]
"/opus/$opusId/image" controller: "opus", action: [POST: "uploadImage", PUT: "uploadImage"]

"/opus/$opusId/update" controller: "opus", action: [GET: "edit", POST: "updateOpus"]
Expand Down Expand Up @@ -187,8 +188,6 @@ class UrlMappings {
"/publication/$pubId" controller: "profile", action: [GET: "getPublication"]
"/publication/$pubId/json" controller: "profile", action: [GET: "getPublicationJson"]

"/image/$imageId/metadata" controller: "profile", action: [POST: "updateLocalImageMetadata"]

"/" controller: "opus", action: [GET: "index"]

"/logout/logout" controller: "logout", action: "logout"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,8 @@ class ImageService {
return ImageOption.byName(displayOptionStr, defaultOption) == ImageOption.INCLUDE
}

def updateLocalImageMetadata(String imageId, Map metadata) {
webService.post("${grailsApplication.config.profile.service.url}/image/${encPath(imageId)}/metadata", metadata, [:], ContentType.APPLICATION_JSON, true, false, profileService.getCustomHeaderWithUserId())
def updateLocalImageMetadata(String opusId, String imageId, Map metadata) {
webService.post("${grailsApplication.config.profile.service.url}/opus/${opusId}/image/${encPath(imageId)}/metadata", metadata, [:], ContentType.APPLICATION_JSON, true, false, profileService.getCustomHeaderWithUserId())
}

def publishPrivateImage(String opusId, String profileId, String imageId) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/js/specs/services/ProfileServiceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ describe("ProfileService tests", function () {

it("should invoke the updateLocalImageMetadata service on the context root when saveImageMetadata is called", function() {
var data = {creator: "one", createdDate: new Date(), rights: "rights", licence: "licence"};
service.saveImageMetadata('abcdefghijlkmnop', data);
service.saveImageMetadata('opusId', 'abcdefghijlkmnop', data);

http.expectPOST("/someContext/image/abcdefghijlkmnop/metadata", data).respond("bla");
http.expectPOST("/someContext/opus/opusId/image/abcdefghijlkmnop/metadata", data).respond("bla");
});

it("should invoke GET request when getImageMetadata is called", function() {
Expand Down

0 comments on commit a87c340

Please sign in to comment.