Skip to content

Commit

Permalink
Merge pull request #300 from AmericaSCORESBayArea/sandbox
Browse files Browse the repository at this point in the history
Fix issues caused by improper conflict handling
  • Loading branch information
AleksandrMolchagin authored Oct 27, 2024
2 parents b9a30dc + 17e208e commit dcb40cd
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 90 deletions.
4 changes: 0 additions & 4 deletions cloudhub-deployment.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# salesforce-data-api

## Automatic Deployment via Github Actions
The [Actions associated with this repo](https://github.com/AmericaSCORESBayArea/salesforce-data-api/actions/workflows/on-push-build-and-deploy.yml) cofigure and deploy to various instances.
#### _Need more explanation here_

## Manual Deployment Process

### Deploying to Sandbox
Expand Down
15 changes: 12 additions & 3 deletions mule-artifact.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"secureProperties": ["sfdc.password", "sfdc.tkn", "typeform.tkn", "typeform.clientid", "typeform.clientsecret"],
"secureProperties": [
"sfdc.password",
"sfdc.tkn",
"typeform.tkn",
"typeform.clientid",
"typeform.clientsecret"
],
"redeploymentEnabled": true,
"name": "secure-properties",
"minMuleVersion": "4.6.8",
Expand All @@ -13,5 +19,8 @@
"bundleDescriptorLoader": {
"id": "mule",
"attributes": {}
}
}
},
"javaSpecificationVersions": [
"17"
]
}
50 changes: 25 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,37 +96,13 @@
<version>1.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-http-connector</artifactId>
<version>1.7.3</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-sockets-connector</artifactId>
<version>1.2.3</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>6c091e72-50d1-49ac-b04d-ee5bb9bc9dbd</groupId>
<artifactId>salesforce-data-api</artifactId>
<version>4.0.3</version>
<version>4.0.4</version>
<classifier>raml</classifier>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-apikit-module</artifactId>
<version>1.9.1</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>com.mulesoft.connectors</groupId>
<artifactId>mule-salesforce-connector</artifactId>
<version>10.18.3</version>
<classifier>mule-plugin</classifier>
</dependency>
<!-- <dependency>
<groupId>com.mulesoft.munit</groupId>
<artifactId>munit-tools</artifactId>
Expand All @@ -141,6 +117,30 @@
<classifier>mule-plugin</classifier>
<scope>test</scope>
</dependency> -->
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-http-connector</artifactId>
<version>1.9.3</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-sockets-connector</artifactId>
<version>1.2.4</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-apikit-module</artifactId>
<version>1.10.4</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>com.mulesoft.connectors</groupId>
<artifactId>mule-salesforce-connector</artifactId>
<version>10.20.3</version>
<classifier>mule-plugin</classifier>
</dependency>
</dependencies>
<repositories>
<repository>
Expand Down
93 changes: 80 additions & 13 deletions src/main/mule/enrollments.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,33 +389,100 @@ output application/json
doc:id="def4e728-8bf5-45ff-85ac-c213895d9de4"
name="exit-flow" />
</flow>

