Merge pull request #68 from deaflynx/develop/3.3-edge

Added edge_name_unq_key in saveEdge
This commit is contained in:
VoBa 2020-12-18 15:03:48 +02:00 committed by GitHub
commit c24cf59980
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,7 @@ import org.apache.http.HttpHost;
import org.apache.http.conn.ssl.DefaultHostnameVerifier; import org.apache.http.conn.ssl.DefaultHostnameVerifier;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.hibernate.exception.ConstraintViolationException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
@ -178,7 +179,17 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic
public Edge saveEdge(Edge edge) { public Edge saveEdge(Edge edge) {
log.trace("Executing saveEdge [{}]", edge); log.trace("Executing saveEdge [{}]", edge);
edgeValidator.validate(edge, Edge::getTenantId); edgeValidator.validate(edge, Edge::getTenantId);
try {
return edgeDao.save(edge.getTenantId(), edge); return edgeDao.save(edge.getTenantId(), edge);
} catch (Exception t) {
ConstraintViolationException e = extractConstraintViolationException(t).orElse(null);
if (e != null && e.getConstraintName() != null
&& e.getConstraintName().equalsIgnoreCase("edge_name_unq_key")) {
throw new DataValidationException("Edge with such name already exists!");
} else {
throw t;
}
}
} }
@Override @Override