diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java index d42c8d428c09f93b038443fa2d9b4397b03cf995..ceaaaa346c3106a417d2676da4c7887aa52055d1 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java @@ -17,6 +17,7 @@ import lcsb.mapviewer.api.BaseRestImpl; import lcsb.mapviewer.api.ObjectNotFoundException; import lcsb.mapviewer.api.QueryException; import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.cache.FileEntry; import lcsb.mapviewer.model.map.layout.InvalidColorSchemaException; @@ -158,11 +159,27 @@ public class OverlayRestImpl extends BaseRestImpl { if (layout.isPublicLayout() && !isAdmin) { throw new SecurityException("You cannot modify given overlay"); } - if (overlayData.containsKey("description")) { - layout.setDescription((String) overlayData.get("description")); - } - if (overlayData.containsKey("name")) { - layout.setTitle((String) overlayData.get("name")); + for (String key : overlayData.keySet()) { + Object value = overlayData.get(key); + if (key.equalsIgnoreCase("description")) { + layout.setDescription((String) value); + } else if (key.equalsIgnoreCase("name")) { + layout.setTitle((String) value); + } else if (key.equalsIgnoreCase("publicOverlay")) { + if (value instanceof Boolean) { + layout.setPublicLayout((Boolean) value); + } else { + layout.setPublicLayout("true".equalsIgnoreCase((String) value)); + } + } else if (key.equalsIgnoreCase("creator")) { + if ("".equals(value)) { + layout.setCreator(null); + } else { + layout.setCreator(getUserService().getUserByLogin((String) value)); + } + } else { + throw new QueryException("Unknown parameter: " + key); + } } layoutDao.update(layout); return layoutService.getLayoutById(Integer.valueOf(overlayId), authenticationToken);