Skip to content

Commit 589e170

Browse files
committed
Release 2.6.0
1 parent 12ae139 commit 589e170

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

src/main/java/io/simplelocalize/cli/client/SimpleLocalizeUriFactory.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ public SimpleLocalizeUriFactory(String baseUrl)
1616
this.baseUrl = baseUrl;
1717
}
1818

19-
URI buildSendKeysURI()
20-
{
21-
return URI.create(baseUrl + "/cli/v1/keys");
22-
}
23-
2419
URI buildDownloadUri(DownloadRequest downloadRequest)
2520
{
2621
String endpointUrl = baseUrl + "/cli/v2/download?downloadFormat=" + downloadRequest.format();
@@ -37,6 +32,12 @@ URI buildDownloadUri(DownloadRequest downloadRequest)
3732
endpointUrl += "&downloadOptions=" + String.join(",", downloadOptions);
3833
}
3934

35+
String namespace = downloadRequest.namespace();
36+
if (StringUtils.isNotEmpty(namespace))
37+
{
38+
endpointUrl += "&namespace=" + namespace;
39+
}
40+
4041
String customerId = downloadRequest.customerId();
4142
if (StringUtils.isNotEmpty(customerId))
4243
{

src/main/java/io/simplelocalize/cli/client/dto/DownloadRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.List;
66

77
@Builder(setterPrefix = "with")
8-
public record DownloadRequest(String format, String languageKey, String customerId, List<String> options, String sort)
8+
public record DownloadRequest(String format, String languageKey, String customerId, String namespace,
9+
List<String> options, String sort)
910
{
1011
}

src/main/java/io/simplelocalize/cli/command/DownloadCommand.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.io.IOException;
1313
import java.util.ArrayList;
1414
import java.util.List;
15+
import java.util.Objects;
1516

1617
public class DownloadCommand implements CliCommand
1718
{
@@ -49,6 +50,7 @@ public void invoke() throws IOException, InterruptedException
4950
DownloadRequest downloadRequest = DownloadRequest.builder()
5051
.withFormat(downloadFormat)
5152
.withOptions(downloadOptions)
53+
.withNamespace(namespace)
5254
.withCustomerId(customerId)
5355
.withLanguageKey(languageKey)
5456
.withSort(sort)
@@ -59,7 +61,8 @@ public void invoke() throws IOException, InterruptedException
5961
log.info("Customer ID: {}", customerId);
6062
}
6163

62-
if (StringUtils.isNotEmpty(namespace))
64+
boolean hasNamespace = StringUtils.isNotEmpty(namespace);
65+
if (hasNamespace)
6366
{
6467
log.info("Namespace: {}", namespace);
6568
}
@@ -74,11 +77,19 @@ public void invoke() throws IOException, InterruptedException
7477
}
7578
log.info("Download options: {}", downloadOptions);
7679
List<DownloadableFile> downloadableFiles = client.fetchDownloadableFiles(downloadRequest);
80+
int downloadedFilesCounter = 0;
7781
for (DownloadableFile downloadableFile : downloadableFiles)
7882
{
83+
boolean isNamespaceMatches = Objects.equals(downloadableFile.namespace(), namespace);
84+
if (hasNamespace && !isNamespaceMatches)
85+
{
86+
log.info("Skipping file download for namespace = {}", downloadableFile.namespace());
87+
continue;
88+
}
7989
client.downloadFile(downloadableFile, downloadPath);
90+
downloadedFilesCounter++;
8091
}
81-
log.info("Downloaded {} files from SimpleLocalize", downloadableFiles.size());
92+
log.info("Downloaded {} file(s) from SimpleLocalize", downloadedFilesCounter);
8293
}
8394

8495
}

src/main/java/io/simplelocalize/cli/command/UploadCommand.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,7 @@ public void invoke() throws IOException, InterruptedException
4141
uploadPath = WindowsUtils.convertToWindowsPath(uploadPath);
4242
}
4343

44-
List<FileToUpload> filesToUpload;
45-
try
46-
{
47-
filesToUpload = fileListReader.findFilesToUpload(uploadPath);
48-
} catch (IOException e)
49-
{
50-
log.error("Matching files could not be found at {}", uploadPath, e);
51-
throw new IllegalArgumentException("Matching files could not be found", e);
52-
}
53-
54-
44+
List<FileToUpload> filesToUpload = fileListReader.findFilesToUpload(uploadPath);
5545
String uploadFormat = configuration.getUploadFormat();
5646
String customerId = configuration.getCustomerId();
5747
List<String> uploadOptions = configuration.getUploadOptions();
@@ -76,13 +66,14 @@ public void invoke() throws IOException, InterruptedException
7666
log.info("Dry run mode enabled, no files will be uploaded");
7767
}
7868

69+
int uploadedFilesCounter = 0;
7970
for (FileToUpload fileToUpload : filesToUpload)
8071
{
8172
Path path = fileToUpload.path();
8273
long length = path.toFile().length();
8374
if (length == 0)
8475
{
85-
log.warn("Skipping empty file: {}", path);
76+
log.warn("Skipping empty file = {}", path);
8677
continue;
8778
}
8879

@@ -96,7 +87,7 @@ public void invoke() throws IOException, InterruptedException
9687
String language = fileToUpload.language();
9788
if (hasFileLanguageKey && hasConfigurationLanguageKey && !isLanguageMatching)
9889
{
99-
log.info("Skipping '{}' language, file: {}", language, path);
90+
log.info("Skipping '{}' language = {}", language, path);
10091
continue;
10192
}
10293

@@ -109,7 +100,7 @@ public void invoke() throws IOException, InterruptedException
109100
boolean isMultiLanguage = isMultiLanguage(configuration);
110101
if (!hasFileLanguageKey && !hasConfigurationLanguageKey && !isMultiLanguage)
111102
{
112-
log.info("Language key not present in '--uploadPath' nor '--languageKey' parameter, file: {}", path);
103+
log.info("Language key not present in '--uploadPath' nor '--languageKey' parameter = {}", path);
113104
}
114105

115106
String effectiveNamespace = fileToUpload.namespace();
@@ -133,12 +124,13 @@ public void invoke() throws IOException, InterruptedException
133124
{
134125
log.info("Uploading file, language=[{}] namespace=[{}] = {}", effectiveLanguageKey, effectiveNamespace, path);
135126
client.uploadFile(uploadRequest);
127+
uploadedFilesCounter++;
136128
}
137129
}
138130

139131
if (!isDryRun)
140132
{
141-
log.info("Uploaded {} file(s) to SimpleLocalize", filesToUpload.size());
133+
log.info("Uploaded {} file(s) to SimpleLocalize", uploadedFilesCounter);
142134
}
143135
}
144136

0 commit comments

Comments
 (0)