Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BLasan committed Aug 16, 2024
1 parent 5e2ddd9 commit 7d98fb2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3104,6 +3104,7 @@ public enum ConfigType {
public static final String SYNAPSE_POLICY_DEFINITION_EXTENSION_XML = ".xml";
public static final String CC_POLICY_DEFINITION_EXTENSION = ".gotmpl";
public static final String YAML_CONTENT_TYPE = "yaml";
public static final String J2_CONTENT_TYPE = "j2";
public static final String COMMON_OPERATION_POLICY_SPECIFICATIONS_LOCATION = "repository" + File.separator
+ "resources" + File.separator + "operation_policies" + File.separator + "specifications";
public static final String COMMON_OPERATION_POLICY_DEFINITIONS_LOCATION = "repository" + File.separator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public Response addCommonOperationPolicy(InputStream policySpecFileInputStream,
if (org.apache.commons.lang3.StringUtils.isBlank(fileContentType)) {
fileContentType = policySpecFileDetail.getContentType().toString();
}

if (APIConstants.YAML_CONTENT_TYPE.equals(fileContentType)) {
jsonContent = CommonUtil.yamlToJson(jsonContent);
}
Expand All @@ -107,6 +108,14 @@ public Response addCommonOperationPolicy(InputStream policySpecFileInputStream,
.prepareOperationPolicyData(policySpecification, organization);

if (synapsePolicyDefinitionFileInputStream != null) {
String defFileName = synapsePolicyDefinitionFileDetail.getDataHandler().getName();
String defFileContentType = FilenameUtils.getExtension(defFileName);
if (org.apache.commons.lang3.StringUtils.isBlank(defFileContentType)) {
defFileContentType = synapsePolicyDefinitionFileDetail.getContentType().toString();
}
if (!APIConstants.J2_CONTENT_TYPE.equals(defFileContentType)) {
throw new APIManagementException("Unsupported file type for Operation Policy");
}
String synapsePolicyDefinition =
RestApiPublisherUtils.readInputStream(synapsePolicyDefinitionFileInputStream,
synapsePolicyDefinitionFileDetail);
Expand All @@ -117,6 +126,14 @@ public Response addCommonOperationPolicy(InputStream policySpecFileInputStream,
}

if (ccPolicyDefinitionFileInputStream != null) {
String defFileName = synapsePolicyDefinitionFileDetail.getDataHandler().getName();
String defFileContentType = FilenameUtils.getExtension(defFileName);
if (org.apache.commons.lang3.StringUtils.isBlank(defFileContentType)) {
defFileContentType = synapsePolicyDefinitionFileDetail.getContentType().toString();
}
if (!APIConstants.CC_POLICY_DEFINITION_EXTENSION.equals(defFileContentType)) {
throw new APIManagementException("Unsupported file type for Operation Policy");
}
String choreoConnectPolicyDefinition = RestApiPublisherUtils
.readInputStream(ccPolicyDefinitionFileInputStream, ccPolicyDefinitionFileDetail);
ccPolicyDefinition = new OperationPolicyDefinition();
Expand Down

0 comments on commit 7d98fb2

Please sign in to comment.