@ -24,8 +24,6 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.exception.ExceptionUtils ;
import org.hibernate.exception.ConstraintViolationException ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Value ;
import org.springframework.context.annotation.Lazy ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.thingsboard.common.util.JacksonUtil ;
@ -67,7 +65,6 @@ import org.thingsboard.server.dao.service.DataValidator;
import org.thingsboard.server.dao.service.PaginatedRemover ;
import org.thingsboard.server.dao.service.Validator ;
import org.thingsboard.server.dao.service.validator.RuleChainDataValidator ;
import org.thingsboard.server.dao.tenant.TbTenantProfileCache ;
import java.util.ArrayList ;
import java.util.Collection ;
@ -79,7 +76,6 @@ import java.util.List;
import java.util.Map ;
import java.util.Optional ;
import java.util.Set ;
import java.util.concurrent.TimeUnit ;
import java.util.function.Function ;
import java.util.stream.Collectors ;
@ -113,13 +109,6 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC
@Autowired
private DataValidator < RuleChain > ruleChainValidator ;
@Autowired
@Lazy
private TbTenantProfileCache tbTenantProfileCache ;
@Value ( "${debug_mode.max_duration:15}" )
private int maxDebugModeDurationMinutes ;
@Override
@Transactional
public RuleChain saveRuleChain ( RuleChain ruleChain ) {
@ -230,14 +219,7 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC
node . setRuleChainId ( ruleChainId ) ;
node = ruleNodeUpdater . apply ( node ) ;
int debugDuration = tbTenantProfileCache . get ( tenantId ) . getDefaultProfileConfiguration ( ) . getMaxDebugModeDurationMinutes ( maxDebugModeDurationMinutes ) ;
long debugUntil = now + TimeUnit . MINUTES . toMillis ( debugDuration ) ;
if ( node . isDebugAll ( ) ) {
node . setDebugAllUntil ( debugUntil ) ;
} else if ( node . getDebugAllUntil ( ) > debugUntil ) {
throw new DataValidationException ( "Unable to update 'debugAllUntil' property. To reset the debug duration, please modify the 'debugAll' property instead." ) ;
}
setDebugAllUntil ( tenantId , node , now ) ;
RuleChainDataValidator . validateRuleNode ( node ) ;
RuleNode savedNode = ruleNodeDao . save ( tenantId , node ) ;