|
|
@ -22,6 +22,7 @@ import com.google.common.util.concurrent.MoreExecutors; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.SneakyThrows; |
|
|
import lombok.SneakyThrows; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.support.TransactionTemplate; |
|
|
import org.springframework.transaction.support.TransactionTemplate; |
|
|
@ -32,7 +33,6 @@ import org.thingsboard.common.util.ThingsBoardExecutors; |
|
|
import org.thingsboard.server.cache.TbTransactionalCache; |
|
|
import org.thingsboard.server.cache.TbTransactionalCache; |
|
|
import org.thingsboard.server.common.data.EntityType; |
|
|
import org.thingsboard.server.common.data.EntityType; |
|
|
import org.thingsboard.server.common.data.ExportableEntity; |
|
|
import org.thingsboard.server.common.data.ExportableEntity; |
|
|
import org.thingsboard.server.common.data.StringUtils; |
|
|
|
|
|
import org.thingsboard.server.common.data.User; |
|
|
import org.thingsboard.server.common.data.User; |
|
|
import org.thingsboard.server.common.data.audit.ActionType; |
|
|
import org.thingsboard.server.common.data.audit.ActionType; |
|
|
import org.thingsboard.server.common.data.exception.ThingsboardErrorCode; |
|
|
import org.thingsboard.server.common.data.exception.ThingsboardErrorCode; |
|
|
@ -101,6 +101,7 @@ import java.util.function.Function; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
import static com.google.common.util.concurrent.Futures.transform; |
|
|
import static com.google.common.util.concurrent.Futures.transform; |
|
|
|
|
|
import static org.thingsboard.server.common.data.sync.vc.VcUtils.checkBranchName; |
|
|
|
|
|
|
|
|
@Service |
|
|
@Service |
|
|
@TbCoreComponent |
|
|
@TbCoreComponent |
|
|
@ -138,6 +139,7 @@ public class DefaultEntitiesVersionControlService implements EntitiesVersionCont |
|
|
@SuppressWarnings("UnstableApiUsage") |
|
|
@SuppressWarnings("UnstableApiUsage") |
|
|
@Override |
|
|
@Override |
|
|
public ListenableFuture<UUID> saveEntitiesVersion(User user, VersionCreateRequest request) throws Exception { |
|
|
public ListenableFuture<UUID> saveEntitiesVersion(User user, VersionCreateRequest request) throws Exception { |
|
|
|
|
|
checkBranchName(request.getBranch()); |
|
|
var pendingCommit = gitServiceQueue.prepareCommit(user, request); |
|
|
var pendingCommit = gitServiceQueue.prepareCommit(user, request); |
|
|
DonAsynchron.withCallback(pendingCommit, commit -> { |
|
|
DonAsynchron.withCallback(pendingCommit, commit -> { |
|
|
cachePut(commit.getTxId(), new VersionCreationResult()); |
|
|
cachePut(commit.getTxId(), new VersionCreationResult()); |
|
|
@ -504,6 +506,7 @@ public class DefaultEntitiesVersionControlService implements EntitiesVersionCont |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public ListenableFuture<RepositorySettings> saveVersionControlSettings(TenantId tenantId, RepositorySettings versionControlSettings) { |
|
|
public ListenableFuture<RepositorySettings> saveVersionControlSettings(TenantId tenantId, RepositorySettings versionControlSettings) { |
|
|
|
|
|
checkBranchName(versionControlSettings.getDefaultBranch()); |
|
|
var restoredSettings = this.repositorySettingsService.restore(tenantId, versionControlSettings); |
|
|
var restoredSettings = this.repositorySettingsService.restore(tenantId, versionControlSettings); |
|
|
try { |
|
|
try { |
|
|
var future = gitServiceQueue.initRepository(tenantId, restoredSettings); |
|
|
var future = gitServiceQueue.initRepository(tenantId, restoredSettings); |
|
|
@ -525,6 +528,7 @@ public class DefaultEntitiesVersionControlService implements EntitiesVersionCont |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public ListenableFuture<Void> checkVersionControlAccess(TenantId tenantId, RepositorySettings settings) throws ThingsboardException { |
|
|
public ListenableFuture<Void> checkVersionControlAccess(TenantId tenantId, RepositorySettings settings) throws ThingsboardException { |
|
|
|
|
|
checkBranchName(settings.getDefaultBranch()); |
|
|
settings = this.repositorySettingsService.restore(tenantId, settings); |
|
|
settings = this.repositorySettingsService.restore(tenantId, settings); |
|
|
try { |
|
|
try { |
|
|
return gitServiceQueue.testRepository(tenantId, settings); |
|
|
return gitServiceQueue.testRepository(tenantId, settings); |
|
|
|