Commit e08be1f3 authored by Viacheslav Pavlov's avatar Viacheslav Pavlov Committed by Matija Obreza
Browse files

fixed overwriting of existing record when slugs are the same

parent d318c4c0
......@@ -18,6 +18,7 @@ package org.genesys2.server.api.v1;
import io.swagger.annotations.Api;
import org.genesys2.server.api.ApiBaseController;
import org.genesys2.server.exception.InvalidApiUsageException;
import org.genesys2.server.exception.NotFoundElement;
import org.genesys2.server.model.impl.Article;
import org.genesys2.server.model.impl.FaoInstitute;
......@@ -83,6 +84,10 @@ public class NetworkController extends ApiBaseController {
if (network == null) {
return networkService.create(organizationJson.getSlug(), organizationJson.getTitle());
}
if (!network.getId().equals(organizationJson.getId())) {
throw new InvalidApiUsageException("Cannot overwrite existing record");
}
return networkService.update(network.getId(), network.getSlug(), organizationJson.getTitle());
}
......
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