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

allow to change overlay owenr and public status

parent 7bcafb01
No related branches found
No related tags found
2 merge requests!115Resolve "admin panel should use API",!114Resolve "admin panel should use API"
......@@ -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);
......
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