Commit 1a9a4514 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1527-removing-creator' into 'devel_16.0.x'

Resolve "removing creator of project might remove project background in projects created by user"

See merge request !1336
parents 8e4031af a932f76d
Pipeline #46582 passed with stage
in 36 minutes and 40 seconds
minerva (16.0.0~beta.2) stable; urgency=medium minerva (16.0.0~beta.2) stable; urgency=medium
* Bug fix: problem with export map with submaps fixed (#1540) * Bug fix: problem with export map with submaps fixed (#1540)
* Bug fix: removing user removed backgrounds in projects created by user
(#1527)
-- Piotr Gawron <piotr.gawron@uni.lu> Fri, 3 Sep 2021 11:00:00 +0200 -- Piotr Gawron <piotr.gawron@uni.lu> Fri, 3 Sep 2021 11:00:00 +0200
......
package lcsb.mapviewer.api.users; package lcsb.mapviewer.api.users;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import javax.mail.MessagingException; import javax.mail.MessagingException;
...@@ -17,17 +27,33 @@ import org.springframework.stereotype.Service; ...@@ -17,17 +27,33 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import lcsb.mapviewer.api.*; import lcsb.mapviewer.api.BaseRestImpl;
import lcsb.mapviewer.api.OperationNotAllowedException;
import lcsb.mapviewer.api.UpdateConflictException;
import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.exception.InvalidStateException;
import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.layout.ProjectBackground;
import lcsb.mapviewer.model.security.Privilege; import lcsb.mapviewer.model.security.Privilege;
import lcsb.mapviewer.model.security.PrivilegeType; import lcsb.mapviewer.model.security.PrivilegeType;
import lcsb.mapviewer.model.user.*; import lcsb.mapviewer.model.user.AnnotatorParamDefinition;
import lcsb.mapviewer.model.user.annotator.*; import lcsb.mapviewer.model.user.ConfigurationElementType;
import lcsb.mapviewer.services.*; import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.model.user.UserAnnotationSchema;
import lcsb.mapviewer.model.user.UserClassAnnotators;
import lcsb.mapviewer.model.user.UserClassRequiredAnnotations;
import lcsb.mapviewer.model.user.UserClassValidAnnotations;
import lcsb.mapviewer.model.user.UserGuiPreference;
import lcsb.mapviewer.model.user.annotator.AnnotatorConfigParameter;
import lcsb.mapviewer.model.user.annotator.AnnotatorData;
import lcsb.mapviewer.model.user.annotator.AnnotatorInputParameter;
import lcsb.mapviewer.model.user.annotator.AnnotatorOutputParameter;
import lcsb.mapviewer.model.user.annotator.AnnotatorParameter;
import lcsb.mapviewer.model.user.annotator.BioEntityField;
import lcsb.mapviewer.services.InvalidTokenException;
import lcsb.mapviewer.services.ObjectExistsException;
import lcsb.mapviewer.services.ObjectNotFoundException;
import lcsb.mapviewer.services.QueryException;
import lcsb.mapviewer.services.interfaces.IProjectBackgroundService; import lcsb.mapviewer.services.interfaces.IProjectBackgroundService;
import lcsb.mapviewer.services.utils.EmailSender; import lcsb.mapviewer.services.utils.EmailSender;
...@@ -98,58 +124,58 @@ public class UserRestImpl extends BaseRestImpl { ...@@ -98,58 +124,58 @@ public class UserRestImpl extends BaseRestImpl {
String column = string.toLowerCase(); String column = string.toLowerCase();
Object value; Object value;
switch (column) { switch (column) {
case "id": case "id":
case "idobject": case "idobject":
value = user.getId(); value = user.getId();
break; break;
case "name": case "name":
value = user.getName(); value = user.getName();
break; break;
case "surname": case "surname":
value = user.getSurname(); value = user.getSurname();
break; break;
case "login": case "login":
value = user.getLogin(); value = user.getLogin();
break; break;
case "email": case "email":
value = user.getEmail(); value = user.getEmail();
break; break;
case "mincolor": case "mincolor":
value = user.getMinColor(); value = user.getMinColor();
break; break;
case "maxcolor": case "maxcolor":
value = user.getMaxColor(); value = user.getMaxColor();
break; break;
case "neutralcolor": case "neutralcolor":
value = user.getNeutralColor(); value = user.getNeutralColor();
break; break;
case "simplecolor": case "simplecolor":
value = user.getSimpleColor(); value = user.getSimpleColor();
break; break;
case "removed": case "removed":
value = user.isRemoved(); value = user.isRemoved();
break; break;
case "termsofuseconsent": case "termsofuseconsent":
value = user.isTermsOfUseConsent(); value = user.isTermsOfUseConsent();
break; break;
case "connectedtoldap": case "connectedtoldap":
value = user.isConnectedToLdap(); value = user.isConnectedToLdap();
break; break;
case "ldapaccountavailable": case "ldapaccountavailable":
if (ldapAvailable == null) { if (ldapAvailable == null) {
ldapAvailable = false; ldapAvailable = false;
} }
value = ldapAvailable; value = ldapAvailable;
break; break;
case "privileges": case "privileges":
value = preparePrivileges(user); value = preparePrivileges(user);
break; break;
case "preferences": case "preferences":
value = preparePreferences(user); value = preparePreferences(user);
break; break;
default: default:
value = "Unknown column"; value = "Unknown column";
break; break;
} }
result.put(string, value); result.put(string, value);
} }
...@@ -750,10 +776,6 @@ public class UserRestImpl extends BaseRestImpl { ...@@ -750,10 +776,6 @@ public class UserRestImpl extends BaseRestImpl {
} else if (user.getLogin().equals(Configuration.ANONYMOUS_LOGIN)) { } else if (user.getLogin().equals(Configuration.ANONYMOUS_LOGIN)) {
throw new OperationNotAllowedException("guest account cannot be removed"); throw new OperationNotAllowedException("guest account cannot be removed");
} }
List<ProjectBackground> backgrounds = projectBackgroundService.getProjectBackgroundsByUser(user);
for (ProjectBackground background : backgrounds) {
projectBackgroundService.removeProjectBackground(background, null);
}
getUserService().deleteUser(user); getUserService().deleteUser(user);
return okStatus(); return okStatus();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment