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