mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-21 21:57:56 +01:00
Improve handling change of ownner exception.
This commit is contained in:
parent
1cabb59b2f
commit
51cfa961e6
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CollabChangeException
|
||||
extends ClientException
|
||||
{
|
||||
|
||||
private static final String MSG_KEY = "OWNER_ROLE_CAN_NOT_BE_CHANGED";
|
||||
|
||||
public CollabChangeException(@NotNull String email)
|
||||
{
|
||||
super("Collab email can not be change. " + email + " is the the owner.",Severity.WARNING);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getMsgBundleKey() {
|
||||
return MSG_KEY;
|
||||
}
|
||||
}
|
@ -299,7 +299,7 @@ public class MindmapController extends BaseController {
|
||||
|
||||
@RequestMapping(method = RequestMethod.PUT, value = "/maps/{id}/collabs/", consumes = {"application/json"}, produces = {"application/json"})
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
public void addCollab(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException, AccessDeniedSecurityException, InvalidEmailException, TooManyInactiveAccountsExceptions {
|
||||
public void addCollab(@PathVariable int id, @NotNull @RequestBody RestCollaborationList restCollabs) throws CollaborationException, MapCouldNotFoundException, AccessDeniedSecurityException, InvalidEmailException, TooManyInactiveAccountsExceptions, CollabChangeException {
|
||||
final Mindmap mindMap = findMindmapById(id);
|
||||
|
||||
// Only owner can change collaborators...
|
||||
@ -345,7 +345,6 @@ public class MindmapController extends BaseController {
|
||||
|
||||
// Great, let's add all the collabs again ...
|
||||
for (RestCollaboration restCollab : restCollabs.getCollaborations()) {
|
||||
final Collaboration collaboration = mindMap.findCollaboration(restCollab.getEmail());
|
||||
// Validate role format ...
|
||||
String roleStr = restCollab.getRole();
|
||||
if (roleStr == null) {
|
||||
@ -353,12 +352,14 @@ public class MindmapController extends BaseController {
|
||||
}
|
||||
|
||||
// Is owner ?
|
||||
final CollaborationRole role = CollaborationRole.valueOf(roleStr.toUpperCase());
|
||||
if (role == CollaborationRole.OWNER) {
|
||||
throw new IllegalArgumentException("Owner can not be added as part of the collaboration list.");
|
||||
final String email = restCollab.getEmail();
|
||||
final Collaboration collaboration = mindMap.findCollaboration(email);
|
||||
if (collaboration != null && collaboration.getRole() == CollaborationRole.OWNER) {
|
||||
throw new CollabChangeException(email);
|
||||
}
|
||||
|
||||
mindmapService.addCollaboration(mindMap, restCollab.getEmail(), role, restCollabs.getMessage());
|
||||
final CollaborationRole role = CollaborationRole.valueOf(roleStr.toUpperCase());
|
||||
mindmapService.addCollaboration(mindMap, email, role, restCollabs.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,3 +68,4 @@ TOO_BIG_MINDMAP=Sie haben das Limit von 5000 Themen in einer Mindmap erreicht.
|
||||
SHARE_MAP.EMAIL_SUBJECT={0} hat eine Mindmap mit Ihnen geteilt
|
||||
EMAIL.DO_NOT_REPLAY=Wichtig: Antworten Sie nicht auf diese E-Mail. Wenn Sie weitere Hilfe benötigen oder Bedenken bezüglich Ihres Kontos haben, kontaktieren Sie uns <a href="mailto:{0}">hier</a>.
|
||||
EMAIL.GREETINGS=Hallo
|
||||
OWNER_ROLE_CAN_NOT_BE_CHANGED=Owner role can not be change. Please, remove owner from the change list.
|
@ -70,3 +70,4 @@ SHARE_MAP.EMAIL_SUBJECT={0} has shared a mind map with you
|
||||
EMAIL.DO_NOT_REPLAY=Important: Do not reply this email. If you need further help or have any concerns regarding your account, contact us to <a href="mailto:{0}">here</a>.
|
||||
EMAIL.GREETINGS=Hi
|
||||
TOO_MANY_INACTIVE_ACCOUNTS=You have shared your mindmaps to more than 20 user that have not registered yet. Please, remove inactive accounts or ask them to register.
|
||||
OWNER_ROLE_CAN_NOT_BE_CHANGED=Owner role can not be change. Please, remove owner from the change list.
|
@ -68,3 +68,4 @@ PASSWORD_CHANGED.EMAIL_BODY=<p>Esto es solo una notificación de que su contrase
|
||||
SHARE_MAP.EMAIL_SUBJECT={0} te ha compartido un mapa mental
|
||||
EMAIL.DO_NOT_REPLAY=Importante: No responda este correo electrónico. Si necesita más ayuda o tiene alguna inquietud con respecto a su cuenta, comuníquese con nosotros a <a href="mailto:{0}">aquí</a>.
|
||||
EMAIL.GREETINGS=Hola
|
||||
OWNER_ROLE_CAN_NOT_BE_CHANGED=Owner role can not be change. Please, remove owner from the change list.
|
@ -68,3 +68,4 @@ TOO_BIG_MINDMAP=Vous avez atteint la limite de 5000 sujets dans une carte mental
|
||||
SHARE_MAP.EMAIL_SUBJECT={0} a partagé une carte mentale avec vous
|
||||
EMAIL.DO_NOT_REPLAY=Important : Ne répondez pas à cet e-mail. Si vous avez besoin d'aide supplémentaire ou si vous avez des inquiétudes concernant votre compte, contactez-nous <a href="mailto:{0}">ici</a>.
|
||||
EMAIL.GREETINGS=Salut
|
||||
OWNER_ROLE_CAN_NOT_BE_CHANGED=Owner role can not be change. Please, remove owner from the change list.
|
@ -62,3 +62,4 @@ REGISTRATION.EMAIL_BODY=<p> Благодарим вас за интерес к W
|
||||
SHARE_MAP.EMAIL_SUBJECT={0} has shared a mindmap with you
|
||||
EMAIL.DO_NOT_REPLAY=Important: Do not reply this email. If you need further help or have any concerns regarding your account, contact us to <a href="mailto:{0}">here</a>.
|
||||
EMAIL.GREETINGS=Hi
|
||||
OWNER_ROLE_CAN_NOT_BE_CHANGED=Owner role can not be change. Please, remove owner from the change list.
|
@ -68,3 +68,4 @@ PASSWORD_CHANGED.EMAIL_BODY=<p>这只是您的密码已更改的通知。无需
|
||||
SHARE_MAP.EMAIL_SUBJECT={0} 与您分享了一张思维导图
|
||||
EMAIL.DO_NOT_REPLAY=Important: Do not reply this email. If you need further help or have any concerns regarding your account, contact us to <a href="mailto:{0}">here</a>.
|
||||
EMAIL.GREETINGS=Hi
|
||||
OWNER_ROLE_CAN_NOT_BE_CHANGED=Owner role can not be change. Please, remove owner from the change list.
|
Loading…
Reference in New Issue
Block a user