This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 521b88a0019cd253baf18b5088adeaad32eed6b7 Author: Yannick Martel <martel@©odelutin.com> Date: Fri Jan 30 10:55:59 2015 +0100 admin should be able to modify document (and its file) --- .../fr/ifremer/coselmar/services/v1/DocumentsWebService.java | 9 +++++---- coselmar-ui/src/main/webapp/js/coselmar-controllers.js | 2 +- coselmar-ui/src/main/webapp/views/documents/editDocument.html | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java index a2cd223..faf3a41 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java @@ -71,7 +71,7 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { private static final Log log = getLog(DocumentsWebService.class); public static final List<String> DOCUMENT_EDIT_ALLOWED_USER_ROLES = - Lists.newArrayList(CoselmarUserRole.EXPERT.name(), CoselmarUserRole.SUPERVISOR.name()); + Lists.newArrayList(CoselmarUserRole.ADMIN.name(), CoselmarUserRole.EXPERT.name(), CoselmarUserRole.SUPERVISOR.name()); public static final List<String> DOCUMENT_VIEW_ALLOWED_USER_ROLES = Lists.newArrayList( @@ -296,12 +296,11 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { Preconditions.checkNotNull(documentId); Preconditions.checkNotNull(uploadFile); - // retrieve user who will be assigned as document owner + // retrieve current user to check identity String userFullId = getFullUserIdFromShort(userWebToken.getUserId()); - CoselmarUser owner; try { - owner = getCoselmarUserDao().forTopiaIdEquals(userFullId).findUnique(); + getCoselmarUserDao().forTopiaIdEquals(userFullId).findUnique(); } catch (TopiaNoResultException tnre) { // Should not happened, cause user are not really deleted String message = String.format("Seems that logged user ('%s') does not exist anymore.", userFullId); @@ -314,6 +313,8 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { String documentFullId = getFullIdFromShort(Document.class, documentId); Document document = getDocumentDao().forTopiaIdEquals(documentFullId).findAny(); + // Get owner to place correctly the file + CoselmarUser owner = document.getOwner(); Pair<String, String> pathAndContentType = managerDocumentFile(uploadFile, owner); String filePath = pathAndContentType.getLeft(); String contentType = pathAndContentType.getRight(); diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index e9a17c8..aa12114 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -239,7 +239,7 @@ coselmarControllers.controller("DocumentViewCtrl", isValid = isValid && $scope.document.authors && $scope.document.authors.length > 0; isValid = isValid && $scope.document.copyright && $scope.document.copyright.length > 0; isValid = isValid && $scope.document.summary && $scope.document.summary.length > 0; - if (!$scope.document.fileName) { + if (!$scope.document.fileName && $scope.currentUser.role != 'ADMIN') { isValid = isValid && (($scope.document.externalUrl && $scope.document.externalUrl.length > 0) || $scope.upload.file); } return isValid; diff --git a/coselmar-ui/src/main/webapp/views/documents/editDocument.html b/coselmar-ui/src/main/webapp/views/documents/editDocument.html index bb6a4be..0cbb2fa 100644 --- a/coselmar-ui/src/main/webapp/views/documents/editDocument.html +++ b/coselmar-ui/src/main/webapp/views/documents/editDocument.html @@ -140,7 +140,7 @@ </div> </div> - <p ng-show="!document.externalUrl && !document.fileName && !upload.file" + <p ng-show="!document.externalUrl && !document.fileName && !upload.file !upload.file && currentUser.role != 'ADMIN'" class="help-block text-center clear">{{ 'document.message.requiredExternalUrlOrFile' | translate }}</p> </div> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.