Skip to content
Snippets Groups Projects
Commit 37617721 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

mesh identifier cannot be set to something invalid

parent afec2b06
No related branches found
No related tags found
2 merge requests!541version 12.1.3 into master,!527Resolve "Unexpected error if MESH term is invalid"
......@@ -28,6 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.MultiValueMap;
import lcsb.mapviewer.annotation.services.MeSHParser;
import lcsb.mapviewer.annotation.services.annotators.AnnotatorException;
import lcsb.mapviewer.api.BaseRestImpl;
import lcsb.mapviewer.api.ObjectExistsException;
import lcsb.mapviewer.api.ObjectNotFoundException;
......@@ -111,6 +113,9 @@ public class ProjectRestImpl extends BaseRestImpl {
@Autowired
private IProjectService projectService;
@Autowired
private MeSHParser meshParser;
@Autowired
private ProjectDao projectDao;
......@@ -549,8 +554,19 @@ public class ProjectRestImpl extends BaseRestImpl {
MiriamData organism = updateMiriamData(project.getOrganism(), value);
project.setOrganism(organism);
} else if (fieldName.equalsIgnoreCase("disease")) {
MiriamData disease = updateMiriamData(project.getDisease(), value);
project.setDisease(disease);
try {
MiriamData sourceData = updateMiriamData(null, value);
if (meshParser.isValidMeshId(sourceData)) {
MiriamData disease = updateMiriamData(project.getDisease(), value);
project.setDisease(disease);
} else if (sourceData.getResource().isEmpty()) {
project.setDisease(null);
} else {
throw new QueryException("invalid mesh identifier: " + value);
}
} catch (AnnotatorException e) {
throw new QueryException("invalid miriamdData: " + value, e);
}
} else if (fieldName.equalsIgnoreCase("mapCanvasType")) {
MapCanvasType mapCanvasType;
try {
......@@ -740,7 +756,8 @@ public class ProjectRestImpl extends BaseRestImpl {
public Map<String, Object> removeProject(String token, String projectId, String path)
throws SecurityException, QueryException {
Project project = getProjectService().getProjectByProjectId(projectId, token);
if (getConfigurationService().getConfigurationValue(ConfigurationElementType.DEFAULT_MAP).equals(project.getProjectId())) {
if (getConfigurationService().getConfigurationValue(ConfigurationElementType.DEFAULT_MAP)
.equals(project.getProjectId())) {
throw new OperationNotAllowedException("You cannot remove default map");
}
getProjectService().removeProject(project, path, true, token);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment