Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public FileFormatSettingsResource deserialize(JsonParser parser, Deserialization
FileFormatSettingsResource resource = this.objectMapper.readValue(parentNode.toString(), FileFormatSettingsResource.class);

Class<? extends FileFormatSettings> classToUse;
String format = parentNode.get("format").asText();
String format = parentNode.path("format").asText();

switch (format) {
case "properties":
Expand Down Expand Up @@ -102,6 +102,22 @@ public FileFormatSettingsResource deserialize(JsonParser parser, Deserialization
case "txt":
classToUse = TxtFileFormatSettings.class;
break;
// the classes below extend OtherFileFormatSettings, so code relying on the previous fallback keeps working
case "csv":
classToUse = CsvFileFormatSettings.class;
break;
case "xlsx":
classToUse = XlsxFileFormatSettings.class;
break;
case "xliff":
classToUse = XliffFileFormatSettings.class;
break;
case "vdf":
classToUse = VdfFileFormatSettings.class;
break;
case "vsdx":
classToUse = VsdxFileFormatSettings.class;
break;
default:
classToUse = OtherFileFormatSettings.class;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.crowdin.client.projectsgroups.model.ProjectSettings;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
Expand All @@ -29,10 +30,20 @@ public Project deserialize(JsonParser p, DeserializationContext ctxt) throws IOE
List<String> fields = StreamSupport
.stream(iterable.spliterator(), false)
.collect(Collectors.toList());
Project project;
if (fields.contains("languageMapping") || fields.contains("inContext")) {
return this.objectMapper.readValue(treeNode.toString(), ProjectSettings.class);
project = this.objectMapper.readValue(treeNode.toString(), ProjectSettings.class);
} else {
return this.objectMapper.readValue(treeNode.toString(), Project.class);
project = this.objectMapper.readValue(treeNode.toString(), Project.class);
}
// the accessor-based mapper exposes the primitive "isExternal" field as "external", so map it explicitly
TreeNode isExternal = treeNode.get("isExternal");
if (project != null && isExternal != null) {
JsonToken token = isExternal.asToken();
if (token == JsonToken.VALUE_TRUE || token == JsonToken.VALUE_FALSE) {
project.setExternal(token == JsonToken.VALUE_TRUE);
}
}
return project;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public StringsExporterSettingsResource deserialize(JsonParser parser, Deserializ
this.objectMapper.readValue(parentNode.toString(), StringsExporterSettingsResource.class);

Class<? extends StringsExporterSettings> classToUse;
String format = parentNode.get("format").asText();
String format = parentNode.path("format").asText();

switch (format) {
case "android":
Expand All @@ -43,7 +43,9 @@ public StringsExporterSettingsResource deserialize(JsonParser parser, Deserializ
classToUse = XliffStringsExporterSettings.class;
break;
default:
throw new IllegalArgumentException("Format not supported by API client: " + format);
// unknown (newly added) formats fall back to the base settings class instead of failing
classToUse = StringsExporterSettings.class;
break;
}

JsonNode settingsNode = parentNode.get("settings");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,19 @@ public ResponseList<Group> listGroups(Long parentId, Integer limit, Integer offs
return listGroups(options);
}

/**
* @param options query parameters (parentId, userId, orderBy, filter, limit, offset)
* @return list of groups
* @see <ul>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.groups.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<Group> listGroups(ListGroupOptions options) throws HttpException, HttpBadRequestException {
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
"parentId", Optional.ofNullable(options.getParentId()),
"userId", Optional.ofNullable(options.getUserId()),
"orderBy", Optional.ofNullable(options.getOrderBy()),
"filter", Optional.ofNullable(options.getFilter()),
"limit", Optional.ofNullable(options.getLimit()),
"offset", Optional.ofNullable(options.getOffset())
);
Expand Down Expand Up @@ -139,6 +147,15 @@ public ResponseList<? extends Project> listProjects(Long groupId, Integer hasMan
return listProjects(options);
}

/**
* @param options query parameters (groupId, hasManagerAccess, orderBy, type, filter, userId, limit, offset).
* {@code type} and {@code userId} are supported by Crowdin only
* @return list of projects
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.getMany" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseList<? extends Project> listProjects(ListProjectOptions options) throws HttpException, HttpBadRequestException {
String orderBy = options.getOrderByList() != null
? OrderByField.generateSortParam(options.getOrderByList())
Expand All @@ -149,6 +166,8 @@ public ResponseList<? extends Project> listProjects(ListProjectOptions options)
"hasManagerAccess", Optional.ofNullable(options.getHasManagerAccess()),
"orderBy", Optional.ofNullable(orderBy),
"type", Optional.ofNullable(options.getType()),
"filter", Optional.ofNullable(options.getFilter()),
"userId", Optional.ofNullable(options.getUserId()),
"limit", Optional.ofNullable(options.getLimit()),
"offset", Optional.ofNullable(options.getOffset())
);
Expand Down Expand Up @@ -394,12 +413,15 @@ public void deleteProjectStringsExporterSettings(
/**
* @param projectId project identifier
* @param systemStringsExporterSettingsId strings exporter settings identifier
* @param request request object
* @return updated strings exporter settings resource
* @deprecated the API expects a JSON Patch document, use {@link #editProjectStringsExporterSettingsWithPatch(Long, Long, List)} instead
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.strings-exporter-settings.patch" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.strings-exporter-settings.patch" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
@Deprecated
public ResponseObject<StringsExporterSettingsResource> editProjectStringsExporterSettings(
Long projectId,
Long systemStringsExporterSettingsId,
Expand All @@ -410,6 +432,26 @@ public ResponseObject<StringsExporterSettingsResource> editProjectStringsExporte
return ResponseObject.of(responseObject.getData());
}

/**
* @param projectId project identifier
* @param systemStringsExporterSettingsId strings exporter settings identifier
* @param request JSON Patch request (supported paths: /format, /settings)
* @return updated strings exporter settings resource
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.strings-exporter-settings.patch" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.strings-exporter-settings.patch" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseObject<StringsExporterSettingsResource> editProjectStringsExporterSettingsWithPatch(
Long projectId,
Long systemStringsExporterSettingsId,
List<PatchRequest> request
) throws HttpException, HttpBadRequestException {
String url = formUrl_projectStringsExporterSettingsId(projectId, systemStringsExporterSettingsId);
StringsExporterSettingsResponseObject responseObject = this.httpClient.patch(url, request, new HttpRequestConfig(), StringsExporterSettingsResponseObject.class);
return ResponseObject.of(responseObject.getData());
}

//<editor-fold desc="Helper methods">

private String formUrl_projectStringsExporterSettings(Long projectId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ public class AddGroupRequest {
private String name;
private Long parentId;
private String description;
private Long savingsReportSettingsTemplateId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
public class AdocFileFormatSettings extends FileFormatSettings {
private Boolean contentSegmentation;
private Long srxStorageId;
private Boolean excludeIncludeDirectives;
private Boolean customSegmentation;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
public class AndroidFileFormatSettings extends FileFormatSettings {
private Boolean contentSegmentation;
private Long srxStorageId;
private Boolean customSegmentation;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
@EqualsAndHashCode(callSuper = true)
public class AndroidStringsExporterSettings extends StringsExporterSettings {
private Boolean convertPlaceholders;
private Boolean convertLineBreaks;
private Boolean useCdataForStringsWithTags;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
public class ArbFileFormatSettings extends FileFormatSettings {
private Boolean contentSegmentation;
private Long srxStorageId;
private Boolean customSegmentation;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
public class ChromeFileFormatSettings extends FileFormatSettings {
private Boolean contentSegmentation;
private Long srxStorageId;
private Boolean customSegmentation;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.crowdin.client.projectsgroups.model;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
* CSV file format settings.
* Extends {@link OtherFileFormatSettings} for backward compatibility: these settings used to be returned as {@link OtherFileFormatSettings}
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class CsvFileFormatSettings extends OtherFileFormatSettings {
private Boolean contentSegmentation;
private Long srxStorageId;
private Boolean customSegmentation;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
public class DitaFileFormatSettings extends FileFormatSettings {
private Boolean contentSegmentation;
private Long srxStorageId;
private Boolean customSegmentation;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

@Data
@EqualsAndHashCode(callSuper = true)
public class DocxFileFormatSettings extends FileFormatSettings {
Expand All @@ -14,4 +16,33 @@ public class DocxFileFormatSettings extends FileFormatSettings {
private Boolean importHiddenSlides;
private Boolean contentSegmentation;
private Long srxStorageId;
private Boolean translateDocProperties;
private Boolean translateComments;
private Boolean ignoreWhitespaceStyles;
private Boolean addTabAsCharacter;
private Boolean addLineSeparatorAsCharacter;
private String lineSeparatorReplacement;
private Boolean replaceNoBreakHyphenTag;
private Boolean ignoreSoftHyphenTag;
private List<String> complexFieldDefinitionsToExtract;
private Boolean translateWordHeadersFooters;
private Boolean translateWordGraphicName;
private Boolean translateWordGraphicDescription;
private Boolean ignoreWordFontColors;
private String wordFontColorsMinIgnoranceThreshold;
private String wordFontColorsMaxIgnoranceThreshold;
private List<String> excludeWordStyles;
private Boolean translateWordInExcludeStyleMode;
private List<String> wordHighlightColors;
private Boolean translateWordInExcludeHighlightMode;
private Boolean translateWordExcludeColors;
private List<String> wordExcludedColors;
private Boolean translateExcelCellsCopied;
private Boolean translateExcelSheetNames;
private List<String> excelExcludedColors;
private Boolean translateExcelDiagramData;
private Boolean translateExcelDrawings;
private Boolean allowWordStyleOptimization;
private Boolean translateExcelExcludeColors;
private Boolean customSegmentation;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.crowdin.client.projectsgroups.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

Expand Down Expand Up @@ -33,31 +35,87 @@ public class EnterpriseProjectRequest extends AddProjectRequest {
private Boolean delayedWorkflowStart;
private Boolean skipUntranslatedStrings;
private Integer exportWithMinApprovalsCount;
/**
* @deprecated the API expects a boolean, use {@link #exportStringsThatPassedWorkflowEnabled} instead.
* The legacy setter maps {@code 0} to {@code false} and any other value to {@code true}
*/
@Deprecated
@JsonIgnore
private Integer exportStringsThatPassedWorkflow;
@JsonProperty("exportStringsThatPassedWorkflow")
private Boolean exportStringsThatPassedWorkflowEnabled;
private Boolean normalizePlaceholder;
private Boolean qaCheckIsActive;
private Integer qaApprovalsCount;
private QaCheckCategories qaCheckCategories;
private QaCheckCategories qaChecksIgnorableCategories;
private List<Integer> customQaCheckIds;
private List<Long> externalQaCheckIds;
/**
* External QA check IDs mapped to whether a failure of the check can be ignored
*/
private Map<String, Boolean> externalQaChecksIgnorable;
private Map<String, Map<String, String>> languageMapping;
/**
* @deprecated
* @deprecated deprecated in the API, use {@link #glossaryAccessOption} instead
*/
@Deprecated
private Boolean glossaryAccess;
private String glossaryAccessOption;
private NotificationSettings notificationSettings;
private Long savingsReportSettingsTemplateId;
/**
* @deprecated no longer part of the documented API
*/
@Deprecated
private Long assistActionAiPromptId;
private Long editorSuggestionAiPromptId;
private Long qaCheckActionAiPromptId;
private Long contextReviewAiPromptId;
private List<Long> assignedStyleGuides;
private Long alignmentActionAiPromptId;
private Integer defaultTmId;
private Integer defaultGlossaryId;
private Boolean inContext;
private Boolean inContextProcessHiddenStrings;
/**
* @deprecated the API expects a language identifier string, use {@link #inContextPseudoLanguageIdValue} instead.
* This field is not sent to the API
*/
@Deprecated
@JsonIgnore
private Boolean inContextPseudoLanguageId;
@JsonProperty("inContextPseudoLanguageId")
private String inContextPseudoLanguageIdValue;
private Boolean saveMetaInfoInSource;
private Integer type;
private Boolean skipUntranslatedFiles;
private TmContextType tmContextType;
/**
* Keys are field slugs
*/
private Map<String, Object> fields;

/**
* @return 1 if enabled, 0 if disabled, null if not set
* @deprecated use {@link #exportStringsThatPassedWorkflowEnabled} instead
*/
@Deprecated
public Integer getExportStringsThatPassedWorkflow() {
if (this.exportStringsThatPassedWorkflowEnabled == null) {
return null;
}
return this.exportStringsThatPassedWorkflowEnabled ? 1 : 0;
}

/**
* @param exportStringsThatPassedWorkflow 0 to disable, any other value to enable
* @deprecated use {@link #exportStringsThatPassedWorkflowEnabled} instead
*/
@Deprecated
public void setExportStringsThatPassedWorkflow(Integer exportStringsThatPassedWorkflow) {
this.exportStringsThatPassedWorkflowEnabled = exportStringsThatPassedWorkflow == null
? null
: exportStringsThatPassedWorkflow != 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
public class FJSFileFormatSettings extends FileFormatSettings {
private Boolean contentSegmentation;
private Long srxStorageId;
private Boolean customSegmentation;
}
Loading
Loading