r2017 - in trunk: wao-persistence/src/main/java/fr/ifremer/wao/entity wao-persistence/src/main/xmi wao-services/src/main/java/fr/ifremer/wao/services
Author: bleny Date: 2014-06-10 15:34:51 +0200 (Tue, 10 Jun 2014) New Revision: 2017 Url: http://forge.codelutin.com/projects/wao/repository/revisions/2017 Log: fixes #5068 Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/UserProfileImpl.java trunk/wao-persistence/src/main/xmi/wao-model.zargo trunk/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/UserProfileImpl.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/UserProfileImpl.java 2014-06-10 13:17:12 UTC (rev 2016) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/UserProfileImpl.java 2014-06-10 13:34:51 UTC (rev 2017) @@ -80,7 +80,7 @@ @Override public boolean isReadOnly() { - return ! getCanWrite(); + return ! isCanWrite(); } @Override Modified: trunk/wao-persistence/src/main/xmi/wao-model.zargo =================================================================== (Binary files differ) Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java 2014-06-10 13:17:12 UTC (rev 2016) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java 2014-06-10 13:34:51 UTC (rev 2017) @@ -90,8 +90,8 @@ return userProfile.getObsProgram(); } - public Boolean getCanWrite() { - return userProfile.getCanWrite(); + public boolean isCanWrite() { + return userProfile.isCanWrite(); } public UserRole getUserRole() { @@ -108,41 +108,41 @@ || isAuthorizedToSetObserver() || isAuthorizedToSetGuest() || isAuthorizedToSetProfessional(); - return authorizedToChangeUserRights; + return authorizedToChangeUserRights && isCanWrite(); } public boolean isAuthorizedToActiveUser() { - return userProfile.isAdmin(); + return userProfile.isAdmin() && isCanWrite(); } public boolean isAuthorizedToChangeUserCompany() { - return userProfile.isAdmin(); + return userProfile.isAdmin() && isCanWrite(); } public boolean isAuthorizedToSetAdmin() { - return userProfile.isAdmin(); + return userProfile.isAdmin() && isCanWrite(); } public boolean isAuthorizedToSetCoordinator() { - return userProfile.isAdmin(); + return userProfile.isAdmin() && isCanWrite(); } public boolean isAuthorizedToSetObserver() { boolean authorizedToSetObserver = userProfile.isAdmin() || userProfile.isCoordinator(); - return authorizedToSetObserver; + return authorizedToSetObserver && isCanWrite(); } public boolean isAuthorizedToSetGuest() { - return userProfile.isAdmin(); + return userProfile.isAdmin() && isCanWrite(); } public boolean isAuthorizedToSetProfessional() { - return userProfile.isAdmin(); + return userProfile.isAdmin() && isCanWrite(); } public boolean isAuthorizedToUpdateReferential() { - return userProfile.isAdmin(); + return userProfile.isAdmin() && isCanWrite(); } public boolean isAuthorizedToViewCompanies() { @@ -154,7 +154,7 @@ } public boolean isAuthorizedToCreateNews() { - return userProfile.isAdmin() || userProfile.isCoordinator(); + return (userProfile.isAdmin() || userProfile.isCoordinator()) && isCanWrite(); } public boolean isAuthorizedToEditOrDeleteNews(News news) { @@ -167,31 +167,31 @@ } else { authorizedToEditOrDeleteNews = false; } - return authorizedToEditOrDeleteNews; + return authorizedToEditOrDeleteNews && isCanWrite(); } public boolean isAuthorizedToCreateSampleRow() { - return userProfile.isAdmin(); + return userProfile.isAdmin() && isCanWrite(); } public boolean isAuthorizedToCommentSampleRow() { - return userProfile.isCoordinator(); + return userProfile.isCoordinator() && isCanWrite(); } public boolean isAuthorizedToImportSamplingPlan() { - return userProfile.isAdmin(); + return userProfile.isAdmin() && isCanWrite(); } public boolean isAuthorizedToImportContacts() { - return userProfile.isAdmin(); + return userProfile.isAdmin() && isCanWrite(); } public boolean isAuthorizedToEditSamplingPlan() { - return userProfile.isAdmin(); + return userProfile.isAdmin() && isCanWrite(); } public boolean isAuthorizedToCreateContact() { - return userProfile.isCoordinatorOrObserver(); + return userProfile.isCoordinatorOrObserver() && isCanWrite(); } public boolean isAuthorizedToViewSamplingPlanReal() { @@ -220,11 +220,12 @@ } public boolean isAuthorizedToEditOrDeleteContact(Contact contact) { - return isAuthorizedToEditContact(contact) || isAuthorizedToDeleteContact(contact); + boolean authorizedToEditOrDeleteContact = (isAuthorizedToEditContact(contact) || isAuthorizedToDeleteContact(contact)) && isCanWrite(); + return authorizedToEditOrDeleteContact; } public boolean isAuthorizedToEditContact(Contact contact) { - boolean canEdit = getCanWrite() && + boolean canEdit = isCanWrite() && // user is admin and no validation program (!isReadOnly() && isAdmin() && contact.getValidationProgram() == null @@ -238,43 +239,21 @@ public boolean isAuthorizedToDeleteContact(Contact contact) { boolean noValidation = contact.getValidationProgram() == null && contact.getValidationCompany() == null; - return noValidation && getCanWrite(); + return noValidation && isCanWrite(); } public boolean isAuthorizedToChangeValidationCompany() { - return userProfile.isCoordinator(); + return userProfile.isCoordinator() && isCanWrite(); } public boolean isAuthorizedToChangeValidationProgram() { - return userProfile.isAdmin(); + return userProfile.isAdmin() && isCanWrite(); } public boolean isAuthorizedToChangeContactValidation() { return isAuthorizedToChangeValidationCompany() || isAuthorizedToChangeValidationProgram(); } - public boolean isAuthorizedToUnvalidateContact(Contact contact) { - switch (getUserRole()) { - case ADMIN: - return contact.getValidationProgram() != null; - // Evo #2063 : only coordinator can unvalidate - case COORDINATOR: - return contact.getValidationCompany() != null && - contact.getValidationProgram() == null; - default: - return false; - } - } - - public boolean isAuthorizedToDisplayContactSecondaryObservers(Contact contact) { - boolean showSecondaryObservers = true; - if (contact.getSampleRow().isPhoneCall()) { - // when phoning, we are always single - showSecondaryObservers = false; - } - return showSecondaryObservers; - } - public boolean isAuthorizedToDisplayContactDataReliability() { return isAdmin() || isCoordinator(); } @@ -282,22 +261,25 @@ public boolean isAuthorizedToEditContactDataReliability(Contact contact) { boolean result = isAdmin() // coordinator can see the value && BooleanUtils.isTrue(contact.getValidationCompany()) - && contact.getValidationProgram() == null; + && contact.getValidationProgram() == null + && isCanWrite(); return result; } public boolean isAuthorizedToEditContactObservers(Contact contact) { return isCoordinatorOrObserver() && - contact.getValidationProgram() == null; + contact.getValidationProgram() == null + && isCanWrite(); } public boolean isAuthorizedToEditObservationReport(Contact contact) { return isCoordinatorOrObserver() && - contact.getValidationCompany() == null; + contact.getValidationCompany() == null + && isCanWrite(); } public boolean isAuthorizedToAllowUsersToSubscribeToMammalsNotifications() { - return isAdmin(); + return isAdmin() && isCanWrite(); } public boolean isAuthorizedToViewContacts() {
participants (1)
-
bleny@users.forge.codelutin.com