<!-- delete flow -->
<flow name="delete:\enrollments:application\json:salesforce-data-api-config" doc:id="7f025bf8-4fc6-4557-9905-879b551ef142" >
<flow-ref doc:name="entry-flow" doc:id="0f3ac219-0a9d-45e8-9f56-78bd80d10a18" name="entry-flow" />
<logger level="INFO" doc:name="Log entry-flow" doc:id="e19144a5-1de4-48e7-ba5c-6fd97100f910" message="Method and Request Path stored as vars: method=#[vars.method], request path=#[vars.requestPath]." />
<ee:transform doc:name="Transform Message" doc:id="f73ccde1-d7ca-41d8-90a1-d9feeb9f4fd1" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
payload map ( payload01 , indexOfPayload01 ) -> {
Id: payload01.EnrollmentId
}]]></ee:set-payload>
output application/java
---
payload map ( payload01 , indexOfPayload01 ) -> {
Id: payload01.EnrollmentId
}]]>
</ee:set-payload>
</ee:message>
</ee:transform>
<salesforce:delete doc:name="Delete" doc:id="85d7c28c-124a-472b-bfa1-541ab9396aff" config-ref="Salesforce_Config">
<salesforce:ids ><![CDATA[#[payload.Id]]]></salesforce:ids>
</salesforce:delete>
<ee:transform doc:name="Transform Message" doc:id="7ff0dfbc-49fc-4b13-9fd5-e7f45ecd92a9" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
message: "Enrollment/s deleted successfully"
}]]></ee:set-payload>
<ee:transform doc:name="Transform Message" doc:id="903290a7-d881-492c-801e-80979a824387">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]>
</ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" message='Post delete payload: #[payload]' doc:name="Logger" doc:id="vvxdmx" />
<choice
doc:name="Enrollment deletion successful?"
doc:id="ee82b0c8-2c07-4456-a51a-80fba2c1e448">
<when expression="#[payload.successful]">
<ee:transform
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd"
doc:name="Success Response"
doc:id="291c1946-dfea-4dd5-aaba-c30a5a5b4311">
<ee:message>
<ee:set-payload>
<![CDATA[%dw 2.0
output application/json
---
{
message: "Enrollment/s deleted successfully"
}]]>
</ee:set-payload>
</ee:message>
<ee:variables>
<ee:set-variable variableName="httpStatus"><![CDATA[200]]></ee:set-variable>
</ee:variables>
</ee:transform>
</when>
<when expression="#[sizeOf(payload.items) == sizeOf(payload.items filter ((item) -> item.successful == false))]">
<ee:transform
doc:name="Create Error Response"
doc:id="aab7a4b8-dfff-4774-bf3e-acdbb63ea782">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{
message: "Enrollment/s Not Found"
}]]>
</ee:set-payload>
</ee:message>
<ee:variables>
<ee:set-variable variableName="httpStatus"><![CDATA[404]]></ee:set-variable>
</ee:variables>
</ee:transform>
</when>
<otherwise>
<ee:transform
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd"
doc:name="Partial Success Response"
doc:id="291c1937-dfea-4dd5-aaba-c30a5a5b4311">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{
message: "Partial Success",
deleted: payload.items filter ((item) -> item.payload.success == true) map ((item) -> item.payload.id),
not_found: payload.items filter ((item) -> item.payload.success == false) map ((item) -> if (item.payload.id == null) "unknown id" else item.payload.id)
}]]>
</ee:set-payload>
</ee:message>
<ee:variables>
<ee:set-variable variableName="httpStatus"><![CDATA[206]]></ee:set-variable>
</ee:variables>
</ee:transform>
</otherwise>
</choice>
<logger level="INFO" doc:name="Log Created Response" doc:id="1cee3392-3963-4ec2-a6d9-17b8509d2102" message="#[payload]" />
<!-- <set-property propertyName="http.status" value="#[vars.httpStatus]" doc:name="Set HTTP Status" /> -->
<flow-ref doc:name="exit flow" doc:id="d6d6a729-bac5-4e4f-b490-96c7029afbce" name="exit-flow" />
</flow>
</mule>
8 changes: 6 additions & 2 deletions src/main/mule/global.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit="http://www.mulesoft.org/schema/mule/mule-apikit" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:salesforce="http://www.mulesoft.org/schema/mule/salesforce" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/mule-apikit http://www.mulesoft.org/schema/mule/mule-apikit/current/mule-apikit.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/salesforce http://www.mulesoft.org/schema/mule/salesforce/current/mule-salesforce.xsd">
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit="http://www.mulesoft.org/schema/mule/mule-apikit" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:salesforce="http://www.mulesoft.org/schema/mule/salesforce" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:api-gateway="http://www.mulesoft.org/schema/mule/api-gateway"
xmlns:tls="http://www.mulesoft.org/schema/mule/tls" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/mule-apikit http://www.mulesoft.org/schema/mule/mule-apikit/current/mule-apikit.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/salesforce http://www.mulesoft.org/schema/mule/salesforce/current/mule-salesforce.xsd
http://www.mulesoft.org/schema/mule/api-gateway http://www.mulesoft.org/schema/mule/api-gateway/current/mule-api-gateway.xsd
http://www.mulesoft.org/schema/mule/tls http://www.mulesoft.org/schema/mule/tls/current/mule-tls.xsd">
<http:listener-config name="salesforce-data-api-httpListenerConfig">
<http:listener-connection host="${http.listener.host}" port="${http.listener.port}"></http:listener-connection>
</http:listener-config>
Expand All @@ -7,4 +11,4 @@
<salesforce:basic-connection password="${sfdc.password}" securityToken="${sfdc.tkn}" url="${sfdc.url}" username="${sfdc.user}"></salesforce:basic-connection>
</salesforce:sfdc-config>
<configuration-properties doc:id="0863edff-f537-40bd-b6de-0d4d7c3d55db" doc:name="Configuration properties" file="properties/${env}.properties"></configuration-properties>
</mule>
</mule>
105 changes: 65 additions & 40 deletions src/main/mule/regions.xml
Original file line number Diff line number Diff line change
@@ -1,54 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:salesforce="http://www.mulesoft.org/schema/mule/salesforce" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/salesforce http://www.mulesoft.org/schema/mule/salesforce/current/mule-salesforce.xsd">
<flow name="get:\regions:salesforce-data-api-config" doc:id="166faefb-233d-4d0a-8703-d5d06b629d7d" >
<flow-ref doc:name="entry-flow" doc:id="027e6ede-aebc-48ce-bd8a-efb07a516e9c" name="entry-flow" />
<salesforce:query doc:name="Query" doc:id="d5b03749-da65-46ae-a1c3-7293f1110e12" config-ref="Salesforce_Config" >
<salesforce:salesforce-query ><![CDATA[SELECT Region__c FROM Account GROUP BY Region__c]]></salesforce:salesforce-query>
</salesforce:query>
<ee:transform doc:name="Transform Message1" doc:id="c9c90255-2681-4e9c-b3c3-e72557a6bd8f" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:salesforce="http://www.mulesoft.org/schema/mule/salesforce" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/salesforce http://www.mulesoft.org/schema/mule/salesforce/current/mule-salesforce.xsd">
<flow doc:id="166faefb-233d-4d0a-8703-d5d06b629d7d" name="get:\regions:salesforce-data-api-config">
<flow-ref doc:id="027e6ede-aebc-48ce-bd8a-efb07a516e9c" doc:name="entry-flow" name="entry-flow"></flow-ref>
<salesforce:query config-ref="Salesforce_Config" doc:id="d5b03749-da65-46ae-a1c3-7293f1110e12" doc:name="Query">
<salesforce:salesforce-query>
<![CDATA[SELECT Region__c FROM Account GROUP BY Region__c]]>
</salesforce:salesforce-query>
</salesforce:query>
<ee:transform doc:id="c9c90255-2681-4e9c-b3c3-e72557a6bd8f" doc:name="Transform Message1">
<ee:message>
<ee:set-payload>
<![CDATA[%dw 2.0
output application/json
---
payload map ( payload01 ,indexOfPayload01 ) -> {
RegionName: payload01.Region__c as String default ""
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<flow-ref doc:name="exit-flow" doc:id="65eed082-9f5b-43f4-8ae6-15be0b79ca52" name="exit-flow" />
</flow>
<flow name="get:\regions\(regionName)\schoolsites:salesforce-data-api-config" doc:id="84da70e8-dfac-4f19-b9fb-c64587e388b2" >
<flow-ref doc:name="entry-flow" doc:id="cd532f25-1f5a-42cd-aa5d-50f0616e6927" name="entry-flow" />
<ee:transform doc:name="Transform Message" doc:id="b82de028-833e-4a66-ac1e-1527ee628f67" >
<ee:message />
<ee:variables >
<ee:set-variable variableName="region" ><![CDATA[attributes.uriParams.'regionName']]></ee:set-variable>
</ee:variables>
</ee:transform>
<salesforce:query doc:name="Query" doc:id="76559089-3881-4d75-937f-1d58c0150f14" config-ref="Salesforce_Config" >
<salesforce:salesforce-query ><![CDATA[SELECT Id, Name FROM Account WHERE Region__C = ':region']]></salesforce:salesforce-query>
<salesforce:parameters ><![CDATA[#[output application/java
}]]>
</ee:set-payload>
</ee:message>
</ee:transform>
<flow-ref doc:id="65eed082-9f5b-43f4-8ae6-15be0b79ca52" doc:name="exit-flow" name="exit-flow"></flow-ref>
</flow>
<flow doc:id="84da70e8-dfac-4f19-b9fb-c64587e388b2" name="get:\regions\(regionName)\schoolsites:salesforce-data-api-config">
<flow-ref doc:id="cd532f25-1f5a-42cd-aa5d-50f0616e6927" doc:name="entry-flow" name="entry-flow"></flow-ref>
<ee:transform doc:id="b82de028-833e-4a66-ac1e-1527ee628f67" doc:name="Transform Message">
<ee:message></ee:message>
<ee:variables>
<ee:set-variable variableName="region">
<![CDATA[attributes.uriParams.'regionName']]>
</ee:set-variable>
</ee:variables>
</ee:transform>
<salesforce:query config-ref="Salesforce_Config" doc:id="76559089-3881-4d75-937f-1d58c0150f14" doc:name="Query">
<salesforce:salesforce-query>
<![CDATA[SELECT Id, Name FROM Account WHERE Region__C = ':region']]>
</salesforce:salesforce-query>
<salesforce:parameters>
<![CDATA[#[output application/java
---
{
region : vars.region
}]]]></salesforce:parameters>
</salesforce:query>
<ee:transform doc:name="Transform Message1" doc:id="85f0ef8b-4719-423e-8f42-95a7a31fd326" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
}]]]>
</salesforce:parameters>
</salesforce:query>
<ee:transform doc:id="85f0ef8b-4719-423e-8f42-95a7a31fd326" doc:name="Transform Message1">
<ee:message>
<ee:set-payload>
<![CDATA[%dw 2.0
output application/json
---
payload map ( payload01 ,indexOfPayload01 ) -> {
Id: payload01.Id as String default "",
Name: payload01.Name as String default "",
}]]></ee:set-payload>
</ee:message>
}]]>
</ee:set-payload>
</ee:message>
</ee:transform>
<flow-ref doc:id="25cb019b-648a-4e65-bd61-95bcd6731dd7" doc:name="exit-flow" name="exit-flow"></flow-ref>
</flow>
<flow name="get:\regions\active">
<flow-ref doc:id="cd532f25-1f5a-42cd-aa5d-50f061626927" doc:name="entry-flow" name="entry-flow"></flow-ref>
<salesforce:query config-ref="Salesforce_Config" doc:name="Retrieve Active Regions" doc:id="urqtug" >
<salesforce:salesforce-query><![CDATA[
SELECT Id, Value, Label, DurableId, EntityParticleId, ValidFor, IsActive FROM PicklistValueInfo WHERE EntityParticle.EntityDefinition.QualifiedApiName = 'Account' AND EntityParticle.QualifiedApiName = 'Region__c' AND isActive = TRUE
]]></salesforce:salesforce-query>
</salesforce:query>
<ee:transform doc:name="Set Payload" doc:id="b82de028-833e-4a66-ac1e-1527ee128f67">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload map ( payload01 ,indexOfPayload01 ) -> {
RegionName: payload01.Value as String default ""
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<flow-ref doc:name="exit-flow" doc:id="25cb019b-648a-4e65-bd61-95bcd6731dd7" name="exit-flow" />
</flow>
<flow-ref doc:id="25cb019b-618a-4e65-bd61-95bcd6731dd7" doc:name="exit-flow" name="exit-flow"></flow-ref>
</flow>
</mule>
12 changes: 12 additions & 0 deletions src/main/mule/tls-context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tls="http://www.mulesoft.org/schema/mule/tls"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/tls http://www.mulesoft.org/schema/mule/tls/current/mule-tls.xsd">

<tls:context name="tls-context">
<tls:key-store path="keystore.jks" keyPassword="${keystore.key.password}" password="${keystore.password}" />
</tls:context>

</mule>
Loading

0 comments on commit dcb40cd

Please sign in to comment.