diff --git a/.gitignore b/.gitignore index 6836c0cc92..bb83a4fa07 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ release.properties /tmp/ /local/ .vscode/ +/webapp/src/main/resources/openapi.* diff --git a/cli/pom.xml b/cli/pom.xml index 3d93d553e0..68ee5620cd 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -37,21 +37,20 @@ - com.box.l10n.mojito - mojito-webapp - 0.111-SNAPSHOT - test + org.springframework.boot + spring-boot-starter-security com.box.l10n.mojito - mojito-common + mojito-webapp 0.111-SNAPSHOT + test com.box.l10n.mojito - mojito-restclient + mojito-common 0.111-SNAPSHOT diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AssetWsApiHelper.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AssetWsApiProxy.java similarity index 60% rename from cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AssetWsApiHelper.java rename to cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AssetWsApiProxy.java index 1b997debfe..8e46b9a3f8 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AssetWsApiHelper.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AssetWsApiProxy.java @@ -3,25 +3,22 @@ import com.box.l10n.mojito.cli.command.CommandException; import com.box.l10n.mojito.cli.model.AssetAssetSummary; import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import org.springframework.util.Assert; -@Component -public class AssetWsApiHelper { - @Autowired AssetWsApi assetClient; +public class AssetWsApiProxy extends AssetWsApi { + + public static final String OUTPUT_BCP47_TAG = "en-x-pseudo"; + + public AssetWsApiProxy(ApiClient apiClient) { + super(apiClient); + } public AssetAssetSummary getAssetByPathAndRepositoryId(String path, Long repositoryId) - throws CommandException { + throws CommandException, ApiException { Assert.notNull(path, "path must not be null"); Assert.notNull(repositoryId, "repository must not be null"); - List assets; - try { - assets = this.assetClient.getAssets(repositoryId, path, null, null, null); - } catch (ApiException e) { - throw new RuntimeException(e); - } + List assets = this.getAssets(repositoryId, path, null, null, null); if (!assets.isEmpty()) { return assets.getFirst(); } else { diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AuthenticatedApiClient.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AuthenticatedApiClient.java index 4845311732..371900d78c 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AuthenticatedApiClient.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AuthenticatedApiClient.java @@ -1,35 +1,18 @@ package com.box.l10n.mojito.cli.apiclient; import com.squareup.okhttp.OkHttpClient; -import jakarta.annotation.PostConstruct; -import java.net.CookieHandler; -import java.net.CookieManager; -import java.net.CookiePolicy; import org.springframework.stereotype.Component; @Component public class AuthenticatedApiClient extends ApiClient { - private CookieManager cookieManager; - - @PostConstruct - public void init() { - this.cookieManager = this.getCookieManager(); + public AuthenticatedApiClient() { this.setHttpClient(this.getOkHttpClient()); } - private CookieManager getCookieManager() { - CookieManager cookieManager = new CookieManager(); - cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER); - CookieHandler.setDefault(cookieManager); - return cookieManager; - } - private OkHttpClient getOkHttpClient() { OkHttpClient httpClient = new OkHttpClient(); - httpClient - .interceptors() - .add(new AuthenticatedApiInterceptor(this.cookieManager, this.getBasePath())); + httpClient.interceptors().add(new AuthenticatedApiInterceptor(this.getBasePath())); return httpClient; } } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AuthenticatedApiInterceptor.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AuthenticatedApiInterceptor.java index 03cc7c1bcf..bb1247ac78 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AuthenticatedApiInterceptor.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/AuthenticatedApiInterceptor.java @@ -11,6 +11,7 @@ import java.io.IOException; import java.net.CookieHandler; import java.net.CookieManager; +import java.net.CookiePolicy; import java.net.CookieStore; import java.net.HttpCookie; import java.util.Optional; @@ -37,11 +38,18 @@ public class AuthenticatedApiInterceptor implements Interceptor { private final String basePath; - public AuthenticatedApiInterceptor(CookieManager cookieManager, String basePath) { - this.cookieManager = cookieManager; + public AuthenticatedApiInterceptor(String basePath) { + this.cookieManager = getCookieManager(); this.basePath = basePath; } + private CookieManager getCookieManager() { + CookieManager cookieManager = new CookieManager(); + cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER); + CookieHandler.setDefault(cookieManager); + return cookieManager; + } + private Optional getCookie() { CookieStore cookieStore = this.cookieManager.getCookieStore(); return cookieStore.getCookies().stream() diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/LocaleWsApiProxy.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/LocaleWsApiProxy.java new file mode 100644 index 0000000000..350c021042 --- /dev/null +++ b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/LocaleWsApiProxy.java @@ -0,0 +1,28 @@ +package com.box.l10n.mojito.cli.apiclient; + +import com.box.l10n.mojito.cli.command.CommandException; +import com.box.l10n.mojito.cli.model.Locale; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LocaleWsApiProxy extends LocaleWsApi { + /** logger */ + static Logger logger = LoggerFactory.getLogger(LocaleWsApiProxy.class); + + public LocaleWsApiProxy(ApiClient apiClient) { + super(apiClient); + } + + public Locale getLocaleByBcp47Tag(String bcp47Tag) throws ApiException { + logger.debug("Getting locale for BCP47 tag: {}", bcp47Tag); + + List locales = this.getLocales(bcp47Tag); + + if (locales.size() != 1) { + throw new CommandException("Could not find locale with BCP47 tag: " + bcp47Tag); + } + + return locales.getFirst(); + } +} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/PollableTaskWsApiProxy.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/PollableTaskWsApiProxy.java new file mode 100644 index 0000000000..5a36f89988 --- /dev/null +++ b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/PollableTaskWsApiProxy.java @@ -0,0 +1,164 @@ +package com.box.l10n.mojito.cli.apiclient; + +import static org.slf4j.LoggerFactory.getLogger; + +import com.box.l10n.mojito.cli.apiclient.exceptions.PollableTaskException; +import com.box.l10n.mojito.cli.apiclient.exceptions.PollableTaskExecutionException; +import com.box.l10n.mojito.cli.apiclient.exceptions.PollableTaskTimeoutException; +import com.box.l10n.mojito.cli.command.CommandException; +import com.box.l10n.mojito.cli.model.PollableTask; +import com.box.l10n.mojito.cli.models.ErrorMessage; +import com.box.l10n.mojito.json.ObjectMapper; +import java.util.ArrayList; +import java.util.List; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class PollableTaskWsApiProxy extends PollableTaskWsApi { + /** logger */ + static Logger logger = getLogger(PollableTaskWsApiProxy.class); + + public static final Long NO_TIMEOUT = -1L; + + private final ObjectMapper objectMapper; + + @Autowired + public PollableTaskWsApiProxy(ApiClient apiClient, ObjectMapper objectMapper) { + super(apiClient); + this.objectMapper = objectMapper; + } + + /** + * Waits for {@link PollableTask} to be all finished (see {@link PollableTask#isAllFinished() }). + * Infinite timeout. + * + * @param pollableId the {@link PollableTask#getId()} + * @throws PollableTaskException + */ + public void waitForPollableTask(Long pollableId) throws PollableTaskException { + waitForPollableTask(pollableId, NO_TIMEOUT); + } + + public void waitForPollableTask(Long pollableTaskId, long timeout) throws PollableTaskException { + waitForPollableTask(pollableTaskId, timeout, null); + } + + /** + * Waits for {@link PollableTask} to be all finished (see {@link PollableTask#isAllFinished() }). + * + * @param pollableId the {@link com.box.l10n.mojito.cli.model.PollableTask#getId()} + * @param timeout timeout in milliseconds. + * @param waitForPollableTaskListener listener to be called during polling + * @throws PollableTaskException + */ + public void waitForPollableTask( + Long pollableId, long timeout, WaitForPollableTaskListener waitForPollableTaskListener) + throws PollableTaskException { + + long timeoutTime = System.currentTimeMillis() + timeout; + long waitTime = 0; + + PollableTask pollableTask = null; + + while (pollableTask == null || !pollableTask.isAllFinished()) { + + logger.debug("Waiting for PollableTask: {} to finish", pollableId); + + try { + pollableTask = this.getPollableTaskById(pollableId); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } + + if (waitForPollableTaskListener != null) { + waitForPollableTaskListener.afterPoll(pollableTask); + } + + List pollableTaskWithErrors = getAllPollableTasksWithError(pollableTask); + + if (!pollableTaskWithErrors.isEmpty()) { + + for (PollableTask pollableTaskWithError : pollableTaskWithErrors) { + ErrorMessage errorMessage = + this.objectMapper.convertValue( + pollableTaskWithError.getErrorMessage(), ErrorMessage.class); + logger.debug( + "Error happened in PollableTask {}: {}", + pollableTaskWithError.getId(), + errorMessage.getMessage()); + } + + // Last task is the root task if it has an error or any of the sub task + // TODO(P1) we might want to show all errors + PollableTask lastTaskInError = + pollableTaskWithErrors.get(pollableTaskWithErrors.size() - 1); + + ErrorMessage errorMessage = + this.objectMapper.convertValue(lastTaskInError.getErrorMessage(), ErrorMessage.class); + throw new PollableTaskExecutionException(errorMessage.getMessage()); + } + + if (!pollableTask.isAllFinished()) { + + if (timeout != NO_TIMEOUT && System.currentTimeMillis() > timeoutTime) { + logger.debug( + "Timed out waiting for PollableTask: {} to finish. \n{}", + pollableId, + ReflectionToStringBuilder.toString(pollableTask)); + throw new PollableTaskTimeoutException( + "Timed out waiting for PollableTask: " + pollableId); + } + + try { + Thread.sleep(waitTime); + waitTime = getNextWaitTime(waitTime); + } catch (InterruptedException ie) { + throw new RuntimeException(ie); + } + } else { + logger.debug("PollableTask: {} finished", pollableId); + } + } + } + + long getNextWaitTime(long lastWaitTime) { + int maxTime = 500; + long nextWaitTime = lastWaitTime + 25; + nextWaitTime = Math.max(maxTime, nextWaitTime); + return nextWaitTime; + } + + /** + * Get all the PollableTasks with error (traverses all the PollableTask's subtasks) + * + * @param pollableTask + * @return + */ + public List getAllPollableTasksWithError(PollableTask pollableTask) { + List result = new ArrayList<>(); + recursivelyGetAllPollableTaskWithError(pollableTask, result); + return result; + } + + /** + * Recursively traverses all subtasks of {@code pollableTask} and return all the {@link + * PollableTask} which had an error message + * + * @param pollableTask + * @param pollableTasksWithError + */ + private void recursivelyGetAllPollableTaskWithError( + PollableTask pollableTask, List pollableTasksWithError) { + + for (PollableTask subTask : pollableTask.getSubTasks()) { + recursivelyGetAllPollableTaskWithError(subTask, pollableTasksWithError); + } + + if (pollableTask.getErrorMessage() != null) { + pollableTasksWithError.add(pollableTask); + } + } +} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/RepositoryWsApiHelper.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/RepositoryWsApiHelper.java deleted file mode 100644 index e3522ecbf1..0000000000 --- a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/RepositoryWsApiHelper.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.box.l10n.mojito.cli.apiclient; - -import com.box.l10n.mojito.cli.command.CommandException; -import com.box.l10n.mojito.cli.model.BranchBranchSummary; -import com.box.l10n.mojito.cli.model.RepositoryRepository; -import com.google.common.base.Preconditions; -import java.time.OffsetDateTime; -import java.util.List; -import java.util.regex.Pattern; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class RepositoryWsApiHelper { - @Autowired RepositoryWsApi repositoryClient; - - public List getBranchesOfRepository( - Long repositoryId, - String branchName, - String branchNameRegex, - Boolean deleted, - Boolean translated, - boolean includeNullBranch, - OffsetDateTime createdBefore) - throws CommandException { - List branches; - try { - branches = - this.repositoryClient.getBranchesOfRepository( - repositoryId, branchName, deleted, translated, createdBefore); - } catch (ApiException e) { - throw new CommandException(e.getMessage(), e); - } - if (branchNameRegex != null) { - Pattern branchNamePattern = Pattern.compile(branchNameRegex); - branches = - branches.stream() - .filter( - b -> { - if (b.getName() == null) { - return includeNullBranch; - } else { - return branchNamePattern.matcher(b.getName()).matches(); - } - }) - .toList(); - } - return branches; - } - - public RepositoryRepository findRepositoryByName(String repositoryName) throws CommandException { - try { - Preconditions.checkNotNull(repositoryName, "Repository name can't be null"); - List repositories = repositoryClient.getRepositories(repositoryName); - if (repositories.size() != 1) { - throw new CommandException("Repository with name [" + repositoryName + "] is not found"); - } - return repositories.getFirst(); - } catch (ApiException e) { - throw new CommandException("Repository [" + repositoryName + "] is not found", e); - } - } -} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/RepositoryWsApiProxy.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/RepositoryWsApiProxy.java new file mode 100644 index 0000000000..fa86704be8 --- /dev/null +++ b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/RepositoryWsApiProxy.java @@ -0,0 +1,145 @@ +package com.box.l10n.mojito.cli.apiclient; + +import com.box.l10n.mojito.cli.apiclient.mappers.RepositoryMapper; +import com.box.l10n.mojito.cli.command.CommandException; +import com.box.l10n.mojito.cli.model.BranchBranchSummary; +import com.box.l10n.mojito.cli.model.ImportRepositoryBody; +import com.box.l10n.mojito.cli.model.Repository; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Objects; +import java.util.regex.Pattern; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; + +public class RepositoryWsApiProxy extends RepositoryWsApi { + + /** logger */ + static Logger logger = LoggerFactory.getLogger(RepositoryWsApiProxy.class); + + public RepositoryWsApiProxy(ApiClient apiClient) { + super(apiClient); + } + + public List getBranchesOfRepository( + Long repositoryId, + String branchName, + String branchNameRegex, + Boolean deleted, + Boolean translated, + boolean includeNullBranch, + OffsetDateTime createdBefore) + throws CommandException { + List branches; + try { + branches = + this.getBranchesOfRepository( + repositoryId, branchName, deleted, translated, createdBefore); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } + if (branchNameRegex != null) { + Pattern branchNamePattern = Pattern.compile(branchNameRegex); + branches = + branches.stream() + .filter( + b -> { + if (b.getName() == null) { + return includeNullBranch; + } else { + return branchNamePattern.matcher(b.getName()).matches(); + } + }) + .toList(); + } + return branches; + } + + public RepositoryRepository getRepositoryByName(String repositoryName) + throws CommandException, ApiException { + logger.debug("Getting repo with name = {}", repositoryName); + + List repositoryList = this.getRepositories(repositoryName); + + if (repositoryList.size() != 1) { + throw new CommandException("Repository with name [" + repositoryName + "] is not found"); + } + + return repositoryList.getFirst(); + } + + /** + * Deletes a {@link RepositoryRepository} by the {@link RepositoryRepository#getName()} + * + * @param repositoryName + * @throws ApiException + */ + public void deleteRepositoryByName(String repositoryName) throws ApiException { + logger.debug("Deleting repository by name = [{}]", repositoryName); + RepositoryRepository repository = this.getRepositoryByName(repositoryName); + this.deleteRepositoryById(repository.getId()); + } + + public BranchBranchSummary getBranch(Long repositoryId, String branchName) { + List branches = + this.getBranchesOfRepository(repositoryId, branchName, null, null, null, false, null); + logger.debug("Support the \"null\" branch (name is null and param filtering doesn't work)"); + return branches.stream() + .filter((b) -> Objects.equals(b.getName(), branchName)) + .findFirst() + .orElse(null); + } + + @Override + public RepositoryRepository createRepository(Repository body) + throws ApiException, CommandException { + try { + return super.createRepository(body); + } catch (ApiException exception) { + if (exception.getCode() == HttpStatus.CONFLICT.value()) { + throw new CommandException(exception.getResponseBody()); + } else { + throw exception; + } + } + } + + @Override + public String importRepository(ImportRepositoryBody body, Long repositoryId) + throws ApiException, CommandException { + try { + return super.importRepository(body, repositoryId); + } catch (ApiException exception) { + if (exception.getCode() == HttpStatus.CONFLICT.value()) { + throw new CommandException("Importing to repository [" + repositoryId + "] failed"); + } else { + throw exception; + } + } + } + + public void updateRepository(String name, Repository repositoryBody) + throws ApiException, CommandException { + logger.debug("Updating repository by name = [{}]", name); + RepositoryRepository repository = this.getRepositoryByName(name); + Repository updatedRepository = RepositoryMapper.mapToRepository(repository); + updatedRepository.setDescription(repositoryBody.getDescription()); + updatedRepository.setName(repositoryBody.getName()); + updatedRepository.setRepositoryLocales(repositoryBody.getRepositoryLocales()); + updatedRepository.setCheckSLA(repositoryBody.isCheckSLA()); + if (repositoryBody.getAssetIntegrityCheckers() != null) { + updatedRepository.setAssetIntegrityCheckers(repositoryBody.getAssetIntegrityCheckers()); + } + try { + this.updateRepository(updatedRepository, repository.getId()); + } catch (ApiException exception) { + if (exception.getCode() == HttpStatus.CONFLICT.value()) { + throw new CommandException(exception.getResponseBody()); + } else { + throw exception; + } + } + } +} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/WaitForPollableTaskListener.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/WaitForPollableTaskListener.java new file mode 100644 index 0000000000..7b68a14de3 --- /dev/null +++ b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/WaitForPollableTaskListener.java @@ -0,0 +1,7 @@ +package com.box.l10n.mojito.cli.apiclient; + +import com.box.l10n.mojito.cli.model.PollableTask; + +public interface WaitForPollableTaskListener { + void afterPoll(PollableTask pollableTask); +} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/WsApiConfig.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/WsApiConfig.java deleted file mode 100644 index 030aadb548..0000000000 --- a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/WsApiConfig.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.box.l10n.mojito.cli.apiclient; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class WsApiConfig { - @Autowired private ApiClient apiClient; - - @Bean - public ThirdPartyWsApi thirdPartyWsApi() { - return new ThirdPartyWsApi(this.apiClient); - } - - @Bean - public UserWsApi userWsApi() { - return new UserWsApi(this.apiClient); - } - - @Bean - public QuartzWsApi quartzWsApi() { - return new QuartzWsApi(this.apiClient); - } - - @Bean - public VirtualAssetWsApi virtualAssetWsApi() { - return new VirtualAssetWsApi(this.apiClient); - } - - @Bean - public RepositoryWsApi repositoryWsApi() { - return new RepositoryWsApi(this.apiClient); - } - - @Bean - public CommitWsApi commitWsApi() { - return new CommitWsApi(this.apiClient); - } - - @Bean - public ImageWsApi imageWsApi() { - return new ImageWsApi(this.apiClient); - } - - @Bean - public AiPromptWsApi aiPromptWsApi() { - return new AiPromptWsApi(this.apiClient); - } - - @Bean - public AiChecksWsApi aiChecksWsApi() { - return new AiChecksWsApi(this.apiClient); - } - - @Bean - public AssetWsApi assetWsApi() { - return new AssetWsApi(this.apiClient); - } - - @Bean - public DropWsApi dropWsApi() { - return new DropWsApi(this.apiClient); - } - - @Bean - public CliWsApi cliWsApi() { - return new CliWsApi(this.apiClient); - } -} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/exceptions/PollableTaskException.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/exceptions/PollableTaskException.java new file mode 100644 index 0000000000..9d75da1ca2 --- /dev/null +++ b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/exceptions/PollableTaskException.java @@ -0,0 +1,7 @@ +package com.box.l10n.mojito.cli.apiclient.exceptions; + +public class PollableTaskException extends RuntimeException { + public PollableTaskException(String message) { + super(message); + } +} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/exceptions/PollableTaskExecutionException.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/exceptions/PollableTaskExecutionException.java new file mode 100644 index 0000000000..159e982be8 --- /dev/null +++ b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/exceptions/PollableTaskExecutionException.java @@ -0,0 +1,7 @@ +package com.box.l10n.mojito.cli.apiclient.exceptions; + +public class PollableTaskExecutionException extends PollableTaskException { + public PollableTaskExecutionException(String message) { + super(message); + } +} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/exceptions/PollableTaskTimeoutException.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/exceptions/PollableTaskTimeoutException.java new file mode 100644 index 0000000000..6177300be4 --- /dev/null +++ b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/exceptions/PollableTaskTimeoutException.java @@ -0,0 +1,7 @@ +package com.box.l10n.mojito.cli.apiclient.exceptions; + +public class PollableTaskTimeoutException extends PollableTaskException { + public PollableTaskTimeoutException(String message) { + super(message); + } +} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/mappers/GitBlameWithUsageMapper.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/mappers/GitBlameWithUsageMapper.java new file mode 100644 index 0000000000..7bfeef29d8 --- /dev/null +++ b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/mappers/GitBlameWithUsageMapper.java @@ -0,0 +1,36 @@ +package com.box.l10n.mojito.cli.apiclient.mappers; + +import static java.util.Optional.ofNullable; + +import com.box.l10n.mojito.cli.model.GitBlame; +import com.box.l10n.mojito.cli.model.GitBlameGitBlameWithUsage; +import com.box.l10n.mojito.cli.model.GitBlameWithUsage; +import com.box.l10n.mojito.cli.model.GitBlameWithUsageGitBlameWithUsage; + +public class GitBlameWithUsageMapper { + public static GitBlame mapToGitBlame(GitBlameGitBlameWithUsage gitBlameWithUsage) { + GitBlame gitBlame = new GitBlame(); + gitBlame.setAuthorEmail(gitBlameWithUsage.getAuthorEmail()); + gitBlame.setAuthorName(gitBlameWithUsage.getAuthorName()); + gitBlame.setCommitTime(gitBlameWithUsage.getCommitTime()); + gitBlame.setCommitName(gitBlameWithUsage.getCommitName()); + return gitBlame; + } + + public static GitBlameWithUsage mapToGitBlameWithUsage( + GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage) { + GitBlameWithUsage newGitBlameWithUsage = new GitBlameWithUsage(); + newGitBlameWithUsage.setUsages(gitBlameWithUsage.getUsages()); + newGitBlameWithUsage.setTextUnitName(gitBlameWithUsage.getTextUnitName()); + newGitBlameWithUsage.setPluralForm(gitBlameWithUsage.getPluralForm()); + newGitBlameWithUsage.setTmTextUnitId(gitBlameWithUsage.getTmTextUnitId()); + newGitBlameWithUsage.setAssetTextUnitId(gitBlameWithUsage.getAssetTextUnitId()); + newGitBlameWithUsage.setContent(gitBlameWithUsage.getContent()); + newGitBlameWithUsage.setComment(gitBlameWithUsage.getComment()); + newGitBlameWithUsage.setGitBlame( + ofNullable(gitBlameWithUsage.getGitBlame()) + .map(GitBlameWithUsageMapper::mapToGitBlame) + .orElse(null)); + return newGitBlameWithUsage; + } +} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/mappers/RepositoryMapper.java b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/mappers/RepositoryMapper.java new file mode 100644 index 0000000000..cb3c3fc2ed --- /dev/null +++ b/cli/src/main/java/com/box/l10n/mojito/cli/apiclient/mappers/RepositoryMapper.java @@ -0,0 +1,116 @@ +package com.box.l10n.mojito.cli.apiclient.mappers; + +import static java.util.Optional.ofNullable; + +import com.box.l10n.mojito.cli.model.AssetIntegrityChecker; +import com.box.l10n.mojito.cli.model.AssetIntegrityCheckerRepository; +import com.box.l10n.mojito.cli.model.Locale; +import com.box.l10n.mojito.cli.model.LocaleRepository; +import com.box.l10n.mojito.cli.model.Repository; +import com.box.l10n.mojito.cli.model.RepositoryLocale; +import com.box.l10n.mojito.cli.model.RepositoryLocaleRepository; +import com.box.l10n.mojito.cli.model.RepositoryLocaleStatistic; +import com.box.l10n.mojito.cli.model.RepositoryLocaleStatisticRepository; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import com.box.l10n.mojito.cli.model.RepositoryStatistic; +import com.box.l10n.mojito.cli.model.RepositoryStatisticRepository; + +public class RepositoryMapper { + public static Locale mapToLocale(LocaleRepository localeRepository) { + Locale locale = new Locale(); + locale.setId(localeRepository.getId()); + locale.setBcp47Tag(localeRepository.getBcp47Tag()); + return locale; + } + + public static RepositoryLocale mapToRepositoryLocale( + RepositoryLocaleRepository repositoryLocaleRepository) { + RepositoryLocale repositoryLocale = new RepositoryLocale(); + repositoryLocale.setId(repositoryLocaleRepository.getId()); + repositoryLocale.setLocale( + ofNullable(repositoryLocaleRepository.getLocale()) + .map(RepositoryMapper::mapToLocale) + .orElse(null)); + repositoryLocale.setToBeFullyTranslated(repositoryLocaleRepository.isToBeFullyTranslated()); + repositoryLocale.setParentLocale( + ofNullable(repositoryLocaleRepository.getParentLocale()) + .map(RepositoryMapper::mapToRepositoryLocale) + .orElse(null)); + return repositoryLocale; + } + + public static AssetIntegrityChecker mapToAssetIntegrityChecker( + AssetIntegrityCheckerRepository assetIntegrityCheckerRepository) { + AssetIntegrityChecker assetIntegrityChecker = new AssetIntegrityChecker(); + assetIntegrityChecker.setId(assetIntegrityCheckerRepository.getId()); + assetIntegrityChecker.setAssetExtension(assetIntegrityCheckerRepository.getAssetExtension()); + assetIntegrityChecker.setIntegrityCheckerType( + ofNullable(assetIntegrityCheckerRepository.getIntegrityCheckerType()) + .map( + integrityCheckerType -> + AssetIntegrityChecker.IntegrityCheckerTypeEnum.fromValue( + integrityCheckerType.name())) + .orElse(null)); + return assetIntegrityChecker; + } + + public static RepositoryLocaleStatistic mapToRepositoryLocaleStatistic( + RepositoryLocaleStatisticRepository repositoryLocaleStatisticRepository) { + RepositoryLocaleStatistic repositoryLocaleStatistic = new RepositoryLocaleStatistic(); + repositoryLocaleStatistic.setLocale( + ofNullable(repositoryLocaleStatisticRepository.getLocale()) + .map(RepositoryMapper::mapToLocale) + .orElse(null)); + repositoryLocaleStatistic.setForTranslationCount( + repositoryLocaleStatisticRepository.getForTranslationCount()); + return repositoryLocaleStatistic; + } + + public static RepositoryStatistic mapToRepositoryStatistic( + RepositoryStatisticRepository repositoryStatisticRepository) { + RepositoryStatistic repositoryStatistic = new RepositoryStatistic(); + repositoryStatistic.setRepositoryLocaleStatistics( + ofNullable(repositoryStatisticRepository.getRepositoryLocaleStatistics()) + .map( + repositoryLocaleStatistics -> + repositoryLocaleStatistics.stream() + .map(RepositoryMapper::mapToRepositoryLocaleStatistic) + .toList()) + .orElse(null)); + return repositoryStatistic; + } + + public static Repository mapToRepository(RepositoryRepository repositoryRepository) { + Repository repository = new Repository(); + repository.setId(repositoryRepository.getId()); + repository.setName(repositoryRepository.getName()); + repository.setDescription(repositoryRepository.getDescription()); + repository.setDeleted(repositoryRepository.isDeleted()); + repository.setCheckSLA(repositoryRepository.isCheckSLA()); + repository.setSourceLocale( + ofNullable(repositoryRepository.getSourceLocale()) + .map(RepositoryMapper::mapToLocale) + .orElse(null)); + repository.setRepositoryLocales( + ofNullable(repositoryRepository.getRepositoryLocales()) + .map( + repositoryLocales -> + repositoryLocales.stream() + .map(RepositoryMapper::mapToRepositoryLocale) + .toList()) + .orElse(null)); + repository.setAssetIntegrityCheckers( + ofNullable(repositoryRepository.getAssetIntegrityCheckers()) + .map( + assetIntegrityCheckers -> + assetIntegrityCheckers.stream() + .map(RepositoryMapper::mapToAssetIntegrityChecker) + .toList()) + .orElse(null)); + repository.setRepositoryStatistic( + ofNullable(repositoryRepository.getRepositoryStatistic()) + .map(RepositoryMapper::mapToRepositoryStatistic) + .orElse(null)); + return repository; + } +} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/AIRepositoryLocaleOverrideCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/AIRepositoryLocaleOverrideCommand.java index 6e70c0be74..9585f452ff 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/AIRepositoryLocaleOverrideCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/AIRepositoryLocaleOverrideCommand.java @@ -3,8 +3,10 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.box.l10n.mojito.cli.apiclient.AiPromptWsApi; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.model.AITranslationLocalePromptOverridesRequest; +import jakarta.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -22,7 +24,7 @@ public class AIRepositoryLocaleOverrideCommand extends Command { static Logger logger = LoggerFactory.getLogger(CreateAIPromptCommand.class); - @Autowired AiPromptWsApi aiServiceClient; + AiPromptWsApi aiServiceClient; @Parameter( names = {"--repository-name", "-r"}, @@ -55,8 +57,14 @@ public class AIRepositoryLocaleOverrideCommand extends Command { description = "Delete the AI prompt overrides for the given locales") boolean isDelete = false; - @Override - protected void execute() throws CommandException { + @Autowired private ApiClient apiClient; + + @PostConstruct + public void init() { + this.aiServiceClient = new AiPromptWsApi(this.apiClient); + } + + private AITranslationLocalePromptOverridesRequest getAiTranslationLocalePromptOverridesRequest() { AITranslationLocalePromptOverridesRequest aiTranslationLocalePromptOverridesRequest = new AITranslationLocalePromptOverridesRequest(); aiTranslationLocalePromptOverridesRequest.setRepositoryName(repository); @@ -64,6 +72,13 @@ protected void execute() throws CommandException { StringUtils.commaDelimitedListToSet(locales).stream().toList()); aiTranslationLocalePromptOverridesRequest.setAiPromptId(aiPromptId); aiTranslationLocalePromptOverridesRequest.setDisabled(disabled); + return aiTranslationLocalePromptOverridesRequest; + } + + @Override + protected void execute() throws CommandException { + AITranslationLocalePromptOverridesRequest aiTranslationLocalePromptOverridesRequest = + getAiTranslationLocalePromptOverridesRequest(); try { if (isDelete) { aiServiceClient.deleteRepositoryLocalePromptOverrides( diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/AddPromptToRepositoryCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/AddPromptToRepositoryCommand.java index c93ad67854..15cdf517fe 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/AddPromptToRepositoryCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/AddPromptToRepositoryCommand.java @@ -3,8 +3,10 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.box.l10n.mojito.cli.apiclient.AiPromptWsApi; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.console.ConsoleWriter; +import jakarta.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -20,7 +22,7 @@ public class AddPromptToRepositoryCommand extends Command { static Logger logger = LoggerFactory.getLogger(AddPromptToRepositoryCommand.class); - @Autowired AiPromptWsApi aiServiceClient; + AiPromptWsApi aiServiceClient; @Parameter( names = {"--repository-name", "-r"}, @@ -42,6 +44,13 @@ public class AddPromptToRepositoryCommand extends Command { @Autowired ConsoleWriter consoleWriter; + @Autowired ApiClient apiClient; + + @PostConstruct + public void init() { + this.aiServiceClient = new AiPromptWsApi(this.apiClient); + } + public void execute() { logger.debug("Add prompt to {} repository with id: {}", repository, promptId); try { diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/BranchDeleteCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/BranchDeleteCommand.java index b1e429dac3..ba32b7c777 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/BranchDeleteCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/BranchDeleteCommand.java @@ -16,14 +16,15 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; -import com.box.l10n.mojito.cli.apiclient.RepositoryWsApi; -import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiHelper; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.model.BranchBranchSummary; import com.box.l10n.mojito.cli.model.PollableTask; import com.box.l10n.mojito.cli.model.RepositoryRepository; +import jakarta.annotation.PostConstruct; import java.time.ZonedDateTime; import java.util.List; import org.fusesource.jansi.Ansi; @@ -44,10 +45,6 @@ public class BranchDeleteCommand extends Command { @Autowired ConsoleWriter consoleWriter; - @Autowired RepositoryWsApi repositoryClient; - - @Autowired RepositoryWsApiHelper repositoryWsApiHelper; - @Autowired CommandHelper commandHelper; @Parameter( @@ -93,6 +90,15 @@ public class BranchDeleteCommand extends Command { description = BRANCH_CREATED_BEFORE_DESCRIPTION) String createdBefore = null; + @Autowired private ApiClient apiClient; + + private RepositoryWsApiProxy repositoryClient; + + @PostConstruct + public void init() { + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + } + @Override public void execute() throws CommandException { consoleWriter @@ -101,8 +107,12 @@ public void execute() throws CommandException { .fg(Ansi.Color.CYAN) .a(repositoryParam) .println(); - RepositoryRepository repository = - this.repositoryWsApiHelper.findRepositoryByName(this.repositoryParam); + RepositoryRepository repository; + try { + repository = this.commandHelper.findRepositoryByName(this.repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } ZonedDateTime createdBeforeDateTime = this.commandHelper.getLastWeekDateIfTrue(this.beforeLastWeek); @@ -118,7 +128,7 @@ public void execute() throws CommandException { } List branches = - this.repositoryWsApiHelper.getBranchesOfRepository( + repositoryClient.getBranchesOfRepository( repository.getId(), branchName, branchNameRegex, diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/BranchViewCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/BranchViewCommand.java index 6466031d2f..fbcb56c07f 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/BranchViewCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/BranchViewCommand.java @@ -13,11 +13,14 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiHelper; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.model.BranchBranchSummary; import com.box.l10n.mojito.cli.model.RepositoryRepository; +import jakarta.annotation.PostConstruct; import java.time.ZonedDateTime; import java.util.List; import org.fusesource.jansi.Ansi; @@ -38,8 +41,6 @@ public class BranchViewCommand extends Command { @Autowired ConsoleWriter consoleWriter; - @Autowired RepositoryWsApiHelper repositoryWsApiHelper; - @Autowired CommandHelper commandHelper; @Parameter( @@ -79,6 +80,15 @@ public class BranchViewCommand extends Command { description = BRANCH_CREATED_BEFORE_LAST_WEEK_DESCRIPTION) boolean beforeLastWeek; + @Autowired private ApiClient apiClient; + + private RepositoryWsApiProxy repositoryClient; + + @PostConstruct + public void init() { + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + } + @Override public void execute() throws CommandException { consoleWriter @@ -87,10 +97,15 @@ public void execute() throws CommandException { .fg(Ansi.Color.CYAN) .a(repositoryParam) .println(); - RepositoryRepository repository = repositoryWsApiHelper.findRepositoryByName(repositoryParam); + RepositoryRepository repository; + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } List branches = - this.repositoryWsApiHelper.getBranchesOfRepository( + repositoryClient.getBranchesOfRepository( repository.getId(), null, branchNameRegex, diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/CommandHelper.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/CommandHelper.java index a8fc13a98a..6e2dd5f61b 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/CommandHelper.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/CommandHelper.java @@ -3,24 +3,26 @@ import static com.box.l10n.mojito.cli.command.param.Param.BRANCH_CREATED_BEFORE_OPTIONS_AND_EXAMPLE; import com.box.l10n.mojito.JSR310Migration; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.PollableTaskWsApiProxy; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; +import com.box.l10n.mojito.cli.apiclient.exceptions.PollableTaskException; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.filefinder.FileFinder; import com.box.l10n.mojito.cli.filefinder.FileFinderException; import com.box.l10n.mojito.cli.filefinder.FileMatch; import com.box.l10n.mojito.cli.filefinder.file.FileType; import com.box.l10n.mojito.cli.filefinder.file.XcodeXliffFileType; -import com.box.l10n.mojito.rest.client.PollableTaskClient; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.client.exception.PollableTaskException; -import com.box.l10n.mojito.rest.client.exception.RestClientException; -import com.box.l10n.mojito.rest.entity.Locale; -import com.box.l10n.mojito.rest.entity.PollableTask; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.RepositoryLocale; +import com.box.l10n.mojito.cli.model.LocaleRepository; +import com.box.l10n.mojito.cli.model.PollableTask; +import com.box.l10n.mojito.cli.model.RepositoryLocaleRepository; +import com.box.l10n.mojito.cli.model.RepositoryRepository; import com.google.common.base.Preconditions; import com.google.common.base.Stopwatch; import com.google.common.base.Strings; import com.google.common.io.Files; +import jakarta.annotation.PostConstruct; import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; @@ -71,12 +73,14 @@ public class CommandHelper { ByteOrderMark.UTF_8, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_16LE }; - @Autowired RepositoryClient repositoryClient; + @Autowired ApiClient apiClient; - @Autowired PollableTaskClient pollableTaskClient; + @Autowired PollableTaskWsApiProxy pollableTaskClient; @Autowired ConsoleWriter consoleWriter; + private RepositoryWsApiProxy repositoryClient; + static { TIMEFRAME_FUNCTIONS = new HashMap<>(); TIMEFRAME_FUNCTIONS.put(TimeframeType.DAYS, Period::ofDays); @@ -85,18 +89,19 @@ public class CommandHelper { TIMEFRAME_FUNCTIONS.put(TimeframeType.YEARS, Period::ofYears); } + @PostConstruct + public void init() { + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + } + /** * @param repositoryName Name of repository * @return */ - public Repository findRepositoryByName(String repositoryName) throws CommandException { - - try { - Preconditions.checkNotNull(repositoryName, "Repository name can't be null"); - return repositoryClient.getRepositoryByName(repositoryName); - } catch (RestClientException e) { - throw new CommandException("Repository [" + repositoryName + "] is not found", e); - } + public RepositoryRepository findRepositoryByName(String repositoryName) + throws CommandException, ApiException { + Preconditions.checkNotNull(repositoryName, "Repository name can't be null"); + return repositoryClient.getRepositoryByName(repositoryName); } /** @@ -104,7 +109,7 @@ public Repository findRepositoryByName(String repositoryName) throws CommandExce * * @return */ - public List getAllRepositories() { + public List getAllRepositories() throws ApiException { return repositoryClient.getRepositories(null); } @@ -290,7 +295,7 @@ public void writeFileContent(String content, Path path) throws CommandException * Waits for {@link PollableTask} to be all finished (see {@link PollableTask#isAllFinished() }). * Infinite timeout. * - * @param pollableId the {@link PollableTask#id} + * @param pollableId the {@link PollableTask#getId()} * @throws com.box.l10n.mojito.cli.command.CommandException */ public void waitForPollableTask(Long pollableId) throws CommandException { @@ -305,7 +310,7 @@ public void waitForPollableTask(Long pollableId) throws CommandException { try { pollableTaskClient.waitForPollableTask( - pollableId, PollableTaskClient.NO_TIMEOUT, new CommandWaitForPollableTaskListener()); + pollableId, PollableTaskWsApiProxy.NO_TIMEOUT, new CommandWaitForPollableTaskListener()); } catch (PollableTaskException e) { throw new CommandException(e.getMessage(), e.getCause()); } @@ -314,7 +319,7 @@ public void waitForPollableTask(Long pollableId) throws CommandException { public void waitForPollableTaskSilencedOutput(Long pollableId) throws CommandException { try { - pollableTaskClient.waitForPollableTask(pollableId, PollableTaskClient.NO_TIMEOUT, null); + pollableTaskClient.waitForPollableTask(pollableId, PollableTaskWsApiProxy.NO_TIMEOUT, null); } catch (PollableTaskException e) { throw new CommandException(e.getMessage(), e.getCause()); } @@ -326,14 +331,15 @@ public void waitForPollableTaskSilencedOutput(Long pollableId) throws CommandExc * @param repository * @return */ - public Map getSortedRepositoryLocales(Repository repository) { + public Map getSortedRepositoryLocales(RepositoryRepository repository) { - LinkedHashMap locales = new LinkedHashMap<>(); + LinkedHashMap locales = new LinkedHashMap<>(); - ArrayDeque toProcess = new ArrayDeque<>(repository.getRepositoryLocales()); - Locale rootLocale = null; + ArrayDeque toProcess = + new ArrayDeque<>(repository.getRepositoryLocales()); + LocaleRepository rootLocale = null; - for (RepositoryLocale rl : toProcess) { + for (RepositoryLocaleRepository rl : toProcess) { if (rl.getParentLocale() == null) { rootLocale = rl.getLocale(); toProcess.remove(rl); @@ -344,7 +350,7 @@ public Map getSortedRepositoryLocales(Repository repository) { Set localeIds = new HashSet<>(); while (!toProcess.isEmpty()) { - RepositoryLocale rl = toProcess.removeFirst(); + RepositoryLocaleRepository rl = toProcess.removeFirst(); Long parentLocaleId = rl.getParentLocale().getLocale().getId(); if (parentLocaleId.equals(rootLocale.getId()) || localeIds.contains(parentLocaleId)) { localeIds.add(rl.getLocale().getId()); diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/CommandWaitForPollableTaskListener.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/CommandWaitForPollableTaskListener.java index 1dd9691457..cf39e41814 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/CommandWaitForPollableTaskListener.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/CommandWaitForPollableTaskListener.java @@ -1,8 +1,10 @@ package com.box.l10n.mojito.cli.command; +import com.box.l10n.mojito.cli.apiclient.WaitForPollableTaskListener; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.client.WaitForPollableTaskListener; -import com.box.l10n.mojito.rest.entity.PollableTask; +import com.box.l10n.mojito.cli.model.PollableTask; +import com.box.l10n.mojito.cli.models.ErrorMessage; +import com.box.l10n.mojito.json.ObjectMapper; import com.google.common.base.Strings; import org.fusesource.jansi.Ansi; import org.slf4j.Logger; @@ -23,10 +25,9 @@ public class CommandWaitForPollableTaskListener implements WaitForPollableTaskLi @Autowired ConsoleWriter consoleWriter; - /** - * Keeps track of the number of callback to {@link - * #afterPoll(com.box.l10n.mojito.rest.entity.PollableTask) } - */ + @Autowired ObjectMapper objectMapper; + + /** Keeps track of the number of callback to {@link #afterPoll(PollableTask) } */ int numberAfterPollCallback = 0; @Override @@ -68,13 +69,11 @@ void printPollableTaskMessages(PollableTask pollableTask, int indentationLevel) .a(") "); if (pollableTask.getErrorMessage() != null) { - consoleWriter - .fg(Ansi.Color.RED) - .a("Failed") - .newLine() - .a(pollableTask.getErrorMessage().getMessage()); + ErrorMessage errorMessage = + this.objectMapper.convertValue(pollableTask.getErrorMessage(), ErrorMessage.class); + consoleWriter.fg(Ansi.Color.RED).a("Failed").newLine().a(errorMessage.getMessage()); - if (!pollableTask.getErrorMessage().isExpected()) { + if (!errorMessage.isExpected()) { consoleWriter.newLine().a("Error stack").newLine().a(pollableTask.getErrorStack()); } } else if (pollableTask.getFinishedDate() != null) { diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/CommitCreateCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/CommitCreateCommand.java index da234262d7..0794c4b8a5 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/CommitCreateCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/CommitCreateCommand.java @@ -5,15 +5,16 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.box.l10n.mojito.JSR310Migration; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.apiclient.CommitWsApi; -import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiHelper; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.model.CommitBody; import com.box.l10n.mojito.cli.model.CommitCommit; import com.box.l10n.mojito.cli.model.RepositoryRepository; import com.google.common.collect.Streams; +import jakarta.annotation.PostConstruct; import java.io.IOException; import java.time.ZonedDateTime; import org.eclipse.jgit.api.Git; @@ -46,9 +47,7 @@ public class CommitCreateCommand extends Command { @Autowired CommandHelper commandHelper; - @Autowired CommitWsApi commitClient; - - @Autowired RepositoryWsApiHelper repositoryWsApiHelper; + CommitWsApi commitClient; @Parameter( names = {Param.COMMIT_HASH_LONG, Param.COMMIT_HASH_SHORT}, @@ -90,6 +89,13 @@ public class CommitCreateCommand extends Command { + " the first commit from 'git log' is used.") boolean readInfoFromGit = false; + @Autowired private ApiClient apiClient; + + @PostConstruct + public void init() { + this.commitClient = new CommitWsApi(this.apiClient); + } + @Override protected void execute() throws CommandException { consoleWriter @@ -98,9 +104,12 @@ protected void execute() throws CommandException { .fg(Ansi.Color.CYAN) .a(repositoryParam) .println(2); - - RepositoryRepository repository = - this.repositoryWsApiHelper.findRepositoryByName(repositoryParam); + RepositoryRepository repository; + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } final CommitInfo commitInfo; @@ -116,13 +125,11 @@ protected void execute() throws CommandException { commitBody.setAuthorName(commitInfo.authorName); commitBody.setAuthorEmail(commitInfo.authorEmail); Long creationDateMilliSeconds = - ofNullable(commitInfo.creationDate) - .map(creationDate -> creationDate.toInstant().getEpochSecond() * 1_000) - .orElse(null); + ofNullable(commitInfo.creationDate).map(JSR310Migration::getMillis).orElse(null); commitBody.setSourceCreationDate(creationDateMilliSeconds); CommitCommit commit; try { - commit = commitClient.createCommit(commitBody); + commit = this.commitClient.createCommit(commitBody); } catch (ApiException e) { throw new CommandException(e.getMessage(), e); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/CommitToPullRunCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/CommitToPullRunCommand.java index 76f0ba43d9..dfb8e9d416 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/CommitToPullRunCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/CommitToPullRunCommand.java @@ -2,14 +2,15 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.apiclient.CommitWsApi; -import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiHelper; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.model.CommitToPullRunBody; import com.box.l10n.mojito.cli.model.RepositoryRepository; import com.box.l10n.mojito.json.ObjectMapper; +import jakarta.annotation.PostConstruct; import java.nio.file.Path; import java.nio.file.Paths; import org.fusesource.jansi.Ansi.Color; @@ -60,18 +61,26 @@ public class CommitToPullRunCommand extends Command { @Autowired ObjectMapper objectMapper; - @Autowired CommitWsApi commitClient; - - @Autowired RepositoryWsApiHelper repositoryWsApiHelper; + @Autowired ApiClient apiClient; RepositoryRepository repository; + CommitWsApi commitClient; + + @PostConstruct + public void init() { + this.commitClient = new CommitWsApi(this.apiClient); + } + @Override public void execute() throws CommandException { consoleWriter.newLine().a("Mapping commit: ").fg(Color.CYAN).a(commitHash).println(2); - - repository = this.repositoryWsApiHelper.findRepositoryByName(repositoryParam); + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } String pullRunName = readPullRunNameFromFile(); @@ -96,7 +105,7 @@ void associateCommitToPullRun( commitToPullRunBody.setRepositoryId(repository.getId()); commitToPullRunBody.setPullRunName(pullRunName); try { - commitClient.associateCommitToPullRun(commitToPullRunBody); + this.commitClient.associateCommitToPullRun(commitToPullRunBody); } catch (ApiException e) { throw new CommandException(e.getMessage(), e); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/CopyTmConfigModeConverter.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/CopyTmConfigModeConverter.java index 71adfb157e..78aff841eb 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/CopyTmConfigModeConverter.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/CopyTmConfigModeConverter.java @@ -1,14 +1,14 @@ package com.box.l10n.mojito.cli.command; -import com.box.l10n.mojito.rest.entity.CopyTmConfig; +import com.box.l10n.mojito.cli.model.CopyTmConfig; /** * @author jaurambault */ -public class CopyTmConfigModeConverter extends EnumConverter { +public class CopyTmConfigModeConverter extends EnumConverter { @Override - protected Class getGenericClass() { - return CopyTmConfig.Mode.class; + protected Class getGenericClass() { + return CopyTmConfig.ModeEnum.class; } } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/CreateAIPromptCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/CreateAIPromptCommand.java index ce9bca9bbb..a3a4bddc05 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/CreateAIPromptCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/CreateAIPromptCommand.java @@ -3,9 +3,11 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.box.l10n.mojito.cli.apiclient.AiPromptWsApi; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.model.AIPromptCreateRequest; +import jakarta.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -21,7 +23,7 @@ public class CreateAIPromptCommand extends Command { static Logger logger = LoggerFactory.getLogger(CreateAIPromptCommand.class); - @Autowired AiPromptWsApi aiServiceClient; + AiPromptWsApi aiServiceClient; @Parameter( names = {"--repository-name", "-r"}, @@ -73,6 +75,13 @@ public class CreateAIPromptCommand extends Command { @Autowired private ConsoleWriter consoleWriter; + @Autowired ApiClient apiClient; + + @PostConstruct + public void init() { + this.aiServiceClient = new AiPromptWsApi(this.apiClient); + } + @Override protected void execute() throws CommandException { createPrompt(); @@ -94,7 +103,7 @@ private void createPrompt() { aiPromptCreateRequest.setJsonResponseKey(jsonResponseKey); long promptId; try { - promptId = aiServiceClient.createPrompt(aiPromptCreateRequest); + promptId = this.aiServiceClient.createPrompt(aiPromptCreateRequest); } catch (ApiException e) { throw new CommandException(e.getMessage(), e); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/CreateAIPromptContextMessageCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/CreateAIPromptContextMessageCommand.java index 8288866e9d..c6b02d9d94 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/CreateAIPromptContextMessageCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/CreateAIPromptContextMessageCommand.java @@ -3,9 +3,11 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.box.l10n.mojito.cli.apiclient.AiPromptWsApi; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.model.AIPromptContextMessageCreateRequest; +import jakarta.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -21,8 +23,6 @@ public class CreateAIPromptContextMessageCommand extends Command { static Logger logger = LoggerFactory.getLogger(CreateAIPromptContextMessageCommand.class); - @Autowired AiPromptWsApi aiServiceClient; - @Parameter( names = {"--content", "-c"}, required = true, @@ -49,19 +49,34 @@ public class CreateAIPromptContextMessageCommand extends Command { @Autowired private ConsoleWriter consoleWriter; + @Autowired private ApiClient apiClient; + + AiPromptWsApi aiServiceClient; + + @PostConstruct + public void init() { + this.aiServiceClient = new AiPromptWsApi(this.apiClient); + } + @Override protected void execute() throws CommandException { createPromptContextMessage(); } - private void createPromptContextMessage() { - logger.debug("Received request to create prompt content message"); + private AIPromptContextMessageCreateRequest getAiPromptContextMessageCreateRequest() { AIPromptContextMessageCreateRequest AIPromptContextMessageCreateRequest = new AIPromptContextMessageCreateRequest(); AIPromptContextMessageCreateRequest.setContent(content); AIPromptContextMessageCreateRequest.setMessageType(messageType); AIPromptContextMessageCreateRequest.setAiPromptId(promptId); AIPromptContextMessageCreateRequest.setOrderIndex(orderIndex); + return AIPromptContextMessageCreateRequest; + } + + private void createPromptContextMessage() { + logger.debug("Received request to create prompt content message"); + AIPromptContextMessageCreateRequest AIPromptContextMessageCreateRequest = + getAiPromptContextMessageCreateRequest(); long contextMessageId; try { contextMessageId = diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/DeleteAIPromptCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/DeleteAIPromptCommand.java index 143eb3953f..a0611216ef 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/DeleteAIPromptCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/DeleteAIPromptCommand.java @@ -3,8 +3,10 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.box.l10n.mojito.cli.apiclient.AiPromptWsApi; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.console.ConsoleWriter; +import jakarta.annotation.PostConstruct; import org.fusesource.jansi.Ansi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,8 +23,6 @@ public class DeleteAIPromptCommand extends Command { static Logger logger = LoggerFactory.getLogger(DeleteAIPromptCommand.class); - @Autowired AiPromptWsApi aiServiceClient; - @Parameter( names = {"--prompt-id", "-pi"}, required = true, @@ -31,6 +31,15 @@ public class DeleteAIPromptCommand extends Command { @Autowired private ConsoleWriter consoleWriter; + @Autowired private ApiClient apiClient; + + AiPromptWsApi aiServiceClient; + + @PostConstruct + public void init() { + this.aiServiceClient = new AiPromptWsApi(this.apiClient); + } + @Override protected void execute() throws CommandException { consoleWriter @@ -44,7 +53,7 @@ protected void execute() throws CommandException { private void deletePrompt() { logger.debug("Received request to delete prompt {}", promptId); try { - aiServiceClient.deletePrompt(promptId); + this.aiServiceClient.deletePrompt(promptId); } catch (ApiException e) { throw new CommandException(e.getMessage(), e); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/DeleteAIPromptContextMessageCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/DeleteAIPromptContextMessageCommand.java index 20860148a4..ac476bd28c 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/DeleteAIPromptContextMessageCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/DeleteAIPromptContextMessageCommand.java @@ -3,8 +3,10 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.box.l10n.mojito.cli.apiclient.AiPromptWsApi; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.console.ConsoleWriter; +import jakarta.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -20,8 +22,6 @@ public class DeleteAIPromptContextMessageCommand extends Command { static Logger logger = LoggerFactory.getLogger(DeleteAIPromptContextMessageCommand.class); - @Autowired AiPromptWsApi aiServiceClient; - @Parameter( names = {"--id", "-i"}, required = true, @@ -30,6 +30,15 @@ public class DeleteAIPromptContextMessageCommand extends Command { @Autowired private ConsoleWriter consoleWriter; + @Autowired private ApiClient apiClient; + + AiPromptWsApi aiServiceClient; + + @PostConstruct + public void init() { + this.aiServiceClient = new AiPromptWsApi(this.apiClient); + } + @Override protected void execute() throws CommandException { deletePromptContextMessage(); @@ -38,7 +47,7 @@ protected void execute() throws CommandException { private void deletePromptContextMessage() { logger.debug("Received request to create prompt content message"); try { - aiServiceClient.deletePromptMessage(id); + this.aiServiceClient.deletePromptMessage(id); } catch (ApiException e) { throw new CommandException(e.getMessage(), e); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/DemoCreateCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/DemoCreateCommand.java index 50e19c2217..4bd481b444 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/DemoCreateCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/DemoCreateCommand.java @@ -3,10 +3,12 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.ParameterException; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.command.param.Param; -import com.box.l10n.mojito.rest.client.exception.ResourceNotCreatedException; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.RepositoryLocale; +import com.box.l10n.mojito.cli.model.ImportRepositoryBody; +import com.box.l10n.mojito.cli.model.Repository; +import com.box.l10n.mojito.cli.model.RepositoryLocale; +import com.box.l10n.mojito.cli.model.RepositoryRepository; import com.google.common.io.Files; import com.google.common.io.Resources; import java.io.IOException; @@ -16,7 +18,6 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; -import java.util.Set; import org.fusesource.jansi.Ansi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,7 +58,7 @@ public class DemoCreateCommand extends RepoCommand { Path outputDirectoryPath; - Repository repository; + RepositoryRepository repository; @Override public void execute() throws CommandException { @@ -131,6 +132,18 @@ void addResourceBundleToDemoDirectory() throws CommandException { static final String DEMO_PROPERTIES = "demo.properties"; + private Repository getRepository() { + Repository repositoryBody = new Repository(); + repositoryBody.setName(nameParam); + repositoryBody.setDescription(""); + repositoryBody.setSourceLocale(null); + repositoryBody.setRepositoryLocales(getRepositoryLocales()); + repositoryBody.setAssetIntegrityCheckers( + extractIntegrityCheckersFromInput("properties:MESSAGE_FORMAT", false)); + repositoryBody.setCheckSLA(null); + return repositoryBody; + } + void createDemoRepository() throws CommandException { consoleWriter @@ -141,21 +154,15 @@ void createDemoRepository() throws CommandException { .println(); try { - repository = - repositoryClient.createRepository( - nameParam, - "", - null, - getRepositoryLocales(), - extractIntegrityCheckersFromInput("properties:MESSAGE_FORMAT", false), - null); - - } catch (ParameterException | ResourceNotCreatedException rnce) { + Repository repositoryBody = getRepository(); + repository = repositoryClient.createRepository(repositoryBody); + + } catch (ParameterException | ApiException rnce) { throw new CommandException(rnce.getMessage(), rnce); } } - Set getRepositoryLocales() throws CommandException { + List getRepositoryLocales() throws CommandException { List encodedBcp47Tags = new ArrayList<>(); @@ -197,12 +204,20 @@ void importTM() throws CommandException { } } + private static ImportRepositoryBody getImportRepositoryBody(String tmFileContent) { + ImportRepositoryBody importRepositoryBody = new ImportRepositoryBody(); + importRepositoryBody.setXliffContent(tmFileContent); + importRepositoryBody.setUpdateTM(false); + return importRepositoryBody; + } + void importTMFile(String tmFileName) throws CommandException { try { String tmFileContent = Resources.toString(getResourceURL(tmFileName), StandardCharsets.UTF_8); - repositoryClient.importRepository(repository.getId(), tmFileContent, false); - } catch (IOException | ResourceNotCreatedException e) { + ImportRepositoryBody importRepositoryBody = getImportRepositoryBody(tmFileContent); + repositoryClient.importRepository(importRepositoryBody, repository.getId()); + } catch (IOException | ApiException e) { throw new CommandException("Error importing file [" + tmFileName + "]", e); } } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/DropExportCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/DropExportCommand.java index 25a298130b..2fab690661 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/DropExportCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/DropExportCommand.java @@ -2,16 +2,19 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.DropWsApi; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.client.DropClient; -import com.box.l10n.mojito.rest.entity.ExportDropConfig; -import com.box.l10n.mojito.rest.entity.PollableTask; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.RepositoryLocale; -import com.box.l10n.mojito.rest.entity.RepositoryLocaleStatistic; -import com.box.l10n.mojito.rest.entity.RepositoryStatistic; +import com.box.l10n.mojito.cli.model.ExportDropConfig; +import com.box.l10n.mojito.cli.model.PollableTask; +import com.box.l10n.mojito.cli.model.RepositoryLocaleRepository; +import com.box.l10n.mojito.cli.model.RepositoryLocaleStatisticRepository; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import com.box.l10n.mojito.cli.model.RepositoryStatisticRepository; import com.google.common.collect.Sets; +import jakarta.annotation.PostConstruct; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -53,7 +56,7 @@ public class DropExportCommand extends Command { required = false, description = "Type of export to perfom: TRANSLATION or REVIEW", converter = ExportDropConfigTypeConverter.class) - ExportDropConfig.Type typeParam; + ExportDropConfig.TypeEnum typeParam; @Parameter( names = {Param.EXPORT_LOCALES_LONG, Param.EXPORT_LOCALES_SHORT}, @@ -71,7 +74,14 @@ public class DropExportCommand extends Command { @Autowired CommandHelper commandHelper; - @Autowired DropClient dropClient; + @Autowired ApiClient apiClient; + + DropWsApi dropClient; + + @PostConstruct + public void init() { + this.dropClient = new DropWsApi(this.apiClient); + } @Override public void execute() throws CommandException { @@ -83,20 +93,29 @@ public void execute() throws CommandException { .a(repositoryParam) .println(2); - Repository repository = commandHelper.findRepositoryByName(repositoryParam); + RepositoryRepository repository; + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } - if (useInheritance && typeParam != ExportDropConfig.Type.REVIEW) { + if (useInheritance && typeParam != ExportDropConfig.TypeEnum.REVIEW) { throw new CommandException("--use-inheritance can only be used with --type REVIEW"); } - if (typeParam == ExportDropConfig.Type.REVIEW || shouldCreateDrop(repository)) { + if (typeParam == ExportDropConfig.TypeEnum.REVIEW || shouldCreateDrop(repository)) { ExportDropConfig exportDropConfig = new ExportDropConfig(); exportDropConfig.setRepositoryId(repository.getId()); exportDropConfig.setType(typeParam); - exportDropConfig.setBcp47Tags(getBcp47TagsForExport(repository)); + exportDropConfig.setLocales(getBcp47TagsForExport(repository)); exportDropConfig.setUseInheritance(useInheritance); - exportDropConfig = dropClient.exportDrop(exportDropConfig); + try { + exportDropConfig = this.dropClient.exportDrop(exportDropConfig); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } consoleWriter.a("Drop id: ").fg(Color.CYAN).a(exportDropConfig.getDropId()).print(); @@ -122,7 +141,7 @@ public void execute() throws CommandException { * @param repository * @return list of Bcp47Tags for the drop */ - List getBcp47TagsForExport(Repository repository) throws CommandException { + List getBcp47TagsForExport(RepositoryRepository repository) throws CommandException { List bcp47tags; @@ -142,11 +161,11 @@ List getBcp47TagsForExport(Repository repository) throws CommandExceptio * @return list of Bcp47Tags for the drop * @throws CommandException */ - List getBcp47TagsForExportFromRepository(Repository repository) { + List getBcp47TagsForExportFromRepository(RepositoryRepository repository) { List bcp47Tags = new ArrayList<>(); - for (RepositoryLocale repositoryLocale : repository.getRepositoryLocales()) { + for (RepositoryLocaleRepository repositoryLocale : repository.getRepositoryLocales()) { if (repositoryLocale.isToBeFullyTranslated()) { bcp47Tags.add(repositoryLocale.getLocale().getBcp47Tag()); } @@ -162,13 +181,14 @@ List getBcp47TagsForExportFromRepository(Repository repository) { * @return list of Bcp47Tags for the drop * @throws CommandException */ - List getBcp47TagsForExportFromParam(Repository repository) throws CommandException { + List getBcp47TagsForExportFromParam(RepositoryRepository repository) + throws CommandException { List bcp47tags = new ArrayList<>(); List validTags = new ArrayList<>(); - for (RepositoryLocale repositoryLocale : repository.getRepositoryLocales()) { + for (RepositoryLocaleRepository repositoryLocale : repository.getRepositoryLocales()) { validTags.add(repositoryLocale.getLocale().getBcp47Tag()); } @@ -183,13 +203,14 @@ List getBcp47TagsForExportFromParam(Repository repository) throws Comman return bcp47tags; } - protected boolean shouldCreateDrop(Repository repository) { + protected boolean shouldCreateDrop(RepositoryRepository repository) { boolean createDrop = false; Set bcp47TagsForTranslation = Sets.newHashSet(getBcp47TagsForExportFromRepository(repository)); - RepositoryStatistic repoStat = repository.getRepositoryStatistic(); + RepositoryStatisticRepository repoStat = repository.getRepositoryStatistic(); if (repoStat != null) { - for (RepositoryLocaleStatistic repoLocaleStat : repoStat.getRepositoryLocaleStatistics()) { + for (RepositoryLocaleStatisticRepository repoLocaleStat : + repoStat.getRepositoryLocaleStatistics()) { if (bcp47TagsForTranslation.contains(repoLocaleStat.getLocale().getBcp47Tag()) && repoLocaleStat.getForTranslationCount() > 0L) { createDrop = true; diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/DropImportCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/DropImportCommand.java index e5fac85c88..911d6417ab 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/DropImportCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/DropImportCommand.java @@ -2,14 +2,18 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.DropWsApi; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.Console; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.client.DropClient; -import com.box.l10n.mojito.rest.entity.Drop; -import com.box.l10n.mojito.rest.entity.ImportDropConfig; -import com.box.l10n.mojito.rest.entity.PollableTask; -import com.box.l10n.mojito.rest.entity.Repository; +import com.box.l10n.mojito.cli.model.DropDropSummary; +import com.box.l10n.mojito.cli.model.ImportDropConfig; +import com.box.l10n.mojito.cli.model.Pageable; +import com.box.l10n.mojito.cli.model.PollableTask; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import jakarta.annotation.PostConstruct; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -65,7 +69,7 @@ public class DropImportCommand extends Command { required = false, description = Param.DROP_IMPORT_STATUS_DESCRIPTION, converter = ImportDropConfigStatusConverter.class) - ImportDropConfig.Status importStatusParam = null; + ImportDropConfig.StatusEnum importStatusParam = null; @Parameter( names = {"--import-fetched"}, @@ -77,14 +81,27 @@ public class DropImportCommand extends Command { @Autowired Console console; - @Autowired DropClient dropClient; + @Autowired ApiClient apiClient; + + DropWsApi dropClient; + + @PostConstruct + public void init() { + this.dropClient = new DropWsApi(this.apiClient); + } @Override public void execute() throws CommandException { - Repository repository = commandHelper.findRepositoryByName(repositoryParam); + RepositoryRepository repository; + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } - Map numberedAvailableDrops = getNumberedAvailableDrops(repository.getId()); + Map numberedAvailableDrops = + getNumberedAvailableDrops(repository.getId()); if (numberedAvailableDrops.isEmpty()) { consoleWriter.newLine().a("No drop available").println(); @@ -92,9 +109,9 @@ public void execute() throws CommandException { consoleWriter.newLine().a("Drops available").println(); logger.debug("Display drops information"); - for (Map.Entry entry : numberedAvailableDrops.entrySet()) { + for (Map.Entry entry : numberedAvailableDrops.entrySet()) { - Drop drop = entry.getValue(); + DropDropSummary drop = entry.getValue(); consoleWriter .a(" ") @@ -110,7 +127,7 @@ public void execute() throws CommandException { .a(drop.getName()) .reset(); - if (Boolean.TRUE.equals(drop.getCanceled())) { + if (Boolean.TRUE.equals(drop.isCanceled())) { consoleWriter.fg(Color.GREEN).a(" CANCELED"); } else if (drop.getLastImportedDate() == null) { consoleWriter.fg(Color.GREEN).a(" NEW"); @@ -135,8 +152,16 @@ public void execute() throws CommandException { .a(repositoryParam) .println(2); - ImportDropConfig importDropConfig = - dropClient.importDrop(repository, dropId, importStatusParam); + ImportDropConfig importDropConfigBody = new ImportDropConfig(); + importDropConfigBody.setRepositoryId(repository.getId()); + importDropConfigBody.setDropId(dropId); + importDropConfigBody.setStatus(importStatusParam); + ImportDropConfig importDropConfig; + try { + importDropConfig = dropClient.importDrop(importDropConfigBody); + } catch (ApiException e) { + throw new RuntimeException(e); + } PollableTask pollableTask = importDropConfig.getPollableTask(); commandHelper.waitForPollableTask(pollableTask.getId()); @@ -147,32 +172,37 @@ public void execute() throws CommandException { } /** - * Gets available {@link Drop}s and assign them a number (map key) to be referenced in the console - * input for selection. + * Gets available {@link com.box.l10n.mojito.cli.model.DropDropSummary}s and assign them a number + * (map key) to be referenced in the console input for selection. * * @return */ - private Map getNumberedAvailableDrops(Long repositoryId) { + private Map getNumberedAvailableDrops(Long repositoryId) { logger.debug("Build a map of drops keyed by an incremented integer"); - Map dropIds = new HashMap<>(); + Map dropIds = new HashMap<>(); long i = 1; - for (Drop availableDrop : - dropClient - .getDrops(repositoryId, getImportedFilter(), 0L, numberOfDropsToFetchParam) - .getContent()) { - dropIds.put(i++, availableDrop); + Pageable pageable = new Pageable(); + pageable.setPage(0); + pageable.setSize(this.numberOfDropsToFetchParam.intValue()); + try { + for (DropDropSummary availableDrop : + dropClient.getDrops(pageable, repositoryId, getImportedFilter(), null).getContent()) { + dropIds.put(i++, availableDrop); + } + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); } return dropIds; } /** - * Returns the "imported" filter to be passed to {@link DropClient#getDrops(java.lang.Long, - * java.lang.Boolean, java.lang.Long, java.lang.Long) } based on the CLI parameter {@link - * #alsoShowImportedParam}. + * Returns the "imported" filter to be passed to {@link + * com.box.l10n.mojito.cli.apiclient.DropWsApi#getDrops(com.box.l10n.mojito.cli.model.Pageable, + * Long, Boolean, Boolean)} based on the CLI parameter {@link #alsoShowImportedParam}. * * @return the imported filter to get drops */ @@ -181,17 +211,19 @@ private Boolean getImportedFilter() { } /** - * Gets the list of selected {@link Drop#id}. + * Gets the list of selected {@link com.box.l10n.mojito.cli.model.DropDropSummary#getId()}. * - *

First, reads a drop number from the console and then gets the {@link Drop} from the map of - * available {@link Drop}s. + *

First, reads a drop number from the console and then gets the {@link + * com.box.l10n.mojito.cli.model.DropDropSummary} from the map of available {@link + * com.box.l10n.mojito.cli.model.DropDropSummary}s. * - * @param numberedAvailableDrops candidate {@link Drop}s for selection - * @return selected {@link Drop#id} + * @param numberedAvailableDrops candidate {@link com.box.l10n.mojito.cli.model.DropDropSummary}s + * for selection + * @return selected {@link com.box.l10n.mojito.cli.model.DropDropSummary#getId()} * @throws CommandException if the input doesn't match a number from the map of available {@link - * Drop}s + * com.box.l10n.mojito.cli.model.DropDropSummary}s */ - private List getSelectedDropIds(Map numberedAvailableDrops) + private List getSelectedDropIds(Map numberedAvailableDrops) throws CommandException { List selectedDropIds; @@ -204,7 +236,7 @@ private List getSelectedDropIds(Map numberedAvailableDrops) return selectedDropIds; } - private List getFromConsoleDropIds(Map numberedAvailableDrops) + private List getFromConsoleDropIds(Map numberedAvailableDrops) throws CommandException { consoleWriter.newLine().a("Enter Drop number to import").println(); Long dropNumber = console.readLine(Long.class); @@ -219,9 +251,10 @@ private List getFromConsoleDropIds(Map numberedAvailableDrops) return Arrays.asList(selectId); } - private List getWithImportFetchedDropIds(Map numberedAvailableDrops) { + private List getWithImportFetchedDropIds( + Map numberedAvailableDrops) { return numberedAvailableDrops.entrySet().stream() - .filter(x -> !Boolean.TRUE.equals(x.getValue().getCanceled())) + .filter(x -> !Boolean.TRUE.equals(x.getValue().isCanceled())) .map(x -> x.getValue().getId()) .collect(Collectors.toList()); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/DropXliffImportCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/DropXliffImportCommand.java index b6938f2754..cffe90a071 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/DropXliffImportCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/DropXliffImportCommand.java @@ -1,13 +1,20 @@ package com.box.l10n.mojito.cli.command; +import static java.util.Optional.ofNullable; + import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.DropWsApi; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.Console; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.client.DropClient; -import com.box.l10n.mojito.rest.entity.ImportDropConfig; -import com.box.l10n.mojito.rest.entity.Repository; +import com.box.l10n.mojito.cli.model.ImportDropConfig; +import com.box.l10n.mojito.cli.model.ImportXliffBody; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import com.google.common.base.Preconditions; +import jakarta.annotation.PostConstruct; import java.nio.file.Path; import java.util.List; import org.fusesource.jansi.Ansi; @@ -63,7 +70,7 @@ public class DropXliffImportCommand extends Command { required = false, description = Param.DROP_IMPORT_STATUS_DESCRIPTION, converter = ImportDropConfigStatusConverter.class) - ImportDropConfig.Status importStatusParam = null; + ImportDropConfig.StatusEnum importStatusParam = null; @Parameter( names = {"--import-by-md5"}, @@ -75,12 +82,19 @@ public class DropXliffImportCommand extends Command { @Autowired Console console; - @Autowired DropClient dropClient; + @Autowired ApiClient apiClient; - Repository repository; + RepositoryRepository repository; CommandDirectories commandDirectories; + DropWsApi dropClient; + + @PostConstruct + public void init() { + this.dropClient = new DropWsApi(this.apiClient); + } + @Override public void execute() throws CommandException { @@ -91,7 +105,11 @@ public void execute() throws CommandException { .a(repositoryParam) .println(2); - repository = commandHelper.findRepositoryByName(repositoryParam); + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } commandDirectories = new CommandDirectories(sourceDirectoryParam, targetDirectoryParam); @@ -109,6 +127,20 @@ void importXliffs() throws CommandException { } } + private ImportXliffBody getImportXliffBody(String xliffContent) { + ImportXliffBody importXliffBody = new ImportXliffBody(); + importXliffBody.setRepositoryId(Preconditions.checkNotNull(this.repository.getId())); + importXliffBody.setTranslationKit(!this.importByMD5); + importXliffBody.setImportStatus( + ofNullable(this.importStatusParam) + .map( + importStatusParam -> + ImportXliffBody.ImportStatusEnum.fromValue(importStatusParam.name())) + .orElse(null)); + importXliffBody.setXliffContent(xliffContent); + return importXliffBody; + } + void importXliff(Path xliffPath) throws CommandException { consoleWriter @@ -119,8 +151,13 @@ void importXliff(Path xliffPath) throws CommandException { String xliffContent = commandHelper.getFileContent(xliffPath); - String importedXliff = - dropClient.importXiff(xliffContent, repository.getId(), !importByMD5, importStatusParam); + String importedXliff; + try { + importedXliff = + this.dropClient.importXliff(getImportXliffBody(xliffContent)).getXliffContent(); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } Path outputPath = commandDirectories.resolveWithTargetDirectoryAndCreateParentDirectories(xliffPath); diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/EvolveCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/EvolveCommand.java index 680529e5a3..a49542294d 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/EvolveCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/EvolveCommand.java @@ -2,21 +2,23 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; +import com.box.l10n.mojito.cli.apiclient.PollableTaskWsApiProxy; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; +import com.box.l10n.mojito.cli.model.LocaleRepository; +import com.box.l10n.mojito.cli.model.LocalizedAssetBody; +import com.box.l10n.mojito.cli.model.RepositoryLocaleRepository; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import com.box.l10n.mojito.cli.model.SourceAsset; import com.box.l10n.mojito.evolve.Course; import com.box.l10n.mojito.evolve.Evolve; import com.box.l10n.mojito.io.Files; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.PollableTaskClient; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.entity.Locale; -import com.box.l10n.mojito.rest.entity.LocalizedAssetBody; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.RepositoryLocale; -import com.box.l10n.mojito.rest.entity.SourceAsset; import com.google.common.base.Preconditions; import com.ibm.icu.util.ULocale; +import jakarta.annotation.PostConstruct; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; @@ -79,14 +81,19 @@ public class EvolveCommand extends Command { @Autowired(required = false) Evolve evolve; - @Autowired RepositoryClient repositoryClient; + @Autowired ApiClient apiClient; - @Autowired AssetClient assetClient; - - @Autowired PollableTaskClient pollableTaskClient; + @Autowired PollableTaskWsApiProxy pollableTaskClient; @Autowired CommandHelper commandHelper; + private AssetWsApiProxy assetClient; + + @PostConstruct + public void init() { + this.assetClient = new AssetWsApiProxy(this.apiClient); + } + @Override public boolean shouldShowInCommandList() { return false; @@ -107,7 +114,12 @@ public void execute() throws CommandException { .a(repositoryParam) .println(2); - Repository repository = commandHelper.findRepositoryByName(repositoryParam); + RepositoryRepository repository; + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } evolve .getCourses() @@ -118,7 +130,7 @@ public void execute() throws CommandException { }); } - void translateCourse(Repository repository, Course course) { + void translateCourse(RepositoryRepository repository, Course course) { consoleWriter .a("Get translations for course: ") @@ -131,7 +143,7 @@ void translateCourse(Repository repository, Course course) { repository.getRepositoryLocales().stream() .filter(repositoryLocale -> repositoryLocale.getParentLocale() != null) - .map(RepositoryLocale::getLocale) + .map(RepositoryLocaleRepository::getLocale) .forEach( locale -> { consoleWriter @@ -157,7 +169,10 @@ void translateCourse(Repository repository, Course course) { } void writeJsonToFile( - Repository repository, Course course, Locale locale, String localizedCourse) { + RepositoryRepository repository, + Course course, + LocaleRepository locale, + String localizedCourse) { Preconditions.checkNotNull(writeJsonTo); Path path = Paths.get( @@ -166,31 +181,41 @@ void writeJsonToFile( Files.write(path, localizedCourse); } - SourceAsset sendSource(Repository repository, String courseId, String translationsByCourseId) { + SourceAsset sendSource( + RepositoryRepository repository, String courseId, String translationsByCourseId) { consoleWriter.a("Sending source course to Mojito").println(); SourceAsset sourceAsset = new SourceAsset(); sourceAsset.setRepositoryId(repository.getId()); sourceAsset.setPath(courseId + ".json"); sourceAsset.setContent(translationsByCourseId); sourceAsset.setFilterOptions(FILTER_OPTIONS); - sourceAsset = assetClient.sendSourceAsset(sourceAsset); + try { + sourceAsset = assetClient.importSourceAsset(sourceAsset); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } pollableTaskClient.waitForPollableTask(sourceAsset.getPollableTask().getId()); return sourceAsset; } String getLocalizedCourse(Long assetId, long localeId, String translationsByCourseId) { - - LocalizedAssetBody localizedAssetForContent = - assetClient.getLocalizedAssetForContent( - assetId, - localeId, - translationsByCourseId, - null, - null, - FILTER_OPTIONS, - LocalizedAssetBody.Status.ALL, - LocalizedAssetBody.InheritanceMode.USE_PARENT, - null); + LocalizedAssetBody localizedAssetBody = new LocalizedAssetBody(); + localizedAssetBody.setAssetId(assetId); + localizedAssetBody.setLocaleId(localeId); + localizedAssetBody.setContent(translationsByCourseId); + localizedAssetBody.setOutputBcp47tag(null); + localizedAssetBody.setFilterConfigIdOverride(null); + localizedAssetBody.setFilterOptions(FILTER_OPTIONS); + localizedAssetBody.setStatus(LocalizedAssetBody.StatusEnum.ALL); + localizedAssetBody.setInheritanceMode(LocalizedAssetBody.InheritanceModeEnum.USE_PARENT); + localizedAssetBody.setPullRunName(null); + LocalizedAssetBody localizedAssetForContent; + try { + localizedAssetForContent = + assetClient.getLocalizedAssetForContent(localizedAssetBody, assetId, localeId); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } return localizedAssetForContent.getContent(); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/ExportDropConfigTypeConverter.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/ExportDropConfigTypeConverter.java index ad06f39dc0..0d2686235e 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/ExportDropConfigTypeConverter.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/ExportDropConfigTypeConverter.java @@ -1,14 +1,14 @@ package com.box.l10n.mojito.cli.command; -import com.box.l10n.mojito.rest.entity.ExportDropConfig; +import com.box.l10n.mojito.cli.model.ExportDropConfig; /** * @author jaurambault */ -public class ExportDropConfigTypeConverter extends EnumConverter { +public class ExportDropConfigTypeConverter extends EnumConverter { @Override - protected Class getGenericClass() { - return ExportDropConfig.Type.class; + protected Class getGenericClass() { + return ExportDropConfig.TypeEnum.class; } } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/ExtractionCheckCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/ExtractionCheckCommand.java index 0c301778a2..cd35f57f3b 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/ExtractionCheckCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/ExtractionCheckCommand.java @@ -2,6 +2,8 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.command.checks.AbstractCliChecker; import com.box.l10n.mojito.cli.command.checks.CheckerOptionsMapEntry; import com.box.l10n.mojito.cli.command.checks.CheckerOptionsMapEntryConverter; @@ -28,12 +30,13 @@ import com.box.l10n.mojito.github.GithubException; import com.box.l10n.mojito.okapi.extractor.AssetExtractorTextUnit; import com.box.l10n.mojito.regex.PlaceholderRegularExpressions; -import com.box.l10n.mojito.rest.resttemplate.AuthenticatedRestTemplate; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; import com.ibm.icu.text.MessageFormat; +import com.squareup.okhttp.Call; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -273,7 +276,7 @@ public class ExtractionCheckCommand extends Command { description = "Full git commit sha, used for setting a status on a commit in Github.") String commitSha; - @Autowired AuthenticatedRestTemplate restTemplate; + @Autowired ApiClient apiClient; List extractionCheckNotificationSenders = new ArrayList<>(); @@ -393,7 +396,23 @@ private void reportStatistic(CliCheckResult result) { .put("outcome", result.isSuccessful() ? "success" : "failure") .build(); String url = urlMessageFormat.format(paramMap); - restTemplate.put(url, null); + + try { + Call call = + this.apiClient.buildCall( + url, + "PUT", + new ArrayList<>(), + new ArrayList<>(), + null, + new HashMap<>(), + new HashMap<>(), + new String[] {}, + null); + this.apiClient.execute(call); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } } catch (RestClientException e) { logger.error("Error reporting statistics to http endpoint " + e.getMessage(), e); consoleWriter diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/ExtractionDiffCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/ExtractionDiffCommand.java index b9e97c1420..3f2da3ee9b 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/ExtractionDiffCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/ExtractionDiffCommand.java @@ -2,9 +2,13 @@ import static java.util.Optional.empty; import static java.util.Optional.of; +import static java.util.Optional.ofNullable; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; import com.box.l10n.mojito.cli.command.extraction.AssetExtractionDiff; import com.box.l10n.mojito.cli.command.extraction.ExtractionDiffPaths; import com.box.l10n.mojito.cli.command.extraction.ExtractionDiffService; @@ -14,19 +18,19 @@ import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.command.utils.SlackNotificationSender; import com.box.l10n.mojito.cli.console.ConsoleWriter; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import com.box.l10n.mojito.cli.model.SourceAsset; import com.box.l10n.mojito.json.ObjectMapper; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.SourceAsset; import com.box.l10n.mojito.shell.Shell; import com.box.l10n.mojito.slack.SlackClient; import com.google.common.base.Strings; +import jakarta.annotation.PostConstruct; import java.nio.file.Path; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Set; import java.util.stream.Stream; import org.apache.commons.lang3.exception.ExceptionUtils; import org.fusesource.jansi.Ansi; @@ -169,7 +173,7 @@ public class ExtractionDiffCommand extends Command { required = false, description = "Optional list of notifiers when pusing to a repository, (notification will be sent eg. when new strings are processed or when translations are ready") - Set pushToBranchNotifiers = Collections.emptySet(); + List pushToBranchNotifiers = Collections.emptyList(); @Parameter( names = Param.PUSH_TYPE_LONG, @@ -241,8 +245,17 @@ public class ExtractionDiffCommand extends Command { @Autowired(required = false) private SlackClient slackClient; + @Autowired private ApiClient apiClient; + + RepositoryWsApiProxy repositoryClient; + private Optional notificationSender; + @PostConstruct + public void init() { + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + } + // Method for testing purposes protected Optional getNotificationSender() { if (!Strings.isNullOrEmpty(this.slackNotificationChannel)) { @@ -361,7 +374,12 @@ void executeUnsafe() { } private String getValidRepositoryName() { - List repositories = commandHelper.getAllRepositories(); + List repositories = null; + try { + repositories = this.repositoryClient.getRepositories(null); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } if (repositories.stream() .anyMatch(repository -> repository.getName().equals(pushToRepository))) { @@ -382,7 +400,12 @@ private String getValidRepositoryName() { void pushToRepository(ExtractionDiffPaths extractionDiffPaths) throws CommandException { - Repository repository = commandHelper.findRepositoryByName(pushToRepository); + RepositoryRepository repository; + try { + repository = this.commandHelper.findRepositoryByName(pushToRepository); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } Stream allAssetExtractionDiffPaths = extractionDiffPaths.findAllAssetExtractionDiffPaths(); @@ -414,7 +437,12 @@ void pushToRepository(ExtractionDiffPaths extractionDiffPaths) throws CommandExc sourceAsset.setExtractedContent(true); sourceAsset.setRepositoryId(repository.getId()); sourceAsset.setFilterConfigIdOverride( - assetExtractionDiff.getCurrentFilterConfigIdOverride()); + ofNullable(assetExtractionDiff.getCurrentFilterConfigIdOverride()) + .map( + filterConfigIdOverride -> + SourceAsset.FilterConfigIdOverrideEnum.fromValue( + filterConfigIdOverride.name())) + .orElse(null)); sourceAsset.setFilterOptions(assetExtractionDiff.getCurrentFilterOptions()); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/GitBlameCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/GitBlameCommand.java index 9cc63dc5db..663ccacde2 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/GitBlameCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/GitBlameCommand.java @@ -5,21 +5,24 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.TextUnitWsApi; +import com.box.l10n.mojito.cli.apiclient.exceptions.PollableTaskException; +import com.box.l10n.mojito.cli.apiclient.mappers.GitBlameWithUsageMapper; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.filefinder.FileMatch; import com.box.l10n.mojito.cli.filefinder.file.FileType; import com.box.l10n.mojito.cli.filefinder.file.GitBlameType; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.GitBlameWithUsageClient; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.client.exception.PollableTaskException; -import com.box.l10n.mojito.rest.entity.GitBlame; -import com.box.l10n.mojito.rest.entity.GitBlameWithUsage; -import com.box.l10n.mojito.rest.entity.PollableTask; -import com.box.l10n.mojito.rest.entity.Repository; +import com.box.l10n.mojito.cli.model.GitBlameGitBlameWithUsage; +import com.box.l10n.mojito.cli.model.GitBlameWithUsage; +import com.box.l10n.mojito.cli.model.GitBlameWithUsageGitBlameWithUsage; +import com.box.l10n.mojito.cli.model.PollableTask; +import com.box.l10n.mojito.cli.model.RepositoryRepository; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; +import jakarta.annotation.PostConstruct; import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.text.MessageFormat; @@ -123,14 +126,12 @@ public class GitBlameCommand extends Command { converter = GitBlameOverrideConverter.class) OverrideType overrideType = OverrideType.NONE; - @Autowired AssetClient assetClient; - - @Autowired RepositoryClient repositoryClient; - - @Autowired GitBlameWithUsageClient gitBlameWithUsageClient; + @Autowired ApiClient apiClient; @Autowired CommandHelper commandHelper; + TextUnitWsApi gitBlameWithUsageClient; + CommandDirectories commandDirectories; GitRepository gitRepository = new GitRepository(); @@ -146,6 +147,11 @@ public class GitBlameCommand extends Command { Cache getBlameResultForFileCache = CacheBuilder.newBuilder().softValues().build(); + @PostConstruct + public void init() { + this.gitBlameWithUsageClient = new TextUnitWsApi(this.apiClient); + } + @Override public void execute() throws CommandException { @@ -153,7 +159,12 @@ public void execute() throws CommandException { consoleWriter.newLine().a("Git blame for repository: ").fg(CYAN).a(repositoryParam).println(2); - Repository repository = commandHelper.findRepositoryByName(repositoryParam); + RepositoryRepository repository; + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } List pollableTasks = new ArrayList<>(); initGitRepository(); @@ -173,11 +184,17 @@ public void execute() throws CommandException { .a("-") .a(offset + BATCH_SIZE) .println(); - List gitBlameWithUsages = - gitBlameWithUsageClient.getGitBlameWithUsages(repository.getId(), offset, BATCH_SIZE); + List gitBlameWithUsages; + try { + gitBlameWithUsages = + gitBlameWithUsageClient.getGitBlameWithUsages( + List.of(repository.getId()), null, null, null, null, null, BATCH_SIZE, offset); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } numGitBlameWithUsages = gitBlameWithUsages.size(); - List getGitBlameWithUsagesToProcess = + List getGitBlameWithUsagesToProcess = getGitBlameWithUsagesToProcess(gitBlameWithUsages); logger.debug( @@ -190,8 +207,15 @@ public void execute() throws CommandException { blameWithTextUnitUsages(getGitBlameWithUsagesToProcess); blameSourceFiles(getGitBlameWithUsagesToProcess); - pollableTasks.add( - gitBlameWithUsageClient.saveGitBlameWithUsages(getGitBlameWithUsagesToProcess)); + try { + pollableTasks.add( + gitBlameWithUsageClient.saveGitBlameWithUsages( + getGitBlameWithUsagesToProcess.stream() + .map(GitBlameWithUsageMapper::mapToGitBlameWithUsage) + .toList())); + } catch (ApiException e) { + throw new RuntimeException(e.getMessage(), e); + } } while (numGitBlameWithUsages == BATCH_SIZE); try { @@ -219,11 +243,11 @@ void initGitRepository() throws CommandException { * @param gitBlameWithUsages * @return the entries to be processed */ - public List getGitBlameWithUsagesToProcess( - List gitBlameWithUsages) { - List filteredGitBlameWithUsages = new ArrayList<>(); + public List getGitBlameWithUsagesToProcess( + List gitBlameWithUsages) { + List filteredGitBlameWithUsages = new ArrayList<>(); - for (GitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { + for (GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { if (gitBlameWithUsage.getGitBlame() == null || OverrideType.ALL.equals(overrideType) || (OverrideType.NO_INFO.equals(overrideType) @@ -242,7 +266,8 @@ public List getGitBlameWithUsagesToProcess( * @param gitBlameWithUsages * @throws CommandException */ - void blameSourceFiles(List gitBlameWithUsages) throws CommandException { + void blameSourceFiles(List gitBlameWithUsages) + throws CommandException { logger.debug("blameSourceFiles"); ArrayList sourceFileMatches = @@ -273,10 +298,10 @@ void blameSourceFiles(List gitBlameWithUsages) throws Command for (int i = 0; i < blameResultForFile.getResultContents().size(); i++) { String lineText = blameResultForFile.getResultContents().getString(i); - List gitBlameWithUsageList = + List gitBlameWithUsageList = getGitBlameWithUsagesFromLine( lineText, gitBlameWithUsages, sourceFileMatch.getFileType()); - for (GitBlameWithUsage gitBlameWithUsage : gitBlameWithUsageList) { + for (GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage : gitBlameWithUsageList) { try { updateBlameResultsInGitBlameWithUsage(i, blameResultForFile, gitBlameWithUsage); } catch (LineMissingException lme) { @@ -301,10 +326,11 @@ void blameSourceFiles(List gitBlameWithUsages) throws Command * @param gitBlameWithUsages * @throws CommandException */ - void blameWithTextUnitUsages(List gitBlameWithUsages) throws CommandException { + void blameWithTextUnitUsages(List gitBlameWithUsages) + throws CommandException { logger.debug("blameWithTextUnitUsages"); - for (GitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { + for (GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { if (gitBlameWithUsage.getUsages() != null && gitBlameWithUsage.getUsages().size() > 0) { @@ -338,9 +364,12 @@ void blameWithTextUnitUsages(List gitBlameWithUsages) throws } void updateBlameResultsInGitBlameWithUsage( - int lineNumber, BlameResult blameResultForFile, GitBlameWithUsage gitBlameWithUsage) + int lineNumber, + BlameResult blameResultForFile, + GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage) throws LineMissingException { - GitBlame gitBlame = gitRepository.getBlameResults(lineNumber, blameResultForFile); + GitBlameGitBlameWithUsage gitBlame = + gitRepository.getBlameResults(lineNumber, blameResultForFile); gitBlameWithUsage.setGitBlame(gitBlame); } @@ -386,13 +415,13 @@ public BlameResult call() throws Exception { * @param fileType * @return list of GitBlameWithUsage objects that match current line */ - List getGitBlameWithUsagesFromLine( - String line, List gitBlameWithUsages, FileType fileType) { + List getGitBlameWithUsagesFromLine( + String line, List gitBlameWithUsages, FileType fileType) { - List gitBlameWithUsagesWithLine = new ArrayList<>(); + List gitBlameWithUsagesWithLine = new ArrayList<>(); if (line != null) { - for (GitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { + for (GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage : gitBlameWithUsages) { String textUnitNameInSource = textUnitNameToTextUnitNameInSource( gitBlameWithUsage.getTextUnitName(), @@ -411,8 +440,9 @@ List getGitBlameWithUsagesFromLine( /** * Converts text unit name to the text unit name in the source code * - * @param textUnitNameToStringInFilePattern * @param textUnitName + * @param fileType + * @param isPluralForm * @return text unit name as string in source file */ String textUnitNameToTextUnitNameInSource( diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/GitRepository.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/GitRepository.java index 2227009a4e..a5b3c196da 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/GitRepository.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/GitRepository.java @@ -1,6 +1,6 @@ package com.box.l10n.mojito.cli.command; -import com.box.l10n.mojito.rest.entity.GitBlame; +import com.box.l10n.mojito.cli.model.GitBlameGitBlameWithUsage; import java.io.File; import java.io.IOException; import java.text.MessageFormat; @@ -45,10 +45,10 @@ public void init(String gitDir) throws CommandException { * @param blameResultForFile * @return */ - public GitBlame getBlameResults(int lineNumber, BlameResult blameResultForFile) + public GitBlameGitBlameWithUsage getBlameResults(int lineNumber, BlameResult blameResultForFile) throws LineMissingException { - GitBlame gitBlame = new GitBlame(); + GitBlameGitBlameWithUsage gitBlame = new GitBlameGitBlameWithUsage(); try { gitBlame.setAuthorName(blameResultForFile.getSourceAuthor(lineNumber).getName()); diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/ImportDropConfigStatusConverter.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/ImportDropConfigStatusConverter.java index acbd018605..f983f0fc18 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/ImportDropConfigStatusConverter.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/ImportDropConfigStatusConverter.java @@ -1,14 +1,14 @@ package com.box.l10n.mojito.cli.command; -import com.box.l10n.mojito.rest.entity.ImportDropConfig; +import com.box.l10n.mojito.cli.model.ImportDropConfig; /** * @author jaurambault */ -public class ImportDropConfigStatusConverter extends EnumConverter { +public class ImportDropConfigStatusConverter extends EnumConverter { @Override - protected Class getGenericClass() { - return ImportDropConfig.Status.class; + protected Class getGenericClass() { + return ImportDropConfig.StatusEnum.class; } } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/ImportLocalizedAssetBodyStatusForEqualTargetConverter.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/ImportLocalizedAssetBodyStatusForEqualTargetConverter.java index 41a093dc29..7c10b01c5e 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/ImportLocalizedAssetBodyStatusForEqualTargetConverter.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/ImportLocalizedAssetBodyStatusForEqualTargetConverter.java @@ -1,15 +1,15 @@ package com.box.l10n.mojito.cli.command; -import com.box.l10n.mojito.rest.entity.ImportLocalizedAssetBody; +import com.box.l10n.mojito.cli.model.ImportLocalizedAssetBody; /** * @author jaurambault */ public class ImportLocalizedAssetBodyStatusForEqualTargetConverter - extends EnumConverter { + extends EnumConverter { @Override - protected Class getGenericClass() { - return ImportLocalizedAssetBody.StatusForEqualTarget.class; + protected Class getGenericClass() { + return ImportLocalizedAssetBody.StatusForEqualTargetEnum.class; } } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommand.java index 896b2f59be..939f9e5021 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommand.java @@ -1,22 +1,23 @@ package com.box.l10n.mojito.cli.command; +import static java.util.Optional.ofNullable; + import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.box.l10n.mojito.LocaleMappingHelper; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; +import com.box.l10n.mojito.cli.apiclient.exceptions.PollableTaskException; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.filefinder.FileMatch; import com.box.l10n.mojito.cli.filefinder.file.FileType; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.LocaleClient; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.client.exception.AssetNotFoundException; -import com.box.l10n.mojito.rest.client.exception.PollableTaskException; -import com.box.l10n.mojito.rest.entity.Asset; -import com.box.l10n.mojito.rest.entity.ImportLocalizedAssetBody; -import com.box.l10n.mojito.rest.entity.ImportLocalizedAssetBody.StatusForEqualTarget; -import com.box.l10n.mojito.rest.entity.Locale; -import com.box.l10n.mojito.rest.entity.Repository; +import com.box.l10n.mojito.cli.model.AssetAssetSummary; +import com.box.l10n.mojito.cli.model.ImportLocalizedAssetBody; +import com.box.l10n.mojito.cli.model.LocaleRepository; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import jakarta.annotation.PostConstruct; import java.nio.file.Path; import java.util.Collection; import java.util.Iterator; @@ -122,25 +123,29 @@ public class ImportLocalizedAssetCommand extends Command { "Status of the imported translation when the target is the same as " + "the parent (SKIPPED for no import). Applies only to fully translated locales", converter = ImportLocalizedAssetBodyStatusForEqualTargetConverter.class) - StatusForEqualTarget statusForEqualTarget = StatusForEqualTarget.APPROVED; - - @Autowired AssetClient assetClient; + ImportLocalizedAssetBody.StatusForEqualTargetEnum statusForEqualTarget = + ImportLocalizedAssetBody.StatusForEqualTargetEnum.APPROVED; - @Autowired LocaleClient localeClient; - - @Autowired RepositoryClient repositoryClient; + @Autowired ApiClient apiClient; @Autowired CommandHelper commandHelper; @Autowired LocaleMappingHelper localeMappingHelper; - Repository repository; + AssetWsApiProxy assetClient; + + RepositoryRepository repository; CommandDirectories commandDirectories; /** Contains a map of locale for generating localized file a locales defined in the repository. */ Map inverseLocaleMapping; + @PostConstruct + public void init() { + this.assetClient = new AssetWsApiProxy(this.apiClient); + } + @Override public void execute() throws CommandException { @@ -151,7 +156,11 @@ public void execute() throws CommandException { .a(repositoryParam) .println(2); - repository = commandHelper.findRepositoryByName(repositoryParam); + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } commandDirectories = new CommandDirectories(sourceDirectoryParam, targetDirectoryParam); inverseLocaleMapping = localeMappingHelper.getInverseLocaleMapping(localeMappingParam); @@ -163,7 +172,7 @@ public void execute() throws CommandException { sourcePathFilterRegex, directoriesIncludePatterns, directoriesExcludePatterns)) { - for (Locale locale : getLocalesForImport()) { + for (LocaleRepository locale : getLocalesForImport()) { doImportFileMatch(sourceFileMatch, locale); } } @@ -171,7 +180,8 @@ public void execute() throws CommandException { consoleWriter.fg(Ansi.Color.GREEN).newLine().a("Finished").println(2); } - protected void doImportFileMatch(FileMatch fileMatch, Locale locale) throws CommandException { + protected void doImportFileMatch(FileMatch fileMatch, LocaleRepository locale) + throws CommandException { try { logger.info("Importing for locale: {}", locale.getBcp47Tag()); Path targetPath = getTargetPath(fileMatch, locale); @@ -182,44 +192,50 @@ protected void doImportFileMatch(FileMatch fileMatch, Locale locale) throws Comm .a(targetPath.toString()) .println(); - Asset assetByPathAndRepositoryId = + AssetAssetSummary assetByPathAndRepositoryId = assetClient.getAssetByPathAndRepositoryId(fileMatch.getSourcePath(), repository.getId()); - ImportLocalizedAssetBody importLocalizedAssetForContent = - assetClient.importLocalizedAssetForContent( - assetByPathAndRepositoryId.getId(), - locale.getId(), - commandHelper.getFileContent(targetPath), - statusForEqualTarget, - fileMatch.getFileType().getFilterConfigIdOverride(), - commandHelper.getFilterOptionsOrDefaults( - fileMatch.getFileType(), filterOptionsParam)); + ImportLocalizedAssetBody importLocalizedAssetBody = new ImportLocalizedAssetBody(); + importLocalizedAssetBody.setContent(commandHelper.getFileContent(targetPath)); + importLocalizedAssetBody.setStatusForEqualTarget(statusForEqualTarget); + importLocalizedAssetBody.setFilterConfigIdOverride( + ofNullable(fileMatch.getFileType().getFilterConfigIdOverride()) + .map( + filterConfigIdOverride -> + ImportLocalizedAssetBody.FilterConfigIdOverrideEnum.fromValue( + filterConfigIdOverride.name())) + .orElse(null)); + importLocalizedAssetBody.setFilterOptions( + commandHelper.getFilterOptionsOrDefaults(fileMatch.getFileType(), filterOptionsParam)); try { + ImportLocalizedAssetBody importLocalizedAssetForContent = + assetClient.importLocalizedAsset( + importLocalizedAssetBody, assetByPathAndRepositoryId.getId(), locale.getId()); commandHelper.waitForPollableTask(importLocalizedAssetForContent.getPollableTask().getId()); } catch (PollableTaskException e) { throw new CommandException(e.getMessage(), e.getCause()); } - } catch (AssetNotFoundException ex) { + } catch (ApiException ex) { throw new CommandException( "No asset for file [" + fileMatch.getPath() + "] into repo [" + repositoryParam + "]", ex); } } - public Collection getLocalesForImport() { - Collection sortedRepositoryLocales = + public Collection getLocalesForImport() { + Collection sortedRepositoryLocales = commandHelper.getSortedRepositoryLocales(repository).values(); filterLocalesWithMapping(sortedRepositoryLocales); return sortedRepositoryLocales; } - private void filterLocalesWithMapping(Collection locales) { + private void filterLocalesWithMapping(Collection locales) { if (inverseLocaleMapping != null) { - Iterator iterator = locales.iterator(); + Iterator iterator = locales.iterator(); while (iterator.hasNext()) { - Locale l = iterator.next(); + LocaleRepository l = iterator.next(); if (!inverseLocaleMapping.containsKey(l.getBcp47Tag())) { iterator.remove(); } @@ -227,7 +243,7 @@ private void filterLocalesWithMapping(Collection locales) { } } - private Path getTargetPath(FileMatch fileMatch, Locale locale) throws CommandException { + private Path getTargetPath(FileMatch fileMatch, LocaleRepository locale) throws CommandException { String targetLocale; diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/L10nJCommander.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/L10nJCommander.java index 2eda4fdcfd..f19eb84b90 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/L10nJCommander.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/L10nJCommander.java @@ -1,9 +1,9 @@ package com.box.l10n.mojito.cli.command; import com.beust.jcommander.JCommander; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.command.utils.SlackNotificationSender; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.resttemplate.AuthenticatedRestTemplate; import com.box.l10n.mojito.slack.SlackClient; import com.google.common.base.Strings; import jakarta.annotation.PostConstruct; @@ -44,8 +44,6 @@ public class L10nJCommander { @Autowired MainCommand mainCommand; - @Autowired AuthenticatedRestTemplate authenticatedRestTemplate; - @Autowired(required = false) SlackClient slackClient; @@ -55,6 +53,8 @@ public class L10nJCommander { @Value("${FAILURE_URL:#{null}}") String failureUrl; + @Autowired private ApiClient apiClient; + static final String PROGRAM_NAME = "mojito"; boolean systemExitEnabled = true; @@ -182,8 +182,7 @@ public void run(String... args) { } exitWithError(); } catch (ResourceAccessException rae) { - String msg = - "Is a server running on: " + authenticatedRestTemplate.getURIForResource("") + "?"; + String msg = "Is a server running on: " + this.apiClient.getBasePath() + "?"; printErrorMessage(msg); logger.error(msg, rae); this.notifyFailure(command, args, msg); diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/LeveragingCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/LeveragingCommand.java index 06159647f1..a0a327e2ca 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/LeveragingCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/LeveragingCommand.java @@ -1,17 +1,22 @@ package com.box.l10n.mojito.cli.command; +import static java.util.Optional.ofNullable; + import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; +import com.box.l10n.mojito.cli.apiclient.LeveragingWsApi; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.LeveragingClient; -import com.box.l10n.mojito.rest.client.exception.AssetNotFoundException; -import com.box.l10n.mojito.rest.entity.Asset; -import com.box.l10n.mojito.rest.entity.CopyTmConfig; -import com.box.l10n.mojito.rest.entity.PollableTask; -import com.box.l10n.mojito.rest.entity.Repository; +import com.box.l10n.mojito.cli.model.AssetAssetSummary; +import com.box.l10n.mojito.cli.model.CopyTmConfig; +import com.box.l10n.mojito.cli.model.PollableTask; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import jakarta.annotation.PostConstruct; import java.util.Map; +import java.util.stream.Collectors; import org.fusesource.jansi.Ansi.Color; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -88,7 +93,7 @@ public class LeveragingCommand extends Command { + "MD5 will perform matching based on the ID, content and comment. " + "EXACT match is only using the content.", converter = CopyTmConfigModeConverter.class) - CopyTmConfig.Mode mode = CopyTmConfig.Mode.MD5; + CopyTmConfig.ModeEnum mode = CopyTmConfig.ModeEnum.MD5; @Parameter( names = {"--tuids-mapping"}, @@ -102,14 +107,22 @@ public class LeveragingCommand extends Command { @Autowired CommandHelper commandHelper; - @Autowired LeveragingClient leveragingClient; + LeveragingWsApi leveragingClient; + + @Autowired ApiClient apiClient; + + AssetWsApiProxy assetClient; - @Autowired AssetClient assetClient; + @PostConstruct + public void init() { + this.assetClient = new AssetWsApiProxy(this.apiClient); + this.leveragingClient = new LeveragingWsApi(this.apiClient); + } @Override public void execute() throws CommandException { - if (CopyTmConfig.Mode.TUIDS.equals(mode)) { + if (CopyTmConfig.ModeEnum.TUIDS.equals(mode)) { copyTranslationBetweenTextUnits(); } else { copyTmBetweenRepositories(); @@ -135,42 +148,57 @@ void copyTmBetweenRepositories() throws CommandException { .a(targetRepositoryParam) .println(2); - Repository sourceRepository = commandHelper.findRepositoryByName(sourceRepositoryParam); - Repository targetRepository = commandHelper.findRepositoryByName(targetRepositoryParam); - + RepositoryRepository sourceRepository; + RepositoryRepository targetRepository; try { - CopyTmConfig copyTmConfig = new CopyTmConfig(); - copyTmConfig.setSourceRepositoryId(sourceRepository.getId()); - copyTmConfig.setTargetRepositoryId(targetRepository.getId()); - copyTmConfig.setNameRegex(nameRegexParam); - copyTmConfig.setTargetBranchName(targetBranchNameParam); - - if (mode != null) { - copyTmConfig.setMode(mode); - } + sourceRepository = commandHelper.findRepositoryByName(sourceRepositoryParam); + targetRepository = commandHelper.findRepositoryByName(targetRepositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } + + CopyTmConfig copyTmConfig = new CopyTmConfig(); + copyTmConfig.setSourceRepositoryId(sourceRepository.getId()); + copyTmConfig.setTargetRepositoryId(targetRepository.getId()); + copyTmConfig.setNameRegex(nameRegexParam); + copyTmConfig.setTargetBranchName(targetBranchNameParam); + + if (mode != null) { + copyTmConfig.setMode(mode); + } - if (targetAssetPathParam != null) { - Asset asset = + if (targetAssetPathParam != null) { + AssetAssetSummary asset; + try { + asset = assetClient.getAssetByPathAndRepositoryId( targetAssetPathParam, targetRepository.getId()); - copyTmConfig.setTargetAssetId(asset.getId()); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); } + copyTmConfig.setTargetAssetId(asset.getId()); + } - if (sourceAssetPathParam != null) { - Asset asset = + if (sourceAssetPathParam != null) { + AssetAssetSummary asset; + try { + asset = assetClient.getAssetByPathAndRepositoryId( sourceAssetPathParam, sourceRepository.getId()); - copyTmConfig.setSourceAssetId(asset.getId()); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); } + copyTmConfig.setSourceAssetId(asset.getId()); + } + try { copyTmConfig = leveragingClient.copyTM(copyTmConfig); - - PollableTask pollableTask = copyTmConfig.getPollableTask(); - commandHelper.waitForPollableTask(pollableTask.getId()); - - } catch (AssetNotFoundException assetNotFoundException) { - throw new CommandException(assetNotFoundException); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); } + + PollableTask pollableTask = copyTmConfig.getPollableTask(); + commandHelper.waitForPollableTask(pollableTask.getId()); } void copyTranslationBetweenTextUnits() throws CommandException { @@ -189,10 +217,22 @@ void copyTranslationBetweenTextUnits() throws CommandException { CopyTmConfig copyTmConfig = new CopyTmConfig(); copyTmConfig.setNameRegex(nameRegexParam); - copyTmConfig.setMode(CopyTmConfig.Mode.TUIDS); - copyTmConfig.setSourceToTargetTmTextUnitIds(sourceToTargetTmTextUnitMapping); + copyTmConfig.setMode(CopyTmConfig.ModeEnum.TUIDS); + copyTmConfig.setSourceToTargetTmTextUnitIds( + ofNullable(sourceToTargetTmTextUnitMapping) + .map( + sourceToTargetTmTextUnitMapping -> + sourceToTargetTmTextUnitMapping.entrySet().stream() + .collect( + Collectors.toMap( + entry -> String.valueOf(entry.getKey()), Map.Entry::getValue))) + .orElse(null)); - copyTmConfig = leveragingClient.copyTM(copyTmConfig); + try { + copyTmConfig = leveragingClient.copyTM(copyTmConfig); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } PollableTask pollableTask = copyTmConfig.getPollableTask(); commandHelper.waitForPollableTask(pollableTask.getId()); diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/LocaleHelper.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/LocaleHelper.java index 6db2d9f4a0..c6a154757e 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/LocaleHelper.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/LocaleHelper.java @@ -1,16 +1,17 @@ package com.box.l10n.mojito.cli.command; import com.beust.jcommander.internal.Lists; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.LocaleWsApiProxy; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.client.LocaleClient; -import com.box.l10n.mojito.rest.entity.Locale; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.RepositoryLocale; +import com.box.l10n.mojito.cli.model.Locale; +import com.box.l10n.mojito.cli.model.RepositoryLocale; +import jakarta.annotation.PostConstruct; +import java.util.ArrayList; import java.util.LinkedHashMap; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.fusesource.jansi.Ansi; @@ -35,21 +36,33 @@ public class LocaleHelper { @Autowired ConsoleWriter consoleWriter; - @Autowired LocaleClient localeClient; + @Autowired ApiClient apiClient; + + LocaleWsApiProxy localeClient; + + @PostConstruct + public void init() { + this.localeClient = new LocaleWsApiProxy(this.apiClient); + } /** * Extract {@link RepositoryLocale} set from {@link RepoCreateCommand#encodedBcp47Tags} to prep - * for {@link Repository} creation + * for {@link com.box.l10n.mojito.cli.model.Repository} creation * * @return * @throws CommandException */ - protected Set extractRepositoryLocalesFromInput( + protected List extractRepositoryLocalesFromInput( List encodedBcp47Tags, boolean doPrint) throws CommandException { - Set repositoryLocales = new LinkedHashSet<>(); + List repositoryLocales = new ArrayList<>(); if (encodedBcp47Tags != null) { - List locales = localeClient.getLocales(); + List locales; + try { + locales = this.localeClient.getLocales(null); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } Map localeMapByBcp47Tag = getLocaleMapByBcp47Tag(locales); for (String encodedBcp47Tag : encodedBcp47Tags) { @@ -63,7 +76,7 @@ protected Set extractRepositoryLocalesFromInput( /** * Convert encoded Bcp47 Tag into {@link RepositoryLocale} with all the parent relationships and - * {@link RepositoryLocale#toBeFullyTranslated} set + * {@link RepositoryLocale#isToBeFullyTranslated()} set * * @param encodedBcp47Tag * @return @@ -109,8 +122,8 @@ protected RepositoryLocale getRepositoryLocaleFromEncodedBcp47Tag( } /** - * Add locale to the end (last) of the parent hierarchy ({@link RepositoryLocale#parentLocale}) in - * this {@link RepositoryLocale} + * Add locale to the end (last) of the parent hierarchy ({@link + * RepositoryLocale#getParentLocale()}) in this {@link RepositoryLocale} * * @param repositoryLocale * @param parentLocale diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/LocalizedAssetBodyInheritanceModeConverter.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/LocalizedAssetBodyInheritanceModeConverter.java index 9206be63ec..cc03deac1b 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/LocalizedAssetBodyInheritanceModeConverter.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/LocalizedAssetBodyInheritanceModeConverter.java @@ -1,15 +1,15 @@ package com.box.l10n.mojito.cli.command; -import com.box.l10n.mojito.rest.entity.LocalizedAssetBody; +import com.box.l10n.mojito.cli.model.LocalizedAssetBody; /** * @author dragosv */ public class LocalizedAssetBodyInheritanceModeConverter - extends EnumConverter { + extends EnumConverter { @Override - protected Class getGenericClass() { - return LocalizedAssetBody.InheritanceMode.class; + protected Class getGenericClass() { + return LocalizedAssetBody.InheritanceModeEnum.class; } } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/LocalizedAssetBodyStatusConverter.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/LocalizedAssetBodyStatusConverter.java index 9183b3f963..45c2db5f4a 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/LocalizedAssetBodyStatusConverter.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/LocalizedAssetBodyStatusConverter.java @@ -1,14 +1,15 @@ package com.box.l10n.mojito.cli.command; -import com.box.l10n.mojito.rest.entity.LocalizedAssetBody; +import com.box.l10n.mojito.cli.model.LocalizedAssetBody; /** * @author dragosv */ -public class LocalizedAssetBodyStatusConverter extends EnumConverter { +public class LocalizedAssetBodyStatusConverter + extends EnumConverter { @Override - protected Class getGenericClass() { - return LocalizedAssetBody.Status.class; + protected Class getGenericClass() { + return LocalizedAssetBody.StatusEnum.class; } } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/MainCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/MainCommand.java index 4953aafc56..d0e83c15d4 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/MainCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/MainCommand.java @@ -3,9 +3,11 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.box.l10n.mojito.cli.GitInfo; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.apiclient.CliWsApi; import com.box.l10n.mojito.cli.console.ConsoleWriter; +import jakarta.annotation.PostConstruct; import org.fusesource.jansi.Ansi; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -38,7 +40,14 @@ public class MainCommand extends Command { @Autowired GitInfo gitInfo; - @Autowired CliWsApi cliClient; + @Autowired ApiClient apiClient; + + CliWsApi cliClient; + + @PostConstruct + public void init() { + this.cliClient = new CliWsApi(this.apiClient); + } @Override void showUsage() { @@ -59,7 +68,7 @@ protected void execute() throws CommandException { void checkServerVersion() throws CommandException { String serverVersion; try { - serverVersion = cliClient.getVersion(); + serverVersion = this.cliClient.getVersion(); } catch (ApiException e) { throw new CommandException(e.getMessage(), e); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/PseudoLocCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/PseudoLocCommand.java index 6a554c5948..1306a4bad0 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/PseudoLocCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/PseudoLocCommand.java @@ -1,16 +1,20 @@ package com.box.l10n.mojito.cli.command; +import static java.util.Optional.ofNullable; + import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.filefinder.FileMatch; import com.box.l10n.mojito.cli.filefinder.file.FileType; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.exception.AssetNotFoundException; -import com.box.l10n.mojito.rest.entity.Asset; -import com.box.l10n.mojito.rest.entity.LocalizedAssetBody; -import com.box.l10n.mojito.rest.entity.Repository; +import com.box.l10n.mojito.cli.model.AssetAssetSummary; +import com.box.l10n.mojito.cli.model.LocalizedAssetBody; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import jakarta.annotation.PostConstruct; import java.nio.file.Path; import java.util.List; import java.util.Map; @@ -99,17 +103,24 @@ public class PseudoLocCommand extends Command { description = Param.DIR_PATH_EXCLUDE_PATTERNS_DESCRIPTION) List directoriesExcludePatterns = null; - @Autowired AssetClient assetClient; + @Autowired ApiClient apiClient; @Autowired CommandHelper commandHelper; - Repository repository; + AssetWsApiProxy assetClient; + + RepositoryRepository repository; CommandDirectories commandDirectories; /** Contains a map of locale for generating localized file a locales defined in the repository. */ Map localeMappings; + @PostConstruct + public void init() { + this.assetClient = new AssetWsApiProxy(this.apiClient); + } + @Override public void execute() throws CommandException { consoleWriter @@ -119,7 +130,11 @@ public void execute() throws CommandException { .a(repositoryParam) .println(2); - repository = commandHelper.findRepositoryByName(repositoryParam); + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } commandDirectories = new CommandDirectories(sourceDirectoryParam, targetDirectoryParam); @@ -150,7 +165,7 @@ public void execute() throws CommandException { * @throws CommandException */ void generatePseudoLocalizedFile( - Repository repository, FileMatch sourceFileMatch, List filterOptions) + RepositoryRepository repository, FileMatch sourceFileMatch, List filterOptions) throws CommandException { logger.debug("Generate pseudo localzied files"); @@ -176,27 +191,35 @@ void writePseudoLocalizedAssetToTargetDirectory( } LocalizedAssetBody getPseudoLocalizedAsset( - Repository repository, FileMatch sourceFileMatch, List filterOptions) + RepositoryRepository repository, FileMatch sourceFileMatch, List filterOptions) throws CommandException { consoleWriter.a(" - Processing locale: ").fg(Color.CYAN).a(OUTPUT_BCP47_TAG).print(); try { - Asset assetByPathAndRepositoryId = + AssetAssetSummary assetByPathAndRepositoryId = assetClient.getAssetByPathAndRepositoryId( sourceFileMatch.getSourcePath(), repository.getId()); String assetContent = commandHelper.getFileContentWithXcodePatch(sourceFileMatch); + LocalizedAssetBody localizedAssetBody = new LocalizedAssetBody(); + localizedAssetBody.setContent(assetContent); + localizedAssetBody.setOutputBcp47tag(AssetWsApiProxy.OUTPUT_BCP47_TAG); + localizedAssetBody.setFilterConfigIdOverride( + ofNullable(sourceFileMatch.getFileType().getFilterConfigIdOverride()) + .map( + filterConfigIdOverride -> + LocalizedAssetBody.FilterConfigIdOverrideEnum.fromValue( + filterConfigIdOverride.name())) + .orElse(null)); + localizedAssetBody.setFilterOptions(filterOptions); LocalizedAssetBody pseudoLocalizedAsset = assetClient.getPseudoLocalizedAssetForContent( - assetByPathAndRepositoryId.getId(), - assetContent, - sourceFileMatch.getFileType().getFilterConfigIdOverride(), - filterOptions); + localizedAssetBody, assetByPathAndRepositoryId.getId()); logger.trace("PseudoLocalizedAsset content = {}", pseudoLocalizedAsset.getContent()); return pseudoLocalizedAsset; - } catch (AssetNotFoundException e) { + } catch (ApiException e) { throw new CommandException( "Asset with path [" + sourceFileMatch.getSourcePath() diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/PullCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/PullCommand.java index 87a016d2eb..7b44368528 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/PullCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/PullCommand.java @@ -1,27 +1,35 @@ package com.box.l10n.mojito.cli.command; +import static java.util.Optional.ofNullable; + import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.box.l10n.mojito.LocaleMappingHelper; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.filefinder.FileMatch; import com.box.l10n.mojito.cli.filefinder.file.FileType; +import com.box.l10n.mojito.cli.model.AssetAssetSummary; +import com.box.l10n.mojito.cli.model.LocaleInfo; +import com.box.l10n.mojito.cli.model.LocalizedAssetBody; +import com.box.l10n.mojito.cli.model.MultiLocalizedAssetBody; +import com.box.l10n.mojito.cli.model.PollableTask; +import com.box.l10n.mojito.cli.model.RepositoryLocaleRepository; +import com.box.l10n.mojito.cli.model.RepositoryLocaleStatisticRepository; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import com.box.l10n.mojito.cli.model.RepositoryStatisticRepository; import com.box.l10n.mojito.json.ObjectMapper; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.exception.AssetNotFoundException; -import com.box.l10n.mojito.rest.entity.Asset; -import com.box.l10n.mojito.rest.entity.LocalizedAssetBody; -import com.box.l10n.mojito.rest.entity.PollableTask; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.RepositoryLocale; -import com.box.l10n.mojito.rest.entity.RepositoryLocaleStatistic; -import com.box.l10n.mojito.rest.entity.RepositoryStatistic; +import jakarta.annotation.PostConstruct; import java.nio.file.Path; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.stream.Collectors; import org.fusesource.jansi.Ansi.Color; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -121,8 +129,8 @@ public class PullCommand extends Command { description = "Inheritance Mode. Used when there is no translations in the target locale for a text unit. (USE_PARENT to fallback to parent locale translation, REMOVE_UNTRANSLATED to remove the text unit from the file ", converter = LocalizedAssetBodyInheritanceModeConverter.class) - LocalizedAssetBody.InheritanceMode inheritanceMode = - LocalizedAssetBody.InheritanceMode.USE_PARENT; + LocalizedAssetBody.InheritanceModeEnum inheritanceMode = + LocalizedAssetBody.InheritanceModeEnum.USE_PARENT; @Parameter( names = {"--status"}, @@ -130,7 +138,7 @@ public class PullCommand extends Command { description = "To choose the translations used to generate the file based on their status. ACCEPTED: only includes translations that are accepted. ACCEPTED_OR_NEEDS_REVIEW: includes translations that are accepted or that need review. ALL: includes all translations available even if they need re-translation (\"rejected\" translations are always excluded as they are considered harmful).", converter = LocalizedAssetBodyStatusConverter.class) - LocalizedAssetBody.Status status = LocalizedAssetBody.Status.ALL; + LocalizedAssetBody.StatusEnum status = LocalizedAssetBody.StatusEnum.ALL; @Parameter( names = {"--asset-mapping", "-am"}, @@ -167,7 +175,9 @@ public class PullCommand extends Command { "Indicates that the pull should use parallel execution. This is run as an asynchronous request, if --async-ws is also specified it will be ignored.") Boolean isParallel = false; - @Autowired AssetClient assetClient; + @Autowired ApiClient apiClient; + + protected AssetWsApiProxy assetClient; @Autowired CommandHelper commandHelper; @@ -175,11 +185,11 @@ public class PullCommand extends Command { @Autowired LocaleMappingHelper localeMappingHelper; - Map repositoryLocalesWithoutRootLocale; + Map repositoryLocalesWithoutRootLocale; - RepositoryLocale rootRepositoryLocale; + RepositoryLocaleRepository rootRepositoryLocale; - Repository repository; + RepositoryRepository repository; CommandDirectories commandDirectories; @@ -191,6 +201,11 @@ public class PullCommand extends Command { String pullRunName; + @PostConstruct + public void init() { + this.assetClient = new AssetWsApiProxy(this.apiClient); + } + @Override public void execute() throws CommandException { @@ -201,7 +216,11 @@ public void execute() throws CommandException { .a(repositoryParam) .println(2); - repository = commandHelper.findRepositoryByName(repositoryParam); + try { + repository = commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } if (onlyIfFullyTranslated) { initLocaleFullyTranslatedMap(repository); @@ -277,12 +296,13 @@ void writePullRunFileIfNeeded() { * @throws CommandException */ void generateLocalizedFilesWithoutLocaleMapping( - Repository repository, FileMatch sourceFileMatch, List filterOptions) + RepositoryRepository repository, FileMatch sourceFileMatch, List filterOptions) throws CommandException { logger.debug("Generate localized files (without locale mapping)"); - for (RepositoryLocale repositoryLocale : repositoryLocalesWithoutRootLocale.values()) { + for (RepositoryLocaleRepository repositoryLocale : + repositoryLocalesWithoutRootLocale.values()) { generateLocalizedFile(repository, sourceFileMatch, filterOptions, null, repositoryLocale); } } @@ -297,25 +317,32 @@ void generateLocalizedFilesWithoutLocaleMapping( * @throws CommandException */ void generateLocalizedFilesWithLocaleMaping( - Repository repository, FileMatch sourceFileMatch, List filterOptions) + RepositoryRepository repository, FileMatch sourceFileMatch, List filterOptions) throws CommandException { logger.debug("Generate localized files with locale mapping"); + List repositoryLocales = + localeMappings.entrySet().stream() + .map(entry -> getRepositoryLocaleForOutputBcp47Tag(entry.getKey())) + .distinct() + .collect(Collectors.toList()); + for (Map.Entry localeMapping : localeMappings.entrySet()) { String outputBcp47tag = localeMapping.getKey(); - RepositoryLocale repositoryLocale = getRepositoryLocaleForOutputBcp47Tag(outputBcp47tag); + RepositoryLocaleRepository repositoryLocale = + getRepositoryLocaleForOutputBcp47Tag(outputBcp47tag); generateLocalizedFile( repository, sourceFileMatch, filterOptions, outputBcp47tag, repositoryLocale); } } void generateLocalizedFile( - Repository repository, + RepositoryRepository repository, FileMatch sourceFileMatch, List filterOptions, String outputBcp47tag, - RepositoryLocale repositoryLocale) + RepositoryLocaleRepository repositoryLocale) throws CommandException { if (shouldGenerateLocalizedFile(repositoryLocale)) { LocalizedAssetBody localizedAsset = @@ -333,19 +360,19 @@ void generateLocalizedFile( } /** - * Gets the {@link RepositoryLocale} that correspond to the output BCP47 tag + * Gets the {@link com.box.l10n.mojito.cli.model.RepositoryLocaleRepository} that correspond to the output BCP47 tag * based on the {@link #localeMappings * * @param outputBcp47tag * @return the repository locale to be used for the output BCP47 tag * @throws CommandException if the mapping is invalid */ - RepositoryLocale getRepositoryLocaleForOutputBcp47Tag(String outputBcp47tag) + RepositoryLocaleRepository getRepositoryLocaleForOutputBcp47Tag(String outputBcp47tag) throws CommandException { String repositoryLocaleBcp47Tag = localeMappings.get(outputBcp47tag); - RepositoryLocale repositoryLocale; + RepositoryLocaleRepository repositoryLocale; if (rootRepositoryLocale.getLocale().getBcp47Tag().equals(outputBcp47tag)) { repositoryLocale = rootRepositoryLocale; @@ -366,18 +393,20 @@ RepositoryLocale getRepositoryLocaleForOutputBcp47Tag(String outputBcp47tag) } /** - * Gets the list of {@link RepositoryLocale}s of a {@link Repository} excluding the root locale - * (the only locale that has no parent locale). + * Gets the list of {@link com.box.l10n.mojito.cli.model.RepositoryLocaleRepository}s of a {@link + * com.box.l10n.mojito.cli.model.RepositoryRepository} excluding the root locale (the only locale + * that has no parent locale). * * @param repository the repository - * @return the list of {@link RepositoryLocale}s excluding the root locale. + * @return the list of {@link com.box.l10n.mojito.cli.model.RepositoryLocaleRepository}s excluding + * the root locale. */ - private Map initRepositoryLocalesMapAndRootRepositoryLocale( - Repository repository) { + private Map initRepositoryLocalesMapAndRootRepositoryLocale( + RepositoryRepository repository) { repositoryLocalesWithoutRootLocale = new HashMap<>(); - for (RepositoryLocale repositoryLocale : repository.getRepositoryLocales()) { + for (RepositoryLocaleRepository repositoryLocale : repository.getRepositoryLocales()) { if (repositoryLocale.getParentLocale() != null) { repositoryLocalesWithoutRootLocale.put( repositoryLocale.getLocale().getBcp47Tag(), repositoryLocale); @@ -404,9 +433,9 @@ void writeLocalizedAssetToTargetDirectory( } LocalizedAssetBody getLocalizedAsset( - Repository repository, + RepositoryRepository repository, FileMatch sourceFileMatch, - RepositoryLocale repositoryLocale, + RepositoryLocaleRepository repositoryLocale, String outputBcp47tag, List filterOptions) throws CommandException { @@ -419,7 +448,7 @@ LocalizedAssetBody getLocalizedAsset( String sourcePath = commandHelper.getMappedSourcePath(assetMapping, sourceFileMatch.getSourcePath()); - Asset assetByPathAndRepositoryId; + AssetAssetSummary assetByPathAndRepositoryId; try { logger.debug( @@ -428,7 +457,7 @@ LocalizedAssetBody getLocalizedAsset( repositoryLocale.getLocale().getBcp47Tag()); assetByPathAndRepositoryId = assetClient.getAssetByPathAndRepositoryId(sourcePath, repository.getId()); - } catch (AssetNotFoundException e) { + } catch (CommandException | ApiException e) { throw new CommandException( "Asset with path [" + sourcePath + "] was not found in repo [" + repositoryParam + "]", e); @@ -466,10 +495,10 @@ LocalizedAssetBody getLocalizedAsset( LocalizedAssetBody getLocalizedAssetBodySync( FileMatch sourceFileMatch, - RepositoryLocale repositoryLocale, + RepositoryLocaleRepository repositoryLocale, String outputBcp47tag, List filterOptions, - Asset assetByPathAndRepositoryId, + AssetAssetSummary assetByPathAndRepositoryId, String assetContent, LocalizedAssetBody localizedAsset) throws CommandException { @@ -479,17 +508,27 @@ LocalizedAssetBody getLocalizedAssetBodySync( int maxCount = 5; while (localizedAsset == null && count < maxCount) { try { + LocalizedAssetBody localizedAssetBody = new LocalizedAssetBody(); + localizedAssetBody.setAssetId(assetByPathAndRepositoryId.getId()); + localizedAssetBody.setLocaleId(repositoryLocale.getLocale().getId()); + localizedAssetBody.setContent(assetContent); + localizedAssetBody.setOutputBcp47tag(outputBcp47tag); + localizedAssetBody.setFilterConfigIdOverride( + ofNullable(sourceFileMatch.getFileType().getFilterConfigIdOverride()) + .map( + filterConfigIdOverride -> + LocalizedAssetBody.FilterConfigIdOverrideEnum.fromValue( + filterConfigIdOverride.name())) + .orElse(null)); + localizedAssetBody.setFilterOptions(filterOptions); + localizedAssetBody.setInheritanceMode(inheritanceMode); + localizedAssetBody.setStatus(status); + localizedAssetBody.setPullRunName(pullRunName); localizedAsset = assetClient.getLocalizedAssetForContent( + localizedAssetBody, assetByPathAndRepositoryId.getId(), - repositoryLocale.getLocale().getId(), - assetContent, - outputBcp47tag, - sourceFileMatch.getFileType().getFilterConfigIdOverride(), - filterOptions, - status, - inheritanceMode, - pullRunName); + repositoryLocale.getLocale().getId()); } catch (Exception e) { count++; consoleWriter @@ -513,59 +552,118 @@ LocalizedAssetBody getLocalizedAssetBodySync( return localizedAsset; } + private static List mapRepoLocaleToLocaleInfos( + RepositoryLocaleRepository locale, + Map> repoLocaleToOutputTagsMap) { + List localeInfos = new ArrayList<>(); + if (repoLocaleToOutputTagsMap.containsKey(locale)) { + for (String outputTag : repoLocaleToOutputTagsMap.get(locale)) { + LocaleInfo localeInfo = new LocaleInfo(); + localeInfo.setLocaleId(locale.getLocale().getId()); + localeInfo.setOutputBcp47tag(outputTag); + localeInfos.add(localeInfo); + } + } else { + LocaleInfo localeInfo = new LocaleInfo(); + localeInfo.setLocaleId(locale.getLocale().getId()); + localeInfos.add(localeInfo); + } + return localeInfos; + } + PollableTask getLocalizedAssetBodyParallel( FileMatch sourceFileMatch, - List repositoryLocales, - Map> localeIdToOutputTagsMap, + List repositoryLocales, + Map> localeIdToOutputTagsMap, List filterOptions, - Asset assetByPathAndRepositoryId, + AssetAssetSummary assetByPathAndRepositoryId, String assetContent) throws CommandException { - - return assetClient.getLocalizedAssetForContentParallel( - assetByPathAndRepositoryId.getId(), - assetContent, - repositoryLocales, - localeIdToOutputTagsMap, - sourceFileMatch.getFileType().getFilterConfigIdOverride(), - filterOptions, - status, - inheritanceMode, - pullRunName); + List localeInfos = + repositoryLocales.stream() + .map(locale -> mapRepoLocaleToLocaleInfos(locale, localeIdToOutputTagsMap)) + .flatMap(List::stream) + .toList(); + MultiLocalizedAssetBody multiLocalizedAssetBody = new MultiLocalizedAssetBody(); + multiLocalizedAssetBody.setAssetId(assetByPathAndRepositoryId.getId()); + multiLocalizedAssetBody.setSourceContent(assetContent); + multiLocalizedAssetBody.setLocaleInfos(localeInfos); + multiLocalizedAssetBody.setGenerateLocalizedAssetJobIds(new HashMap<>()); + multiLocalizedAssetBody.setFilterConfigIdOverride( + ofNullable(sourceFileMatch.getFileType().getFilterConfigIdOverride()) + .map( + filterConfigIdOverride -> + MultiLocalizedAssetBody.FilterConfigIdOverrideEnum.fromValue( + filterConfigIdOverride.name())) + .orElse(null)); + multiLocalizedAssetBody.setFilterOptions(filterOptions); + multiLocalizedAssetBody.setInheritanceMode( + ofNullable(inheritanceMode) + .map( + inheritanceModeEnum -> + MultiLocalizedAssetBody.InheritanceModeEnum.fromValue( + inheritanceModeEnum.name())) + .orElse(null)); + multiLocalizedAssetBody.setStatus( + ofNullable(status) + .map(statusEnum -> MultiLocalizedAssetBody.StatusEnum.fromValue(statusEnum.name())) + .orElse(null)); + multiLocalizedAssetBody.setPullRunName(pullRunName); + try { + return assetClient.getLocalizedAssetForContentParallel( + multiLocalizedAssetBody, assetByPathAndRepositoryId.getId()); + } catch (ApiException e) { + throw new RuntimeException(e); + } } LocalizedAssetBody getLocalizedAssetBodyAsync( FileMatch sourceFileMatch, - RepositoryLocale repositoryLocale, + RepositoryLocaleRepository repositoryLocale, String outputBcp47tag, List filterOptions, - Asset assetByPathAndRepositoryId, + AssetAssetSummary assetByPathAndRepositoryId, String assetContent) throws CommandException { LocalizedAssetBody localizedAsset; - PollableTask localizedAssetForContentAsync = - assetClient.getLocalizedAssetForContentAsync( - assetByPathAndRepositoryId.getId(), - repositoryLocale.getLocale().getId(), - assetContent, - outputBcp47tag, - sourceFileMatch.getFileType().getFilterConfigIdOverride(), - filterOptions, - status, - inheritanceMode, - pullRunName); - commandHelper.waitForPollableTask(localizedAssetForContentAsync.getId()); - String jsonOutput = - commandHelper.pollableTaskClient.getPollableTaskOutput( - localizedAssetForContentAsync.getId()); + LocalizedAssetBody localizedAssetBody = new LocalizedAssetBody(); + localizedAssetBody.setAssetId(assetByPathAndRepositoryId.getId()); + localizedAssetBody.setLocaleId(repositoryLocale.getLocale().getId()); + localizedAssetBody.setContent(assetContent); + localizedAssetBody.setOutputBcp47tag(outputBcp47tag); + localizedAssetBody.setFilterConfigIdOverride( + ofNullable(sourceFileMatch.getFileType().getFilterConfigIdOverride()) + .map( + filterConfigIdOverride -> + LocalizedAssetBody.FilterConfigIdOverrideEnum.fromValue( + filterConfigIdOverride.name())) + .orElse(null)); + localizedAssetBody.setFilterOptions(filterOptions); + localizedAssetBody.setInheritanceMode(inheritanceMode); + localizedAssetBody.setStatus(status); + localizedAssetBody.setPullRunName(pullRunName); + String jsonOutput; + try { + PollableTask localizedAssetForContentAsync = + assetClient.getLocalizedAssetForContentAsync( + localizedAssetBody, assetByPathAndRepositoryId.getId()); + commandHelper.waitForPollableTask(localizedAssetForContentAsync.getId()); + + jsonOutput = + commandHelper.pollableTaskClient.getPollableTaskOutput( + localizedAssetForContentAsync.getId()); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } localizedAsset = objectMapper.readValueUnchecked(jsonOutput, LocalizedAssetBody.class); return localizedAsset; } - private void initLocaleFullyTranslatedMap(Repository repository) { - RepositoryStatistic repoStat = repository.getRepositoryStatistic(); + private void initLocaleFullyTranslatedMap(RepositoryRepository repository) { + RepositoryStatisticRepository repoStat = repository.getRepositoryStatistic(); if (repoStat != null) { - for (RepositoryLocaleStatistic repoLocaleStat : repoStat.getRepositoryLocaleStatistics()) { + for (RepositoryLocaleStatisticRepository repoLocaleStat : + repoStat.getRepositoryLocaleStatistics()) { localeFullyTranslated.put( repoLocaleStat.getLocale().getBcp47Tag(), repoLocaleStat.getForTranslationCount() == 0L); @@ -573,7 +671,7 @@ private void initLocaleFullyTranslatedMap(Repository repository) { } } - protected boolean shouldGenerateLocalizedFile(RepositoryLocale repositoryLocale) { + protected boolean shouldGenerateLocalizedFile(RepositoryLocaleRepository repositoryLocale) { boolean localize = true; if (onlyIfFullyTranslated) { diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/PullCommandParallel.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/PullCommandParallel.java index a8452ce6e0..f1600f9aa8 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/PullCommandParallel.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/PullCommandParallel.java @@ -1,13 +1,13 @@ package com.box.l10n.mojito.cli.command; +import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.filefinder.FileMatch; -import com.box.l10n.mojito.rest.client.exception.AssetNotFoundException; -import com.box.l10n.mojito.rest.entity.Asset; -import com.box.l10n.mojito.rest.entity.LocalizedAssetBody; -import com.box.l10n.mojito.rest.entity.MultiLocalizedAssetBody; -import com.box.l10n.mojito.rest.entity.PollableTask; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.RepositoryLocale; +import com.box.l10n.mojito.cli.model.AssetAssetSummary; +import com.box.l10n.mojito.cli.model.LocalizedAssetBody; +import com.box.l10n.mojito.cli.model.MultiLocalizedAssetBody; +import com.box.l10n.mojito.cli.model.PollableTask; +import com.box.l10n.mojito.cli.model.RepositoryLocaleRepository; +import com.box.l10n.mojito.cli.model.RepositoryRepository; import com.google.common.collect.Lists; import java.nio.file.Path; import java.util.HashMap; @@ -102,27 +102,31 @@ private void pollForLocalizedFiles() { .forEach( entry -> { commandHelper.waitForPollableTaskSilencedOutput(entry.getKey()); - String jsonOutput = - commandHelper.pollableTaskClient.getPollableTaskOutput(entry.getKey()); - MultiLocalizedAssetBody multiLocalizedAsset = - objectMapper.readValueUnchecked(jsonOutput, MultiLocalizedAssetBody.class); - for (String outputTag : - multiLocalizedAsset.getGenerateLocalizedAssetJobIds().keySet()) { - jsonOutput = - commandHelper.pollableTaskClient.getPollableTaskOutput( - multiLocalizedAsset.getGenerateLocalizedAssetJobIds().get(outputTag)); - writeLocalizedAssetToTargetDirectory( - objectMapper.readValueUnchecked(jsonOutput, LocalizedAssetBody.class), - entry.getValue()); + String jsonOutput; + try { + jsonOutput = commandHelper.pollableTaskClient.getPollableTaskOutput(entry.getKey()); + MultiLocalizedAssetBody multiLocalizedAsset = + objectMapper.readValueUnchecked(jsonOutput, MultiLocalizedAssetBody.class); + for (String outputTag : + multiLocalizedAsset.getGenerateLocalizedAssetJobIds().keySet()) { + jsonOutput = + commandHelper.pollableTaskClient.getPollableTaskOutput( + multiLocalizedAsset.getGenerateLocalizedAssetJobIds().get(outputTag)); + writeLocalizedAssetToTargetDirectory( + objectMapper.readValueUnchecked(jsonOutput, LocalizedAssetBody.class), + entry.getValue()); + } + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); } }); } private PollableTask generateLocalizedFilesWithLocaleMappingParallel( - Repository repository, FileMatch sourceFileMatch, List filterOptions) + RepositoryRepository repository, FileMatch sourceFileMatch, List filterOptions) throws CommandException { - List repositoryLocales = + List repositoryLocales = localeMappings.entrySet().stream() .map(entry -> getRepositoryLocaleForOutputBcp47Tag(entry.getKey())) .distinct() @@ -131,7 +135,7 @@ private PollableTask generateLocalizedFilesWithLocaleMappingParallel( } private PollableTask generateLocalizedFilesWithoutLocaleMappingParallel( - Repository repository, FileMatch sourceFileMatch, List filterOptions) + RepositoryRepository repository, FileMatch sourceFileMatch, List filterOptions) throws CommandException { logger.debug("Generate localized files (without locale mapping)"); @@ -174,7 +178,7 @@ private synchronized void printFileGeneratedToConsole( } void generateLocalizedFilesWithoutLocaleMapping( - Repository repository, FileMatch sourceFileMatch, List filterOptions) + RepositoryRepository repository, FileMatch sourceFileMatch, List filterOptions) throws CommandException { logger.debug("Generate localized files (without locale mapping)"); @@ -187,11 +191,11 @@ void generateLocalizedFilesWithoutLocaleMapping( } private PollableTask generateLocalizedFiles( - Repository repository, + RepositoryRepository repository, FileMatch sourceFileMatch, List filterOptions, - List repositoryLocales) { - Asset assetByPathAndRepositoryId; + List repositoryLocales) { + AssetAssetSummary assetByPathAndRepositoryId; String sourcePath = commandHelper.getMappedSourcePath(assetMapping, sourceFileMatch.getSourcePath()); @@ -200,7 +204,7 @@ private PollableTask generateLocalizedFiles( logger.debug("Getting the asset for path: {}", sourceFileMatch.getSourcePath()); assetByPathAndRepositoryId = assetClient.getAssetByPathAndRepositoryId(sourcePath, repository.getId()); - } catch (AssetNotFoundException e) { + } catch (CommandException | ApiException e) { throw new CommandException( String.format( "Asset with path [%s] was not found in repo [%s]", sourcePath, repositoryParam), @@ -219,13 +223,13 @@ private PollableTask generateLocalizedFiles( commandHelper.getFileContentWithXcodePatch(sourceFileMatch)); } - private Map> getRepoLocaleToOutputTagsMap() { - Map> localeIdToOutputTagsMap = new HashMap<>(); + private Map> getRepoLocaleToOutputTagsMap() { + Map> localeIdToOutputTagsMap = new HashMap<>(); if (localeMappings != null) { for (Map.Entry mapping : localeMappings.entrySet()) { String outputBcp47tag = mapping.getKey(); - RepositoryLocale locale = getRepositoryLocaleForOutputBcp47Tag(outputBcp47tag); + RepositoryLocaleRepository locale = getRepositoryLocaleForOutputBcp47Tag(outputBcp47tag); if (localeIdToOutputTagsMap.containsKey(locale)) { localeIdToOutputTagsMap.get(locale).add(outputBcp47tag); } else { @@ -238,7 +242,7 @@ private Map> getRepoLocaleToOutputTagsMap() { } private boolean shouldGenerateLocalizedFileWithCliOutput( - FileMatch sourceFileMatch, RepositoryLocale repositoryLocale) { + FileMatch sourceFileMatch, RepositoryLocaleRepository repositoryLocale) { boolean localize = shouldGenerateLocalizedFile(repositoryLocale); if (!localize) { printLocaleSkippedToConsole(sourceFileMatch, repositoryLocale); @@ -247,7 +251,7 @@ private boolean shouldGenerateLocalizedFileWithCliOutput( } private synchronized void printLocaleSkippedToConsole( - FileMatch sourceFileMatch, RepositoryLocale repositoryLocale) { + FileMatch sourceFileMatch, RepositoryLocaleRepository repositoryLocale) { consoleWriter .a("Skipping locale: ") .fg(Ansi.Color.CYAN) diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/PushCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/PushCommand.java index 272a30e84b..63c005f865 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/PushCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/PushCommand.java @@ -1,21 +1,23 @@ package com.box.l10n.mojito.cli.command; +import static java.util.Optional.ofNullable; + import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.filefinder.FileMatch; import com.box.l10n.mojito.cli.filefinder.file.FileType; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.SourceAsset; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import com.box.l10n.mojito.cli.model.SourceAsset; import com.ibm.icu.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.UUID; import java.util.stream.Stream; import org.apache.commons.lang3.StringUtils; @@ -118,7 +120,7 @@ public class PushCommand extends Command { required = false, description = "Optional list of notifiers when pusing to a repository (notification will be sent eg. when new strings are processed or when translations are ready)") - Set pushToBranchNotifiers = Collections.emptySet(); + List pushToBranchNotifiers = Collections.emptyList(); @Parameter( names = Param.PUSH_TYPE_LONG, @@ -147,12 +149,12 @@ public class PushCommand extends Command { converter = AssetMappingConverter.class) Map assetMapping; - @Autowired RepositoryClient repositoryClient; - @Autowired CommandHelper commandHelper; @Autowired PushService pushService; + @Autowired ApiClient apiClient; + CommandDirectories commandDirectories; @Override @@ -167,7 +169,12 @@ public void execute() throws CommandException { .a(repositoryParam) .println(2); - Repository repository = commandHelper.findRepositoryByName(repositoryParam); + RepositoryRepository repository; + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } if (commitHash != null && StringUtils.isBlank(commitHash)) { throw new CommandException( @@ -225,7 +232,12 @@ public void execute() throws CommandException { sourceAsset.setRepositoryId(repository.getId()); sourceAsset.setPushRunName(recordPushRun ? pushRunName : null); sourceAsset.setFilterConfigIdOverride( - sourceFileMatch.getFileType().getFilterConfigIdOverride()); + ofNullable(sourceFileMatch.getFileType().getFilterConfigIdOverride()) + .map( + filterConfigIdOverride -> + SourceAsset.FilterConfigIdOverrideEnum.fromValue( + filterConfigIdOverride.name())) + .orElse(null)); sourceAsset.setFilterOptions( commandHelper.getFilterOptionsOrDefaults( sourceFileMatch.getFileType(), filterOptionsParam)); diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/PushService.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/PushService.java index faaca978e2..864345c5f4 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/PushService.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/PushService.java @@ -1,15 +1,18 @@ package com.box.l10n.mojito.cli.command; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; +import com.box.l10n.mojito.cli.apiclient.CommitWsApi; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; +import com.box.l10n.mojito.cli.apiclient.exceptions.PollableTaskException; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.CommitClient; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.client.exception.PollableTaskException; -import com.box.l10n.mojito.rest.entity.Branch; -import com.box.l10n.mojito.rest.entity.PollableTask; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.SourceAsset; -import com.google.common.collect.Sets; +import com.box.l10n.mojito.cli.model.BranchBranchSummary; +import com.box.l10n.mojito.cli.model.CommitToPushRunBody; +import com.box.l10n.mojito.cli.model.PollableTask; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import com.box.l10n.mojito.cli.model.SourceAsset; +import jakarta.annotation.PostConstruct; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -33,16 +36,25 @@ public class PushService { @Autowired ConsoleWriter consoleWriter; - @Autowired AssetClient assetClient; + private AssetWsApiProxy assetClient; - @Autowired CommitClient commitClient; + @Autowired CommandHelper commandHelper; - @Autowired RepositoryClient repositoryClient; + @Autowired ApiClient apiClient; - @Autowired CommandHelper commandHelper; + RepositoryWsApiProxy repositoryClient; + + CommitWsApi commitClient; + + @PostConstruct + public void init() { + this.assetClient = new AssetWsApiProxy(this.apiClient); + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + this.commitClient = new CommitWsApi(this.apiClient); + } public void push( - Repository repository, + RepositoryRepository repository, Stream sourceAssetStream, String branchName, PushType pushType) @@ -55,7 +67,12 @@ public void push( sourceAsset -> { consoleWriter.a(" - Uploading: ").fg(Ansi.Color.CYAN).a(sourceAsset.getPath()).println(); - SourceAsset assetAfterSend = assetClient.sendSourceAsset(sourceAsset); + SourceAsset assetAfterSend = null; + try { + assetAfterSend = assetClient.importSourceAsset(sourceAsset); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } pollableTasks.add(assetAfterSend.getPollableTask()); consoleWriter @@ -84,9 +101,9 @@ public void push( } void optionalDeleteUnusedAssets( - Repository repository, String branchName, PushType pushType, Set usedAssetIds) + RepositoryRepository repository, String branchName, PushType pushType, Set usedAssetIds) throws CommandException { - Branch branch = repositoryClient.getBranch(repository.getId(), branchName); + BranchBranchSummary branch = this.repositoryClient.getBranch(repository.getId(), branchName); if (PushType.NO_DELETE.equals(pushType)) { logger.debug("Don't delete unused asset"); @@ -95,26 +112,30 @@ void optionalDeleteUnusedAssets( logger.debug( "No branch in the repository, no asset must have been pushed yet, no need to delete"); } else { - logger.debug("process deleted assets here"); - Set assetIds = - Sets.newHashSet( - assetClient.getAssetIds(repository.getId(), false, false, branch.getId())); - - assetIds.removeAll(usedAssetIds); - if (!assetIds.isEmpty()) { - consoleWriter - .newLine() - .a("Delete assets from repository, ids: ") - .fg(Ansi.Color.CYAN) - .a(assetIds.toString()) - .println(); - PollableTask pollableTask = assetClient.deleteAssetsInBranch(assetIds, branch.getId()); - consoleWriter - .a(" --> task id: ") - .fg(Ansi.Color.MAGENTA) - .a(pollableTask.getId()) - .println(); - commandHelper.waitForPollableTask(pollableTask.getId()); + try { + logger.debug("process deleted assets here"); + List assetIds = + assetClient.getAssetIds(repository.getId(), false, false, branch.getId()); + + assetIds.removeAll(usedAssetIds); + if (!assetIds.isEmpty()) { + consoleWriter + .newLine() + .a("Delete assets from repository, ids: ") + .fg(Ansi.Color.CYAN) + .a(assetIds.toString()) + .println(); + PollableTask pollableTask = + assetClient.deleteAssetsOfBranches(assetIds, branch.getId()); + consoleWriter + .a(" --> task id: ") + .fg(Ansi.Color.MAGENTA) + .a(pollableTask.getId()) + .println(); + commandHelper.waitForPollableTask(pollableTask.getId()); + } + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); } } } @@ -131,11 +152,20 @@ void waitForPollableTasks(List pollableTasks) throws CommandExcept } } - public void associatePushRun(Repository repository, String pushRunName, String commitHash) { + public void associatePushRun( + RepositoryRepository repository, String pushRunName, String commitHash) { if (!StringUtils.isBlank(pushRunName) && !StringUtils.isBlank(commitHash)) { logger.debug( "Associating commit with hash: {} to push run with name: {}.", commitHash, pushRunName); - commitClient.associateCommitToPushRun(commitHash, repository.getId(), pushRunName); + CommitToPushRunBody commitToPushRunBody = new CommitToPushRunBody(); + commitToPushRunBody.setCommitName(commitHash); + commitToPushRunBody.setRepositoryId(repository.getId()); + commitToPushRunBody.setPushRunName(pushRunName); + try { + this.commitClient.associateCommitToPushRun(commitToPushRunBody); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } } } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/QuartzJobsDeleteCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/QuartzJobsDeleteCommand.java index f2de2f7b16..476a891b3b 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/QuartzJobsDeleteCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/QuartzJobsDeleteCommand.java @@ -1,9 +1,11 @@ package com.box.l10n.mojito.cli.command; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.apiclient.QuartzWsApi; import com.box.l10n.mojito.cli.console.ConsoleWriter; +import jakarta.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -22,7 +24,14 @@ public class QuartzJobsDeleteCommand extends Command { @Autowired ConsoleWriter consoleWriter; - @Autowired QuartzWsApi quartzJobsClient; + @Autowired ApiClient apiClient; + + QuartzWsApi quartzJobsClient; + + @PostConstruct + public void init() { + this.quartzJobsClient = new QuartzWsApi(this.apiClient); + } @Override public boolean shouldShowInCommandList() { @@ -33,9 +42,9 @@ public boolean shouldShowInCommandList() { protected void execute() throws CommandException { consoleWriter.a("Delete quartz jobs").println(); try { - quartzJobsClient.deleteAllDynamicJobs(); + this.quartzJobsClient.deleteAllDynamicJobs(); } catch (ApiException e) { - throw new RuntimeException(e); + throw new CommandException(e.getMessage(), e); } } } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/QuartzJobsViewCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/QuartzJobsViewCommand.java index 0a42672c5b..d7e41fa216 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/QuartzJobsViewCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/QuartzJobsViewCommand.java @@ -1,9 +1,11 @@ package com.box.l10n.mojito.cli.command; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.apiclient.QuartzWsApi; import com.box.l10n.mojito.cli.console.ConsoleWriter; +import jakarta.annotation.PostConstruct; import java.util.List; import org.fusesource.jansi.Ansi; import org.slf4j.Logger; @@ -24,7 +26,14 @@ public class QuartzJobsViewCommand extends Command { @Autowired ConsoleWriter consoleWriter; - @Autowired QuartzWsApi quartzJobsClient; + @Autowired ApiClient apiClient; + + QuartzWsApi quartzJobsClient; + + @PostConstruct + public void init() { + this.quartzJobsClient = new QuartzWsApi(this.apiClient); + } @Override public boolean shouldShowInCommandList() { @@ -36,7 +45,7 @@ protected void execute() throws CommandException { consoleWriter.a("Dynamic quartz jobs:").println(); List allDynamicJobs; try { - allDynamicJobs = quartzJobsClient.getAllDynamicJobs(); + allDynamicJobs = this.quartzJobsClient.getAllDynamicJobs(); } catch (ApiException e) { throw new CommandException(e.getMessage(), e); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoCommand.java index 344a8a2a7a..dd6c06b8b2 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoCommand.java @@ -1,11 +1,13 @@ package com.box.l10n.mojito.cli.command; import com.beust.jcommander.ParameterException; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.entity.IntegrityChecker; -import com.box.l10n.mojito.rest.entity.IntegrityCheckerType; -import java.util.HashSet; +import com.box.l10n.mojito.cli.model.AssetIntegrityChecker; +import jakarta.annotation.PostConstruct; +import java.util.ArrayList; +import java.util.List; import java.util.Set; import org.fusesource.jansi.Ansi; import org.springframework.beans.factory.annotation.Autowired; @@ -25,23 +27,31 @@ public abstract class RepoCommand extends Command { @Autowired protected ConsoleWriter consoleWriter; - @Autowired protected RepositoryClient repositoryClient; - @Autowired protected LocaleHelper localeHelper; + @Autowired private ApiClient apiClient; + + protected RepositoryWsApiProxy repositoryClient; + + @PostConstruct + protected void init() { + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + } + /** - * Extract {@link IntegrityChecker} Set from {@link RepoCreateCommand#integrityCheckParam} to prep - * for {@link Repository} creation + * Extract {@link com.box.l10n.mojito.cli.model.AssetIntegrityChecker} Set from {@link + * RepoCreateCommand#integrityCheckParam} to prep for {@link + * com.box.l10n.mojito.cli.model.Repository} creation * * @param integrityCheckParam * @param doPrint * @return */ - protected Set extractIntegrityCheckersFromInput( + protected List extractIntegrityCheckersFromInput( String integrityCheckParam, boolean doPrint) throws CommandException { - Set integrityCheckers = null; + List integrityCheckers = null; if (integrityCheckParam != null) { - integrityCheckers = new HashSet<>(); + integrityCheckers = new ArrayList<>(); Set integrityCheckerParams = StringUtils.commaDelimitedListToSet(integrityCheckParam); if (doPrint) { consoleWriter.a("Extracted Integrity Checkers").println(); @@ -55,10 +65,11 @@ protected Set extractIntegrityCheckersFromInput( } String fileExtension = param[0]; String checkerType = param[1]; - IntegrityChecker integrityChecker = new IntegrityChecker(); + AssetIntegrityChecker integrityChecker = new AssetIntegrityChecker(); integrityChecker.setAssetExtension(fileExtension); try { - integrityChecker.setIntegrityCheckerType(IntegrityCheckerType.valueOf(checkerType)); + integrityChecker.setIntegrityCheckerType( + AssetIntegrityChecker.IntegrityCheckerTypeEnum.valueOf(checkerType)); } catch (IllegalArgumentException ex) { throw new ParameterException("Invalid integrity checker type [" + checkerType + "]"); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoCreateCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoCreateCommand.java index 14e8699219..e9f3876db8 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoCreateCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoCreateCommand.java @@ -3,16 +3,17 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.ParameterException; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.LocaleWsApiProxy; import com.box.l10n.mojito.cli.command.param.Param; -import com.box.l10n.mojito.rest.client.LocaleClient; -import com.box.l10n.mojito.rest.client.exception.LocaleNotFoundException; -import com.box.l10n.mojito.rest.client.exception.ResourceNotCreatedException; -import com.box.l10n.mojito.rest.entity.IntegrityChecker; -import com.box.l10n.mojito.rest.entity.Locale; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.RepositoryLocale; +import com.box.l10n.mojito.cli.model.AssetIntegrityChecker; +import com.box.l10n.mojito.cli.model.Locale; +import com.box.l10n.mojito.cli.model.Repository; +import com.box.l10n.mojito.cli.model.RepositoryLocale; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import jakarta.annotation.PostConstruct; import java.util.List; -import java.util.Set; import org.fusesource.jansi.Ansi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,39 +93,47 @@ public class RepoCreateCommand extends RepoCommand { description = INTEGRITY_CHECK_DESCRIPTION) String integrityCheckParam; - @Autowired LocaleClient localeClient; + @Autowired ApiClient apiClient; + + LocaleWsApiProxy localeClient; + + @PostConstruct + public void init() { + super.init(); + this.localeClient = new LocaleWsApiProxy(this.apiClient); + } @Override public void execute() throws CommandException { consoleWriter.a("Create repository: ").fg(Ansi.Color.CYAN).a(nameParam).println(); try { - Set repositoryLocales = + List repositoryLocales = localeHelper.extractRepositoryLocalesFromInput(encodedBcp47Tags, true); - Set integrityCheckers = + List integrityCheckers = extractIntegrityCheckersFromInput(integrityCheckParam, true); Locale sourceLocale = null; if (sourceLocaleBcp47Tags != null) { - sourceLocale = localeClient.getLocaleByBcp47Tag(sourceLocaleBcp47Tags); + sourceLocale = this.localeClient.getLocaleByBcp47Tag(sourceLocaleBcp47Tags); } - Repository repository = - repositoryClient.createRepository( - nameParam, - descriptionParam, - sourceLocale, - repositoryLocales, - integrityCheckers, - checkSLA); + Repository repositoryBody = new Repository(); + repositoryBody.setName(nameParam); + repositoryBody.setDescription(descriptionParam); + repositoryBody.setSourceLocale(sourceLocale); + repositoryBody.setRepositoryLocales(repositoryLocales); + repositoryBody.setAssetIntegrityCheckers(integrityCheckers); + repositoryBody.setCheckSLA(checkSLA); + RepositoryRepository repository = this.repositoryClient.createRepository(repositoryBody); consoleWriter .newLine() .a("created --> repository id: ") .fg(Ansi.Color.MAGENTA) .a(repository.getId()) .println(); - } catch (ParameterException | ResourceNotCreatedException | LocaleNotFoundException ex) { + } catch (ParameterException | ApiException ex) { throw new CommandException(ex.getMessage(), ex); } } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoDeleteCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoDeleteCommand.java index 830384c23b..89956d5342 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoDeleteCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoDeleteCommand.java @@ -2,10 +2,12 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.client.exception.RepositoryNotFoundException; +import jakarta.annotation.PostConstruct; import org.fusesource.jansi.Ansi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,21 +39,28 @@ public class RepoDeleteCommand extends Command { description = Param.REPOSITORY_NAME_DESCRIPTION) String nameParam; - @Autowired RepositoryClient repositoryClient; + @Autowired private ApiClient apiClient; + + RepositoryWsApiProxy repositoryClient; + + @PostConstruct + public void init() { + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + } @Override protected void execute() throws CommandException { consoleWriter.a("Delete repository: ").fg(Ansi.Color.CYAN).a(nameParam).println(); try { - repositoryClient.deleteRepositoryByName(nameParam); + this.repositoryClient.deleteRepositoryByName(nameParam); consoleWriter .newLine() .a("deleted --> repository name: ") .fg(Ansi.Color.MAGENTA) .a(nameParam) .println(); - } catch (RepositoryNotFoundException ex) { + } catch (ApiException ex) { throw new CommandException(ex.getMessage(), ex); } } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoUpdateCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoUpdateCommand.java index 0500daf5a3..2beafe33a4 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoUpdateCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoUpdateCommand.java @@ -1,21 +1,18 @@ package com.box.l10n.mojito.cli.command; -import static com.box.l10n.mojito.cli.command.RepoCommand.INTEGRITY_CHECK_LONG_PARAM; - import com.beust.jcommander.Parameter; import com.beust.jcommander.ParameterException; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.command.param.Param; -import com.box.l10n.mojito.rest.client.exception.RepositoryNotFoundException; -import com.box.l10n.mojito.rest.client.exception.ResourceNotUpdatedException; -import com.box.l10n.mojito.rest.entity.IntegrityChecker; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.RepositoryLocale; +import com.box.l10n.mojito.cli.model.AssetIntegrityChecker; +import com.box.l10n.mojito.cli.model.Repository; +import com.box.l10n.mojito.cli.model.RepositoryLocale; +import com.box.l10n.mojito.cli.model.RepositoryRepository; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; -import java.util.Set; import org.fusesource.jansi.Ansi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -127,22 +124,24 @@ public void execute() throws CommandException { public void updateRepositoriesForRepositoryNames() throws CommandException { try { - List repositoriesForUpdate = getRepositoriesToUpdateFromParams(); + List repositoriesForUpdate = getRepositoriesToUpdateFromParams(); - Set repositoryLocales = + List repositoryLocales = localeHelper.extractRepositoryLocalesFromInput(encodedBcp47Tags, true); - Set integrityCheckers = + List integrityCheckers = extractIntegrityCheckersFromInput(integrityCheckParam, true); consoleWriter.a("Update repositories").println(); - for (Repository repository : repositoriesForUpdate) { - repositoryClient.updateRepository( - repository.getName(), - newNameParam, - descriptionParam, - checkSLA, - repositoryLocales, - integrityCheckers); + for (RepositoryRepository repository : repositoriesForUpdate) { + Repository repositoryBody = new Repository(); + repositoryBody.setDescription(descriptionParam); + repositoryBody.setName(newNameParam); + repositoryBody.setRepositoryLocales(repositoryLocales); + repositoryBody.setCheckSLA(checkSLA); + if (integrityCheckers != null) { + repositoryBody.setAssetIntegrityCheckers(integrityCheckers); + } + repositoryClient.updateRepository(repository.getName(), repositoryBody); consoleWriter .newLine() .a("updated --> repository name: ") @@ -151,19 +150,24 @@ public void updateRepositoriesForRepositoryNames() throws CommandException { .println(); } - } catch (ParameterException | RepositoryNotFoundException | ResourceNotUpdatedException ex) { + } catch (ParameterException | ApiException ex) { throw new CommandException(ex.getMessage(), ex); } } - List getRepositoriesToUpdateFromParams() throws CommandException { - List repositoriesForUpdate = new ArrayList<>(); + List getRepositoriesToUpdateFromParams() throws CommandException { + List repositoriesForUpdate = new ArrayList<>(); - List allRepositories = repositoryClient.getRepositories(null); + List allRepositories; + try { + allRepositories = repositoryClient.getRepositories(null); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } if (repositoryNames != null) { HashSet repositoryNamesAsSet = new HashSet<>(repositoryNames); - for (Repository allRepository : allRepositories) { + for (RepositoryRepository allRepository : allRepositories) { if (repositoryNamesAsSet.contains(allRepository.getName())) { repositoriesForUpdate.add(allRepository); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoViewCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoViewCommand.java index 84b1ff5944..dba309177d 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoViewCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/RepoViewCommand.java @@ -2,7 +2,8 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiHelper; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.model.AssetIntegrityCheckerRepository; import com.box.l10n.mojito.cli.model.RepositoryLocaleRepository; @@ -39,13 +40,17 @@ public class RepoViewCommand extends RepoCommand { description = Param.REPOSITORY_NAME_DESCRIPTION) String nameParam; - @Autowired RepositoryWsApiHelper repositoryWsApiHelper; + @Autowired private ApiClient apiClient; @Override public void execute() throws CommandException { consoleWriter.a("View repository: ").fg(Ansi.Color.CYAN).a(nameParam).println(); - - RepositoryRepository repository = this.repositoryWsApiHelper.findRepositoryByName(nameParam); + RepositoryRepository repository; + try { + repository = this.repositoryClient.getRepositoryByName(nameParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } consoleWriter .newLine() .a("Repository id --> ") diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/RepositoryMachineTranslationCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/RepositoryMachineTranslationCommand.java index 57a98f3510..1a9e0d87b0 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/RepositoryMachineTranslationCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/RepositoryMachineTranslationCommand.java @@ -2,11 +2,14 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.MachineTranslationWsApi; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.client.RepositoryMachineTranslationClient; -import com.box.l10n.mojito.rest.entity.PollableTask; -import com.box.l10n.mojito.rest.entity.RepositoryMachineTranslationBody; +import com.box.l10n.mojito.cli.model.PollableTask; +import com.box.l10n.mojito.cli.model.RepositoryMachineTranslationBody; +import jakarta.annotation.PostConstruct; import java.util.List; import java.util.stream.Collectors; import org.fusesource.jansi.Ansi.Color; @@ -57,7 +60,14 @@ public class RepositoryMachineTranslationCommand extends Command { @Autowired CommandHelper commandHelper; - @Autowired RepositoryMachineTranslationClient repositoryMachineTranslationClient; + @Autowired ApiClient apiClient; + + MachineTranslationWsApi repositoryMachineTranslationClient; + + @PostConstruct + public void init() { + this.repositoryMachineTranslationClient = new MachineTranslationWsApi(this.apiClient); + } @Override public boolean shouldShowInCommandList() { @@ -84,8 +94,13 @@ public void execute() throws CommandException { repositoryMachineTranslationBody.setTargetBcp47tags(locales); repositoryMachineTranslationBody.setSourceTextMaxCountPerLocale(sourceTextMaxCount); - repositoryMachineTranslationBody = - repositoryMachineTranslationClient.translateRepository(repositoryMachineTranslationBody); + try { + repositoryMachineTranslationBody = + this.repositoryMachineTranslationClient.translateRepository( + repositoryMachineTranslationBody); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } PollableTask pollableTask = repositoryMachineTranslationBody.getPollableTask(); commandHelper.waitForPollableTask(pollableTask.getId()); diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/ScreenshotCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/ScreenshotCommand.java index 52130f0da4..26e96da44f 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/ScreenshotCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/ScreenshotCommand.java @@ -1,18 +1,24 @@ package com.box.l10n.mojito.cli.command; +import static java.util.Optional.ofNullable; + import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.box.l10n.mojito.LocaleMappingHelper; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.apiclient.ImageWsApi; +import com.box.l10n.mojito.cli.apiclient.ScreenshotWsApi; +import com.box.l10n.mojito.cli.apiclient.mappers.RepositoryMapper; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.client.ScreenshotClient; -import com.box.l10n.mojito.rest.entity.Locale; -import com.box.l10n.mojito.rest.entity.Repository; -import com.box.l10n.mojito.rest.entity.Screenshot; -import com.box.l10n.mojito.rest.entity.ScreenshotRun; +import com.box.l10n.mojito.cli.model.Locale; +import com.box.l10n.mojito.cli.model.LocaleRepository; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import com.box.l10n.mojito.cli.model.Screenshot; +import com.box.l10n.mojito.cli.model.ScreenshotRun; import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.annotation.PostConstruct; import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -90,16 +96,24 @@ public class ScreenshotCommand extends Command { CommandDirectories commandDirectories; - @Autowired ImageWsApi imageClient; - - @Autowired ScreenshotClient screenshotClient; + @Autowired ApiClient apiClient; @Autowired LocaleMappingHelper localeMappingHelper; /** Contains a map of locale for generating localized file a locales defined in the repository. */ Map localeMappings; - Map repositoryLocales; + Map repositoryLocales; + + ScreenshotWsApi screenshotClient; + + ImageWsApi imageClient; + + @PostConstruct + public void init() { + this.screenshotClient = new ScreenshotWsApi(this.apiClient); + this.imageClient = new ImageWsApi(this.apiClient); + } @Override public void execute() throws CommandException { @@ -110,29 +124,32 @@ public void execute() throws CommandException { .fg(Color.CYAN) .a(repositoryParam) .println(2); - Repository repository = commandHelper.findRepositoryByName(repositoryParam); + try { + RepositoryRepository repository = this.commandHelper.findRepositoryByName(repositoryParam); - commandDirectories = new CommandDirectories(sourceDirectoryParam); - localeMappings = localeMappingHelper.getLocaleMapping(localeMappingParam); - repositoryLocales = commandHelper.getSortedRepositoryLocales(repository); + commandDirectories = new CommandDirectories(sourceDirectoryParam); + localeMappings = localeMappingHelper.getLocaleMapping(localeMappingParam); + repositoryLocales = commandHelper.getSortedRepositoryLocales(repository); - List listFilesWithExtensionInSourceDirectory = - commandDirectories.listFilesWithExtensionInSourceDirectory("png", "jpg", "jpeg", "gif"); + List listFilesWithExtensionInSourceDirectory = + commandDirectories.listFilesWithExtensionInSourceDirectory("png", "jpg", "jpeg", "gif"); - ScreenshotRun screenshotRun = new ScreenshotRun(); - screenshotRun.setRepository(repository); + ScreenshotRun screenshotRun = new ScreenshotRun(); + screenshotRun.setRepository(RepositoryMapper.mapToRepository(repository)); - if (screenshotRunName == null) { - screenshotRun.setName(UUID.randomUUID().toString()); - } else { - screenshotRun.setName(screenshotRunName); - } + if (screenshotRunName == null) { + screenshotRun.setName(UUID.randomUUID().toString()); + } else { + screenshotRun.setName(screenshotRunName); + } - for (Path imagePath : listFilesWithExtensionInSourceDirectory) { - processImage(imagePath, screenshotRun); + for (Path imagePath : listFilesWithExtensionInSourceDirectory) { + processImage(imagePath, screenshotRun); + } + this.screenshotClient.createOrAddToScreenshotRun(screenshotRun); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); } - - screenshotClient.uploadScreenshots(screenshotRun); } void processImage(Path imagePath, ScreenshotRun screenshotRun) throws CommandException { @@ -177,7 +194,9 @@ Locale getLocaleFromImagePath(Path path) throws InvalidLocaleException { "The locale: " + localeStr + " is not supported by the repository"); } - return repositoryLocales.get(localeStr); + return ofNullable(repositoryLocales.get(localeStr)) + .map(RepositoryMapper::mapToLocale) + .orElse(null); } catch (IllegalArgumentException iae) { throw new InvalidLocaleException( "The image: " @@ -206,7 +225,7 @@ void uploadImage(Path image, String uploadPath) throws CommandException { logger.debug("Upload image: {} to path: {}", image.toString(), uploadPath); try { byte[] content = Files.readAllBytes(image); - imageClient.uploadImage(content, uploadPath); + this.imageClient.uploadImage(content, uploadPath); } catch (IOException | ApiException ex) { throw new CommandException("Failed to upload image: " + image.toString(), ex); } diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/TMExportCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/TMExportCommand.java index 3951d68d0f..76dac0edd8 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/TMExportCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/TMExportCommand.java @@ -2,17 +2,18 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; -import com.box.l10n.mojito.cli.apiclient.AssetWsApi; -import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiHelper; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; +import com.box.l10n.mojito.cli.apiclient.exceptions.PollableTaskException; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.model.AssetAssetSummary; import com.box.l10n.mojito.cli.model.RepositoryLocaleRepository; import com.box.l10n.mojito.cli.model.RepositoryRepository; import com.box.l10n.mojito.cli.model.XliffExportBody; -import com.box.l10n.mojito.rest.client.exception.PollableTaskException; import com.google.common.base.MoreObjects; +import jakarta.annotation.PostConstruct; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; @@ -70,12 +71,17 @@ public class TMExportCommand extends Command { @Autowired CommandHelper commandHelper; - @Autowired RepositoryWsApiHelper repositoryWsApiHelper; - - @Autowired AssetWsApi assetClient; + @Autowired private ApiClient apiClient; CommandDirectories commandDirectories; + AssetWsApiProxy assetClient; + + @PostConstruct + public void init() { + this.assetClient = new AssetWsApiProxy(this.apiClient); + } + @Override public void execute() throws CommandException { @@ -91,8 +97,12 @@ public void execute() throws CommandException { logger.debug("Initialize targetBasename (use repository if no target bases name is specified)"); targetBasenameParam = MoreObjects.firstNonNull(targetBasenameParam, repositoryParam); - RepositoryRepository repository = - this.repositoryWsApiHelper.findRepositoryByName(repositoryParam); + RepositoryRepository repository; + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } List assets; try { diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/TMImportCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/TMImportCommand.java index d5533b5cb4..196651b550 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/TMImportCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/TMImportCommand.java @@ -2,9 +2,9 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; -import com.box.l10n.mojito.cli.apiclient.RepositoryWsApi; -import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiHelper; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.filefinder.FileMatch; @@ -12,6 +12,7 @@ import com.box.l10n.mojito.cli.filefinder.file.XliffFileType; import com.box.l10n.mojito.cli.model.ImportRepositoryBody; import com.box.l10n.mojito.cli.model.RepositoryRepository; +import jakarta.annotation.PostConstruct; import java.nio.file.Path; import java.util.Arrays; import org.fusesource.jansi.Ansi; @@ -70,16 +71,21 @@ public class TMImportCommand extends Command { description = "Skip the source file import") Boolean skipSourceImportParam = false; - @Autowired RepositoryWsApi repositoryClient; - @Autowired CommandHelper commandHelper; - @Autowired RepositoryWsApiHelper repositoryWsApiHelper; + @Autowired private ApiClient apiClient; RepositoryRepository repository; CommandDirectories commandDirectories; + RepositoryWsApiProxy repositoryClient; + + @PostConstruct + public void init() { + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + } + @Override public void execute() throws CommandException { @@ -90,7 +96,11 @@ public void execute() throws CommandException { .a(repositoryParam) .println(2); - repository = this.repositoryWsApiHelper.findRepositoryByName(repositoryParam); + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } commandDirectories = new CommandDirectories(sourceDirectoryParam); FileType xliffFileType = new XliffFileType(); @@ -131,7 +141,7 @@ protected void doImportFileMatch(FileMatch fileMatch) throws CommandException { ImportRepositoryBody importRepositoryBody = new ImportRepositoryBody(); importRepositoryBody.setUpdateTM(updateTMParam); importRepositoryBody.setXliffContent(getFileContent(fileMatch)); - repositoryClient.importRepository(importRepositoryBody, repository.getId()); + this.repositoryClient.importRepository(importRepositoryBody, repository.getId()); consoleWriter.erasePreviouslyPrintedLines(); consoleWriter diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/ThirdPartySyncCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/ThirdPartySyncCommand.java index 8e7d898e1f..699d50d99c 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/ThirdPartySyncCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/ThirdPartySyncCommand.java @@ -4,14 +4,15 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; -import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiHelper; import com.box.l10n.mojito.cli.apiclient.ThirdPartyWsApi; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.model.PollableTask; import com.box.l10n.mojito.cli.model.RepositoryRepository; import com.box.l10n.mojito.cli.model.ThirdPartySync; +import jakarta.annotation.PostConstruct; import java.util.Arrays; import java.util.List; import java.util.Objects; @@ -119,11 +120,16 @@ public class ThirdPartySyncCommand extends Command { description = "Options to synchronize") List options; - @Autowired ThirdPartyWsApi thirdPartyClient; - @Autowired CommandHelper commandHelper; - @Autowired RepositoryWsApiHelper repositoryWsApiHelper; + @Autowired ApiClient apiClient; + + ThirdPartyWsApi thirdPartyClient; + + @PostConstruct + public void init() { + this.thirdPartyClient = new ThirdPartyWsApi(this.apiClient); + } private ThirdPartySync getThirdPartySync(RepositoryRepository repository) { ThirdPartySync thirdPartySyncBody = new ThirdPartySync(); @@ -189,13 +195,12 @@ public void execute() throws CommandException { .a(Objects.toString(options)) .println(2); - RepositoryRepository repository = - this.repositoryWsApiHelper.findRepositoryByName(repositoryParam); + try { + RepositoryRepository repository = this.commandHelper.findRepositoryByName(repositoryParam); - ThirdPartySync thirdPartySyncBody = getThirdPartySync(repository); + ThirdPartySync thirdPartySyncBody = getThirdPartySync(repository); - try { - PollableTask pollableTask = thirdPartyClient.sync(thirdPartySyncBody); + PollableTask pollableTask = this.thirdPartyClient.sync(thirdPartySyncBody); commandHelper.waitForPollableTask(pollableTask.getId()); consoleWriter.fg(Ansi.Color.GREEN).newLine().a("Finished").println(2); diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/UserCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/UserCommand.java index ac347adc36..39cfd3b091 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/UserCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/UserCommand.java @@ -1,5 +1,6 @@ package com.box.l10n.mojito.cli.command; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.apiclient.UserWsApi; import com.box.l10n.mojito.cli.console.ConsoleWriter; @@ -7,14 +8,22 @@ import com.box.l10n.mojito.cli.model.PageUser; import com.box.l10n.mojito.cli.model.Pageable; import com.box.l10n.mojito.cli.model.User; -import com.box.l10n.mojito.rest.entity.Role; +import com.box.l10n.mojito.cli.models.Role; import java.util.List; +import javax.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; public abstract class UserCommand extends Command { - @Autowired UserWsApi userClient; + @Autowired protected ApiClient apiClient; - @Autowired ConsoleWriter consoleWriter; + @Autowired protected ConsoleWriter consoleWriter; + + protected UserWsApi userClient; + + @PostConstruct + protected void init() { + this.userClient = new UserWsApi(this.apiClient); + } protected PageUser getPageUser(String username) throws ApiException { Pageable pageable = new Pageable(); diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/VirtualAssetCreateCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/VirtualAssetCreateCommand.java index 9e0ecb6639..28cddf1e92 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/VirtualAssetCreateCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/VirtualAssetCreateCommand.java @@ -2,15 +2,16 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; -import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiHelper; import com.box.l10n.mojito.cli.apiclient.VirtualAssetWsApi; import com.box.l10n.mojito.cli.command.param.Param; import com.box.l10n.mojito.cli.console.ConsoleWriter; import com.box.l10n.mojito.cli.model.RepositoryRepository; import com.box.l10n.mojito.cli.model.VirtualAsset; -import com.box.l10n.mojito.rest.client.HttpClientErrorJson; +import com.box.l10n.mojito.cli.models.HttpClientErrorJson; import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.annotation.PostConstruct; import java.io.IOException; import org.fusesource.jansi.Ansi; import org.slf4j.Logger; @@ -48,9 +49,16 @@ public class VirtualAssetCreateCommand extends Command { description = Param.REPOSITORY_DESCRIPTION) String pathParam; - @Autowired VirtualAssetWsApi virtualAssetClient; + @Autowired private ApiClient apiClient; - @Autowired RepositoryWsApiHelper repositoryWsApiHelper; + @Autowired CommandHelper commandHelper; + + VirtualAssetWsApi virtualAssetClient; + + @PostConstruct + public void init() { + this.virtualAssetClient = new VirtualAssetWsApi(this.apiClient); + } private HttpClientErrorJson toHttpClientErrorJson(ApiException ae) { try { @@ -74,8 +82,12 @@ public void execute() throws CommandException { .a(repositoryParam) .println(2); - RepositoryRepository repository = - this.repositoryWsApiHelper.findRepositoryByName(repositoryParam); + RepositoryRepository repository; + try { + repository = this.commandHelper.findRepositoryByName(repositoryParam); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } VirtualAsset virtualAsset = new VirtualAsset(); virtualAsset.setPath(pathParam); @@ -84,7 +96,7 @@ public void execute() throws CommandException { try { consoleWriter.a(" - Create virtual asset: ").fg(Ansi.Color.CYAN).a(pathParam).println(); - virtualAsset = virtualAssetClient.createOrUpdateVirtualAsset(virtualAsset); + virtualAsset = this.virtualAssetClient.createOrUpdateVirtualAsset(virtualAsset); consoleWriter.a(" --> asset id: ").fg(Ansi.Color.MAGENTA).a(virtualAsset.getId()).println(); consoleWriter.fg(Ansi.Color.GREEN).newLine().a("Finished").println(2); } catch (ApiException ae) { diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/checks/AIChecker.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/checks/AIChecker.java index 65fde9e8a2..e3ccb0728c 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/checks/AIChecker.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/checks/AIChecker.java @@ -4,6 +4,7 @@ import static java.util.stream.Collectors.toList; import com.box.l10n.mojito.cli.apiclient.AiChecksWsApi; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.command.CommandException; import com.box.l10n.mojito.cli.command.extraction.AssetExtractionDiff; @@ -16,6 +17,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -39,7 +41,14 @@ public class AIChecker extends AbstractCliChecker { Retry.backoff(RETRY_MAX_ATTEMPTS, Duration.ofSeconds(RETRY_MIN_DURATION_SECONDS)) .maxBackoff(Duration.ofSeconds(RETRY_MAX_BACKOFF_DURATION_SECONDS)); - @Autowired AiChecksWsApi aiServiceClient; + @Autowired ApiClient apiClient; + + AiChecksWsApi aiServiceClient; + + @PostConstruct + public void init() { + this.aiServiceClient = new AiChecksWsApi(apiClient); + } @Override public CliCheckResult run(List assetExtractionDiffs) { diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/models/ErrorMessage.java b/cli/src/main/java/com/box/l10n/mojito/cli/models/ErrorMessage.java new file mode 100644 index 0000000000..9b0f9dd9fa --- /dev/null +++ b/cli/src/main/java/com/box/l10n/mojito/cli/models/ErrorMessage.java @@ -0,0 +1,32 @@ +package com.box.l10n.mojito.cli.models; + +public class ErrorMessage { + + String type; + String message; + boolean expected; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isExpected() { + return expected; + } + + public void setExpected(boolean expected) { + this.expected = expected; + } +} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/models/HttpClientErrorJson.java b/cli/src/main/java/com/box/l10n/mojito/cli/models/HttpClientErrorJson.java new file mode 100644 index 0000000000..0cbdfa65cc --- /dev/null +++ b/cli/src/main/java/com/box/l10n/mojito/cli/models/HttpClientErrorJson.java @@ -0,0 +1,38 @@ +package com.box.l10n.mojito.cli.models; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * @author jeanaurambault + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class HttpClientErrorJson { + + String status; + String message; + String exception; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getException() { + return exception; + } + + public void setException(String exception) { + this.exception = exception; + } +} diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/models/Role.java b/cli/src/main/java/com/box/l10n/mojito/cli/models/Role.java new file mode 100644 index 0000000000..b58d154e9b --- /dev/null +++ b/cli/src/main/java/com/box/l10n/mojito/cli/models/Role.java @@ -0,0 +1,19 @@ +package com.box.l10n.mojito.cli.models; + +public enum Role { + ROLE_PM, + ROLE_TRANSLATOR, + ROLE_ADMIN, + ROLE_USER; + + public static Role fromString(String roleName) { + if (roleName == null || roleName.isBlank()) { + return null; + } + + if (!roleName.startsWith("ROLE_")) { + roleName = "ROLE_" + roleName; + } + return Role.valueOf(roleName); + } +} diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/CLITestBase.java b/cli/src/test/java/com/box/l10n/mojito/cli/CLITestBase.java index 6d788742de..a3fd7e2256 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/CLITestBase.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/CLITestBase.java @@ -1,13 +1,11 @@ package com.box.l10n.mojito.cli; import com.box.l10n.mojito.Application; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.command.L10nJCommander; import com.box.l10n.mojito.entity.Locale; import com.box.l10n.mojito.entity.Repository; import com.box.l10n.mojito.entity.TMTextUnitVariant; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.resttemplate.AuthenticatedRestTemplate; -import com.box.l10n.mojito.rest.resttemplate.ResttemplateConfig; import com.box.l10n.mojito.service.asset.AssetRepository; import com.box.l10n.mojito.service.locale.LocaleService; import com.box.l10n.mojito.service.repository.RepositoryService; @@ -17,9 +15,7 @@ import com.box.l10n.mojito.service.tm.search.TextUnitSearcher; import com.box.l10n.mojito.service.tm.search.TextUnitSearcherParameters; import com.box.l10n.mojito.test.IOTestBase; -import com.box.l10n.mojito.xml.XmlParsingConfiguration; import com.google.common.io.Files; -import jakarta.annotation.PostConstruct; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -52,8 +48,6 @@ public class CLITestBase extends IOTestBase { /** logger */ static Logger logger = LoggerFactory.getLogger(CLITestBase.class); - @Autowired AuthenticatedRestTemplate authenticatedRestTemplate; - @Autowired protected RepositoryService repositoryService; @Autowired LocaleService localeService; @@ -62,10 +56,6 @@ public class CLITestBase extends IOTestBase { @Autowired TMService tmService; - @Autowired ResttemplateConfig resttemplateConfig; - - @Autowired RepositoryClient repositoryClient; - @Autowired AssetRepository assetRepository; @Autowired TextUnitSearcher textUnitSearcher; @@ -74,21 +64,7 @@ public class CLITestBase extends IOTestBase { @LocalServerPort int port; - @PostConstruct - public void setPort() { - logger.debug("Saving port number = {}", port); - resttemplateConfig.setPort(port); - - XmlParsingConfiguration.disableXPathLimits(); - } - - public void resetHost() { - resttemplateConfig.setHost("localhost"); - } - - public void setNonExistentHost() { - resttemplateConfig.setHost("nonExistentHostAddress"); - } + @Autowired protected ApiClient apiClient; public L10nJCommander getL10nJCommander() { L10nJCommander l10nJCommander = new L10nJCommander(); diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/BranchDeleteCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/BranchDeleteCommandTest.java index 46e0304c64..efca22c15f 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/BranchDeleteCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/BranchDeleteCommandTest.java @@ -9,10 +9,11 @@ import static org.junit.Assert.assertEquals; import com.box.l10n.mojito.cli.CLITestBase; -import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiHelper; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; import com.box.l10n.mojito.cli.model.BranchBranchSummary; import com.box.l10n.mojito.entity.Repository; import com.box.l10n.mojito.service.branch.BranchRepository; +import jakarta.annotation.PostConstruct; import java.time.ZonedDateTime; import java.util.Collections; import java.util.Comparator; @@ -25,10 +26,15 @@ public class BranchDeleteCommandTest extends CLITestBase { - @Autowired RepositoryWsApiHelper repositoryClient; + RepositoryWsApiProxy repositoryClient; @Autowired BranchRepository branchRepository; + @PostConstruct + public void init() { + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + } + @Test public void delete() throws Exception { Repository repository = createTestRepoUsingRepoService(); diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/DropExportCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/DropExportCommandTest.java index 9a64957efd..e4e7998c32 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/DropExportCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/DropExportCommandTest.java @@ -3,16 +3,19 @@ import static org.junit.Assert.assertEquals; import com.box.l10n.mojito.cli.CLITestBase; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; +import com.box.l10n.mojito.cli.apiclient.DropWsApi; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; +import com.box.l10n.mojito.cli.model.AssetAssetSummary; +import com.box.l10n.mojito.cli.model.PageDropDropSummary; +import com.box.l10n.mojito.cli.model.Pageable; import com.box.l10n.mojito.entity.Repository; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.DropClient; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.entity.Asset; -import com.box.l10n.mojito.rest.entity.Drop; -import com.box.l10n.mojito.rest.entity.Page; import com.box.l10n.mojito.service.repository.RepositoryRepository; import com.box.l10n.mojito.service.tm.TMImportService; import com.google.common.collect.Sets; +import jakarta.annotation.PostConstruct; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -23,12 +26,22 @@ public class DropExportCommandTest extends CLITestBase { @Autowired TMImportService tmImport; - @Autowired AssetClient assetClient; + AssetWsApiProxy assetClient; - @Autowired DropClient dropClient; @Autowired RepositoryRepository repositoryRepository; - @Autowired RepositoryClient repositoryClient; + @Autowired ApiClient apiClient; + + DropWsApi dropClient; + + RepositoryWsApiProxy repositoryClient; + + @PostConstruct + public void init() { + this.assetClient = new AssetWsApiProxy(this.apiClient); + this.dropClient = new DropWsApi(this.apiClient); + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + } @Test public void export() throws Exception { @@ -46,20 +59,27 @@ public void export() throws Exception { RepositoryStatusChecker repositoryStatusChecker = new RepositoryStatusChecker(); waitForCondition( "wait for repository stats to show forTranslationCount > 0 before exporting a drop", - () -> - repositoryStatusChecker.hasStringsForTranslationsForExportableLocales( - repositoryClient.getRepositoryById(repository.getId()))); + () -> { + try { + return repositoryStatusChecker.hasStringsForTranslationsForExportableLocales( + this.repositoryClient.getRepositoryById(repository.getId())); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } + }); - Page findAllBefore = dropClient.getDrops(repository.getId(), null, null, null); + PageDropDropSummary findAllBefore = + dropClient.getDrops(new Pageable(), repository.getId(), null, null); getL10nJCommander().run("drop-export", "-r", repository.getName()); - Page findAllAfter = dropClient.getDrops(repository.getId(), null, null, null); + PageDropDropSummary findAllAfter = + dropClient.getDrops(new Pageable(), repository.getId(), null, null); assertEquals( "A Drop must have been added", findAllBefore.getTotalElements() + 1, - findAllAfter.getTotalElements()); + (long) findAllAfter.getTotalElements()); } @Test @@ -75,7 +95,7 @@ public void exportFullyTranslated() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -97,11 +117,13 @@ public void exportFullyTranslated() throws Exception { .orElse(false); }); - Page findAllBefore = dropClient.getDrops(repository.getId(), null, null, null); + PageDropDropSummary findAllBefore = + dropClient.getDrops(new Pageable(), repository.getId(), null, null); getL10nJCommander().run("drop-export", "-r", repository.getName()); - Page findAllAfter = dropClient.getDrops(repository.getId(), null, null, null); + PageDropDropSummary findAllAfter = + dropClient.getDrops(new Pageable(), repository.getId(), null, null); assertEquals( "A Drop should not have been added", @@ -122,17 +144,18 @@ public void exportReviewWithInheritance() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); - Asset asset2 = + AssetAssetSummary asset2 = assetClient.getAssetByPathAndRepositoryId("source2-xliff.xliff", repository.getId()); importTranslations(asset2.getId(), "source2-xliff_", "fr-FR"); importTranslations(asset2.getId(), "source2-xliff_", "ja-JP"); - Page findAllBefore = dropClient.getDrops(repository.getId(), null, null, null); + PageDropDropSummary findAllBefore = + dropClient.getDrops(new Pageable(), repository.getId(), null, null); getL10nJCommander() .run( @@ -147,11 +170,12 @@ public void exportReviewWithInheritance() throws Exception { "--use-inheritance" }); - Page findAllAfter = dropClient.getDrops(repository.getId(), null, null, null); + PageDropDropSummary findAllAfter = + dropClient.getDrops(new Pageable(), repository.getId(), null, null); assertEquals( "A Drop must have been added", findAllBefore.getTotalElements() + 1, - findAllAfter.getTotalElements()); + (long) findAllAfter.getTotalElements()); } } diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/DropImportCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/DropImportCommandTest.java index 4e5d12c84f..feb5b2754d 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/DropImportCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/DropImportCommandTest.java @@ -11,12 +11,14 @@ import com.box.l10n.mojito.boxsdk.BoxSDKService; import com.box.l10n.mojito.boxsdk.BoxSDKServiceException; import com.box.l10n.mojito.cli.CLITestBase; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; import com.box.l10n.mojito.cli.console.Console; +import com.box.l10n.mojito.cli.model.AssetAssetSummary; import com.box.l10n.mojito.entity.Drop; import com.box.l10n.mojito.entity.Repository; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.entity.Asset; import com.box.l10n.mojito.service.drop.DropRepository; import com.box.l10n.mojito.service.drop.DropService; import com.box.l10n.mojito.service.drop.exporter.DropExporterException; @@ -28,6 +30,7 @@ import com.box.l10n.mojito.service.tm.TMTextUnitCurrentVariantRepository; import com.box.l10n.mojito.test.XliffUtils; import com.google.common.io.Files; +import jakarta.annotation.PostConstruct; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -53,8 +56,6 @@ public class DropImportCommandTest extends CLITestBase { @Autowired TMImportService tmImport; - @Autowired AssetClient assetClient; - @Autowired TMTextUnitCurrentVariantRepository textUnitCurrentVariantRepository; @Autowired LocaleService localeService; @@ -67,7 +68,17 @@ public class DropImportCommandTest extends CLITestBase { @Autowired DropRepository dropRepository; - @Autowired private RepositoryClient repositoryClient; + @Autowired ApiClient apiClient; + + RepositoryWsApiProxy repositoryClient; + + AssetWsApiProxy assetClient; + + @PostConstruct + public void init() { + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + this.assetClient = new AssetWsApiProxy(this.apiClient); + } @Test public void dropImport() throws Exception { @@ -82,12 +93,12 @@ public void dropImport() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); - Asset asset2 = + AssetAssetSummary asset2 = assetClient.getAssetByPathAndRepositoryId("source2-xliff.xliff", repository.getId()); importTranslations(asset2.getId(), "source2-xliff_", "fr-FR"); importTranslations(asset2.getId(), "source2-xliff_", "ja-JP"); @@ -95,9 +106,14 @@ public void dropImport() throws Exception { RepositoryStatusChecker repositoryStatusChecker = new RepositoryStatusChecker(); waitForCondition( "wait for repository stats to show forTranslationCount > 0 before exporting a drop", - () -> - repositoryStatusChecker.hasStringsForTranslationsForExportableLocales( - repositoryClient.getRepositoryById(repository.getId()))); + () -> { + try { + return repositoryStatusChecker.hasStringsForTranslationsForExportableLocales( + repositoryClient.getRepositoryById(repository.getId())); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } + }); getL10nJCommander().run("drop-export", "-r", repository.getName()); @@ -161,12 +177,12 @@ public void importFetched() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); - Asset asset2 = + AssetAssetSummary asset2 = assetClient.getAssetByPathAndRepositoryId("source2-xliff.xliff", repository.getId()); importTranslations(asset2.getId(), "source2-xliff_", "fr-FR"); importTranslations(asset2.getId(), "source2-xliff_", "ja-JP"); @@ -174,9 +190,14 @@ public void importFetched() throws Exception { RepositoryStatusChecker repositoryStatusChecker = new RepositoryStatusChecker(); waitForCondition( "wait for repository stats to show forTranslationCount > 0 before exporting a drop", - () -> - repositoryStatusChecker.hasStringsForTranslationsForExportableLocales( - repositoryClient.getRepositoryById(repository.getId()))); + () -> { + try { + return repositoryStatusChecker.hasStringsForTranslationsForExportableLocales( + repositoryClient.getRepositoryById(repository.getId())); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } + }); getL10nJCommander().run("drop-export", "-r", repository.getName()); diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/DropXliffImportCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/DropXliffImportCommandTest.java index 777461d90a..948e08eb38 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/DropXliffImportCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/DropXliffImportCommandTest.java @@ -5,11 +5,13 @@ import com.box.l10n.mojito.boxsdk.BoxSDKService; import com.box.l10n.mojito.boxsdk.BoxSDKServiceException; import com.box.l10n.mojito.cli.CLITestBase; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; +import com.box.l10n.mojito.cli.model.AssetAssetSummary; import com.box.l10n.mojito.entity.Drop; import com.box.l10n.mojito.entity.Repository; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.entity.Asset; import com.box.l10n.mojito.service.drop.DropRepository; import com.box.l10n.mojito.service.drop.DropService; import com.box.l10n.mojito.service.drop.exporter.DropExporterException; @@ -21,6 +23,7 @@ import com.box.l10n.mojito.service.tm.TMTextUnitCurrentVariantRepository; import com.box.l10n.mojito.test.XliffUtils; import com.google.common.io.Files; +import jakarta.annotation.PostConstruct; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -42,7 +45,7 @@ public class DropXliffImportCommandTest extends CLITestBase { @Autowired TMImportService tmImport; - @Autowired AssetClient assetClient; + AssetWsApiProxy assetClient; @Autowired TMTextUnitCurrentVariantRepository textUnitCurrentVariantRepository; @@ -58,7 +61,15 @@ public class DropXliffImportCommandTest extends CLITestBase { @Autowired DropImportCommand dropImportCommand; - @Autowired RepositoryClient repositoryClient; + @Autowired ApiClient apiClient; + + RepositoryWsApiProxy repositoryClient; + + @PostConstruct + public void init() { + this.assetClient = new AssetWsApiProxy(this.apiClient); + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + } @Test public void dropXliffImport() throws Exception { @@ -73,12 +84,12 @@ public void dropXliffImport() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); - Asset asset2 = + AssetAssetSummary asset2 = assetClient.getAssetByPathAndRepositoryId("source2-xliff.xliff", repository.getId()); importTranslations(asset2.getId(), "source2-xliff_", "fr-FR"); importTranslations(asset2.getId(), "source2-xliff_", "ja-JP"); @@ -86,9 +97,14 @@ public void dropXliffImport() throws Exception { RepositoryStatusChecker repositoryStatusChecker = new RepositoryStatusChecker(); waitForCondition( "wait for repository stats to show forTranslationCount > 0 before exporting a drop", - () -> - repositoryStatusChecker.hasStringsForTranslationsForExportableLocales( - repositoryClient.getRepositoryById(repository.getId()))); + () -> { + try { + return repositoryStatusChecker.hasStringsForTranslationsForExportableLocales( + this.repositoryClient.getRepositoryById(repository.getId())); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } + }); getL10nJCommander().run("drop-export", "-r", repository.getName()); diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/EvolveCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/EvolveCommandTest.java index e6fbe889cd..6003db567c 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/EvolveCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/EvolveCommandTest.java @@ -1,10 +1,11 @@ package com.box.l10n.mojito.cli.command; import com.box.l10n.mojito.cli.CLITestBase; +import com.box.l10n.mojito.cli.model.LocaleRepository; +import com.box.l10n.mojito.cli.model.RepositoryRepository; import com.box.l10n.mojito.entity.Repository; import com.box.l10n.mojito.evolve.Course; import com.box.l10n.mojito.evolve.Evolve; -import com.box.l10n.mojito.rest.entity.Locale; import org.junit.Assume; import org.junit.Test; import org.slf4j.Logger; @@ -30,14 +31,13 @@ public void writeJsonTo() { EvolveCommand evolveCommand = new EvolveCommand(); evolveCommand.writeJsonTo = getTargetTestDir().toString(); - com.box.l10n.mojito.rest.entity.Repository repository = - new com.box.l10n.mojito.rest.entity.Repository(); + RepositoryRepository repository = new RepositoryRepository(); repository.setName("evolveRepository"); Course course = new Course(); course.setId("course1"); - Locale locale = new Locale(); + LocaleRepository locale = new LocaleRepository(); locale.setBcp47Tag("fr-FR"); evolveCommand.writeJsonToFile(repository, course, locale, "{\"key\" : \"value\"}"); diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/ExtractionCheckCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/ExtractionCheckCommandTest.java index d33067d637..6ad433b072 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/ExtractionCheckCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/ExtractionCheckCommandTest.java @@ -1,6 +1,11 @@ package com.box.l10n.mojito.cli.command; import static com.box.l10n.mojito.cli.command.checks.AbstractCliChecker.BULLET_POINT; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; @@ -8,10 +13,12 @@ import static org.mockito.Mockito.when; import com.box.l10n.mojito.cli.CLITestBase; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.ApiException; import com.box.l10n.mojito.cli.command.checks.CliCheckResult; import com.box.l10n.mojito.cli.console.ConsoleWriter; -import com.box.l10n.mojito.rest.resttemplate.AuthenticatedRestTemplate; import com.google.common.collect.Lists; +import com.squareup.okhttp.Call; import java.util.List; import org.fusesource.jansi.Ansi; import org.junit.Assert; @@ -580,7 +587,7 @@ public void runHardFailChecksWithInvalidCheckName() throws Exception { /** * this is a functional test for the {@link - * com.box.l10n.mojito.cli.command.checks.AbstractCliChecker#getAddedTextUnitsExcludingInconsistentComments(List)} + * com.box.l10n.mojito.cli.command.checks.AbstractCliChecker#getAddedTextUnitsExcludingInconsistentComments(java.util.List)} * *

If combination source+context is added again with a different comment we run the check and * eventually reject it if it is not valid @@ -787,62 +794,143 @@ public void testChecksSkippedIfSkipChecksEnabled() { } @Test - public void testStatsAreReportedIfUrlTemplateSet() { + public void testStatsAreReportedIfUrlTemplateSet() throws ApiException { ConsoleWriter consoleWriter = Mockito.mock(ConsoleWriter.class); - AuthenticatedRestTemplate restTemplateMock = Mockito.mock(AuthenticatedRestTemplate.class); + ApiClient apiClientMock = Mockito.mock(ApiClient.class); + Call callMock = Mockito.mock(Call.class); + when(apiClientMock.buildCall( + anyString(), + anyString(), + anyList(), + anyList(), + any(), + anyMap(), + anyMap(), + any(), + any())) + .thenReturn(callMock); when(consoleWriter.fg(isA(Ansi.Color.class))).thenReturn(consoleWriter); when(consoleWriter.newLine()).thenReturn(consoleWriter); when(consoleWriter.a(isA(String.class))).thenReturn(consoleWriter); ExtractionCheckCommand extractionCheckCommand = new ExtractionCheckCommand(); extractionCheckCommand.consoleWriter = consoleWriter; - extractionCheckCommand.restTemplate = restTemplateMock; + extractionCheckCommand.apiClient = apiClientMock; extractionCheckCommand.statsUrlTemplate = "http://someUrl.com/my_test_stat_{check_name}_{outcome}?value=1"; CliCheckResult success = new CliCheckResult(true, false, "testCheck1"); CliCheckResult failure = new CliCheckResult(false, false, "testCheck2"); extractionCheckCommand.reportStatistics(Lists.newArrayList(success, failure)); - verify(restTemplateMock, times(1)) - .put("http://someUrl.com/my_test_stat_testCheck1_success?value=1", null); - verify(restTemplateMock, times(1)) - .put("http://someUrl.com/my_test_stat_testCheck2_failure?value=1", null); + verify(apiClientMock, times(1)) + .buildCall( + eq("http://someUrl.com/my_test_stat_testCheck1_success?value=1"), + eq("PUT"), + anyList(), + anyList(), + any(), + anyMap(), + anyMap(), + any(), + any()); + verify(apiClientMock, times(1)) + .buildCall( + eq("http://someUrl.com/my_test_stat_testCheck2_failure?value=1"), + eq("PUT"), + anyList(), + anyList(), + any(), + anyMap(), + anyMap(), + any(), + any()); } @Test - public void testStatsAreNotReportedIfUrlTemplateIsNull() { + public void testStatsAreNotReportedIfUrlTemplateIsNull() throws ApiException { ConsoleWriter consoleWriter = Mockito.mock(ConsoleWriter.class); - AuthenticatedRestTemplate restTemplateMock = Mockito.mock(AuthenticatedRestTemplate.class); + ApiClient apiClientMock = Mockito.mock(ApiClient.class); + Call callMock = Mockito.mock(Call.class); + when(apiClientMock.buildCall( + anyString(), + anyString(), + anyList(), + anyList(), + any(), + anyMap(), + anyMap(), + any(), + any())) + .thenReturn(callMock); when(consoleWriter.fg(isA(Ansi.Color.class))).thenReturn(consoleWriter); when(consoleWriter.newLine()).thenReturn(consoleWriter); when(consoleWriter.a(isA(String.class))).thenReturn(consoleWriter); ExtractionCheckCommand extractionCheckCommand = new ExtractionCheckCommand(); extractionCheckCommand.consoleWriter = consoleWriter; - extractionCheckCommand.restTemplate = restTemplateMock; + extractionCheckCommand.apiClient = apiClientMock; extractionCheckCommand.statsUrlTemplate = null; CliCheckResult success = new CliCheckResult(true, false, "testCheck1"); CliCheckResult failure = new CliCheckResult(false, false, "testCheck2"); extractionCheckCommand.reportStatistics(Lists.newArrayList(success, failure)); - verify(restTemplateMock, times(0)) - .put("http://someUrl.com/my_test_stat_testCheck1_success?value=1", null); - verify(restTemplateMock, times(0)) - .put("http://someUrl.com/my_test_stat_testCheck2_failure?value=1", null); + verify(apiClientMock, times(0)) + .buildCall( + eq("http://someUrl.com/my_test_stat_testCheck1_success?value=1"), + eq("PUT"), + anyList(), + anyList(), + any(), + anyMap(), + anyMap(), + any(), + any()); + verify(apiClientMock, times(0)) + .buildCall( + eq("http://someUrl.com/my_test_stat_testCheck2_failure?value=1"), + eq("PUT"), + anyList(), + anyList(), + any(), + anyMap(), + anyMap(), + any(), + any()); } @Test - public void testErrorReportingStatistics() { + public void testErrorReportingStatistics() throws ApiException { ConsoleWriter consoleWriter = Mockito.mock(ConsoleWriter.class); - AuthenticatedRestTemplate restTemplateMock = Mockito.mock(AuthenticatedRestTemplate.class); + ApiClient apiClientMock = Mockito.mock(ApiClient.class); + Call callMock = Mockito.mock(Call.class); + when(apiClientMock.buildCall( + anyString(), + anyString(), + anyList(), + anyList(), + any(), + anyMap(), + anyMap(), + any(), + any())) + .thenReturn(callMock); when(consoleWriter.fg(isA(Ansi.Color.class))).thenReturn(consoleWriter); when(consoleWriter.newLine()).thenReturn(consoleWriter); when(consoleWriter.a(isA(String.class))).thenReturn(consoleWriter); doThrow(new RestClientException("test exception")) - .when(restTemplateMock) - .put("http://someUrl.com/my_test_stat_testCheck1_success?value=1", null); + .when(apiClientMock) + .buildCall( + eq("http://someUrl.com/my_test_stat_testCheck1_success?value=1"), + eq("PUT"), + anyList(), + anyList(), + any(), + anyMap(), + anyMap(), + any(), + any()); ExtractionCheckCommand extractionCheckCommand = new ExtractionCheckCommand(); extractionCheckCommand.consoleWriter = consoleWriter; - extractionCheckCommand.restTemplate = restTemplateMock; + extractionCheckCommand.apiClient = apiClientMock; extractionCheckCommand.statsUrlTemplate = "http://someUrl.com/my_test_stat_{check_name}_{outcome}?value=1"; CliCheckResult success = new CliCheckResult(true, false, "testCheck1"); diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/ExtractionDiffCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/ExtractionDiffCommandTest.java index ebfacc78e4..9288687f50 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/ExtractionDiffCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/ExtractionDiffCommandTest.java @@ -7,6 +7,7 @@ import static org.mockito.Mockito.verify; import com.box.l10n.mojito.cli.CLITestBase; +import com.box.l10n.mojito.cli.apiclient.ApiClient; import com.box.l10n.mojito.cli.command.utils.SlackNotificationSender; import com.box.l10n.mojito.entity.Repository; import com.box.l10n.mojito.service.tm.search.TextUnitDTO; @@ -35,9 +36,11 @@ public class ExtractionDiffCommandTest extends CLITestBase { @Autowired TextUnitSearcher textUnitSearcher; + @Autowired ApiClient apiClient; + @Before public void init() { - resetHost(); + this.apiClient.setBasePath("http://localhost:8080"); } @Test @@ -324,7 +327,7 @@ public void noDiffChangesNoDatabaseCalls() throws Exception { "-fo", "sometestoption=value1"); - setNonExistentHost(); + this.apiClient.setBasePath("http://nonExistentHostAddress:8080"); L10nJCommander l10nJCommander = getL10nJCommander(); l10nJCommander.run( diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/GitBlameCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/GitBlameCommandTest.java index 3137d70594..b60ecd02be 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/GitBlameCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/GitBlameCommandTest.java @@ -14,9 +14,9 @@ import com.box.l10n.mojito.cli.filefinder.file.ChromeExtensionJSONFileType; import com.box.l10n.mojito.cli.filefinder.file.FileType; import com.box.l10n.mojito.cli.filefinder.file.POFileType; +import com.box.l10n.mojito.cli.model.GitBlameGitBlameWithUsage; +import com.box.l10n.mojito.cli.model.GitBlameWithUsageGitBlameWithUsage; import com.box.l10n.mojito.entity.Repository; -import com.box.l10n.mojito.rest.entity.GitBlame; -import com.box.l10n.mojito.rest.entity.GitBlameWithUsage; import com.box.l10n.mojito.service.gitblame.GitBlameService; import com.box.l10n.mojito.service.tm.search.TextUnitSearcherParameters; import java.io.File; @@ -69,7 +69,7 @@ public void android() throws Exception { assertNull(gitBlameWithUsage.getGitBlame()); } - GitBlame gitBlame = new GitBlame(); + GitBlameGitBlameWithUsage gitBlame = new GitBlameGitBlameWithUsage(); gitBlame.setCommitName("37801193683d2e852a8a2b81e6dd05ca9ed13598"); gitBlame.setCommitTime("1537568049"); gitBlame.setAuthorName("Jean Aurambault"); @@ -104,7 +104,7 @@ public void poFile() throws Exception { assertNull(gitBlameWithUsage.getGitBlame()); } - GitBlame gitBlame = new GitBlame(); + GitBlameGitBlameWithUsage gitBlame = new GitBlameGitBlameWithUsage(); gitBlame.setCommitName("1a86b8a2003f4d20858bfb53770119f039520f79"); gitBlame.setCommitTime("1537572147"); gitBlame.setAuthorName("Liz Magalindan"); @@ -213,19 +213,20 @@ public void getTextUnitName() { new String[] { "Test 0\n", " Test 1" }; - GitBlameWithUsage gitBlameWithUsage = new GitBlameWithUsage(); + GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage = new GitBlameWithUsageGitBlameWithUsage(); gitBlameWithUsage.setTextUnitName("test_0"); - GitBlameWithUsage gitBlameWithUsage1 = new GitBlameWithUsage(); + GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage1 = + new GitBlameWithUsageGitBlameWithUsage(); gitBlameWithUsage1.setTextUnitName("test_1"); - List textUnitWithUsages = new ArrayList<>(); + List textUnitWithUsages = new ArrayList<>(); textUnitWithUsages.add(gitBlameWithUsage); textUnitWithUsages.add(gitBlameWithUsage1); GitBlameCommand gitBlameCommand = new GitBlameCommand(); for (int i = 0; i < lines.length; i++) { - List gitBlameWithUsages = + List gitBlameWithUsages = gitBlameCommand.getGitBlameWithUsagesFromLine( lines[i], textUnitWithUsages, new AndroidStringsFileType()); assertEquals(textUnitWithUsages.get(i), gitBlameWithUsages.get(i)); @@ -236,20 +237,26 @@ public void getTextUnitName() { @Test public void getTextUnitNamePlural() { String line = "\n"; - GitBlameWithUsage gitBlameWithUsage_zero = new GitBlameWithUsage(); + GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage_zero = + new GitBlameWithUsageGitBlameWithUsage(); gitBlameWithUsage_zero.setTextUnitName("plural_tests_zero"); - GitBlameWithUsage gitBlameWithUsage_one = new GitBlameWithUsage(); + GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage_one = + new GitBlameWithUsageGitBlameWithUsage(); gitBlameWithUsage_one.setTextUnitName("plural_tests_one"); - GitBlameWithUsage gitBlameWithUsage_two = new GitBlameWithUsage(); + GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage_two = + new GitBlameWithUsageGitBlameWithUsage(); gitBlameWithUsage_two.setTextUnitName("plural_tests_two"); - GitBlameWithUsage gitBlameWithUsage_few = new GitBlameWithUsage(); + GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage_few = + new GitBlameWithUsageGitBlameWithUsage(); gitBlameWithUsage_few.setTextUnitName("plural_tests_few"); - GitBlameWithUsage gitBlameWithUsage_many = new GitBlameWithUsage(); + GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage_many = + new GitBlameWithUsageGitBlameWithUsage(); gitBlameWithUsage_many.setTextUnitName("plural_tests_many"); - GitBlameWithUsage gitBlameWithUsage_other = new GitBlameWithUsage(); + GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage_other = + new GitBlameWithUsageGitBlameWithUsage(); gitBlameWithUsage_other.setTextUnitName("plural_tests_other"); - List gitBlameWithUsagesExpected = new ArrayList<>(); + List gitBlameWithUsagesExpected = new ArrayList<>(); gitBlameWithUsagesExpected.add(gitBlameWithUsage_zero); gitBlameWithUsagesExpected.add(gitBlameWithUsage_one); gitBlameWithUsagesExpected.add(gitBlameWithUsage_two); @@ -258,7 +265,7 @@ public void getTextUnitNamePlural() { gitBlameWithUsagesExpected.add(gitBlameWithUsage_other); GitBlameCommand gitBlameCommand = new GitBlameCommand(); - List gitBlameWithUsagesActual = + List gitBlameWithUsagesActual = gitBlameCommand.getGitBlameWithUsagesFromLine( line, gitBlameWithUsagesExpected, new AndroidStringsFileType()); @@ -352,7 +359,7 @@ public void updateGitBlameOutOfBousnd() gitBlameCommand.commandDirectories = new CommandDirectories(getBaseDir().getAbsolutePath()); gitBlameCommand.initGitRepository(); BlameResult blameResult = gitBlameCommand.getBlameResultForFileCached("pom.xml"); - GitBlameWithUsage gitBlameWithUsage = new GitBlameWithUsage(); + GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage = new GitBlameWithUsageGitBlameWithUsage(); gitBlameCommand.updateBlameResultsInGitBlameWithUsage(100000, blameResult, gitBlameWithUsage); assertNull(gitBlameWithUsage.getGitBlame().getAuthorName()); } @@ -364,7 +371,7 @@ public void updateGitBlameOMissingFile() gitBlameCommand.commandDirectories = new CommandDirectories(getBaseDir().getAbsolutePath()); gitBlameCommand.initGitRepository(); BlameResult blameResult = gitBlameCommand.getBlameResultForFileCached("somemissginfile"); - GitBlameWithUsage gitBlameWithUsage = new GitBlameWithUsage(); + GitBlameWithUsageGitBlameWithUsage gitBlameWithUsage = new GitBlameWithUsageGitBlameWithUsage(); gitBlameCommand.updateBlameResultsInGitBlameWithUsage(10, blameResult, gitBlameWithUsage); assertNull(gitBlameWithUsage.getGitBlame().getAuthorName()); } @@ -384,13 +391,13 @@ public void getSourceCommitsAccessOutOfBound() throws CommandException, NoSuchFi public void getGitBlameWithUsagesToProcess() { GitBlameCommand gitBlameCommand = new GitBlameCommand(); - ArrayList gitBlameWithUsages = new ArrayList<>(); - GitBlameWithUsage toSkip = new GitBlameWithUsage(); - toSkip.setGitBlame(new GitBlame()); + ArrayList gitBlameWithUsages = new ArrayList<>(); + GitBlameWithUsageGitBlameWithUsage toSkip = new GitBlameWithUsageGitBlameWithUsage(); + toSkip.setGitBlame(new GitBlameGitBlameWithUsage()); gitBlameWithUsages.add(toSkip); - gitBlameWithUsages.add(new GitBlameWithUsage()); + gitBlameWithUsages.add(new GitBlameWithUsageGitBlameWithUsage()); - List gitBlameWithUsagesToProcess = + List gitBlameWithUsagesToProcess = gitBlameCommand.getGitBlameWithUsagesToProcess(gitBlameWithUsages); assertEquals(1, gitBlameWithUsagesToProcess.size()); @@ -399,7 +406,7 @@ public void getGitBlameWithUsagesToProcess() { void verifyGitBlame( List gitBlameWithUsages, - GitBlame gitBlame) { + GitBlameGitBlameWithUsage gitBlame) { assertFalse(gitBlameWithUsages.isEmpty()); gitBlameWithUsages.stream() @@ -421,7 +428,8 @@ void verifyGitBlame( } } - L10nJCommander getL10nJCommanderWithSpiedIfShallow(GitBlame gitBlame) throws Exception { + L10nJCommander getL10nJCommanderWithSpiedIfShallow(GitBlameGitBlameWithUsage gitBlame) + throws Exception { L10nJCommander l10nJCommander = getL10nJCommander(); if (shallowClone) { diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/LeveragingCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/LeveragingCommandTest.java index 9619622667..5bed6f002d 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/LeveragingCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/LeveragingCommandTest.java @@ -3,14 +3,15 @@ import static org.junit.Assert.assertEquals; import com.box.l10n.mojito.cli.CLITestBase; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; +import com.box.l10n.mojito.cli.model.AssetAssetSummary; import com.box.l10n.mojito.entity.Locale; import com.box.l10n.mojito.entity.Repository; import com.box.l10n.mojito.entity.TMTextUnitVariant; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.entity.Asset; import com.box.l10n.mojito.service.repository.RepositoryService; import com.box.l10n.mojito.service.tm.TMImportService; import com.box.l10n.mojito.service.tm.TMTextUnitVariantRepository; +import jakarta.annotation.PostConstruct; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -33,12 +34,17 @@ public class LeveragingCommandTest extends CLITestBase { @Autowired TMImportService tmImport; - @Autowired AssetClient assetClient; + AssetWsApiProxy assetClient; @Autowired RepositoryService repositoryService; @Autowired TMTextUnitVariantRepository tmTextUnitVariantRepository; + @PostConstruct + public void init() { + this.assetClient = new AssetWsApiProxy(this.apiClient); + } + @Test public void copyTMModeMD5() throws Exception { @@ -66,7 +72,7 @@ public void copyTMModeMD5() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", sourceRepository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -136,7 +142,7 @@ public void copyTMModeExact() throws Exception { "-s", getInputResourcesTestDir("source2").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", sourceRepository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -234,7 +240,7 @@ public void copyTMModeTUIDs() throws Exception { Long sourceTmTextUnitId1 = initialSource.get(0).getTmTextUnit().getId(); Long sourceTmTextUnitId2 = initialSource.get(3).getTmTextUnit().getId(); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", sourceRepository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -336,7 +342,7 @@ public void copyTMModeTargetBranchName() throws Exception { "-s", getInputResourcesTestDir("source2b").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", sourceRepository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/PerformanceSanboxTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/PerformanceSanboxTest.java index ebddcf5bbd..7eca5ea93f 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/PerformanceSanboxTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/PerformanceSanboxTest.java @@ -3,8 +3,6 @@ import com.box.l10n.mojito.cli.CLITestBase; import com.box.l10n.mojito.entity.Repository; import com.box.l10n.mojito.io.Files; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.RepositoryClient; import com.box.l10n.mojito.service.repository.RepositoryRepository; import com.box.l10n.mojito.service.tm.TMTextUnitVariantRepository; import com.google.common.base.Strings; @@ -30,12 +28,8 @@ public class PerformanceSanboxTest extends CLITestBase { static int NUMBER_OF_TEXTUNITS = 10000; - @Autowired RepositoryClient repositoryClient; - @Autowired RepositoryRepository repositoryRepository; - @Autowired AssetClient assetClient; - @Autowired TMTextUnitVariantRepository tmTextUnitVariantRepository; @Value("${test.l10n.cli.performance:false}") diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/PseudoLocCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/PseudoLocCommandTest.java index 76d808b203..ab5769adf7 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/PseudoLocCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/PseudoLocCommandTest.java @@ -2,11 +2,9 @@ import com.box.l10n.mojito.cli.CLITestBase; import com.box.l10n.mojito.entity.Repository; -import com.box.l10n.mojito.rest.client.RepositoryClient; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; /** */ public class PseudoLocCommandTest extends CLITestBase { @@ -14,8 +12,6 @@ public class PseudoLocCommandTest extends CLITestBase { /** logger */ static Logger logger = LoggerFactory.getLogger(PseudoLocCommandTest.class); - @Autowired RepositoryClient repositoryClient; - @Test public void pseudo() throws Exception { diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/PullCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/PullCommandTest.java index f66d48be26..018ff0a180 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/PullCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/PullCommandTest.java @@ -4,16 +4,18 @@ import static org.junit.Assert.assertNotNull; import com.box.l10n.mojito.cli.CLITestBase; +import com.box.l10n.mojito.cli.apiclient.ApiException; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; +import com.box.l10n.mojito.cli.model.AssetAssetSummary; +import com.box.l10n.mojito.cli.model.RepositoryRepository; +import com.box.l10n.mojito.cli.model.RepositoryStatisticRepository; import com.box.l10n.mojito.entity.Locale; import com.box.l10n.mojito.entity.PullRun; import com.box.l10n.mojito.entity.PushRun; import com.box.l10n.mojito.entity.Repository; import com.box.l10n.mojito.entity.TMTextUnit; import com.box.l10n.mojito.entity.TMTextUnitVariant; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.entity.Asset; -import com.box.l10n.mojito.rest.entity.RepositoryStatistic; import com.box.l10n.mojito.service.commit.CommitService; import com.box.l10n.mojito.service.delta.DeltaService; import com.box.l10n.mojito.service.delta.DeltaType; @@ -27,6 +29,7 @@ import com.box.l10n.mojito.service.tm.TMTextUnitRepository; import com.box.l10n.mojito.service.tm.TMTextUnitVariantRepository; import com.google.common.collect.ImmutableList; +import jakarta.annotation.PostConstruct; import java.io.IOException; import java.time.ZonedDateTime; import java.util.List; @@ -46,9 +49,9 @@ public class PullCommandTest extends CLITestBase { /** logger */ static Logger logger = LoggerFactory.getLogger(PullCommandTest.class); - @Autowired RepositoryClient repositoryClient; + RepositoryWsApiProxy repositoryClient; - @Autowired AssetClient assetClient; + AssetWsApiProxy assetClient; @Autowired TMTextUnitVariantRepository tmTextUnitVariantRepository; @@ -70,6 +73,12 @@ public class PullCommandTest extends CLITestBase { @Autowired PullRunTextUnitVariantRepository pullRunTextUnitVariantRepository; + @PostConstruct + public void init() { + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + this.assetClient = new AssetWsApiProxy(this.apiClient); + } + @Test public void pull() throws Exception { @@ -83,12 +92,12 @@ public void pull() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); - Asset asset2 = + AssetAssetSummary asset2 = assetClient.getAssetByPathAndRepositoryId("source2-xliff.xliff", repository.getId()); importTranslations(asset2.getId(), "source2-xliff_", "fr-FR"); importTranslations(asset2.getId(), "source2-xliff_", "ja-JP"); @@ -129,12 +138,12 @@ public void pullWithAsyncWS() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); - Asset asset2 = + AssetAssetSummary asset2 = assetClient.getAssetByPathAndRepositoryId("source2-xliff.xliff", repository.getId()); importTranslations(asset2.getId(), "source2-xliff_", "fr-FR"); importTranslations(asset2.getId(), "source2-xliff_", "ja-JP"); @@ -177,12 +186,12 @@ public void pullWithParallelWS() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); - Asset asset2 = + AssetAssetSummary asset2 = assetClient.getAssetByPathAndRepositoryId("source2-xliff.xliff", repository.getId()); importTranslations(asset2.getId(), "source2-xliff_", "fr-FR"); importTranslations(asset2.getId(), "source2-xliff_", "ja-JP"); @@ -227,7 +236,8 @@ public void pullWithDuplicatedTextUnits() throws Exception { "-ft", "PROPERTIES_NOBASENAME"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("en.properties", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("en.properties", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -261,7 +271,8 @@ public void pullPropertiesNoBasename() throws Exception { "-ft", "PROPERTIES_NOBASENAME"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("en.properties", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("en.properties", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -305,7 +316,8 @@ public void pullProperties() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = assetClient.getAssetByPathAndRepositoryId("demo.properties", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("demo.properties", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -347,7 +359,8 @@ public void pullPropertiesJava() throws Exception { "-ft", "PROPERTIES_JAVA"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("demo.properties", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("demo.properties", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -395,7 +408,8 @@ public void pullPropertiesNoBasenameEnUs() throws Exception { "-sl", "en-US"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("en-US.properties", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("en-US.properties", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -445,7 +459,8 @@ public void leveraging() throws Exception { "-ft", "PROPERTIES_NOBASENAME"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("en.properties", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("en.properties", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -501,7 +516,7 @@ public void localeMapping() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -534,7 +549,7 @@ public void localeMappingParallel() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -567,7 +582,7 @@ public void assetMapping() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -599,7 +614,7 @@ public void assetMappingParallel() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -633,7 +648,7 @@ public void pullAndroidStrings() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("res/values/strings.xml", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -674,7 +689,7 @@ public void pullMacStrings() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId( "en.lproj/Localizable.strings", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); @@ -716,7 +731,7 @@ public void pullMacStringsdict() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId( "en.lproj/Localizable.stringsdict", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); @@ -758,7 +773,7 @@ public void pullResw() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("en/Resources.resw", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -803,7 +818,8 @@ public void pullResx() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = assetClient.getAssetByPathAndRepositoryId("Test.resx", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("Test.resx", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -845,7 +861,7 @@ public void pullResxSourceRegex() throws Exception { "-sr", "Localization\\.resx|Test\\.resx"); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("Localization.resx", repository.getId()); importTranslations(asset.getId(), "source-xliff_Localization_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_Localization_", "ja-JP"); @@ -898,7 +914,7 @@ public void pullDirectoryIncludeExcludePatterns() throws Exception { "--dir-path-exclude-patterns", "b/resources"); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId( "a/resources/demo.properties", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); @@ -950,7 +966,7 @@ public void testLatestTMTextUnitVariant() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset1 = + AssetAssetSummary asset1 = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository1.getId()); importTranslations(asset1.getId(), "source-xliff_", "fr-FR"); @@ -962,7 +978,7 @@ public void testLatestTMTextUnitVariant() throws Exception { "should have TMTextUnitVariant from imports above", latestTmTextUnitVariantOfRepository1); logger.debug("Test findLatestTMTextUnitVariant again after a translation is added to other TM"); - Asset asset2 = + AssetAssetSummary asset2 = assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository2.getId()); importTranslations(asset2.getId(), "source-xliff_", "fr-FR"); TMTextUnitVariant tmTextUnitVariant = @@ -989,7 +1005,8 @@ public void pullXcodeXliff() throws Exception { "-ft", "XCODE_XLIFF"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("en.xliff", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("en.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1037,7 +1054,7 @@ public void pullPo() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("LC_MESSAGES/messages.pot", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1086,7 +1103,8 @@ public void pullHtml() throws Exception { "-fo", "processImageUrls=true"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("demo.html", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("demo.html", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1138,7 +1156,7 @@ public void removeUntranslated() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("LC_MESSAGES/messages.pot", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1187,7 +1205,8 @@ public void onlyApproved() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = assetClient.getAssetByPathAndRepositoryId("test.xliff", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("test.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1246,7 +1265,7 @@ public void pullXtb() throws Exception { "-sl", "en-US"); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("Resources-en-US.xtb", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1290,7 +1309,8 @@ public void pullCsv() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = assetClient.getAssetByPathAndRepositoryId("demo.csv", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("demo.csv", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1334,7 +1354,8 @@ public void pullCsvAdobeMagento() throws Exception { "-sl", "en_US"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("i18n/en_US.csv", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("i18n/en_US.csv", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1382,7 +1403,8 @@ public void pullJS() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = assetClient.getAssetByPathAndRepositoryId("en.js", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("en.js", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1426,7 +1448,8 @@ public void pullTS() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = assetClient.getAssetByPathAndRepositoryId("en.ts", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("en.ts", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1473,7 +1496,8 @@ public void pullJson() throws Exception { "-ft", "JSON"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("demo.json", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("demo.json", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1519,7 +1543,8 @@ public void pullJsonNobasename() throws Exception { "-ft", "JSON_NOBASENAME"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("en.json", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("en.json", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1569,7 +1594,8 @@ public void pullJsonWithNote() throws Exception { "-ft", "JSON"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("demo.json", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("demo.json", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1627,7 +1653,8 @@ public void pullJsonDefaultFormatJs() throws Exception { "-ft", "JSON_NOBASENAME"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("en.json", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("en.json", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1684,7 +1711,8 @@ public void pullJsonDefaultFormatJsRemoveUntranslated() throws Exception { "-ft", "JSON_NOBASENAME"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("en.json", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("en.json", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1724,7 +1752,7 @@ public void pullJsonFromChromeExtension() throws Exception { "-ft", "CHROME_EXT_JSON"); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("_locales/en/messages.json", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1771,7 +1799,7 @@ public void pullJsonI18NextParser() throws Exception { "-ft", "I18NEXT_PARSER_JSON"); - Asset asset = + AssetAssetSummary asset = assetClient.getAssetByPathAndRepositoryId("locales/en/demo.json", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1817,7 +1845,8 @@ public void pullFullyTranslated() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = assetClient.getAssetByPathAndRepositoryId("demo.properties", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("demo.properties", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1834,9 +1863,13 @@ public void pullFullyTranslated() throws Exception { waitForCondition( "repo stats must be updated - wait for jp to be fully translated and others to be untranslated", () -> { - com.box.l10n.mojito.rest.entity.Repository repo = - repositoryClient.getRepositoryById(repository.getId()); - RepositoryStatistic repositoryStatistic = repo.getRepositoryStatistic(); + RepositoryRepository repo; + try { + repo = repositoryClient.getRepositoryById(repository.getId()); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } + RepositoryStatisticRepository repositoryStatistic = repo.getRepositoryStatistic(); boolean statsReady = repositoryStatistic.getRepositoryLocaleStatistics().stream() @@ -1880,7 +1913,8 @@ public void pullFullyTranslatedParallel() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = assetClient.getAssetByPathAndRepositoryId("demo.properties", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("demo.properties", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -1898,9 +1932,13 @@ public void pullFullyTranslatedParallel() throws Exception { waitForCondition( "repo stats must be updated - wait for jp to be fully translated and others to be untranslated", () -> { - com.box.l10n.mojito.rest.entity.Repository repo = - repositoryClient.getRepositoryById(repository.getId()); - RepositoryStatistic repositoryStatistic = repo.getRepositoryStatistic(); + RepositoryRepository repo; + try { + repo = repositoryClient.getRepositoryById(repository.getId()); + } catch (ApiException e) { + throw new CommandException(e.getMessage(), e); + } + RepositoryStatisticRepository repositoryStatistic = repo.getRepositoryStatistic(); boolean statsReady = repositoryStatistic.getRepositoryLocaleStatistics().stream() @@ -2182,7 +2220,8 @@ public void recordPullRunAndOTA() throws Exception { Assertions.assertThat(deltaForBaseline.getTranslationsPerLocale()).isEmpty(); logger.debug("Import French translations to test delta generation"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("demo.properties", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("demo.properties", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); logger.debug( @@ -2466,7 +2505,8 @@ public void pullYaml() throws Exception { "-s", getInputResourcesTestDir("source").getAbsolutePath()); - Asset asset = assetClient.getAssetByPathAndRepositoryId("demo.yaml", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("demo.yaml", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); @@ -2513,7 +2553,8 @@ public void pullYamlWithFilterOptions() throws Exception { "extractAllPairs=false", "exceptions=1_day_duration|1_year_duration"); - Asset asset = assetClient.getAssetByPathAndRepositoryId("demo.yaml", repository.getId()); + AssetAssetSummary asset = + assetClient.getAssetByPathAndRepositoryId("demo.yaml", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/PushCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/PushCommandTest.java index 7edd43cb4e..975e289c75 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/PushCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/PushCommandTest.java @@ -3,7 +3,9 @@ import static org.junit.Assert.*; import com.box.l10n.mojito.cli.CLITestBase; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; import com.box.l10n.mojito.cli.command.param.Param; +import com.box.l10n.mojito.cli.model.AssetAssetSummary; import com.box.l10n.mojito.entity.Commit; import com.box.l10n.mojito.entity.Locale; import com.box.l10n.mojito.entity.PushRun; @@ -11,9 +13,6 @@ import com.box.l10n.mojito.entity.PushRunAssetTmTextUnit; import com.box.l10n.mojito.entity.Repository; import com.box.l10n.mojito.entity.TMTextUnit; -import com.box.l10n.mojito.rest.client.AssetClient; -import com.box.l10n.mojito.rest.client.CommitClient; -import com.box.l10n.mojito.rest.entity.Asset; import com.box.l10n.mojito.service.commit.CommitRepository; import com.box.l10n.mojito.service.commit.CommitService; import com.box.l10n.mojito.service.locale.LocaleService; @@ -23,6 +22,7 @@ import com.box.l10n.mojito.service.tm.search.TextUnitSearcher; import com.box.l10n.mojito.service.tm.search.TextUnitSearcherParameters; import com.box.l10n.mojito.service.tm.search.UsedFilter; +import jakarta.annotation.PostConstruct; import java.io.File; import java.time.ZonedDateTime; import java.util.Arrays; @@ -46,9 +46,7 @@ public class PushCommandTest extends CLITestBase { /** logger */ static Logger logger = LoggerFactory.getLogger(PushCommandTest.class); - @Autowired AssetClient assetClient; - - @Autowired CommitClient commitClient; + AssetWsApiProxy assetClient; @Autowired TextUnitSearcher textUnitSearcher; @@ -60,6 +58,11 @@ public class PushCommandTest extends CLITestBase { @Autowired PushRunRepository pushRunRepository; + @PostConstruct + public void init() { + this.assetClient = new AssetWsApiProxy(this.apiClient); + } + @Test public void testCommandName() throws Exception { @@ -78,7 +81,7 @@ public void testCommandName() throws Exception { String sourcePath = matcher.group(1); logger.debug("Source path is [{}]", sourcePath); - Asset assetByPathAndRepositoryId = + AssetAssetSummary assetByPathAndRepositoryId = assetClient.getAssetByPathAndRepositoryId(sourcePath, repository.getId()); assertEquals(sourcePath, assetByPathAndRepositoryId.getPath()); } @@ -485,7 +488,7 @@ public void testPushRunRecording() throws Exception { } @Transactional - private List getTextUnits(Long commitId) { + protected List getTextUnits(Long commitId) { PushRun pushRun = commitRepository .findById(commitId) diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/RepositoryStatusChecker.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/RepositoryStatusChecker.java index ac3d627428..b14b2c1846 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/RepositoryStatusChecker.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/RepositoryStatusChecker.java @@ -1,12 +1,12 @@ package com.box.l10n.mojito.cli.command; -import com.box.l10n.mojito.rest.entity.Repository; +import com.box.l10n.mojito.cli.model.RepositoryRepository; /** * @author garion */ public class RepositoryStatusChecker { - public boolean hasStringsForTranslationsForExportableLocales(Repository repository) { + public boolean hasStringsForTranslationsForExportableLocales(RepositoryRepository repository) { DropExportCommand dropExportCommand = new DropExportCommand(); return dropExportCommand.shouldCreateDrop(repository); } diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/ScreenshotCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/ScreenshotCommandTest.java index f42f63c298..2e46afce89 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/ScreenshotCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/ScreenshotCommandTest.java @@ -4,9 +4,12 @@ import com.box.l10n.mojito.LocaleMappingHelper; import com.box.l10n.mojito.cli.CLITestBase; +import com.box.l10n.mojito.cli.apiclient.ApiClient; +import com.box.l10n.mojito.cli.apiclient.RepositoryWsApiProxy; +import com.box.l10n.mojito.cli.model.Locale; +import com.box.l10n.mojito.cli.model.RepositoryRepository; import com.box.l10n.mojito.entity.Repository; -import com.box.l10n.mojito.rest.client.RepositoryClient; -import com.box.l10n.mojito.rest.entity.Locale; +import jakarta.annotation.PostConstruct; import java.nio.file.Path; import java.nio.file.Paths; import org.junit.Test; @@ -19,12 +22,19 @@ public class ScreenshotCommandTest extends CLITestBase { /** logger */ static Logger logger = LoggerFactory.getLogger(ScreenshotCommandTest.class); - @Autowired RepositoryClient repositoryClient; + RepositoryWsApiProxy repositoryClient; @Autowired CommandHelper commandHelper; @Autowired LocaleMappingHelper localeMappingHelper; + @Autowired ApiClient apiClient; + + @PostConstruct + public void init() { + this.repositoryClient = new RepositoryWsApiProxy(this.apiClient); + } + @Test public void execute() throws Exception { String repoName = testIdWatcher.getEntityName("screenshot_execute"); @@ -92,7 +102,7 @@ public void testGetFirstElementInPathNoDir() throws CommandException { @Test public void testGetLocaleFromImagePathNoMapping() throws Exception { Repository repository = createTestRepoUsingRepoService(); - com.box.l10n.mojito.rest.entity.Repository repositoryByName = + RepositoryRepository repositoryByName = repositoryClient.getRepositoryByName(repository.getName()); ScreenshotCommand screenshotCommand = new ScreenshotCommand(); screenshotCommand.repositoryLocales = @@ -106,7 +116,7 @@ public void testGetLocaleFromImagePathNoMapping() throws Exception { @Test(expected = ScreenshotCommand.InvalidLocaleException.class) public void testGetLocaleFromImagePathNoMappingUnsupportedLocale() throws Exception { Repository repository = createTestRepoUsingRepoService(); - com.box.l10n.mojito.rest.entity.Repository repositoryByName = + RepositoryRepository repositoryByName = repositoryClient.getRepositoryByName(repository.getName()); ScreenshotCommand screenshotCommand = new ScreenshotCommand(); screenshotCommand.repositoryLocales = @@ -120,7 +130,7 @@ public void testGetLocaleFromImagePathNoMappingUnsupportedLocale() throws Except @Test public void testGetLocaleFromImagePathMappedLocale() throws Exception { Repository repository = createTestRepoUsingRepoService(); - com.box.l10n.mojito.rest.entity.Repository repositoryByName = + RepositoryRepository repositoryByName = repositoryClient.getRepositoryByName(repository.getName()); ScreenshotCommand screenshotCommand = new ScreenshotCommand(); screenshotCommand.localeMappings = localeMappingHelper.getLocaleMapping("fr:fr-FR"); diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/TMExportCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/TMExportCommandTest.java index 9abe48285d..cc2e65957d 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/TMExportCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/TMExportCommandTest.java @@ -1,19 +1,24 @@ package com.box.l10n.mojito.cli.command; import com.box.l10n.mojito.cli.CLITestBase; -import com.box.l10n.mojito.cli.apiclient.AssetWsApiHelper; +import com.box.l10n.mojito.cli.apiclient.AssetWsApiProxy; import com.box.l10n.mojito.cli.model.AssetAssetSummary; import com.box.l10n.mojito.entity.Repository; import com.box.l10n.mojito.test.XliffUtils; +import jakarta.annotation.PostConstruct; import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; /** * @author jaurambault */ public class TMExportCommandTest extends CLITestBase { - @Autowired AssetWsApiHelper assetWsApiHelper; + AssetWsApiProxy assetClient; + + @PostConstruct + public void init() { + this.assetClient = new AssetWsApiProxy(this.apiClient); + } @Test public void export() throws Exception { @@ -29,14 +34,12 @@ public void export() throws Exception { getInputResourcesTestDir("source").getAbsolutePath()); AssetAssetSummary asset = - this.assetWsApiHelper.getAssetByPathAndRepositoryId( - "source-xliff.xliff", repository.getId()); + this.assetClient.getAssetByPathAndRepositoryId("source-xliff.xliff", repository.getId()); importTranslations(asset.getId(), "source-xliff_", "fr-FR"); importTranslations(asset.getId(), "source-xliff_", "ja-JP"); AssetAssetSummary asset2 = - this.assetWsApiHelper.getAssetByPathAndRepositoryId( - "source2-xliff.xliff", repository.getId()); + this.assetClient.getAssetByPathAndRepositoryId("source2-xliff.xliff", repository.getId()); importTranslations(asset2.getId(), "source2-xliff_", "fr-FR"); importTranslations(asset2.getId(), "source2-xliff_", "ja-JP"); diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/TMImportCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/TMImportCommandTest.java index 8839419e5b..47838490ea 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/TMImportCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/TMImportCommandTest.java @@ -14,7 +14,6 @@ import com.box.l10n.mojito.entity.TMTextUnit; import com.box.l10n.mojito.entity.TMTextUnitVariant; import com.box.l10n.mojito.entity.TMTextUnitVariantComment; -import com.box.l10n.mojito.rest.client.AssetClient; import com.box.l10n.mojito.service.asset.AssetService; import com.box.l10n.mojito.service.locale.LocaleService; import com.box.l10n.mojito.service.tm.TMService; @@ -42,8 +41,6 @@ public class TMImportCommandTest extends CLITestBase { /** logger */ static Logger logger = getLogger(TMImportCommandTest.class); - @Autowired AssetClient assetClient; - @Autowired TMService tmService; @Autowired TMTextUnitVariantRepository tmTextUnitVariantRepository; diff --git a/webapp/src/main/java/com/box/l10n/mojito/CustomModelResolver.java b/webapp/src/main/java/com/box/l10n/mojito/CustomModelResolver.java index f30119ff81..f248077daf 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/CustomModelResolver.java +++ b/webapp/src/main/java/com/box/l10n/mojito/CustomModelResolver.java @@ -15,6 +15,7 @@ import java.lang.annotation.Annotation; import java.time.ZonedDateTime; import java.util.Arrays; +import java.util.Date; import java.util.Iterator; import java.util.Map; import org.springdoc.core.converters.models.SortObject; @@ -43,7 +44,8 @@ private boolean hasAnnotation(AnnotatedType annotatedType, Class annotationCl public Schema resolve( AnnotatedType annotatedType, ModelConverterContext context, Iterator next) { if (annotatedType.getType() instanceof SimpleType - && ((SimpleType) annotatedType.getType()).getRawClass().equals(ZonedDateTime.class)) { + && (((SimpleType) annotatedType.getType()).getRawClass().equals(ZonedDateTime.class) + || ((SimpleType) annotatedType.getType()).getRawClass().equals(Date.class))) { return new IntegerSchema().format("int64").example(1715699917000L); } if (annotatedType.getType().equals(SortObject.class)) { diff --git a/webapp/src/main/java/com/box/l10n/mojito/entity/ScreenshotRun.java b/webapp/src/main/java/com/box/l10n/mojito/entity/ScreenshotRun.java index f00fe7d257..a7517587fe 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/entity/ScreenshotRun.java +++ b/webapp/src/main/java/com/box/l10n/mojito/entity/ScreenshotRun.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; @@ -38,6 +39,7 @@ public class ScreenshotRun extends SettableAuditableEntity { foreignKey = @ForeignKey(name = "FK__SCREENSHOT_RUN__REPOSITORY__ID"), nullable = false) @JsonBackReference + @Schema(accessMode = Schema.AccessMode.WRITE_ONLY) private Repository repository; @Column(name = "name") diff --git a/webapp/src/main/resources/config/application.properties b/webapp/src/main/resources/config/application.properties index ad6b879f73..90df9dc432 100644 --- a/webapp/src/main/resources/config/application.properties +++ b/webapp/src/main/resources/config/application.properties @@ -291,7 +291,4 @@ server.servlet.session.cookie.name=JSESSIONID l10n.ai.enabled=true l10n.ai.openai.host=http://127.0.0.1:19193/ -l10n.ai.openai.customHeaders.host=openai.example.com -l10n.ai.openai.customHeaders.X-Pinterest-Forwarded-Project=mojito -l10n.ai.openai.allowRestrictedHeaders=host l10n.ai.service.type=OpenAI \ No newline at end of file diff --git a/webapp/src/main/resources/openapi.yml b/webapp/src/main/resources/openapi.yml deleted file mode 100644 index 1d8974ffa3..0000000000 --- a/webapp/src/main/resources/openapi.yml +++ /dev/null @@ -1,6745 +0,0 @@ -openapi: 3.0.1 -info: - title: Mojito API - description: Mojito API Documentation - version: 0.111-SNAPSHOT -servers: - - url: http://localhost:8080 - description: Generated server url -paths: - /branchSources: - get: - tags: - - branch-source-entity-controller - description: get-branchsource - operationId: getCollectionResource-branchsource-get_1 - parameters: - - name: page - in: query - description: Zero-based page index (0..N) - required: false - schema: - minimum: 0 - type: integer - default: 0 - - name: size - in: query - description: The size of the page to be returned - required: false - schema: - minimum: 1 - type: integer - default: 20 - - name: sort - in: query - description: 'Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.' - required: false - schema: - type: array - items: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/PagedModelEntityModelBranchSource' - text/uri-list: - schema: - type: string - application/x-spring-data-compact+json: - schema: - $ref: '#/components/schemas/PagedModelEntityModelBranchSource' - post: - tags: - - branch-source-entity-controller - description: create-branchsource - operationId: postCollectionResource-branchsource-post - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/BranchSourceRequestBody' - required: true - responses: - '201': - description: Created - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelBranchSource' - /branchSources/search/findByTextUnitId: - get: - tags: - - branch-source-search-controller - operationId: executeSearch-branchsource-get - parameters: - - name: textUnitId - in: query - schema: - type: integer - format: int64 - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelBranchSource' - '404': - description: Not Found - /branchSources/{id}: - get: - tags: - - branch-source-entity-controller - description: get-branchsource - operationId: getItemResource-branchsource-get - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelBranchSource' - '404': - description: Not Found - put: - tags: - - branch-source-entity-controller - description: update-branchsource - operationId: putItemResource-branchsource-put - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/BranchSourceRequestBody' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelBranchSource' - '201': - description: Created - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelBranchSource' - '204': - description: No Content - delete: - tags: - - branch-source-entity-controller - description: delete-branchsource - operationId: deleteItemResource-branchsource-delete - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '204': - description: No Content - '404': - description: Not Found - patch: - tags: - - branch-source-entity-controller - description: patch-branchsource - operationId: patchItemResource-branchsource-patch - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/BranchSourceRequestBody' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelBranchSource' - '204': - description: No Content - /profile: - get: - tags: - - profile-controller - operationId: listAllFormsOfMetadata_1 - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/RepresentationModelObject' - /profile/branchSources: - get: - tags: - - profile-controller - operationId: descriptor_1_1_1 - responses: - '200': - description: OK - content: - '*/*': - schema: - type: string - application/alps+json: - schema: - type: string - application/schema+json: - schema: - $ref: '#/components/schemas/JsonSchema' - /profile/scheduledJobStatuses: - get: - tags: - - profile-controller - operationId: descriptor_1_1_2 - responses: - '200': - description: OK - content: - '*/*': - schema: - type: string - application/alps+json: - schema: - type: string - application/schema+json: - schema: - $ref: '#/components/schemas/JsonSchema' - /profile/scheduledJobTypes: - get: - tags: - - profile-controller - operationId: descriptor_1_1_3 - responses: - '200': - description: OK - content: - '*/*': - schema: - type: string - application/alps+json: - schema: - type: string - application/schema+json: - schema: - $ref: '#/components/schemas/JsonSchema' - /profile/scheduledJobs: - get: - tags: - - profile-controller - operationId: descriptor_1_1_4 - responses: - '200': - description: OK - content: - '*/*': - schema: - type: string - application/alps+json: - schema: - type: string - application/schema+json: - schema: - $ref: '#/components/schemas/JsonSchema' - /profile/tMTextUnitToBranches: - get: - tags: - - profile-controller - operationId: descriptor_1_1_5 - responses: - '200': - description: OK - content: - '*/*': - schema: - type: string - application/alps+json: - schema: - type: string - application/schema+json: - schema: - $ref: '#/components/schemas/JsonSchema' - /scheduledJobStatuses: - get: - tags: - - scheduled-job-status-entity-controller - description: get-scheduledjobstatus - operationId: getCollectionResource-scheduledjobstatus-get_1 - parameters: - - name: page - in: query - description: Zero-based page index (0..N) - required: false - schema: - minimum: 0 - type: integer - default: 0 - - name: size - in: query - description: The size of the page to be returned - required: false - schema: - minimum: 1 - type: integer - default: 20 - - name: sort - in: query - description: 'Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.' - required: false - schema: - type: array - items: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/PagedModelEntityModelScheduledJobStatus' - text/uri-list: - schema: - type: string - application/x-spring-data-compact+json: - schema: - $ref: '#/components/schemas/PagedModelEntityModelScheduledJobStatus' - post: - tags: - - scheduled-job-status-entity-controller - description: create-scheduledjobstatus - operationId: postCollectionResource-scheduledjobstatus-post - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ScheduledJobStatusRequestBody' - required: true - responses: - '201': - description: Created - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobStatus' - /scheduledJobStatuses/search/findByEnum: - get: - tags: - - scheduled-job-status-search-controller - operationId: executeSearch-scheduledjobstatus-get - parameters: - - name: jobStatus - in: query - schema: - type: string - enum: - - SCHEDULED - - IN_PROGRESS - - FAILED - - SUCCEEDED - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobStatus' - '404': - description: Not Found - /scheduledJobStatuses/{id}: - get: - tags: - - scheduled-job-status-entity-controller - description: get-scheduledjobstatus - operationId: getItemResource-scheduledjobstatus-get - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobStatus' - '404': - description: Not Found - put: - tags: - - scheduled-job-status-entity-controller - description: update-scheduledjobstatus - operationId: putItemResource-scheduledjobstatus-put - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ScheduledJobStatusRequestBody' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobStatus' - '201': - description: Created - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobStatus' - '204': - description: No Content - delete: - tags: - - scheduled-job-status-entity-controller - description: delete-scheduledjobstatus - operationId: deleteItemResource-scheduledjobstatus-delete - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '204': - description: No Content - '404': - description: Not Found - patch: - tags: - - scheduled-job-status-entity-controller - description: patch-scheduledjobstatus - operationId: patchItemResource-scheduledjobstatus-patch - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ScheduledJobStatusRequestBody' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobStatus' - '204': - description: No Content - /scheduledJobTypes: - get: - tags: - - scheduled-job-type-entity-controller - description: get-scheduledjobtype - operationId: getCollectionResource-scheduledjobtype-get_1 - parameters: - - name: page - in: query - description: Zero-based page index (0..N) - required: false - schema: - minimum: 0 - type: integer - default: 0 - - name: size - in: query - description: The size of the page to be returned - required: false - schema: - minimum: 1 - type: integer - default: 20 - - name: sort - in: query - description: 'Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.' - required: false - schema: - type: array - items: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/PagedModelEntityModelScheduledJobType' - text/uri-list: - schema: - type: string - application/x-spring-data-compact+json: - schema: - $ref: '#/components/schemas/PagedModelEntityModelScheduledJobType' - post: - tags: - - scheduled-job-type-entity-controller - description: create-scheduledjobtype - operationId: postCollectionResource-scheduledjobtype-post - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ScheduledJobTypeRequestBody' - required: true - responses: - '201': - description: Created - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobType' - /scheduledJobTypes/search/findByEnum: - get: - tags: - - scheduled-job-type-search-controller - operationId: executeSearch-scheduledjobtype-get - parameters: - - name: jobType - in: query - schema: - type: string - enum: - - THIRD_PARTY_SYNC - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobType' - '404': - description: Not Found - /scheduledJobTypes/{id}: - get: - tags: - - scheduled-job-type-entity-controller - description: get-scheduledjobtype - operationId: getItemResource-scheduledjobtype-get - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobType' - '404': - description: Not Found - put: - tags: - - scheduled-job-type-entity-controller - description: update-scheduledjobtype - operationId: putItemResource-scheduledjobtype-put - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ScheduledJobTypeRequestBody' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobType' - '201': - description: Created - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobType' - '204': - description: No Content - delete: - tags: - - scheduled-job-type-entity-controller - description: delete-scheduledjobtype - operationId: deleteItemResource-scheduledjobtype-delete - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '204': - description: No Content - '404': - description: Not Found - patch: - tags: - - scheduled-job-type-entity-controller - description: patch-scheduledjobtype - operationId: patchItemResource-scheduledjobtype-patch - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ScheduledJobTypeRequestBody' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobType' - '204': - description: No Content - /scheduledJobs: - get: - tags: - - scheduled-job-entity-controller - description: get-scheduledjob - operationId: getCollectionResource-scheduledjob-get_1 - parameters: - - name: page - in: query - description: Zero-based page index (0..N) - required: false - schema: - minimum: 0 - type: integer - default: 0 - - name: size - in: query - description: The size of the page to be returned - required: false - schema: - minimum: 1 - type: integer - default: 20 - - name: sort - in: query - description: 'Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.' - required: false - schema: - type: array - items: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/PagedModelEntityModelScheduledJob' - text/uri-list: - schema: - type: string - application/x-spring-data-compact+json: - schema: - $ref: '#/components/schemas/PagedModelEntityModelScheduledJob' - post: - tags: - - scheduled-job-entity-controller - description: create-scheduledjob - operationId: postCollectionResource-scheduledjob-post - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ScheduledJobRequestBody' - required: true - responses: - '201': - description: Created - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJob' - /scheduledJobs/search/findByIdAndJobType: - get: - tags: - - scheduled-job-search-controller - operationId: executeSearch-scheduledjob-get - parameters: - - name: uuid - in: query - schema: - type: string - - name: jobType - in: query - schema: - type: string - enum: - - THIRD_PARTY_SYNC - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJob' - '404': - description: Not Found - /scheduledJobs/search/findByUuid: - get: - tags: - - scheduled-job-search-controller - operationId: executeSearch-scheduledjob-get_1 - parameters: - - name: uuid - in: query - schema: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJob' - '404': - description: Not Found - /scheduledJobs/{id}: - get: - tags: - - scheduled-job-entity-controller - description: get-scheduledjob - operationId: getItemResource-scheduledjob-get - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJob' - '404': - description: Not Found - put: - tags: - - scheduled-job-entity-controller - description: update-scheduledjob - operationId: putItemResource-scheduledjob-put - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ScheduledJobRequestBody' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJob' - '201': - description: Created - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJob' - '204': - description: No Content - delete: - tags: - - scheduled-job-entity-controller - description: delete-scheduledjob - operationId: deleteItemResource-scheduledjob-delete - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '204': - description: No Content - '404': - description: Not Found - patch: - tags: - - scheduled-job-entity-controller - description: patch-scheduledjob - operationId: patchItemResource-scheduledjob-patch - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ScheduledJobRequestBody' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJob' - '204': - description: No Content - /scheduledJobs/{id}/jobStatus: - get: - tags: - - scheduled-job-property-reference-controller - description: get-scheduledjobstatus-by-scheduledjob-Id - operationId: followPropertyReference-scheduledjob-get_1 - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobStatus' - text/uri-list: - schema: - type: string - '404': - description: Not Found - put: - tags: - - scheduled-job-property-reference-controller - description: update-scheduledjobstatus-by-scheduledjob-Id - operationId: createPropertyReference-scheduledjob-put - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CollectionModelObject' - text/uri-list: - schema: - type: string - application/x-spring-data-compact+json: - schema: - $ref: '#/components/schemas/CollectionModelObject' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobStatus' - '201': - description: Created - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobStatus' - '204': - description: No Content - delete: - tags: - - scheduled-job-property-reference-controller - description: delete-scheduledjobstatus-by-scheduledjob-Id - operationId: deletePropertyReference-scheduledjob-delete - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '204': - description: No Content - '404': - description: Not Found - patch: - tags: - - scheduled-job-property-reference-controller - description: patch-scheduledjobstatus-by-scheduledjob-Id - operationId: createPropertyReference-scheduledjob-patch - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CollectionModelObject' - text/uri-list: - schema: - type: string - application/x-spring-data-compact+json: - schema: - $ref: '#/components/schemas/CollectionModelObject' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobStatus' - '204': - description: No Content - /scheduledJobs/{id}/jobStatus/{propertyId}: - get: - tags: - - scheduled-job-property-reference-controller - description: get-scheduledjobstatus-by-scheduledjob-Id - operationId: followPropertyReference-scheduledjob-get - parameters: - - name: id - in: path - required: true - schema: - type: string - - name: propertyId - in: path - required: true - schema: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobStatus' - '404': - description: Not Found - delete: - tags: - - scheduled-job-property-reference-controller - description: delete-scheduledjobstatus-by-scheduledjob-Id - operationId: deletePropertyReferenceId-scheduledjob-delete - parameters: - - name: id - in: path - required: true - schema: - type: string - - name: propertyId - in: path - required: true - schema: - type: string - responses: - '204': - description: No Content - '404': - description: Not Found - /scheduledJobs/{id}/jobType: - get: - tags: - - scheduled-job-property-reference-controller - description: get-scheduledjobtype-by-scheduledjob-Id - operationId: followPropertyReference-scheduledjob-get_2_1 - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobType' - text/uri-list: - schema: - type: string - '404': - description: Not Found - put: - tags: - - scheduled-job-property-reference-controller - description: update-scheduledjobtype-by-scheduledjob-Id - operationId: createPropertyReference-scheduledjob-put_1 - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CollectionModelObject' - text/uri-list: - schema: - type: string - application/x-spring-data-compact+json: - schema: - $ref: '#/components/schemas/CollectionModelObject' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobType' - '201': - description: Created - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobType' - '204': - description: No Content - delete: - tags: - - scheduled-job-property-reference-controller - description: delete-scheduledjobtype-by-scheduledjob-Id - operationId: deletePropertyReference-scheduledjob-delete_1 - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '204': - description: No Content - '404': - description: Not Found - patch: - tags: - - scheduled-job-property-reference-controller - description: patch-scheduledjobtype-by-scheduledjob-Id - operationId: createPropertyReference-scheduledjob-patch_1 - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CollectionModelObject' - text/uri-list: - schema: - type: string - application/x-spring-data-compact+json: - schema: - $ref: '#/components/schemas/CollectionModelObject' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobType' - '204': - description: No Content - /scheduledJobs/{id}/jobType/{propertyId}: - get: - tags: - - scheduled-job-property-reference-controller - description: get-scheduledjobtype-by-scheduledjob-Id - operationId: followPropertyReference-scheduledjob-get_2 - parameters: - - name: id - in: path - required: true - schema: - type: string - - name: propertyId - in: path - required: true - schema: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelScheduledJobType' - '404': - description: Not Found - delete: - tags: - - scheduled-job-property-reference-controller - description: delete-scheduledjobtype-by-scheduledjob-Id - operationId: deletePropertyReferenceId-scheduledjob-delete_1 - parameters: - - name: id - in: path - required: true - schema: - type: string - - name: propertyId - in: path - required: true - schema: - type: string - responses: - '204': - description: No Content - '404': - description: Not Found - /tMTextUnitToBranches: - get: - tags: - - tm-text-unit-to-branch-entity-controller - description: get-tmtextunittobranch - operationId: getCollectionResource-tmtextunittobranch-get_1 - parameters: - - name: page - in: query - description: Zero-based page index (0..N) - required: false - schema: - minimum: 0 - type: integer - default: 0 - - name: size - in: query - description: The size of the page to be returned - required: false - schema: - minimum: 1 - type: integer - default: 20 - - name: sort - in: query - description: 'Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.' - required: false - schema: - type: array - items: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/PagedModelEntityModelTMTextUnitToBranch' - text/uri-list: - schema: - type: string - application/x-spring-data-compact+json: - schema: - $ref: '#/components/schemas/PagedModelEntityModelTMTextUnitToBranch' - post: - tags: - - tm-text-unit-to-branch-entity-controller - description: create-tmtextunittobranch - operationId: postCollectionResource-tmtextunittobranch-post - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TMTextUnitToBranchRequestBody' - required: true - responses: - '201': - description: Created - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelTMTextUnitToBranch' - /tMTextUnitToBranches/{id}: - get: - tags: - - tm-text-unit-to-branch-entity-controller - description: get-tmtextunittobranch - operationId: getItemResource-tmtextunittobranch-get - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelTMTextUnitToBranch' - '404': - description: Not Found - put: - tags: - - tm-text-unit-to-branch-entity-controller - description: update-tmtextunittobranch - operationId: putItemResource-tmtextunittobranch-put - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TMTextUnitToBranchRequestBody' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelTMTextUnitToBranch' - '201': - description: Created - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelTMTextUnitToBranch' - '204': - description: No Content - delete: - tags: - - tm-text-unit-to-branch-entity-controller - description: delete-tmtextunittobranch - operationId: deleteItemResource-tmtextunittobranch-delete - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '204': - description: No Content - '404': - description: Not Found - patch: - tags: - - tm-text-unit-to-branch-entity-controller - description: patch-tmtextunittobranch - operationId: patchItemResource-tmtextunittobranch-patch - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TMTextUnitToBranchRequestBody' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - $ref: '#/components/schemas/EntityModelTMTextUnitToBranch' - '204': - description: No Content - /api/virtualAssets/{assetId}/textUnits: - get: - tags: - - virtual-asset-ws - operationId: getTextUnits - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - - name: doNotTranslateFilter - in: query - required: false - schema: - type: boolean - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/VirtualAssetTextUnit' - put: - tags: - - virtual-asset-ws - summary: Update Text Units for a specific Virtual Asset asynchronously - operationId: replaceTextUnits - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/VirtualAssetTextUnit' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableTask' - post: - tags: - - virtual-asset-ws - summary: Create Text Units for a specific Virtual Asset asynchronously - operationId: addTextUnits - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/VirtualAssetTextUnit' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableTask' - /api/screenshots/{id}: - put: - tags: - - screenshot-ws - operationId: updateScreenshot - parameters: - - name: id - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Screenshot' - required: true - responses: - '200': - description: OK - delete: - tags: - - screenshot-ws - operationId: deleteScreenshot - parameters: - - name: id - in: path - required: true - schema: - type: integer - format: int64 - responses: - '202': - description: Accepted - /api/images/**: - get: - tags: - - image-ws - summary: Get an image by its name (receive the image name as a path variable) - operationId: getImage - responses: - '200': - description: OK - content: - image/png: - schema: - type: string - application/octet-stream: - schema: - type: string - image/jpeg: - schema: - type: string - image/gif: - schema: - type: string - put: - tags: - - image-ws - summary: Upload an image (receive the image name as a path variable) - operationId: uploadImage - requestBody: - content: - image/png: - schema: - type: string - format: byte - application/octet-stream: - schema: - type: string - format: byte - image/jpeg: - schema: - type: string - format: byte - image/gif: - schema: - type: string - format: byte - required: true - responses: - '200': - description: OK - /api/virtualAssets: - post: - tags: - - virtual-asset-ws - summary: Create or update a new Virtual Asset - operationId: createOrUpdateVirtualAsset - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/VirtualAsset' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/VirtualAsset' - /api/virtualAssets/{assetId}/locale/{localeId}/textUnits: - get: - tags: - - virtual-asset-ws - operationId: getLocalizedTextUnits - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - - name: localeId - in: path - required: true - schema: - type: integer - format: int64 - - name: inheritanceMode - in: query - required: false - schema: - type: string - default: USE_PARENT - enum: - - REMOVE_UNTRANSLATED - - USE_PARENT - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/VirtualAssetTextUnit' - post: - tags: - - virtual-asset-ws - summary: Create Text Units for a specific Virtual Asset asynchronously - operationId: importLocalizedTextUnits - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - - name: localeId - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/VirtualAssetTextUnit' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableTask' - /api/users: - get: - tags: - - user-ws - summary: Get paginated Users - operationId: getUsers - parameters: - - name: username - in: query - required: false - schema: - type: string - - name: search - in: query - required: false - schema: - type: string - - name: pageable - in: query - required: true - schema: - $ref: '#/components/schemas/Pageable' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PageUser' - post: - tags: - - user-ws - operationId: createUser - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/User' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/User' - /api/users/pw: - post: - tags: - - user-ws - summary: Update a user password - operationId: changePassword - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/PasswordChangeRequest' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/User' - /api/thirdparty/sync: - post: - tags: - - third-party-ws - summary: Run Third-Party synchronization asynchronously - operationId: sync - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ThirdPartySync' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableTask' - /api/textunits: - get: - tags: - - text-unit-ws - operationId: getTextUnitsWithGet - parameters: - - name: textUnitSearchBody - in: query - required: true - schema: - $ref: '#/components/schemas/TextUnitSearchBody' - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/TextUnitDTO' - post: - tags: - - text-unit-ws - operationId: addTextUnit - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TextUnitDTO' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/TextUnitDTO' - /api/textunitsBatch: - post: - tags: - - text-unit-ws - summary: Import batch of text units asynchronously - operationId: importTextUnitBatch - requestBody: - content: - text/plain: - schema: - type: string - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableTask' - /api/textunits/statistics: - post: - tags: - - text-unit-ws - summary: Update a bulk of text unit statistics information asynchronously - operationId: importStatistics - parameters: - - name: repositoryName - in: query - required: true - schema: - type: string - - name: assetPath - in: query - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/ImportTextUnitStatisticsBody' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableTask' - /api/textunits/search: - post: - tags: - - text-unit-ws - operationId: getTextUnitsWithPost - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TextUnitSearchBody' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/TextUnitDTO' - /api/textunits/gitBlameWithUsagesBatch: - post: - tags: - - text-unit-ws - summary: Save the GitBlame information of the text units asynchronously - operationId: saveGitBlameWithUsages - requestBody: - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/GitBlameWithUsage' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableTask' - /api/textunits/check: - post: - tags: - - text-unit-ws - summary: Run integrity checks on a Text Unit - operationId: checkTMTextUnit - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TextUnitCheckBody' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/TMTextUnitIntegrityCheckResult' - /api/screenshots: - get: - tags: - - screenshot-ws - operationId: getScreeenshots - parameters: - - name: repositoryIds[] - in: query - required: false - schema: - type: array - items: - type: integer - format: int64 - - name: bcp47Tags[] - in: query - required: false - schema: - type: array - items: - type: string - - name: screenshotName - in: query - required: false - schema: - type: string - - name: status - in: query - required: false - schema: - type: string - enum: - - REJECTED - - NEEDS_REVIEW - - ACCEPTED - - name: name - in: query - required: false - schema: - type: string - - name: source - in: query - required: false - schema: - type: string - - name: target - in: query - required: false - schema: - type: string - - name: searchType - in: query - required: false - schema: - type: string - default: EXACT - enum: - - EXACT - - CONTAINS - - ILIKE - - name: screenshotRunType - in: query - required: false - schema: - type: string - enum: - - LAST_SUCCESSFUL_RUN - - MANUAL_RUN - - name: limit - in: query - required: false - schema: - type: integer - format: int32 - default: 10 - - name: offset - in: query - required: false - schema: - type: integer - format: int32 - default: 0 - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Screenshot_Screenshots' - post: - tags: - - screenshot-ws - summary: Create or add a Screenshot Run - operationId: createOrAddToScreenshotRun - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ScreenshotRun' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ScreenshotRun' - /api/rotation: - post: - tags: - - rotation-ws - summary: Update Health rotation - operationId: setRotation - requestBody: - content: - application/json: - schema: - type: boolean - required: true - responses: - '200': - description: OK - /api/repositories: - get: - tags: - - repository-ws - operationId: getRepositories_1 - parameters: - - name: name - in: query - required: true - schema: - type: string - responses: - '200': - description: OK - content: - application/json: - schema: - oneOf: - - type: array - items: - $ref: '#/components/schemas/Repository_Repository' - - type: array - items: - $ref: '#/components/schemas/Repository_RepositorySummary' - post: - tags: - - repository-ws - operationId: createRepository - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Repository_Repository' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Repository_Repository' - /api/repositories/{repositoryId}/xliffImport: - post: - tags: - - repository-ws - summary: Import an entire Repository given an XLIFF - operationId: importRepository - parameters: - - name: repositoryId - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ImportRepositoryBody' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - type: string - /api/machine-translation: - post: - tags: - - machine-translation-ws - summary: Return a single Translation - operationId: getSingleTranslation - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TranslationRequestDTO' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/TranslationDTO' - /api/machine-translation/repository: - post: - tags: - - machine-translation-ws - operationId: translateRepository - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/RepositoryMachineTranslationBody' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/RepositoryMachineTranslationBody' - /api/machine-translation-batch: - post: - tags: - - machine-translation-ws - summary: Generate translations asynchronously - operationId: getTranslations - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/BatchTranslationRequestDTO' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableTask' - /api/leveraging/copyTM: - post: - tags: - - leveraging-ws - summary: Copy the TM of a source repository into the a target repository - operationId: copyTM - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CopyTmConfig' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/CopyTmConfig' - /api/drops/import: - post: - tags: - - drop-ws - operationId: importDrop - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ImportDropConfig' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ImportDropConfig' - /api/drops/importXliff: - post: - tags: - - drop-ws - operationId: importXliff - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ImportXliffBody' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ImportXliffBody' - /api/drops/export: - post: - tags: - - drop-ws - operationId: exportDrop - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ExportDropConfig' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ExportDropConfig' - /api/drops/complete/{dropId}: - post: - tags: - - drop-ws - operationId: completeDropById - parameters: - - name: dropId - in: path - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: OK - /api/drops/cancel: - post: - tags: - - drop-ws - operationId: cancelDrop - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CancelDropConfig' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/CancelDropConfig' - /api/commits: - get: - tags: - - commit-ws - operationId: getCommits - parameters: - - name: repositoryId - in: query - required: true - schema: - type: integer - format: int64 - - name: commitNames - in: query - required: false - schema: - type: array - items: - type: string - - name: pushRunName - in: query - required: false - schema: - type: string - - name: pullRunName - in: query - required: false - schema: - type: string - - name: hasPushRun - in: query - required: false - schema: - type: boolean - - name: hasPullRun - in: query - required: false - schema: - type: boolean - - name: pageable - in: query - required: true - schema: - $ref: '#/components/schemas/Pageable' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PageCommit_Commit' - post: - tags: - - commit-ws - operationId: createCommit - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CommitBody_Commit' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Commit_Commit' - /api/commits/pushRun: - post: - tags: - - commit-ws - operationId: associateCommitToPushRun - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CommitToPushRunBody' - required: true - responses: - '200': - description: OK - /api/commits/pullRun: - post: - tags: - - commit-ws - operationId: associateCommitToPullRun - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CommitToPullRunBody' - required: true - responses: - '200': - description: OK - /api/commits/lastPushed/: - post: - tags: - - commit-ws - operationId: getLastPushedCommit - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CommitListWithRepositoryIdBody_Commit' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Commit_Commit' - /api/commits/lastPushRun/: - post: - tags: - - commit-ws - operationId: getLastPushRun - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CommitListWithRepositoryIdBody_CommitDetailed' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PushRun_CommitDetailed' - /api/commits/lastPulled/: - post: - tags: - - commit-ws - operationId: getLastPulledCommit - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CommitListWithRepositoryIdBody_Commit' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Commit_Commit' - /api/commits/lastPullRun/: - post: - tags: - - commit-ws - operationId: getLastPullRun - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CommitListWithRepositoryIdBody_CommitDetailed' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PullRun_CommitDetailed' - /api/clobstorage: - post: - tags: - - clob-storage-ws - operationId: postClob - requestBody: - content: - text/plain: - schema: - type: string - required: true - responses: - '200': - description: OK - content: - text/plain: - schema: - type: string - format: uuid - /api/boxSDKServiceConfigs: - get: - tags: - - box-sdk-service-config-ws - operationId: getBoxSDKServiceConfig - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/BoxSDKServiceConfigEntity' - post: - tags: - - box-sdk-service-config-ws - operationId: setBoxSDKServiceConfig - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/BoxSDKServiceConfigEntity' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableFutureBoxSDKServiceConfigEntity' - /api/assets: - get: - tags: - - asset-ws - operationId: getAssets - parameters: - - name: repositoryId - in: query - required: true - schema: - type: integer - format: int64 - - name: path - in: query - required: false - schema: - type: string - - name: deleted - in: query - required: false - schema: - type: boolean - - name: virtual - in: query - required: false - schema: - type: boolean - - name: branchId - in: query - required: false - schema: - type: integer - format: int64 - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/AssetDTO_AssetSummary' - post: - tags: - - asset-ws - summary: Create an Asset and kicks off extraction process - operationId: importSourceAsset - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/SourceAsset' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/SourceAsset' - /api/assets/{assetId}/xliffExport: - post: - tags: - - asset-ws - summary: Exports all the translations (used and unused) of an Asset into XLIFF asynchronously - operationId: xliffExportAsync - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - - name: bcp47tag - in: query - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/XliffExportBody' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/XliffExportBody' - /api/assets/{assetId}/pseudo: - post: - tags: - - asset-ws - summary: Pseudo localize the payload content with translations of a given Asset - operationId: getPseudoLocalizedAssetForContent - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/LocalizedAssetBody' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/LocalizedAssetBody' - /api/assets/{assetId}/localized: - post: - tags: - - asset-ws - summary: Get Localized Asset asynchronously - operationId: getLocalizedAssetForContentAsync - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/LocalizedAssetBody' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableTask' - /api/assets/{assetId}/localized/{localeId}: - post: - tags: - - asset-ws - summary: Localize the payload content with translations of a given Asset - operationId: getLocalizedAssetForContent - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - - name: localeId - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/LocalizedAssetBody' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/LocalizedAssetBody' - /api/assets/{assetId}/localized/{localeId}/import: - post: - tags: - - asset-ws - operationId: importLocalizedAsset - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - - name: localeId - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ImportLocalizedAssetBody' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ImportLocalizedAssetBody' - /api/assets/{assetId}/localized/parallel: - post: - tags: - - asset-ws - summary: Localize the payload content with translations of a given Asset in parallel - operationId: getLocalizedAssetForContentParallel - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/MultiLocalizedAssetBody' - required: true - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableTask' - /api/users/{userId}: - delete: - tags: - - user-ws - operationId: deleteUserByUserId - parameters: - - name: userId - in: path - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: OK - patch: - tags: - - user-ws - operationId: updateUserByUserId - parameters: - - name: userId - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/User' - required: true - responses: - '200': - description: OK - /api/repositories/{repositoryId}: - get: - tags: - - repository-ws - operationId: getRepositoryById - parameters: - - name: repositoryId - in: path - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Repository_Repository' - delete: - tags: - - repository-ws - operationId: deleteRepositoryById - parameters: - - name: repositoryId - in: path - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: OK - patch: - tags: - - repository-ws - operationId: updateRepository - parameters: - - name: repositoryId - in: path - required: true - schema: - type: integer - format: int64 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Repository' - required: true - responses: - '200': - description: OK - content: - application/hal+json: - schema: - type: string - /cli/version: - get: - tags: - - cli-ws - summary: Get the CLI version - operationId: getVersion - responses: - '200': - description: OK - content: - text/plain: - schema: - type: string - /cli/mojito-cli.jar: - get: - tags: - - cli-ws - summary: Get the mojito-cli.jar file - operationId: getFile - responses: - '200': - description: OK - content: - application/octet-stream: - schema: - type: string - format: binary - /cli/install.sh: - get: - tags: - - cli-ws - summary: Get the script to install the CLI - operationId: getInstallCliScript - parameters: - - name: installDirectory - in: query - required: false - schema: - type: string - default: ${PWD}/.mojito - responses: - '200': - description: OK - content: - text/plain: - schema: - type: string - /api/users/session: - get: - tags: - - user-ws - summary: Check if session is active - operationId: isSessionActive - responses: - '200': - description: OK - /api/textunits/{tmTextUnitId}/history: - get: - tags: - - text-unit-ws - summary: Get the translation history for a given text unit for a particular locale - operationId: getTextUnitHistory - parameters: - - name: tmTextUnitId - in: path - required: true - schema: - type: integer - format: int64 - - name: bcp47Tag - in: query - required: true - schema: - type: string - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/TMTextUnitVariant_TranslationHistorySummary' - /api/textunits/gitBlameWithUsages: - get: - tags: - - text-unit-ws - operationId: getGitBlameWithUsages - parameters: - - name: repositoryIds[] - in: query - required: false - schema: - type: array - items: - type: integer - format: int64 - - name: repositoryNames[] - in: query - required: false - schema: - type: array - items: - type: string - - name: tmTextUnitId - in: query - required: false - schema: - type: integer - format: int64 - - name: usedFilter - in: query - required: false - schema: - type: string - enum: - - USED - - UNUSED - - name: statusFilter - in: query - required: false - schema: - type: string - enum: - - ALL - - TRANSLATED - - UNTRANSLATED - - TRANSLATED_AND_NOT_REJECTED - - APPROVED_OR_NEEDS_REVIEW_AND_NOT_REJECTED - - APPROVED_AND_NOT_REJECTED - - FOR_TRANSLATION - - REVIEW_NEEDED - - REVIEW_NOT_NEEDED - - TRANSLATION_NEEDED - - REJECTED - - NOT_REJECTED - - OVERRIDDEN - - MT_TRANSLATED - - MT_REVIEW_NEEDED - - name: doNotTranslateFilter - in: query - required: false - schema: - type: boolean - - name: limit - in: query - required: false - schema: - type: integer - format: int32 - default: 10 - - name: offset - in: query - required: false - schema: - type: integer - format: int32 - default: 0 - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/GitBlameWithUsage_GitBlameWithUsage' - /api/textunits/count: - get: - tags: - - text-unit-ws - operationId: getTextUnitsCount - parameters: - - name: textUnitSearchBody - in: query - required: true - schema: - $ref: '#/components/schemas/TextUnitSearchBody' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/TextUnitAndWordCount' - /api/repositories/{repositoryId}/branches: - get: - tags: - - repository-ws - operationId: getBranchesOfRepository - parameters: - - name: repositoryId - in: path - required: true - schema: - type: integer - format: int64 - - name: name - in: query - required: false - schema: - type: string - - name: deleted - in: query - required: false - schema: - type: boolean - - name: translated - in: query - required: false - schema: - type: boolean - - name: createdBefore - in: query - required: false - schema: - type: string - format: date-time - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Branch_BranchSummary' - delete: - tags: - - repository-ws - summary: Delete a Branch asynchronously - operationId: deleteBranch - parameters: - - name: repositoryId - in: path - required: true - schema: - type: integer - format: int64 - - name: branchId - in: query - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableTask' - /api/quartz/jobs/dynamic: - get: - tags: - - quartz-ws - summary: Get all dynamic jobs - operationId: getAllDynamicJobs - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - type: string - delete: - tags: - - quartz-ws - summary: Delete all dynamic jobs - operationId: deleteAllDynamicJobs - responses: - '200': - description: OK - /api/pollableTasks/{pollableTaskId}: - get: - tags: - - pollable-task-ws - summary: Get a Pollable Task by ID - operationId: getPollableTaskById - parameters: - - name: pollableTaskId - in: path - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PollableTask' - /api/pollableTasks/{pollableTaskId}/output: - get: - tags: - - pollable-task-ws - summary: Get output JSON for a Pollable Task - operationId: getPollableTaskOutput - parameters: - - name: pollableTaskId - in: path - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: OK - content: - text/plain: - schema: - type: string - /api/pollableTasks/{pollableTaskId}/input: - get: - tags: - - pollable-task-ws - summary: Get input JSON for a Pollable Task - operationId: getPollableTaskInput - parameters: - - name: pollableTaskId - in: path - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: OK - content: - text/plain: - schema: - type: string - /api/machine-translation/config: - get: - tags: - - machine-translation-ws - operationId: getMachineTranslationConfiguration - responses: - '200': - description: OK - content: - text/plain: - schema: - type: string - /api/locales: - get: - tags: - - locale-ws - summary: Get Locales for specific BCP 47 Tags - operationId: getLocales - parameters: - - name: bcp47Tag - in: query - required: false - schema: - type: string - responses: - '200': - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Locale' - /api/drops: - get: - tags: - - drop-ws - operationId: getDrops - parameters: - - name: repositoryId - in: query - required: false - schema: - type: integer - format: int64 - - name: imported - in: query - required: false - schema: - type: boolean - - name: canceled - in: query - required: false - schema: - type: boolean - - name: pageable - in: query - required: true - schema: - $ref: '#/components/schemas/Pageable' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PageDrop_DropSummary' - /api/deltas/state: - get: - tags: - - delta-ws - summary: Get Delta Content for a given set of parameters - operationId: getDeltasForRuns - parameters: - - name: repositoryId - in: query - required: true - schema: - type: integer - format: int64 - - name: pushRunIds - in: query - required: true - schema: - type: array - items: - type: integer - format: int64 - - name: bcp47Tags - in: query - required: false - schema: - type: array - items: - type: string - - name: pullRunIds - in: query - required: false - schema: - type: array - items: - type: integer - format: int64 - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/DeltaResponseDTO' - /api/deltas/date: - get: - tags: - - delta-ws - summary: Get paginated Text Unit Variants Deltas for a given set of parameters - operationId: getDeltasFromDate - parameters: - - name: repositoryId - in: query - required: true - schema: - type: integer - format: int64 - - name: bcp47Tags - in: query - required: false - schema: - type: array - items: - type: string - - name: fromDate - in: query - required: false - schema: - type: string - format: date-time - - name: toDate - in: query - required: false - schema: - type: string - format: date-time - - name: pageable - in: query - required: true - schema: - $ref: '#/components/schemas/Pageable' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PageTextUnitVariantDeltaDTO' - /api/csrf-token: - get: - tags: - - csrf-token-controller - summary: Get a CSRF Token - operationId: getCsrfToken - responses: - '200': - description: OK - content: - text/plain: - schema: - type: string - /api/commits/detailed: - get: - tags: - - commit-ws - operationId: getCommitsDetailed - parameters: - - name: repositoryId - in: query - required: true - schema: - type: integer - format: int64 - - name: commitNames - in: query - required: false - schema: - type: array - items: - type: string - - name: pushRunName - in: query - required: false - schema: - type: string - - name: pullRunName - in: query - required: false - schema: - type: string - - name: hasPushRun - in: query - required: false - schema: - type: boolean - - name: hasPullRun - in: query - required: false - schema: - type: boolean - - name: pageable - in: query - required: true - schema: - $ref: '#/components/schemas/Pageable' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PageCommit_CommitDetailed' - /api/clobstorage/{uuid}: - get: - tags: - - clob-storage-ws - operationId: getClob - parameters: - - name: uuid - in: path - required: true - schema: - type: string - format: uuid - responses: - '200': - description: OK - content: - text/plain: - schema: - type: string - /api/branchStatistics: - get: - tags: - - branch-statistic-ws - summary: Get paginated Branch Statistics for a given set of parameters - operationId: getBranchesOfRepository_1 - parameters: - - name: createdByUserName - in: query - required: false - schema: - type: string - - name: branchId - in: query - required: false - schema: - type: integer - format: int64 - - name: branchName - in: query - required: false - schema: - type: string - - name: search - in: query - required: false - schema: - type: string - - name: deleted - in: query - required: false - schema: - type: boolean - - name: empty - in: query - required: false - schema: - type: boolean - - name: totalCountLte - in: query - required: false - schema: - type: integer - format: int64 - default: 30000 - - name: createdBefore - in: query - required: false - schema: - type: string - format: date-time - - name: createdAfter - in: query - required: false - schema: - type: string - format: date-time - - name: pageable - in: query - required: true - schema: - $ref: '#/components/schemas/Pageable' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PageBranchStatistic_BranchStatistic' - /api/branchStatistics/{id}/branchTextUnitStatistics: - get: - tags: - - branch-statistic-ws - summary: Get Branch Text Unit Statistics paginated for a specific Branch Statistic - operationId: getBranchTextUnitStatisticsOfBranch - parameters: - - name: id - in: path - required: true - schema: - type: integer - format: int64 - - name: pageable - in: query - required: true - schema: - $ref: '#/components/schemas/Pageable' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/PageBranchTextUnitStatistic_BranchTextUnitStatistic' - /api/assets/{assetId}/xliffExport/{tmXliffId}: - get: - tags: - - asset-ws - summary: Exports all the translations (used and unused) of an Asset into XLIFF - operationId: xliffExport - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - - name: tmXliffId - in: path - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/XliffExportBody' - /api/assets/ids: - get: - tags: - - asset-ws - operationId: getAssetIds - parameters: - - name: repositoryId - in: query - required: true - schema: - type: integer - format: int64 - - name: deleted - in: query - required: false - schema: - type: boolean - - name: virtual - in: query - required: false - schema: - type: boolean - - name: branchId - in: query - required: false - schema: - type: integer - format: int64 - responses: - '200': - description: OK - content: - application/json: - schema: - uniqueItems: true - type: array - items: - type: integer - format: int64 - /api/assetTextUnits/{assetTextUnitId}/usages: - get: - tags: - - text-unit-ws - operationId: getAssetTextUnitUsages - parameters: - - name: assetTextUnitId - in: path - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: OK - content: - application/json: - schema: - uniqueItems: true - type: array - items: - type: string - /api/textunits/{textUnitId}: - delete: - tags: - - text-unit-ws - operationId: deleteTMTextUnitCurrentVariant - parameters: - - name: textUnitId - in: path - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: OK - /api/assets/{assetId}: - delete: - tags: - - asset-ws - operationId: deleteAssetById - parameters: - - name: assetId - in: path - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: OK -components: - schemas: - AbstractJsonSchemaPropertyObject: - type: object - properties: - title: - type: string - readOnly: - type: boolean - Item: - type: object - properties: - type: - type: string - properties: - type: object - additionalProperties: - $ref: '#/components/schemas/AbstractJsonSchemaPropertyObject' - requiredProperties: - type: array - items: - type: string - JsonSchema: - type: object - properties: - title: - type: string - description: - type: string - properties: - type: object - additionalProperties: - $ref: '#/components/schemas/AbstractJsonSchemaPropertyObject' - requiredProperties: - type: array - items: - type: string - definitions: - type: object - additionalProperties: - $ref: '#/components/schemas/Item' - type: - type: string - $schema: - type: string - Links: - type: object - additionalProperties: - $ref: '#/components/schemas/Link' - RepresentationModelObject: - type: object - properties: - _links: - $ref: '#/components/schemas/Links' - Asset: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - repository: - $ref: '#/components/schemas/Repository' - path: - type: string - virtual: - type: boolean - lastSuccessfulAssetExtraction: - $ref: '#/components/schemas/AssetExtraction' - createdByUser: - $ref: '#/components/schemas/User' - deleted: - type: boolean - assetExtractionByBranches: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/AssetExtractionByBranch' - AssetExtraction: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - contentMd5: - type: string - filterOptionsMd5: - type: string - assetTextUnits: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/AssetTextUnit' - assetExtractionByBranches: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/AssetExtractionByBranch' - pollableTask: - $ref: '#/components/schemas/PollableTask' - version: - type: integer - format: int64 - createdByUser: - $ref: '#/components/schemas/User' - AssetExtractionByBranch: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - asset: - $ref: '#/components/schemas/Asset' - branch: - $ref: '#/components/schemas/Branch' - deleted: - type: boolean - AssetIntegrityChecker: - type: object - properties: - id: - type: integer - format: int64 - assetExtension: - type: string - integrityCheckerType: - type: string - enum: - - MESSAGE_FORMAT - - MESSAGE_FORMAT_DOUBLE_BRACES - - PRINTF_LIKE - - SIMPLE_PRINTF_LIKE - - PRINTF_LIKE_IGNORE_PERCENTAGE_AFTER_BRACKETS - - PRINTF_LIKE_VARIABLE_TYPE - - PRINTF_LIKE_ADD_PARAMETER_SPECIFIER - - COMPOSITE_FORMAT - - WHITESPACE - - TRAILING_WHITESPACE - - HTML_TAG - - ELLIPSIS - - BACKQUOTE - - EMPTY_TARGET_NOT_EMPTY_SOURCE - - SPAN_TRANSLATE_TAG - AssetTextUnit: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - content: - type: string - md5: - type: string - contentMd5: - type: string - comment: - type: string - createdByUser: - $ref: '#/components/schemas/User' - pluralForm: - $ref: '#/components/schemas/PluralForm' - pluralFormOther: - type: string - usages: - uniqueItems: true - type: array - items: - type: string - doNotTranslate: - type: boolean - branch: - $ref: '#/components/schemas/Branch' - Authority: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - authority: - type: string - Branch: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - repository: - $ref: '#/components/schemas/Repository' - name: - type: string - createdByUser: - $ref: '#/components/schemas/User' - deleted: - type: boolean - screenshots: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/Screenshot' - branchStatistic: - $ref: '#/components/schemas/BranchStatistic' - notifiers: - uniqueItems: true - type: array - items: - type: string - BranchStatistic: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - branch: - $ref: '#/components/schemas/Branch' - branchTextUnitStatistics: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/BranchTextUnitStatistic' - totalCount: - type: integer - format: int64 - forTranslationCount: - type: integer - format: int64 - BranchTextUnitStatistic: - type: object - properties: - id: - type: integer - format: int64 - tmTextUnit: - $ref: '#/components/schemas/TMTextUnit' - forTranslationCount: - type: integer - format: int64 - totalCount: - type: integer - format: int64 - Locale: - type: object - properties: - id: - type: integer - format: int64 - bcp47Tag: - type: string - PluralForm: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - PollableTask: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - finishedDate: - type: integer - format: int64 - example: 1715699917000 - errorStack: - type: string - expectedSubTaskNumber: - type: integer - format: int32 - subTasks: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/PollableTask' - createdByUser: - $ref: '#/components/schemas/User' - allFinished: - type: boolean - message: - type: string - errorMessage: - type: string - Repository: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - description: - type: string - dropExporterType: - type: string - enum: - - BOX - - FILE_SYSTEM - sourceLocale: - $ref: '#/components/schemas/Locale' - repositoryLocales: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/RepositoryLocale' - repositoryStatistic: - $ref: '#/components/schemas/RepositoryStatistic' - assetIntegrityCheckers: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/AssetIntegrityChecker' - branches: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/Branch' - tm: - $ref: '#/components/schemas/TM' - createdByUser: - $ref: '#/components/schemas/User' - manualScreenshotRun: - $ref: '#/components/schemas/ScreenshotRun' - deleted: - type: boolean - checkSLA: - type: boolean - RepositoryLocale: - type: object - properties: - id: - type: integer - format: int64 - locale: - $ref: '#/components/schemas/Locale' - toBeFullyTranslated: - type: boolean - parentLocale: - $ref: '#/components/schemas/RepositoryLocale' - RepositoryLocaleStatistic: - type: object - properties: - id: - type: integer - format: int64 - locale: - $ref: '#/components/schemas/Locale' - translatedCount: - type: integer - format: int64 - translatedWordCount: - type: integer - format: int64 - translationNeededCount: - type: integer - format: int64 - translationNeededWordCount: - type: integer - format: int64 - reviewNeededCount: - type: integer - format: int64 - reviewNeededWordCount: - type: integer - format: int64 - includeInFileCount: - type: integer - format: int64 - includeInFileWordCount: - type: integer - format: int64 - diffToSourcePluralCount: - type: integer - format: int64 - forTranslationCount: - type: integer - format: int64 - forTranslationWordCount: - type: integer - format: int64 - RepositoryStatistic: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - usedTextUnitCount: - type: integer - format: int64 - usedTextUnitWordCount: - type: integer - format: int64 - unusedTextUnitCount: - type: integer - format: int64 - unusedTextUnitWordCount: - type: integer - format: int64 - pluralTextUnitCount: - type: integer - format: int64 - pluralTextUnitWordCount: - type: integer - format: int64 - ooslaTextUnitCount: - type: integer - format: int64 - ooslaTextUnitWordCount: - type: integer - format: int64 - ooslaCreatedBefore: - type: integer - format: int64 - example: 1715699917000 - uncommentedTextUnitCount: - type: integer - format: int64 - repositoryLocaleStatistics: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/RepositoryLocaleStatistic' - createdByUser: - $ref: '#/components/schemas/User' - Screenshot: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - screenshotRun: - $ref: '#/components/schemas/ScreenshotRun' - branch: - $ref: '#/components/schemas/Branch' - locale: - $ref: '#/components/schemas/Locale' - src: - type: string - status: - type: string - enum: - - REJECTED - - NEEDS_REVIEW - - ACCEPTED - sequence: - type: integer - format: int64 - comment: - type: string - thirdPartyScreenshots: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/ThirdPartyScreenshot' - textUnits: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/ScreenshotTextUnit' - ScreenshotRun: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - screenshots: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/Screenshot' - lastSuccessfulRun: - type: boolean - ScreenshotTextUnit: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - source: - type: string - target: - type: string - renderedTarget: - type: string - numberOfMatch: - type: integer - format: int32 - tmTextUnit: - $ref: '#/components/schemas/TMTextUnit' - tmTextUnitVariant: - $ref: '#/components/schemas/TMTextUnitVariant' - TM: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - createdByUser: - $ref: '#/components/schemas/User' - TMTextUnit: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - content: - type: string - md5: - type: string - contentMd5: - type: string - comment: - type: string - wordCount: - type: integer - format: int32 - tm: - $ref: '#/components/schemas/TM' - asset: - $ref: '#/components/schemas/Asset' - createdByUser: - $ref: '#/components/schemas/User' - pluralForm: - $ref: '#/components/schemas/PluralForm' - pluralFormOther: - type: string - tmTextUnitStatistic: - $ref: '#/components/schemas/TMTextUnitStatistic' - TMTextUnitStatistic: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - lastDayUsageCount: - type: number - format: double - lastPeriodUsageCount: - type: number - format: double - lastSeenDate: - type: string - format: date-time - tmtextUnit: - $ref: '#/components/schemas/TMTextUnit' - TMTextUnitVariant: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - content: - type: string - tmTextUnit: - $ref: '#/components/schemas/TMTextUnit' - locale: - $ref: '#/components/schemas/Locale' - contentMD5: - type: string - comment: - type: string - status: - type: string - enum: - - TRANSLATION_NEEDED - - REVIEW_NEEDED - - MT_TRANSLATED - - MT_REVIEW_NEEDED - - APPROVED - - OVERRIDDEN - includedInLocalizedFile: - type: boolean - createdByUser: - $ref: '#/components/schemas/User' - tmTextUnitVariantComments: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/TMTextUnitVariantComment' - TMTextUnitVariantComment: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - severity: - type: string - enum: - - INFO - - WARNING - - ERROR - type: - type: string - enum: - - LEVERAGING - - INTEGRITY_CHECK - - QUALITY_CHECK - content: - type: string - createdByUser: - $ref: '#/components/schemas/User' - ThirdPartyScreenshot: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - thirdPartyId: - type: string - screenshot: - $ref: '#/components/schemas/Screenshot' - User: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - username: - type: string - password: - type: string - writeOnly: true - enabled: - type: boolean - surname: - type: string - givenName: - type: string - commonName: - type: string - partiallyCreated: - type: boolean - authorities: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/Authority' - EntityModelBranchSource: - type: object - properties: - branch: - $ref: '#/components/schemas/Branch' - url: - type: string - _links: - $ref: '#/components/schemas/Links' - PageMetadata: - type: object - properties: - size: - type: integer - format: int64 - totalElements: - type: integer - format: int64 - totalPages: - type: integer - format: int64 - number: - type: integer - format: int64 - PagedModelEntityModelBranchSource: - type: object - properties: - _embedded: - type: object - properties: - branchSources: - type: array - items: - $ref: '#/components/schemas/EntityModelBranchSource' - _links: - $ref: '#/components/schemas/Links' - page: - $ref: '#/components/schemas/PageMetadata' - EntityModelScheduledJobType: - type: object - properties: - jobType: - type: string - enum: - - THIRD_PARTY_SYNC - enum: - type: string - enum: - - THIRD_PARTY_SYNC - _links: - $ref: '#/components/schemas/Links' - PagedModelEntityModelScheduledJobType: - type: object - properties: - _embedded: - type: object - properties: - scheduledJobTypes: - type: array - items: - $ref: '#/components/schemas/EntityModelScheduledJobType' - _links: - $ref: '#/components/schemas/Links' - page: - $ref: '#/components/schemas/PageMetadata' - ScheduledJobProperties: - type: object - properties: - version: - type: integer - format: int32 - EntityModelScheduledJob: - type: object - properties: - uuid: - type: string - repository: - $ref: '#/components/schemas/Repository' - cron: - type: string - properties: - $ref: '#/components/schemas/ScheduledJobProperties' - propertiesString: - type: string - startDate: - type: string - format: date-time - endDate: - type: string - format: date-time - enabled: - type: boolean - _links: - $ref: '#/components/schemas/Links' - PagedModelEntityModelScheduledJob: - type: object - properties: - _embedded: - type: object - properties: - scheduledJobs: - type: array - items: - $ref: '#/components/schemas/EntityModelScheduledJob' - _links: - $ref: '#/components/schemas/Links' - page: - $ref: '#/components/schemas/PageMetadata' - CollectionModelObject: - type: object - properties: - _embedded: - type: object - properties: - objects: - type: array - items: - type: object - _links: - $ref: '#/components/schemas/Links' - EntityModelScheduledJobStatus: - type: object - properties: - jobStatus: - type: string - enum: - - SCHEDULED - - IN_PROGRESS - - FAILED - - SUCCEEDED - enum: - type: string - enum: - - SCHEDULED - - IN_PROGRESS - - FAILED - - SUCCEEDED - _links: - $ref: '#/components/schemas/Links' - PagedModelEntityModelScheduledJobStatus: - type: object - properties: - _embedded: - type: object - properties: - scheduledJobStatuses: - type: array - items: - $ref: '#/components/schemas/EntityModelScheduledJobStatus' - _links: - $ref: '#/components/schemas/Links' - page: - $ref: '#/components/schemas/PageMetadata' - EntityModelTMTextUnitToBranch: - type: object - properties: - tmTextUnit: - $ref: '#/components/schemas/TMTextUnit' - branch: - $ref: '#/components/schemas/Branch' - _links: - $ref: '#/components/schemas/Links' - PagedModelEntityModelTMTextUnitToBranch: - type: object - properties: - _embedded: - type: object - properties: - tMTextUnitToBranches: - type: array - items: - $ref: '#/components/schemas/EntityModelTMTextUnitToBranch' - _links: - $ref: '#/components/schemas/Links' - page: - $ref: '#/components/schemas/PageMetadata' - BranchSourceRequestBody: - type: object - properties: - id: - type: integer - format: int64 - branch: - $ref: '#/components/schemas/Branch' - url: - type: string - ScheduledJobStatusRequestBody: - type: object - properties: - id: - type: integer - format: int64 - jobStatus: - type: string - enum: - - SCHEDULED - - IN_PROGRESS - - FAILED - - SUCCEEDED - enum: - type: string - enum: - - SCHEDULED - - IN_PROGRESS - - FAILED - - SUCCEEDED - ScheduledJobTypeRequestBody: - type: object - properties: - id: - type: integer - format: int64 - jobType: - type: string - enum: - - THIRD_PARTY_SYNC - enum: - type: string - enum: - - THIRD_PARTY_SYNC - ScheduledJobRequestBody: - type: object - properties: - id: - type: integer - format: int64 - uuid: - type: string - repository: - $ref: '#/components/schemas/Repository' - jobType: - type: string - cron: - type: string - properties: - $ref: '#/components/schemas/ScheduledJobProperties' - propertiesString: - type: string - jobStatus: - type: string - startDate: - type: string - format: date-time - endDate: - type: string - format: date-time - enabled: - type: boolean - TMTextUnitToBranchRequestBody: - type: object - properties: - id: - type: integer - format: int64 - tmTextUnit: - $ref: '#/components/schemas/TMTextUnit' - branch: - $ref: '#/components/schemas/Branch' - VirtualAssetTextUnit: - type: object - properties: - name: - type: string - content: - type: string - comment: - type: string - pluralForm: - type: string - pluralFormOther: - type: string - doNotTranslate: - type: boolean - VirtualAsset: - type: object - properties: - id: - type: integer - format: int64 - repositoryId: - type: integer - format: int64 - path: - type: string - deleted: - type: boolean - PasswordChangeRequest: - type: object - properties: - currentPassword: - type: string - newPassword: - type: string - ThirdPartySync: - type: object - properties: - repositoryId: - type: integer - format: int64 - projectId: - type: string - actions: - type: array - items: - type: string - enum: - - PUSH - - PUSH_TRANSLATION - - PULL - - PULL_SOURCE - - MAP_TEXTUNIT - - PUSH_SCREENSHOT - - PUSH_AI_TRANSLATION - pluralSeparator: - type: string - localeMapping: - type: string - skipTextUnitsWithPattern: - type: string - skipAssetsWithPathPattern: - type: string - includeTextUnitsWithPattern: - type: string - options: - type: array - items: - type: string - timeout: - type: integer - format: int64 - TextUnitDTO: - type: object - properties: - tmTextUnitId: - type: integer - format: int64 - tmTextUnitVariantId: - type: integer - format: int64 - localeId: - type: integer - format: int64 - name: - type: string - source: - type: string - comment: - type: string - target: - type: string - targetLocale: - type: string - targetComment: - type: string - assetId: - type: integer - format: int64 - lastSuccessfulAssetExtractionId: - type: integer - format: int64 - assetExtractionId: - type: integer - format: int64 - tmTextUnitCurrentVariantId: - type: integer - format: int64 - status: - type: string - enum: - - TRANSLATION_NEEDED - - REVIEW_NEEDED - - MT_TRANSLATED - - MT_REVIEW_NEEDED - - APPROVED - - OVERRIDDEN - includedInLocalizedFile: - type: boolean - createdDate: - type: integer - format: int64 - example: 1715699917000 - assetDeleted: - type: boolean - pluralForm: - type: string - pluralFormOther: - type: string - repositoryName: - type: string - assetPath: - type: string - assetTextUnitId: - type: integer - format: int64 - tmTextUnitCreatedDate: - type: integer - format: int64 - example: 1715699917000 - doNotTranslate: - type: boolean - uploadedFileUri: - type: string - used: - type: boolean - translated: - type: boolean - ImportTextUnitStatisticsBody: - type: object - properties: - name: - type: string - content: - type: string - comment: - type: string - lastDayEstimatedVolume: - type: number - format: double - lastPeriodEstimatedVolume: - type: number - format: double - lastSeenDate: - type: string - format: date-time - TextUnitSearchBody: - type: object - properties: - repositoryIds: - type: array - items: - type: integer - format: int64 - repositoryNames: - type: array - items: - type: string - tmTextUnitIds: - type: array - items: - type: integer - format: int64 - name: - type: string - source: - type: string - target: - type: string - assetPath: - type: string - pluralFormOther: - type: string - locationUsage: - type: string - pluralFormFiltered: - type: boolean - pluralFormExcluded: - type: boolean - searchType: - type: string - enum: - - EXACT - - CONTAINS - - ILIKE - localeTags: - type: array - items: - type: string - usedFilter: - type: string - enum: - - USED - - UNUSED - statusFilter: - type: string - enum: - - ALL - - TRANSLATED - - UNTRANSLATED - - TRANSLATED_AND_NOT_REJECTED - - APPROVED_OR_NEEDS_REVIEW_AND_NOT_REJECTED - - APPROVED_AND_NOT_REJECTED - - FOR_TRANSLATION - - REVIEW_NEEDED - - REVIEW_NOT_NEEDED - - TRANSLATION_NEEDED - - REJECTED - - NOT_REJECTED - - OVERRIDDEN - - MT_TRANSLATED - - MT_REVIEW_NEEDED - doNotTranslateFilter: - type: boolean - tmTextUnitCreatedBefore: - type: string - format: date-time - tmTextUnitCreatedAfter: - type: string - format: date-time - branchId: - type: integer - format: int64 - limit: - type: integer - format: int32 - offset: - type: integer - format: int32 - GitBlame: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - tmTextUnit: - $ref: '#/components/schemas/TMTextUnit' - authorEmail: - type: string - authorName: - type: string - commitTime: - type: string - commitName: - type: string - GitBlameWithUsage: - type: object - properties: - usages: - uniqueItems: true - type: array - items: - type: string - textUnitName: - type: string - pluralForm: - type: string - tmTextUnitId: - type: integer - format: int64 - assetId: - type: integer - format: int64 - assetTextUnitId: - type: integer - format: int64 - thirdPartyTextUnitId: - type: string - content: - type: string - comment: - type: string - gitBlame: - $ref: '#/components/schemas/GitBlame' - branch: - $ref: '#/components/schemas/Branch' - screenshots: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/Screenshot' - introducedBy: - type: string - isVirtual: - type: boolean - virtual: - type: boolean - TextUnitCheckBody: - type: object - properties: - tmTextUnitId: - type: integer - format: int64 - content: - type: string - TMTextUnitIntegrityCheckResult: - type: object - properties: - checkResult: - type: boolean - failureDetail: - type: string - AssetIntegrityChecker_Repository: - type: object - properties: - id: - type: integer - format: int64 - assetExtension: - type: string - integrityCheckerType: - type: string - enum: - - MESSAGE_FORMAT - - MESSAGE_FORMAT_DOUBLE_BRACES - - PRINTF_LIKE - - SIMPLE_PRINTF_LIKE - - PRINTF_LIKE_IGNORE_PERCENTAGE_AFTER_BRACKETS - - PRINTF_LIKE_VARIABLE_TYPE - - PRINTF_LIKE_ADD_PARAMETER_SPECIFIER - - COMPOSITE_FORMAT - - WHITESPACE - - TRAILING_WHITESPACE - - HTML_TAG - - ELLIPSIS - - BACKQUOTE - - EMPTY_TARGET_NOT_EMPTY_SOURCE - - SPAN_TRANSLATE_TAG - Locale_Repository: - type: object - properties: - id: - type: integer - format: int64 - bcp47Tag: - type: string - RepositoryLocaleStatistic_Repository: - type: object - properties: - id: - type: integer - format: int64 - locale: - $ref: '#/components/schemas/Locale_Repository' - translatedCount: - type: integer - format: int64 - translatedWordCount: - type: integer - format: int64 - translationNeededCount: - type: integer - format: int64 - translationNeededWordCount: - type: integer - format: int64 - reviewNeededCount: - type: integer - format: int64 - reviewNeededWordCount: - type: integer - format: int64 - includeInFileCount: - type: integer - format: int64 - includeInFileWordCount: - type: integer - format: int64 - diffToSourcePluralCount: - type: integer - format: int64 - forTranslationCount: - type: integer - format: int64 - forTranslationWordCount: - type: integer - format: int64 - RepositoryLocale_Repository: - type: object - properties: - id: - type: integer - format: int64 - locale: - $ref: '#/components/schemas/Locale_Repository' - toBeFullyTranslated: - type: boolean - parentLocale: - $ref: '#/components/schemas/RepositoryLocale_Repository' - RepositoryStatistic_Repository: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - usedTextUnitCount: - type: integer - format: int64 - usedTextUnitWordCount: - type: integer - format: int64 - pluralTextUnitCount: - type: integer - format: int64 - pluralTextUnitWordCount: - type: integer - format: int64 - ooslaTextUnitCount: - type: integer - format: int64 - ooslaTextUnitWordCount: - type: integer - format: int64 - ooslaCreatedBefore: - type: integer - format: int64 - example: 1715699917000 - repositoryLocaleStatistics: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/RepositoryLocaleStatistic_Repository' - Repository_Repository: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - description: - type: string - dropExporterType: - type: string - enum: - - BOX - - FILE_SYSTEM - sourceLocale: - $ref: '#/components/schemas/Locale_Repository' - repositoryLocales: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/RepositoryLocale_Repository' - repositoryStatistic: - $ref: '#/components/schemas/RepositoryStatistic_Repository' - assetIntegrityCheckers: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/AssetIntegrityChecker_Repository' - tm: - $ref: '#/components/schemas/TM_Repository' - createdByUser: - $ref: '#/components/schemas/User_Repository' - manualScreenshotRun: - $ref: '#/components/schemas/ScreenshotRun_Repository' - deleted: - type: boolean - checkSLA: - type: boolean - ScreenshotRun_Repository: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - TM_Repository: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - User_Repository: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - username: - type: string - commonName: - type: string - ImportRepositoryBody: - type: object - properties: - xliffContent: - type: string - updateTM: - type: boolean - TranslationRequestDTO: - type: object - properties: - textSource: - type: string - sourceBcp47Tag: - type: string - targetBcp47Tag: - type: string - skipFunctionalProtection: - type: boolean - skipLeveraging: - type: boolean - repositoryIds: - type: array - items: - type: integer - format: int64 - repositoryNames: - type: array - items: - type: string - TranslationDTO: - type: object - properties: - text: - type: string - matchedTextUnitId: - type: integer - format: int64 - matchedTextUnitVariantId: - type: integer - format: int64 - bcp47Tag: - type: string - translationSource: - type: string - enum: - - MOJITO_TM_LEVERAGE - - GOOGLE_MT - - MICROSOFT_MT - - NOOP - - UNTRANSLATED - RepositoryMachineTranslationBody: - type: object - properties: - repositoryName: - type: string - targetBcp47tags: - type: array - items: - type: string - sourceTextMaxCountPerLocale: - type: integer - format: int32 - pollableTask: - $ref: '#/components/schemas/PollableTask' - BatchTranslationRequestDTO: - type: object - properties: - textSources: - type: array - items: - type: string - sourceBcp47Tag: - type: string - targetBcp47Tags: - type: array - items: - type: string - skipFunctionalProtection: - type: boolean - skipLeveraging: - type: boolean - repositoryIds: - type: array - items: - type: integer - format: int64 - repositoryNames: - type: array - items: - type: string - CopyTmConfig: - type: object - properties: - sourceRepositoryId: - type: integer - format: int64 - targetRepositoryId: - type: integer - format: int64 - targetAssetId: - type: integer - format: int64 - sourceAssetId: - type: integer - format: int64 - nameRegex: - type: string - sourceToTargetTmTextUnitIds: - type: object - additionalProperties: - type: integer - format: int64 - targetBranchName: - type: string - mode: - type: string - enum: - - MD5 - - EXACT - - TUIDS - pollableTask: - $ref: '#/components/schemas/PollableTask' - ImportDropConfig: - required: - - dropId - - repositoryId - type: object - properties: - repositoryId: - type: integer - format: int64 - dropId: - type: integer - format: int64 - status: - type: string - enum: - - TRANSLATION_NEEDED - - REVIEW_NEEDED - - MT_TRANSLATED - - MT_REVIEW_NEEDED - - APPROVED - - OVERRIDDEN - pollableTask: - $ref: '#/components/schemas/PollableTask' - ImportXliffBody: - type: object - properties: - repositoryId: - type: integer - format: int64 - translationKit: - type: boolean - importStatus: - type: string - enum: - - TRANSLATION_NEEDED - - REVIEW_NEEDED - - MT_TRANSLATED - - MT_REVIEW_NEEDED - - APPROVED - - OVERRIDDEN - xliffContent: - type: string - ExportDropConfig: - required: - - repositoryId - type: object - properties: - repositoryId: - type: integer - format: int64 - dropId: - type: integer - format: int64 - uploadTime: - type: string - format: date-time - pollableTask: - $ref: '#/components/schemas/PollableTask' - type: - type: string - enum: - - TRANSLATION - - REVIEW - useInheritance: - type: boolean - locales: - type: array - items: - type: string - CancelDropConfig: - required: - - dropId - type: object - properties: - dropId: - type: integer - format: int64 - pollableTask: - $ref: '#/components/schemas/PollableTask' - CommitBody_Commit: - type: object - Commit_Commit: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - authorEmail: - type: string - authorName: - type: string - sourceCreationDate: - type: integer - format: int64 - example: 1715699917000 - repository_id: - type: integer - format: int64 - CommitToPushRunBody: - type: object - properties: - repositoryId: - type: integer - format: int64 - commitName: - type: string - pushRunName: - type: string - CommitToPullRunBody: - type: object - properties: - repositoryId: - type: integer - format: int64 - commitName: - type: string - pullRunName: - type: string - CommitListWithRepositoryIdBody_Commit: - type: object - CommitListWithRepositoryIdBody_CommitDetailed: - type: object - PushRun_CommitDetailed: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - PullRun_CommitDetailed: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - BoxSDKServiceConfigEntity: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - clientId: - type: string - clientSecret: - type: string - writeOnly: true - publicKeyId: - type: string - privateKey: - type: string - writeOnly: true - privateKeyPassword: - type: string - writeOnly: true - enterpriseId: - type: string - appUserId: - type: string - rootFolderId: - type: string - rootFolderUrl: - type: string - dropsFolderId: - type: string - bootstrap: - type: boolean - validated: - type: boolean - PollableFutureBoxSDKServiceConfigEntity: - type: object - properties: - pollableTask: - $ref: '#/components/schemas/PollableTask' - SourceAsset: - type: object - properties: - repositoryId: - type: integer - format: int64 - path: - type: string - content: - type: string - branch: - type: string - branchCreatedByUsername: - type: string - branchNotifiers: - uniqueItems: true - type: array - items: - type: string - addedAssetId: - type: integer - format: int64 - pushRunName: - type: string - pollableTask: - $ref: '#/components/schemas/PollableTask' - filterConfigIdOverride: - type: string - enum: - - PROPERTIES_JAVA - - MACSTRINGSDICT_FILTER_KEY - - XCODE_XLIFF - - CSV_ADOBE_MAGENTO - - HTML_ALPHA - filterOptions: - type: array - items: - type: string - extractedContent: - type: boolean - commitHash: - type: string - XliffExportBody: - type: object - properties: - tmXliffId: - type: integer - format: int64 - content: - type: string - pollableTask: - $ref: '#/components/schemas/PollableTask' - LocalizedAssetBody: - type: object - properties: - assetId: - type: integer - format: int64 - localeId: - type: integer - format: int64 - bcp47Tag: - type: string - content: - type: string - outputBcp47tag: - type: string - filterConfigIdOverride: - type: string - enum: - - PROPERTIES_JAVA - - MACSTRINGSDICT_FILTER_KEY - - XCODE_XLIFF - - CSV_ADOBE_MAGENTO - - HTML_ALPHA - filterOptions: - type: array - items: - type: string - pullRunName: - type: string - inheritanceMode: - type: string - enum: - - REMOVE_UNTRANSLATED - - USE_PARENT - status: - type: string - enum: - - ALL - - ACCEPTED_OR_NEEDS_REVIEW - - ACCEPTED - ImportLocalizedAssetBody: - type: object - properties: - bcp47Tag: - type: string - content: - type: string - statusForEqualTarget: - type: string - enum: - - SKIPPED - - REVIEW_NEEDED - - TRANSLATION_NEEDED - - APPROVED - filterConfigIdOverride: - type: string - enum: - - PROPERTIES_JAVA - - MACSTRINGSDICT_FILTER_KEY - - XCODE_XLIFF - - CSV_ADOBE_MAGENTO - - HTML_ALPHA - filterOptions: - type: array - items: - type: string - pollableTask: - $ref: '#/components/schemas/PollableTask' - LocaleInfo: - type: object - properties: - localeId: - type: integer - format: int64 - outputBcp47tag: - type: string - MultiLocalizedAssetBody: - type: object - properties: - assetId: - type: integer - format: int64 - localeInfos: - type: array - items: - $ref: '#/components/schemas/LocaleInfo' - generateLocalizedAssetJobIds: - type: object - additionalProperties: - type: integer - format: int64 - sourceContent: - type: string - filterConfigIdOverride: - type: string - enum: - - PROPERTIES_JAVA - - MACSTRINGSDICT_FILTER_KEY - - XCODE_XLIFF - - CSV_ADOBE_MAGENTO - - HTML_ALPHA - filterOptions: - type: array - items: - type: string - pullRunName: - type: string - inheritanceMode: - type: string - enum: - - REMOVE_UNTRANSLATED - - USE_PARENT - status: - type: string - enum: - - ALL - - ACCEPTED_OR_NEEDS_REVIEW - - ACCEPTED - schedulerName: - type: string - Pageable: - type: object - properties: - page: - minimum: 0 - type: integer - format: int32 - size: - minimum: 1 - type: integer - format: int32 - sort: - type: array - items: - type: string - PageUser: - type: object - properties: - totalPages: - type: integer - format: int32 - totalElements: - type: integer - format: int64 - first: - type: boolean - last: - type: boolean - size: - type: integer - format: int32 - content: - type: array - items: - $ref: '#/components/schemas/User' - number: - type: integer - format: int32 - sort: - type: array - items: - $ref: '#/components/schemas/SortObject' - pageable: - $ref: '#/components/schemas/PageableObject' - numberOfElements: - type: integer - format: int32 - empty: - type: boolean - PageableObject: - type: object - properties: - offset: - type: integer - format: int64 - sort: - type: array - items: - $ref: '#/components/schemas/SortObject' - unpaged: - type: boolean - paged: - type: boolean - pageNumber: - type: integer - format: int32 - pageSize: - type: integer - format: int32 - SortObject: - type: object - properties: - direction: - type: string - nullHandling: - type: string - ascending: - type: boolean - property: - type: string - ignoreCase: - type: boolean - Locale_TranslationHistorySummary: - type: object - properties: - id: - type: integer - format: int64 - bcp47Tag: - type: string - TMTextUnitVariantComment_TranslationHistorySummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - severity: - type: string - enum: - - INFO - - WARNING - - ERROR - type: - type: string - enum: - - LEVERAGING - - INTEGRITY_CHECK - - QUALITY_CHECK - content: - type: string - TMTextUnitVariant_TranslationHistorySummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - content: - type: string - locale: - $ref: '#/components/schemas/Locale_TranslationHistorySummary' - comment: - type: string - status: - type: string - enum: - - TRANSLATION_NEEDED - - REVIEW_NEEDED - - MT_TRANSLATED - - MT_REVIEW_NEEDED - - APPROVED - - OVERRIDDEN - includedInLocalizedFile: - type: boolean - createdByUser: - $ref: '#/components/schemas/User_TranslationHistorySummary' - tmTextUnitVariantComments: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/TMTextUnitVariantComment_TranslationHistorySummary' - User_TranslationHistorySummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - username: - type: string - commonName: - type: string - Branch_GitBlameWithUsage: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - repository: - $ref: '#/components/schemas/Repository_GitBlameWithUsage' - name: - type: string - createdByUser: - $ref: '#/components/schemas/User_GitBlameWithUsage' - deleted: - type: boolean - screenshots: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/Screenshot_GitBlameWithUsage' - GitBlameWithUsage_GitBlameWithUsage: - type: object - properties: - usages: - uniqueItems: true - type: array - items: - type: string - textUnitName: - type: string - pluralForm: - type: string - tmTextUnitId: - type: integer - format: int64 - assetId: - type: integer - format: int64 - assetTextUnitId: - type: integer - format: int64 - thirdPartyTextUnitId: - type: string - content: - type: string - comment: - type: string - gitBlame: - $ref: '#/components/schemas/GitBlame_GitBlameWithUsage' - branch: - $ref: '#/components/schemas/Branch_GitBlameWithUsage' - screenshots: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/Screenshot_GitBlameWithUsage' - introducedBy: - type: string - isVirtual: - type: boolean - GitBlame_GitBlameWithUsage: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - authorEmail: - type: string - authorName: - type: string - commitTime: - type: string - commitName: - type: string - Repository_GitBlameWithUsage: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - ScreenshotTextUnit_GitBlameWithUsage: - type: object - properties: - id: - type: integer - format: int64 - tmTextUnit: - $ref: '#/components/schemas/TMTextUnit_GitBlameWithUsage' - Screenshot_GitBlameWithUsage: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - src: - type: string - textUnits: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/ScreenshotTextUnit_GitBlameWithUsage' - TMTextUnit_GitBlameWithUsage: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - User_GitBlameWithUsage: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - username: - type: string - commonName: - type: string - TextUnitAndWordCount: - type: object - properties: - textUnitCount: - type: integer - format: int64 - textUnitWordCount: - type: integer - format: int64 - Branch_Screenshots: - type: object - properties: - id: - type: integer - format: int64 - Locale_Screenshots: - type: object - properties: - id: - type: integer - format: int64 - ScreenshotRun_Screenshots: - type: object - properties: - id: - type: integer - format: int64 - ScreenshotTextUnit_Screenshots: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - source: - type: string - target: - type: string - renderedTarget: - type: string - numberOfMatch: - type: integer - format: int32 - tmTextUnit: - $ref: '#/components/schemas/TMTextUnit_Screenshots' - tmTextUnitVariant: - $ref: '#/components/schemas/TMTextUnitVariant_Screenshots' - Screenshot_Screenshots: - type: object - properties: - id: - type: integer - format: int64 - screenshotRun: - $ref: '#/components/schemas/ScreenshotRun_Screenshots' - branch: - $ref: '#/components/schemas/Branch_Screenshots' - locale: - $ref: '#/components/schemas/Locale_Screenshots' - src: - type: string - status: - type: string - enum: - - REJECTED - - NEEDS_REVIEW - - ACCEPTED - sequence: - type: integer - format: int64 - comment: - type: string - textUnits: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/ScreenshotTextUnit_Screenshots' - TMTextUnitVariant_Screenshots: - type: object - properties: - id: - type: integer - format: int64 - TMTextUnit_Screenshots: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - content: - type: string - Locale_RepositorySummary: - type: object - properties: - id: - type: integer - format: int64 - bcp47Tag: - type: string - RepositoryLocaleStatistic_RepositorySummary: - type: object - properties: - id: - type: integer - format: int64 - locale: - $ref: '#/components/schemas/Locale_RepositorySummary' - translatedCount: - type: integer - format: int64 - translatedWordCount: - type: integer - format: int64 - translationNeededCount: - type: integer - format: int64 - translationNeededWordCount: - type: integer - format: int64 - reviewNeededCount: - type: integer - format: int64 - reviewNeededWordCount: - type: integer - format: int64 - includeInFileCount: - type: integer - format: int64 - includeInFileWordCount: - type: integer - format: int64 - diffToSourcePluralCount: - type: integer - format: int64 - forTranslationCount: - type: integer - format: int64 - forTranslationWordCount: - type: integer - format: int64 - RepositoryLocale_RepositorySummary: - type: object - properties: - id: - type: integer - format: int64 - locale: - $ref: '#/components/schemas/Locale_RepositorySummary' - toBeFullyTranslated: - type: boolean - parentLocale: - $ref: '#/components/schemas/RepositoryLocale_RepositorySummary' - RepositoryStatistic_RepositorySummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - usedTextUnitCount: - type: integer - format: int64 - usedTextUnitWordCount: - type: integer - format: int64 - pluralTextUnitCount: - type: integer - format: int64 - pluralTextUnitWordCount: - type: integer - format: int64 - ooslaTextUnitCount: - type: integer - format: int64 - ooslaTextUnitWordCount: - type: integer - format: int64 - ooslaCreatedBefore: - type: integer - format: int64 - example: 1715699917000 - repositoryLocaleStatistics: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/RepositoryLocaleStatistic_RepositorySummary' - Repository_RepositorySummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - description: - type: string - sourceLocale: - $ref: '#/components/schemas/Locale_RepositorySummary' - repositoryLocales: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/RepositoryLocale_RepositorySummary' - repositoryStatistic: - $ref: '#/components/schemas/RepositoryStatistic_RepositorySummary' - checkSLA: - type: boolean - Branch_BranchSummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - repository: - $ref: '#/components/schemas/Repository_BranchSummary' - name: - type: string - createdByUser: - $ref: '#/components/schemas/User_BranchSummary' - deleted: - type: boolean - screenshots: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/Screenshot_BranchSummary' - Repository_BranchSummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - Screenshot_BranchSummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - User_BranchSummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - username: - type: string - commonName: - type: string - Drop_DropSummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - dropExporterConfig: - type: string - importPollableTask: - $ref: '#/components/schemas/PollableTask_DropSummary' - exportPollableTask: - $ref: '#/components/schemas/PollableTask_DropSummary' - translationKits: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/TranslationKit_DropSummary' - repository: - $ref: '#/components/schemas/Repository_DropSummary' - lastImportedDate: - type: integer - format: int64 - example: 1715699917000 - canceled: - type: boolean - createdByUser: - $ref: '#/components/schemas/User_DropSummary' - exportFailed: - type: boolean - importFailed: - type: boolean - partiallyImported: - type: boolean - Locale_DropSummary: - type: object - properties: - id: - type: integer - format: int64 - bcp47Tag: - type: string - PageDrop_DropSummary: - type: object - properties: - totalPages: - type: integer - format: int32 - totalElements: - type: integer - format: int64 - first: - type: boolean - last: - type: boolean - size: - type: integer - format: int32 - content: - type: array - items: - $ref: '#/components/schemas/Drop_DropSummary' - number: - type: integer - format: int32 - sort: - type: array - items: - $ref: '#/components/schemas/SortObject' - pageable: - $ref: '#/components/schemas/PageableObject_DropSummary' - numberOfElements: - type: integer - format: int32 - empty: - type: boolean - PageableObject_DropSummary: - type: object - PollableTask_DropSummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - allFinished: - type: boolean - Repository_DropSummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - TranslationKit_DropSummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - locale: - $ref: '#/components/schemas/Locale_DropSummary' - type: - type: string - enum: - - TRANSLATION - - REVIEW - wordCount: - type: integer - format: int64 - imported: - type: boolean - User_DropSummary: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - username: - type: string - commonName: - type: string - DeltaLocaleDataDTO: - type: object - properties: - translationsByTextUnitName: - type: object - additionalProperties: - $ref: '#/components/schemas/DeltaTranslationDTO' - DeltaMetadataDTO: - type: object - properties: - fromDate: - type: string - format: date-time - toDate: - type: string - format: date-time - DeltaResponseDTO: - type: object - properties: - metadata: - $ref: '#/components/schemas/DeltaMetadataDTO' - content: - type: object - additionalProperties: - $ref: '#/components/schemas/DeltaLocaleDataDTO' - DeltaTranslationDTO: - type: object - properties: - text: - type: string - deltaType: - type: string - enum: - - UNKNOWN - - NEW_TRANSLATION - - UPDATED_TRANSLATION - PageTextUnitVariantDeltaDTO: - type: object - properties: - totalPages: - type: integer - format: int32 - totalElements: - type: integer - format: int64 - first: - type: boolean - last: - type: boolean - size: - type: integer - format: int32 - content: - type: array - items: - $ref: '#/components/schemas/TextUnitVariantDeltaDTO' - number: - type: integer - format: int32 - sort: - type: array - items: - $ref: '#/components/schemas/SortObject' - pageable: - $ref: '#/components/schemas/PageableObject' - numberOfElements: - type: integer - format: int32 - empty: - type: boolean - TextUnitVariantDeltaDTO: - type: object - properties: - textUnitName: - type: string - bcp47Tag: - type: string - content: - type: string - deltaType: - type: string - enum: - - UNKNOWN - - NEW_TRANSLATION - - UPDATED_TRANSLATION - PageCommit_Commit: - type: object - properties: - totalPages: - type: integer - format: int32 - totalElements: - type: integer - format: int64 - first: - type: boolean - last: - type: boolean - size: - type: integer - format: int32 - content: - type: array - items: - $ref: '#/components/schemas/Commit_Commit' - number: - type: integer - format: int32 - sort: - type: array - items: - $ref: '#/components/schemas/SortObject' - pageable: - $ref: '#/components/schemas/PageableObject_Commit' - numberOfElements: - type: integer - format: int32 - empty: - type: boolean - PageableObject_Commit: - type: object - CommitToPullRun_CommitDetailed: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - pullRun: - $ref: '#/components/schemas/PullRun_CommitDetailed' - CommitToPushRun_CommitDetailed: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - pushRun: - $ref: '#/components/schemas/PushRun_CommitDetailed' - Commit_CommitDetailed: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - lastModifiedDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - authorEmail: - type: string - authorName: - type: string - sourceCreationDate: - type: integer - format: int64 - example: 1715699917000 - commitToPushRun: - $ref: '#/components/schemas/CommitToPushRun_CommitDetailed' - commitToPullRun: - $ref: '#/components/schemas/CommitToPullRun_CommitDetailed' - repository_id: - type: integer - format: int64 - PageCommit_CommitDetailed: - type: object - properties: - totalPages: - type: integer - format: int32 - totalElements: - type: integer - format: int64 - first: - type: boolean - last: - type: boolean - size: - type: integer - format: int32 - content: - type: array - items: - $ref: '#/components/schemas/Commit_CommitDetailed' - number: - type: integer - format: int32 - sort: - type: array - items: - $ref: '#/components/schemas/SortObject' - pageable: - $ref: '#/components/schemas/PageableObject_CommitDetailed' - numberOfElements: - type: integer - format: int32 - empty: - type: boolean - PageableObject_CommitDetailed: - type: object - BranchStatistic_BranchStatistic: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - branch: - $ref: '#/components/schemas/Branch_BranchStatistic' - branchTextUnitStatistics: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/BranchTextUnitStatistic_BranchStatistic' - totalCount: - type: integer - format: int64 - forTranslationCount: - type: integer - format: int64 - BranchTextUnitStatistic_BranchStatistic: - type: object - properties: - id: - type: integer - format: int64 - tmTextUnit: - $ref: '#/components/schemas/TMTextUnit_BranchStatistic' - forTranslationCount: - type: integer - format: int64 - totalCount: - type: integer - format: int64 - Branch_BranchStatistic: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - repository: - $ref: '#/components/schemas/Repository_BranchStatistic' - name: - type: string - createdByUser: - $ref: '#/components/schemas/User_BranchStatistic' - deleted: - type: boolean - screenshots: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/Screenshot_BranchStatistic' - Locale_BranchStatistic: - type: object - properties: - id: - type: integer - format: int64 - PageBranchStatistic_BranchStatistic: - type: object - properties: - totalPages: - type: integer - format: int32 - totalElements: - type: integer - format: int64 - first: - type: boolean - last: - type: boolean - size: - type: integer - format: int32 - content: - type: array - items: - $ref: '#/components/schemas/BranchStatistic_BranchStatistic' - number: - type: integer - format: int32 - sort: - type: array - items: - $ref: '#/components/schemas/SortObject' - pageable: - $ref: '#/components/schemas/PageableObject_BranchStatistic' - numberOfElements: - type: integer - format: int32 - empty: - type: boolean - PageableObject_BranchStatistic: - type: object - Repository_BranchStatistic: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - sourceLocale: - $ref: '#/components/schemas/Locale_BranchStatistic' - manualScreenshotRun: - $ref: '#/components/schemas/ScreenshotRun_BranchStatistic' - ScreenshotRun_BranchStatistic: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - ScreenshotTextUnit_BranchStatistic: - type: object - properties: - id: - type: integer - format: int64 - tmTextUnit: - $ref: '#/components/schemas/TMTextUnit_BranchStatistic' - Screenshot_BranchStatistic: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - src: - type: string - textUnits: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/ScreenshotTextUnit_BranchStatistic' - TMTextUnit_BranchStatistic: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - name: - type: string - content: - type: string - User_BranchStatistic: - type: object - properties: - id: - type: integer - format: int64 - createdDate: - type: integer - format: int64 - example: 1715699917000 - username: - type: string - commonName: - type: string - BranchTextUnitStatistic_BranchTextUnitStatistic: - type: object - properties: - id: - type: integer - format: int64 - tmTextUnit: - $ref: '#/components/schemas/TMTextUnit_BranchTextUnitStatistic' - forTranslationCount: - type: integer - format: int64 - totalCount: - type: integer - format: int64 - PageBranchTextUnitStatistic_BranchTextUnitStatistic: - type: object - properties: - totalPages: - type: integer - format: int32 - totalElements: - type: integer - format: int64 - first: - type: boolean - last: - type: boolean - size: - type: integer - format: int32 - content: - type: array - items: - $ref: '#/components/schemas/BranchTextUnitStatistic_BranchTextUnitStatistic' - number: - type: integer - format: int32 - sort: - type: array - items: - $ref: '#/components/schemas/SortObject' - pageable: - $ref: '#/components/schemas/PageableObject_BranchTextUnitStatistic' - numberOfElements: - type: integer - format: int32 - empty: - type: boolean - PageableObject_BranchTextUnitStatistic: - type: object - TMTextUnit_BranchTextUnitStatistic: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - content: - type: string - AssetDTO_AssetSummary: - type: object - Link: - type: object - properties: - href: - type: string - hreflang: - type: string - title: - type: string - type: - type: string - deprecation: - type: string - profile: - type: string - name: - type: string - templated: - type: boolean