Merge pull request #68 from deaflynx/develop/3.3-edge
Added edge_name_unq_key in saveEdge
This commit is contained in:
commit
c24cf59980
@ -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);
|
||||||
return edgeDao.save(edge.getTenantId(), edge);
|
try {
|
||||||
|
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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user