Showing
4 changed files
with
17 additions
and
7 deletions
@@ -318,6 +318,7 @@ public abstract class BaseController { | @@ -318,6 +318,7 @@ public abstract class BaseController { | ||
318 | 318 | ||
319 | @ExceptionHandler(Exception.class) | 319 | @ExceptionHandler(Exception.class) |
320 | public void handleControllerException(Exception e, HttpServletResponse response) { | 320 | public void handleControllerException(Exception e, HttpServletResponse response) { |
321 | + log.error(e.getMessage(),e); | ||
321 | ThingsboardException thingsboardException = handleException(e); | 322 | ThingsboardException thingsboardException = handleException(e); |
322 | if (thingsboardException.getErrorCode() == ThingsboardErrorCode.GENERAL && thingsboardException.getCause() instanceof Exception | 323 | if (thingsboardException.getErrorCode() == ThingsboardErrorCode.GENERAL && thingsboardException.getCause() instanceof Exception |
323 | && StringUtils.equals(thingsboardException.getCause().getMessage(), thingsboardException.getMessage())) { | 324 | && StringUtils.equals(thingsboardException.getCause().getMessage(), thingsboardException.getMessage())) { |
@@ -330,6 +331,7 @@ public abstract class BaseController { | @@ -330,6 +331,7 @@ public abstract class BaseController { | ||
330 | 331 | ||
331 | @ExceptionHandler(ThingsboardException.class) | 332 | @ExceptionHandler(ThingsboardException.class) |
332 | public void handleThingsboardException(ThingsboardException ex, HttpServletResponse response) { | 333 | public void handleThingsboardException(ThingsboardException ex, HttpServletResponse response) { |
334 | + log.error(ex.getMessage(),ex); | ||
333 | errorResponseHandler.handle(ex, response); | 335 | errorResponseHandler.handle(ex, response); |
334 | } | 336 | } |
335 | 337 | ||
@@ -393,6 +395,7 @@ public abstract class BaseController { | @@ -393,6 +395,7 @@ public abstract class BaseController { | ||
393 | * */ | 395 | * */ |
394 | @ExceptionHandler(MethodArgumentNotValidException.class) | 396 | @ExceptionHandler(MethodArgumentNotValidException.class) |
395 | public void handleValidationError(MethodArgumentNotValidException validationError, HttpServletResponse response) { | 397 | public void handleValidationError(MethodArgumentNotValidException validationError, HttpServletResponse response) { |
398 | + log.error(validationError.getMessage(),validationError); | ||
396 | List<ConstraintViolation<Object>> constraintsViolations = validationError.getFieldErrors().stream() | 399 | List<ConstraintViolation<Object>> constraintsViolations = validationError.getFieldErrors().stream() |
397 | .map(fieldError -> { | 400 | .map(fieldError -> { |
398 | try { | 401 | try { |
@@ -53,6 +53,10 @@ public class RuleChainMetaData { | @@ -53,6 +53,10 @@ public class RuleChainMetaData { | ||
53 | connectionInfo.setFromIndex(fromIndex); | 53 | connectionInfo.setFromIndex(fromIndex); |
54 | connectionInfo.setToIndex(toIndex); | 54 | connectionInfo.setToIndex(toIndex); |
55 | connectionInfo.setType(type); | 55 | connectionInfo.setType(type); |
56 | + addConnectionInfo(connectionInfo); | ||
57 | + } | ||
58 | + | ||
59 | + public void addConnectionInfo(NodeConnectionInfo connectionInfo) { | ||
56 | if (connections == null) { | 60 | if (connections == null) { |
57 | connections = new ArrayList<>(); | 61 | connections = new ArrayList<>(); |
58 | } | 62 | } |
@@ -164,7 +164,7 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC | @@ -164,7 +164,7 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC | ||
164 | List<EntityRelation> relations = new ArrayList<>(); | 164 | List<EntityRelation> relations = new ArrayList<>(); |
165 | 165 | ||
166 | Map<RuleNodeId, Integer> ruleNodeIndexMap = new HashMap<>(); | 166 | Map<RuleNodeId, Integer> ruleNodeIndexMap = new HashMap<>(); |
167 | - if (nodes != null) { | 167 | + if (nodes != null && nodes.size()>0) { |
168 | for (RuleNode node : nodes) { | 168 | for (RuleNode node : nodes) { |
169 | setSingletonMode(node); | 169 | setSingletonMode(node); |
170 | if (node.getId() != null) { | 170 | if (node.getId() != null) { |
@@ -191,7 +191,7 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC | @@ -191,7 +191,7 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC | ||
191 | updatedRuleNodes.add(new RuleNodeUpdateResult(existingNode, newRuleNode)); | 191 | updatedRuleNodes.add(new RuleNodeUpdateResult(existingNode, newRuleNode)); |
192 | } | 192 | } |
193 | RuleChainId ruleChainId = ruleChain.getId(); | 193 | RuleChainId ruleChainId = ruleChain.getId(); |
194 | - if (nodes != null) { | 194 | + if (nodes != null && nodes.size()>0) { |
195 | for (RuleNode node : toAddOrUpdate) { | 195 | for (RuleNode node : toAddOrUpdate) { |
196 | node.setRuleChainId(ruleChainId); | 196 | node.setRuleChainId(ruleChainId); |
197 | node = ruleNodeUpdater.apply(node); | 197 | node = ruleNodeUpdater.apply(node); |
@@ -208,7 +208,7 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC | @@ -208,7 +208,7 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC | ||
208 | deleteRuleNodes(tenantId, toDelete); | 208 | deleteRuleNodes(tenantId, toDelete); |
209 | } | 209 | } |
210 | RuleNodeId firstRuleNodeId = null; | 210 | RuleNodeId firstRuleNodeId = null; |
211 | - if (nodes != null) { | 211 | + if (nodes != null && nodes.size()>0) { |
212 | if (ruleChainMetaData.getFirstNodeIndex() != null) { | 212 | if (ruleChainMetaData.getFirstNodeIndex() != null) { |
213 | firstRuleNodeId = nodes.get(ruleChainMetaData.getFirstNodeIndex()).getId(); | 213 | firstRuleNodeId = nodes.get(ruleChainMetaData.getFirstNodeIndex()).getId(); |
214 | } | 214 | } |
@@ -431,7 +431,10 @@ public class TkConvertConfigServiceImpl | @@ -431,7 +431,10 @@ public class TkConvertConfigServiceImpl | ||
431 | private void freshRuleChainMetaData(RuleChainMetaData ruleChainMetaData, int removeNodeIndex) { | 431 | private void freshRuleChainMetaData(RuleChainMetaData ruleChainMetaData, int removeNodeIndex) { |
432 | ruleChainMetaData.getNodes().remove(removeNodeIndex); | 432 | ruleChainMetaData.getNodes().remove(removeNodeIndex); |
433 | 433 | ||
434 | - int firstIndex = ruleChainMetaData.getFirstNodeIndex(); | 434 | + Integer firstIndex = ruleChainMetaData.getFirstNodeIndex(); |
435 | + if(firstIndex==null){ | ||
436 | + return; | ||
437 | + } | ||
435 | ruleChainMetaData.setFirstNodeIndex( | 438 | ruleChainMetaData.setFirstNodeIndex( |
436 | Math.max(firstIndex < removeNodeIndex ? firstIndex : firstIndex - 1, 0)); | 439 | Math.max(firstIndex < removeNodeIndex ? firstIndex : firstIndex - 1, 0)); |
437 | 440 | ||
@@ -834,7 +837,7 @@ public class TkConvertConfigServiceImpl | @@ -834,7 +837,7 @@ public class TkConvertConfigServiceImpl | ||
834 | nodeConnectionInfo.setFromIndex(ruleNodeIndex.get()); | 837 | nodeConnectionInfo.setFromIndex(ruleNodeIndex.get()); |
835 | nodeConnectionInfo.setToIndex(ruleChainMetaData.getNodes().size() - 2); | 838 | nodeConnectionInfo.setToIndex(ruleChainMetaData.getNodes().size() - 2); |
836 | nodeConnectionInfo.setType(connectionType); | 839 | nodeConnectionInfo.setType(connectionType); |
837 | - ruleChainMetaData.getConnections().add(nodeConnectionInfo); | 840 | + ruleChainMetaData.addConnectionInfo(nodeConnectionInfo); |
838 | } | 841 | } |
839 | if (node.getName().equals(sceneOriginatorName) | 842 | if (node.getName().equals(sceneOriginatorName) |
840 | && node.getType().equals(originatorType)) { | 843 | && node.getType().equals(originatorType)) { |
@@ -842,7 +845,7 @@ public class TkConvertConfigServiceImpl | @@ -842,7 +845,7 @@ public class TkConvertConfigServiceImpl | ||
842 | nodeConnectionInfo.setFromIndex(ruleNodeIndex.get()); | 845 | nodeConnectionInfo.setFromIndex(ruleNodeIndex.get()); |
843 | nodeConnectionInfo.setToIndex(ruleChainMetaData.getNodes().size() - 1); | 846 | nodeConnectionInfo.setToIndex(ruleChainMetaData.getNodes().size() - 1); |
844 | nodeConnectionInfo.setType(connectionType); | 847 | nodeConnectionInfo.setType(connectionType); |
845 | - ruleChainMetaData.getConnections().add(nodeConnectionInfo); | 848 | + ruleChainMetaData.addConnectionInfo(nodeConnectionInfo); |
846 | } | 849 | } |
847 | 850 | ||
848 | if (node.getType().equals("org.thingsboard.rule.engine.rpc.TbSendRPCRequestNode")) { | 851 | if (node.getType().equals("org.thingsboard.rule.engine.rpc.TbSendRPCRequestNode")) { |
@@ -850,7 +853,7 @@ public class TkConvertConfigServiceImpl | @@ -850,7 +853,7 @@ public class TkConvertConfigServiceImpl | ||
850 | nodeConnectionInfo.setFromIndex(ruleChainMetaData.getNodes().size() - 1); | 853 | nodeConnectionInfo.setFromIndex(ruleChainMetaData.getNodes().size() - 1); |
851 | nodeConnectionInfo.setToIndex(ruleNodeIndex.get()); | 854 | nodeConnectionInfo.setToIndex(ruleNodeIndex.get()); |
852 | nodeConnectionInfo.setType("RPC Request"); | 855 | nodeConnectionInfo.setType("RPC Request"); |
853 | - ruleChainMetaData.getConnections().add(nodeConnectionInfo); | 856 | + ruleChainMetaData.addConnectionInfo(nodeConnectionInfo); |
854 | } | 857 | } |
855 | ruleNodeIndex.getAndIncrement(); | 858 | ruleNodeIndex.getAndIncrement(); |
856 | }); | 859 | }); |