Commit 9ac3fef4 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

don't remove project backgrounds when removing user

parent 8e4031af
Pipeline #46526 canceled with stage
in 1 minute and 17 seconds
package lcsb.mapviewer.api.users;
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;
......@@ -17,17 +27,33 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
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.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.InvalidStateException;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.layout.ProjectBackground;
import lcsb.mapviewer.model.security.Privilege;
import lcsb.mapviewer.model.security.PrivilegeType;
import lcsb.mapviewer.model.user.*;
import lcsb.mapviewer.model.user.annotator.*;
import lcsb.mapviewer.services.*;
import lcsb.mapviewer.model.user.AnnotatorParamDefinition;
import lcsb.mapviewer.model.user.ConfigurationElementType;
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.utils.EmailSender;
......@@ -98,58 +124,58 @@ public class UserRestImpl extends BaseRestImpl {
String column = string.toLowerCase();
Object value;
switch (column) {
case "id":
case "idobject":
value = user.getId();
break;
case "name":
value = user.getName();
break;
case "surname":
value = user.getSurname();
break;
case "login":
value = user.getLogin();
break;
case "email":
value = user.getEmail();
break;
case "mincolor":
value = user.getMinColor();
break;
case "maxcolor":
value = user.getMaxColor();
break;
case "neutralcolor":
value = user.getNeutralColor();
break;
case "simplecolor":
value = user.getSimpleColor();
break;
case "removed":
value = user.isRemoved();
break;
case "termsofuseconsent":
value = user.isTermsOfUseConsent();
break;
case "connectedtoldap":
value = user.isConnectedToLdap();
break;
case "ldapaccountavailable":
if (ldapAvailable == null) {
ldapAvailable = false;
}
value = ldapAvailable;
break;
case "privileges":
value = preparePrivileges(user);
break;
case "preferences":
value = preparePreferences(user);
break;
default:
value = "Unknown column";
break;
case "id":
case "idobject":
value = user.getId();
break;
case "name":
value = user.getName();
break;
case "surname":
value = user.getSurname();
break;
case "login":
value = user.getLogin();
break;
case "email":
value = user.getEmail();
break;
case "mincolor":
value = user.getMinColor();
break;
case "maxcolor":
value = user.getMaxColor();
break;
case "neutralcolor":
value = user.getNeutralColor();
break;
case "simplecolor":
value = user.getSimpleColor();
break;
case "removed":
value = user.isRemoved();
break;
case "termsofuseconsent":
value = user.isTermsOfUseConsent();
break;
case "connectedtoldap":
value = user.isConnectedToLdap();
break;
case "ldapaccountavailable":
if (ldapAvailable == null) {
ldapAvailable = false;
}
value = ldapAvailable;
break;
case "privileges":
value = preparePrivileges(user);
break;
case "preferences":
value = preparePreferences(user);
break;
default:
value = "Unknown column";
break;
}
result.put(string, value);
}
......@@ -750,10 +776,6 @@ public class UserRestImpl extends BaseRestImpl {
} else if (user.getLogin().equals(Configuration.ANONYMOUS_LOGIN)) {
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);
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