Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.

Commit 3bc5925

Browse files
SLDSS-5181 support for retrievalType param as part of a file/get
request.
1 parent 79c8b3f commit 3bc5925

9 files changed

Lines changed: 18 additions & 10 deletions

File tree

1.88 MB
Binary file not shown.

api-sdk/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>smartling</groupId>
66
<artifactId>smartling-api-sdk</artifactId>
7-
<version>0.7.0</version>
7+
<version>0.8.0</version>
88
<packaging>jar</packaging>
99

1010
<build>

api-sdk/src/main/java/com/smartling/api/sdk/file/FileApiClientAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ public interface FileApiClientAdapter
4747
*
4848
* @param fileUri the identifier of the file
4949
* @param locale the locale to retrieve the translation for, or null to request the original file.
50-
* @param includePendingTranslations include pending translations in the returned file contents.
50+
* @param retrievalType flag indicating the type of file retrieval being requested. Can be null.
5151
* @return {@link StringResponse} the contents of the requested file along with the encoding of the file.
5252
* @throws FileApiException if an exception has occurred or non success is returned from the Smartling Translation API.
5353
*/
54-
StringResponse getFile(String fileUri, String locale, boolean includePendingTranslations) throws FileApiException;
54+
StringResponse getFile(String fileUri, String locale, RetrievalType retrievalType) throws FileApiException;
5555

5656
/**
5757
* Get the listing of translated files for the specified locale.

api-sdk/src/main/java/com/smartling/api/sdk/file/FileApiClientAdapterImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import static com.smartling.api.sdk.file.FileApiParams.TIMESTAMP_AFTER;
2828
import static com.smartling.api.sdk.file.FileApiParams.TIMESTAMP_BEFORE;
2929
import static com.smartling.api.sdk.file.FileApiParams.URI_MASK;
30-
import static com.smartling.api.sdk.file.FileApiParams.INCLUDE_PENDING_TRANSLATIONS;
30+
import static com.smartling.api.sdk.file.FileApiParams.RETRIEVAL_TYPE;
3131

3232
import com.google.gson.Gson;
3333
import com.google.gson.reflect.TypeToken;
@@ -130,10 +130,10 @@ public FileApiClientAdapterImpl(String baseApiUrl, String apiKey, String project
130130
this.projectId = projectId;
131131
}
132132

133-
public StringResponse getFile(String fileUri, String locale, boolean includePendingTranslations) throws FileApiException
133+
public StringResponse getFile(String fileUri, String locale, RetrievalType retrievalType) throws FileApiException
134134
{
135135
String params = buildParamsQuery(new BasicNameValuePair(FILE_URI, fileUri), new BasicNameValuePair(LOCALE, locale),
136-
new BasicNameValuePair(INCLUDE_PENDING_TRANSLATIONS, Boolean.valueOf(includePendingTranslations).toString()));
136+
new BasicNameValuePair(RETRIEVAL_TYPE, null == retrievalType ? null : retrievalType.name()));
137137
HttpGet getRequest = createHttpGetRequest(GET_FILE_API_URL, params);
138138
StringResponse response = executeHttpcall(getRequest);
139139

api-sdk/src/main/java/com/smartling/api/sdk/file/FileApiParams.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ public class FileApiParams
3333
public static final String CONDITIONS = "conditions";
3434
public static final String ORDERBY = "orderBy";
3535
public static final String FILE = "file";
36-
public static final String INCLUDE_PENDING_TRANSLATIONS = "includePendingTranslations";
36+
public static final String RETRIEVAL_TYPE = "retrievalType";
3737
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.smartling.api.sdk.file;
2+
3+
public enum RetrievalType
4+
{
5+
PUBLISHED,
6+
PENDING,
7+
PSEUDO;
8+
}

api-sdk/src/main/java/com/smartling/api/sdk/file/commandline/RetrieveFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected static File retrieve(String[] args) throws FileApiException, IOExcepti
6565

6666
File file = new File(retrieveFileParams.getPathToFile());
6767
FileApiClientAdapter smartlingFAPI = new FileApiClientAdapterImpl(retrieveFileParams.isProductionMode(), retrieveFileParams.getApiKey(), retrieveFileParams.getProjectId());
68-
StringResponse response = smartlingFAPI.getFile(file.getName(), retrieveFileParams.getLocale(), false);
68+
StringResponse response = smartlingFAPI.getFile(file.getName(), retrieveFileParams.getLocale(), null);
6969

7070
File translatedFile = new File(getTranslatedFilePath(file, retrieveFileParams.getLocale(), retrieveFileParams.getPathToStoreFile()));
7171
FileUtils.writeStringToFile(translatedFile, response.getContents(), response.getEncoding());

api-sdk/src/test/java/com/smartling/api/sdk/file/FileApiClientAdapterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void testFileActions() throws FileApiException, IOException
6565
FileApiTestHelper.validateSuccessUpload(uploadFileResponse);
6666

6767
// /file/get
68-
StringResponse fileContents = fileApiClientAdapter.getFile(fileUri, null, false);
68+
StringResponse fileContents = fileApiClientAdapter.getFile(fileUri, null, null);
6969
assertEquals(FileUtils.readFileToString(fileForUpload), fileContents.getContents());
7070

7171
// /file/list

example/SmartlingApiExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void main(String args[]) throws FileApiException
4747
System.out.println(fileStatusResponse);
4848

4949
// get the file back, including any translations that have been published.
50-
StringResponse translatedContent = smartlingFAPI.getFile(getFileUri(file), LOCALE, false);
50+
StringResponse translatedContent = smartlingFAPI.getFile(getFileUri(file), LOCALE, RetrievalType.PUBLISHED);
5151
System.out.println(translatedContent.getContents());
5252
}
5353

0 commit comments

Comments
 (0)