Browse Source
Merge pull request #68 from deaflynx/develop/3.3-edge
Added edge_name_unq_key in saveEdge
pull/3811/head
VoBa
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
12 additions and
1 deletions
-
dao/src/main/java/org/thingsboard/server/dao/edge/EdgeServiceImpl.java
|
|
|
@ -25,6 +25,7 @@ import org.apache.http.HttpHost; |
|
|
|
import org.apache.http.conn.ssl.DefaultHostnameVerifier; |
|
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
|
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.Value; |
|
|
|
import org.springframework.cache.Cache; |
|
|
|
@ -178,7 +179,17 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic |
|
|
|
public Edge saveEdge(Edge edge) { |
|
|
|
log.trace("Executing saveEdge [{}]", edge); |
|
|
|
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 |
|
|
|
|