Showing
4 changed files
with
58 additions
and
59 deletions
... | ... | @@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j; |
19 | 19 | import org.springframework.beans.factory.annotation.Autowired; |
20 | 20 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
21 | 21 | import org.springframework.security.core.userdetails.UsernameNotFoundException; |
22 | +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | |
22 | 23 | import org.springframework.util.StringUtils; |
23 | 24 | import org.thingsboard.server.common.data.Customer; |
24 | 25 | import org.thingsboard.server.common.data.Tenant; |
... | ... | @@ -27,6 +28,7 @@ import org.thingsboard.server.common.data.id.CustomerId; |
27 | 28 | import org.thingsboard.server.common.data.id.TenantId; |
28 | 29 | import org.thingsboard.server.common.data.page.PageLink; |
29 | 30 | import org.thingsboard.server.common.data.security.Authority; |
31 | +import org.thingsboard.server.common.data.security.UserCredentials; | |
30 | 32 | import org.thingsboard.server.dao.customer.CustomerService; |
31 | 33 | import org.thingsboard.server.dao.oauth2.OAuth2User; |
32 | 34 | import org.thingsboard.server.dao.tenant.TenantService; |
... | ... | @@ -48,6 +50,9 @@ public abstract class AbstractOAuth2ClientMapper { |
48 | 50 | private UserService userService; |
49 | 51 | |
50 | 52 | @Autowired |
53 | + private BCryptPasswordEncoder passwordEncoder; | |
54 | + | |
55 | + @Autowired | |
51 | 56 | private TenantService tenantService; |
52 | 57 | |
53 | 58 | @Autowired |
... | ... | @@ -88,6 +93,8 @@ public abstract class AbstractOAuth2ClientMapper { |
88 | 93 | user.setFirstName(oauth2User.getFirstName()); |
89 | 94 | user.setLastName(oauth2User.getLastName()); |
90 | 95 | user = userService.saveUser(user); |
96 | + UserCredentials userCredentials = userService.findUserCredentialsByUserId(user.getTenantId(), user.getId()); | |
97 | + userService.activateUserCredentials(user.getTenantId(), userCredentials.getActivateToken(), passwordEncoder.encode("")); | |
91 | 98 | } |
92 | 99 | } catch (Exception e) { |
93 | 100 | log.error("Can't get or create security user from oauth2 user", e); | ... | ... |
... | ... | @@ -20,7 +20,6 @@ import com.google.common.cache.CacheLoader; |
20 | 20 | import com.google.common.cache.LoadingCache; |
21 | 21 | import com.google.common.util.concurrent.Futures; |
22 | 22 | import com.google.common.util.concurrent.ListenableFuture; |
23 | -import com.google.common.util.concurrent.MoreExecutors; | |
24 | 23 | import lombok.AllArgsConstructor; |
25 | 24 | import lombok.Data; |
26 | 25 | import lombok.NoArgsConstructor; |
... | ... | @@ -78,7 +77,8 @@ public abstract class TbAbstractRelationActionNode<C extends TbAbstractRelationA |
78 | 77 | |
79 | 78 | @Override |
80 | 79 | public void onMsg(TbContext ctx, TbMsg msg) { |
81 | - withCallback(processEntityRelationAction(ctx, msg), | |
80 | + String relationType = processPattern(msg, config.getRelationType()); | |
81 | + withCallback(processEntityRelationAction(ctx, msg, relationType), | |
82 | 82 | filterResult -> ctx.tellNext(filterResult.getMsg(), filterResult.isResult() ? SUCCESS : FAILURE), t -> ctx.tellFailure(msg, t), ctx.getDbCallbackExecutor()); |
83 | 83 | } |
84 | 84 | |
... | ... | @@ -86,13 +86,13 @@ public abstract class TbAbstractRelationActionNode<C extends TbAbstractRelationA |
86 | 86 | public void destroy() { |
87 | 87 | } |
88 | 88 | |
89 | - protected ListenableFuture<RelationContainer> processEntityRelationAction(TbContext ctx, TbMsg msg) { | |
90 | - return Futures.transformAsync(getEntity(ctx, msg), entityContainer -> doProcessEntityRelationAction(ctx, msg, entityContainer), MoreExecutors.directExecutor()); | |
89 | + protected ListenableFuture<RelationContainer> processEntityRelationAction(TbContext ctx, TbMsg msg, String relationType) { | |
90 | + return Futures.transformAsync(getEntity(ctx, msg), entityContainer -> doProcessEntityRelationAction(ctx, msg, entityContainer, relationType), ctx.getDbCallbackExecutor()); | |
91 | 91 | } |
92 | 92 | |
93 | 93 | protected abstract boolean createEntityIfNotExists(); |
94 | 94 | |
95 | - protected abstract ListenableFuture<RelationContainer> doProcessEntityRelationAction(TbContext ctx, TbMsg msg, EntityContainer entityContainer); | |
95 | + protected abstract ListenableFuture<RelationContainer> doProcessEntityRelationAction(TbContext ctx, TbMsg msg, EntityContainer entityContainer, String relationType); | |
96 | 96 | |
97 | 97 | protected abstract C loadEntityNodeActionConfig(TbNodeConfiguration configuration) throws TbNodeException; |
98 | 98 | |
... | ... | @@ -120,11 +120,11 @@ public abstract class TbAbstractRelationActionNode<C extends TbAbstractRelationA |
120 | 120 | if (EntitySearchDirection.FROM.name().equals(this.config.getDirection())) { |
121 | 121 | searchDirectionIds.setFromId(EntityIdFactory.getByTypeAndId(entityContainer.getEntityType().name(), entityContainer.getEntityId().toString())); |
122 | 122 | searchDirectionIds.setToId(msg.getOriginator()); |
123 | - searchDirectionIds.setOrignatorDirectionFrom(false); | |
123 | + searchDirectionIds.setOriginatorDirectionFrom(false); | |
124 | 124 | } else { |
125 | 125 | searchDirectionIds.setToId(EntityIdFactory.getByTypeAndId(entityContainer.getEntityType().name(), entityContainer.getEntityId().toString())); |
126 | 126 | searchDirectionIds.setFromId(msg.getOriginator()); |
127 | - searchDirectionIds.setOrignatorDirectionFrom(true); | |
127 | + searchDirectionIds.setOriginatorDirectionFrom(true); | |
128 | 128 | } |
129 | 129 | return searchDirectionIds; |
130 | 130 | } |
... | ... | @@ -153,7 +153,7 @@ public abstract class TbAbstractRelationActionNode<C extends TbAbstractRelationA |
153 | 153 | protected static class SearchDirectionIds { |
154 | 154 | private EntityId fromId; |
155 | 155 | private EntityId toId; |
156 | - private boolean orignatorDirectionFrom; | |
156 | + private boolean originatorDirectionFrom; | |
157 | 157 | } |
158 | 158 | |
159 | 159 | private static class EntityCacheLoader extends CacheLoader<EntityKey, EntityContainer> { | ... | ... |
... | ... | @@ -17,7 +17,6 @@ package org.thingsboard.rule.engine.action; |
17 | 17 | |
18 | 18 | import com.google.common.util.concurrent.Futures; |
19 | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | -import com.google.common.util.concurrent.MoreExecutors; | |
21 | 20 | import lombok.extern.slf4j.Slf4j; |
22 | 21 | import org.thingsboard.rule.engine.api.RuleNode; |
23 | 22 | import org.thingsboard.rule.engine.api.TbContext; |
... | ... | @@ -57,8 +56,6 @@ import java.util.List; |
57 | 56 | ) |
58 | 57 | public class TbCreateRelationNode extends TbAbstractRelationActionNode<TbCreateRelationNodeConfiguration> { |
59 | 58 | |
60 | - private String relationType; | |
61 | - | |
62 | 59 | @Override |
63 | 60 | protected TbCreateRelationNodeConfiguration loadEntityNodeActionConfig(TbNodeConfiguration configuration) throws TbNodeException { |
64 | 61 | return TbNodeUtils.convert(configuration, TbCreateRelationNodeConfiguration.class); |
... | ... | @@ -70,8 +67,8 @@ public class TbCreateRelationNode extends TbAbstractRelationActionNode<TbCreateR |
70 | 67 | } |
71 | 68 | |
72 | 69 | @Override |
73 | - protected ListenableFuture<RelationContainer> doProcessEntityRelationAction(TbContext ctx, TbMsg msg, EntityContainer entity) { | |
74 | - ListenableFuture<Boolean> future = createIfAbsent(ctx, msg, entity); | |
70 | + protected ListenableFuture<RelationContainer> doProcessEntityRelationAction(TbContext ctx, TbMsg msg, EntityContainer entity, String relationType) { | |
71 | + ListenableFuture<Boolean> future = createIfAbsent(ctx, msg, entity, relationType); | |
75 | 72 | return Futures.transform(future, result -> { |
76 | 73 | RelationContainer container = new RelationContainer(); |
77 | 74 | if (result && config.isChangeOriginatorToRelatedEntity()) { |
... | ... | @@ -82,16 +79,15 @@ public class TbCreateRelationNode extends TbAbstractRelationActionNode<TbCreateR |
82 | 79 | } |
83 | 80 | container.setResult(result); |
84 | 81 | return container; |
85 | - }, MoreExecutors.directExecutor()); | |
82 | + }, ctx.getDbCallbackExecutor()); | |
86 | 83 | } |
87 | 84 | |
88 | - private ListenableFuture<Boolean> createIfAbsent(TbContext ctx, TbMsg msg, EntityContainer entityContainer) { | |
89 | - relationType = processPattern(msg, config.getRelationType()); | |
85 | + private ListenableFuture<Boolean> createIfAbsent(TbContext ctx, TbMsg msg, EntityContainer entityContainer, String relationType) { | |
90 | 86 | SearchDirectionIds sdId = processSingleSearchDirection(msg, entityContainer); |
91 | 87 | ListenableFuture<Boolean> checkRelationFuture = Futures.transformAsync(ctx.getRelationService().checkRelation(ctx.getTenantId(), sdId.getFromId(), sdId.getToId(), relationType, RelationTypeGroup.COMMON), result -> { |
92 | 88 | if (!result) { |
93 | 89 | if (config.isRemoveCurrentRelations()) { |
94 | - return processDeleteRelations(ctx, processFindRelations(ctx, msg, sdId)); | |
90 | + return processDeleteRelations(ctx, processFindRelations(ctx, msg, sdId, relationType)); | |
95 | 91 | } |
96 | 92 | return Futures.immediateFuture(false); |
97 | 93 | } |
... | ... | @@ -100,14 +96,14 @@ public class TbCreateRelationNode extends TbAbstractRelationActionNode<TbCreateR |
100 | 96 | |
101 | 97 | return Futures.transformAsync(checkRelationFuture, result -> { |
102 | 98 | if (!result) { |
103 | - return processCreateRelation(ctx, entityContainer, sdId); | |
99 | + return processCreateRelation(ctx, entityContainer, sdId, relationType); | |
104 | 100 | } |
105 | 101 | return Futures.immediateFuture(true); |
106 | 102 | }, ctx.getDbCallbackExecutor()); |
107 | 103 | } |
108 | 104 | |
109 | - private ListenableFuture<List<EntityRelation>> processFindRelations(TbContext ctx, TbMsg msg, SearchDirectionIds sdId) { | |
110 | - if (sdId.isOrignatorDirectionFrom()) { | |
105 | + private ListenableFuture<List<EntityRelation>> processFindRelations(TbContext ctx, TbMsg msg, SearchDirectionIds sdId, String relationType) { | |
106 | + if (sdId.isOriginatorDirectionFrom()) { | |
111 | 107 | return ctx.getRelationService().findByFromAndTypeAsync(ctx.getTenantId(), msg.getOriginator(), relationType, RelationTypeGroup.COMMON); |
112 | 108 | } else { |
113 | 109 | return ctx.getRelationService().findByToAndTypeAsync(ctx.getTenantId(), msg.getOriginator(), relationType, RelationTypeGroup.COMMON); |
... | ... | @@ -121,91 +117,91 @@ public class TbCreateRelationNode extends TbAbstractRelationActionNode<TbCreateR |
121 | 117 | for (EntityRelation relation : entityRelations) { |
122 | 118 | list.add(ctx.getRelationService().deleteRelationAsync(ctx.getTenantId(), relation)); |
123 | 119 | } |
124 | - return Futures.transform(Futures.allAsList(list), result -> false, MoreExecutors.directExecutor()); | |
120 | + return Futures.transform(Futures.allAsList(list), result -> false, ctx.getDbCallbackExecutor()); | |
125 | 121 | } |
126 | 122 | return Futures.immediateFuture(false); |
127 | 123 | }, ctx.getDbCallbackExecutor()); |
128 | 124 | } |
129 | 125 | |
130 | - private ListenableFuture<Boolean> processCreateRelation(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId) { | |
126 | + private ListenableFuture<Boolean> processCreateRelation(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId, String relationType) { | |
131 | 127 | switch (entityContainer.getEntityType()) { |
132 | 128 | case ASSET: |
133 | - return processAsset(ctx, entityContainer, sdId); | |
129 | + return processAsset(ctx, entityContainer, sdId, relationType); | |
134 | 130 | case DEVICE: |
135 | - return processDevice(ctx, entityContainer, sdId); | |
131 | + return processDevice(ctx, entityContainer, sdId, relationType); | |
136 | 132 | case CUSTOMER: |
137 | - return processCustomer(ctx, entityContainer, sdId); | |
133 | + return processCustomer(ctx, entityContainer, sdId, relationType); | |
138 | 134 | case DASHBOARD: |
139 | - return processDashboard(ctx, entityContainer, sdId); | |
135 | + return processDashboard(ctx, entityContainer, sdId, relationType); | |
140 | 136 | case ENTITY_VIEW: |
141 | - return processView(ctx, entityContainer, sdId); | |
137 | + return processView(ctx, entityContainer, sdId, relationType); | |
142 | 138 | case TENANT: |
143 | - return processTenant(ctx, entityContainer, sdId); | |
139 | + return processTenant(ctx, entityContainer, sdId, relationType); | |
144 | 140 | } |
145 | 141 | return Futures.immediateFuture(true); |
146 | 142 | } |
147 | 143 | |
148 | - private ListenableFuture<Boolean> processView(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId) { | |
144 | + private ListenableFuture<Boolean> processView(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId, String relationType) { | |
149 | 145 | return Futures.transformAsync(ctx.getEntityViewService().findEntityViewByIdAsync(ctx.getTenantId(), new EntityViewId(entityContainer.getEntityId().getId())), entityView -> { |
150 | 146 | if (entityView != null) { |
151 | - return processSave(ctx, sdId); | |
147 | + return processSave(ctx, sdId, relationType); | |
152 | 148 | } else { |
153 | 149 | return Futures.immediateFuture(true); |
154 | 150 | } |
155 | 151 | }, ctx.getDbCallbackExecutor()); |
156 | 152 | } |
157 | 153 | |
158 | - private ListenableFuture<Boolean> processDevice(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId) { | |
154 | + private ListenableFuture<Boolean> processDevice(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId, String relationType) { | |
159 | 155 | return Futures.transformAsync(ctx.getDeviceService().findDeviceByIdAsync(ctx.getTenantId(), new DeviceId(entityContainer.getEntityId().getId())), device -> { |
160 | 156 | if (device != null) { |
161 | - return processSave(ctx, sdId); | |
157 | + return processSave(ctx, sdId, relationType); | |
162 | 158 | } else { |
163 | 159 | return Futures.immediateFuture(true); |
164 | 160 | } |
165 | - }, MoreExecutors.directExecutor()); | |
161 | + }, ctx.getDbCallbackExecutor()); | |
166 | 162 | } |
167 | 163 | |
168 | - private ListenableFuture<Boolean> processAsset(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId) { | |
164 | + private ListenableFuture<Boolean> processAsset(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId, String relationType) { | |
169 | 165 | return Futures.transformAsync(ctx.getAssetService().findAssetByIdAsync(ctx.getTenantId(), new AssetId(entityContainer.getEntityId().getId())), asset -> { |
170 | 166 | if (asset != null) { |
171 | - return processSave(ctx, sdId); | |
167 | + return processSave(ctx, sdId, relationType); | |
172 | 168 | } else { |
173 | 169 | return Futures.immediateFuture(true); |
174 | 170 | } |
175 | 171 | }, ctx.getDbCallbackExecutor()); |
176 | 172 | } |
177 | 173 | |
178 | - private ListenableFuture<Boolean> processCustomer(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId) { | |
174 | + private ListenableFuture<Boolean> processCustomer(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId, String relationType) { | |
179 | 175 | return Futures.transformAsync(ctx.getCustomerService().findCustomerByIdAsync(ctx.getTenantId(), new CustomerId(entityContainer.getEntityId().getId())), customer -> { |
180 | 176 | if (customer != null) { |
181 | - return processSave(ctx, sdId); | |
177 | + return processSave(ctx, sdId, relationType); | |
182 | 178 | } else { |
183 | 179 | return Futures.immediateFuture(true); |
184 | 180 | } |
185 | 181 | }, ctx.getDbCallbackExecutor()); |
186 | 182 | } |
187 | 183 | |
188 | - private ListenableFuture<Boolean> processDashboard(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId) { | |
184 | + private ListenableFuture<Boolean> processDashboard(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId, String relationType) { | |
189 | 185 | return Futures.transformAsync(ctx.getDashboardService().findDashboardByIdAsync(ctx.getTenantId(), new DashboardId(entityContainer.getEntityId().getId())), dashboard -> { |
190 | 186 | if (dashboard != null) { |
191 | - return processSave(ctx, sdId); | |
187 | + return processSave(ctx, sdId, relationType); | |
192 | 188 | } else { |
193 | 189 | return Futures.immediateFuture(true); |
194 | 190 | } |
195 | 191 | }, ctx.getDbCallbackExecutor()); |
196 | 192 | } |
197 | 193 | |
198 | - private ListenableFuture<Boolean> processTenant(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId) { | |
194 | + private ListenableFuture<Boolean> processTenant(TbContext ctx, EntityContainer entityContainer, SearchDirectionIds sdId, String relationType) { | |
199 | 195 | return Futures.transformAsync(ctx.getTenantService().findTenantByIdAsync(ctx.getTenantId(), new TenantId(entityContainer.getEntityId().getId())), tenant -> { |
200 | 196 | if (tenant != null) { |
201 | - return processSave(ctx, sdId); | |
197 | + return processSave(ctx, sdId, relationType); | |
202 | 198 | } else { |
203 | 199 | return Futures.immediateFuture(true); |
204 | 200 | } |
205 | 201 | }, ctx.getDbCallbackExecutor()); |
206 | 202 | } |
207 | 203 | |
208 | - private ListenableFuture<Boolean> processSave(TbContext ctx, SearchDirectionIds sdId) { | |
204 | + private ListenableFuture<Boolean> processSave(TbContext ctx, SearchDirectionIds sdId, String relationType) { | |
209 | 205 | return ctx.getRelationService().saveRelationAsync(ctx.getTenantId(), new EntityRelation(sdId.getFromId(), sdId.getToId(), relationType, RelationTypeGroup.COMMON)); |
210 | 206 | } |
211 | 207 | ... | ... |
... | ... | @@ -17,7 +17,6 @@ package org.thingsboard.rule.engine.action; |
17 | 17 | |
18 | 18 | import com.google.common.util.concurrent.Futures; |
19 | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | -import com.google.common.util.concurrent.MoreExecutors; | |
21 | 20 | import lombok.extern.slf4j.Slf4j; |
22 | 21 | import org.thingsboard.rule.engine.api.RuleNode; |
23 | 22 | import org.thingsboard.rule.engine.api.TbContext; |
... | ... | @@ -48,8 +47,6 @@ import java.util.List; |
48 | 47 | ) |
49 | 48 | public class TbDeleteRelationNode extends TbAbstractRelationActionNode<TbDeleteRelationNodeConfiguration> { |
50 | 49 | |
51 | - private String relationType; | |
52 | - | |
53 | 50 | @Override |
54 | 51 | protected TbDeleteRelationNodeConfiguration loadEntityNodeActionConfig(TbNodeConfiguration configuration) throws TbNodeException { |
55 | 52 | return TbNodeUtils.convert(configuration, TbDeleteRelationNodeConfiguration.class); |
... | ... | @@ -61,21 +58,20 @@ public class TbDeleteRelationNode extends TbAbstractRelationActionNode<TbDeleteR |
61 | 58 | } |
62 | 59 | |
63 | 60 | @Override |
64 | - protected ListenableFuture<RelationContainer> processEntityRelationAction(TbContext ctx, TbMsg msg) { | |
65 | - return getRelationContainerListenableFuture(ctx, msg); | |
61 | + protected ListenableFuture<RelationContainer> processEntityRelationAction(TbContext ctx, TbMsg msg, String relationType) { | |
62 | + return getRelationContainerListenableFuture(ctx, msg, relationType); | |
66 | 63 | } |
67 | 64 | |
68 | 65 | @Override |
69 | - protected ListenableFuture<RelationContainer> doProcessEntityRelationAction(TbContext ctx, TbMsg msg, EntityContainer entityContainer) { | |
70 | - return Futures.transform(processSingle(ctx, msg, entityContainer), result -> new RelationContainer(msg, result), MoreExecutors.directExecutor()); | |
66 | + protected ListenableFuture<RelationContainer> doProcessEntityRelationAction(TbContext ctx, TbMsg msg, EntityContainer entityContainer, String relationType) { | |
67 | + return Futures.transform(processSingle(ctx, msg, entityContainer, relationType), result -> new RelationContainer(msg, result), ctx.getDbCallbackExecutor()); | |
71 | 68 | } |
72 | 69 | |
73 | - private ListenableFuture<RelationContainer> getRelationContainerListenableFuture(TbContext ctx, TbMsg msg) { | |
74 | - relationType = processPattern(msg, config.getRelationType()); | |
70 | + private ListenableFuture<RelationContainer> getRelationContainerListenableFuture(TbContext ctx, TbMsg msg, String relationType) { | |
75 | 71 | if (config.isDeleteForSingleEntity()) { |
76 | - return Futures.transformAsync(getEntity(ctx, msg), entityContainer -> doProcessEntityRelationAction(ctx, msg, entityContainer), MoreExecutors.directExecutor()); | |
72 | + return Futures.transformAsync(getEntity(ctx, msg), entityContainer -> doProcessEntityRelationAction(ctx, msg, entityContainer, relationType), ctx.getDbCallbackExecutor()); | |
77 | 73 | } else { |
78 | - return Futures.transform(processList(ctx, msg), result -> new RelationContainer(msg, result), MoreExecutors.directExecutor()); | |
74 | + return Futures.transform(processList(ctx, msg), result -> new RelationContainer(msg, result), ctx.getDbCallbackExecutor()); | |
79 | 75 | } |
80 | 76 | } |
81 | 77 | |
... | ... | @@ -95,23 +91,23 @@ public class TbDeleteRelationNode extends TbAbstractRelationActionNode<TbDeleteR |
95 | 91 | } |
96 | 92 | } |
97 | 93 | return Futures.immediateFuture(true); |
98 | - }, MoreExecutors.directExecutor()); | |
94 | + }, ctx.getDbCallbackExecutor()); | |
99 | 95 | } |
100 | - }, MoreExecutors.directExecutor()); | |
96 | + }, ctx.getDbCallbackExecutor()); | |
101 | 97 | } |
102 | 98 | |
103 | - private ListenableFuture<Boolean> processSingle(TbContext ctx, TbMsg msg, EntityContainer entityContainer) { | |
99 | + private ListenableFuture<Boolean> processSingle(TbContext ctx, TbMsg msg, EntityContainer entityContainer, String relationType) { | |
104 | 100 | SearchDirectionIds sdId = processSingleSearchDirection(msg, entityContainer); |
105 | 101 | return Futures.transformAsync(ctx.getRelationService().checkRelation(ctx.getTenantId(), sdId.getFromId(), sdId.getToId(), relationType, RelationTypeGroup.COMMON), |
106 | 102 | result -> { |
107 | 103 | if (result) { |
108 | - return processSingleDeleteRelation(ctx, sdId); | |
104 | + return processSingleDeleteRelation(ctx, sdId, relationType); | |
109 | 105 | } |
110 | 106 | return Futures.immediateFuture(true); |
111 | - }, MoreExecutors.directExecutor()); | |
107 | + }, ctx.getDbCallbackExecutor()); | |
112 | 108 | } |
113 | 109 | |
114 | - private ListenableFuture<Boolean> processSingleDeleteRelation(TbContext ctx, SearchDirectionIds sdId) { | |
110 | + private ListenableFuture<Boolean> processSingleDeleteRelation(TbContext ctx, SearchDirectionIds sdId, String relationType) { | |
115 | 111 | return ctx.getRelationService().deleteRelationAsync(ctx.getTenantId(), sdId.getFromId(), sdId.getToId(), relationType, RelationTypeGroup.COMMON); |
116 | 112 | } |
117 | 113 | ... | ... |