f5e625a1 by acetousk

Rename resourceId to htmlResource and grapesResource and tidy up comments and code

1 parent b0231d7f
...@@ -13,13 +13,8 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -13,13 +13,8 @@ along with this software (see the LICENSE.md file). If not, see
13 <http://creativecommons.org/publicdomain/zero/1.0/>. 13 <http://creativecommons.org/publicdomain/zero/1.0/>.
14 --> 14 -->
15 <entity-facade-xml type="seed-initial"> 15 <entity-facade-xml type="seed-initial">
16 <!-- NOTE: subscreen configuration is now in the MoquiConf.xml file instead of DB records
17 <moqui.screen.SubscreensItem screenLocation="component://webroot/screen/webroot/apps.xml" subscreenName="mjml" menuTitle="Example"
18 menuIndex="97" menuInclude="Y" subscreenLocation="component://mjml/screen/MjmlApp.xml"/>
19 -->
20
21 <!-- Artifact group for all of the Moqui Mjml application via the MoquiMjmlApp screen (the root screen for the app) --> 16 <!-- Artifact group for all of the Moqui Mjml application via the MoquiMjmlApp screen (the root screen for the app) -->
22 <moqui.security.ArtifactGroup artifactGroupId="MOQUI_MJML_APP" description="Moqui Mjml App (via root screen)"/> 17 <moqui.security.ArtifactGroup artifactGroupId="MOQUI_MJML_APP" description="Moqui Mjml App"/>
23 <moqui.security.ArtifactGroupMember artifactGroupId="MOQUI_MJML_APP" artifactTypeEnumId="AT_XML_SCREEN" 18 <moqui.security.ArtifactGroupMember artifactGroupId="MOQUI_MJML_APP" artifactTypeEnumId="AT_XML_SCREEN"
24 inheritAuthz="Y" artifactName="component://moqui-mjml/screen/MjmlApp.xml"/> 19 inheritAuthz="Y" artifactName="component://moqui-mjml/screen/MjmlApp.xml"/>
25 <!-- Full permissions for the ADMIN user group --> 20 <!-- Full permissions for the ADMIN user group -->
...@@ -27,7 +22,7 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -27,7 +22,7 @@ along with this software (see the LICENSE.md file). If not, see
27 authzTypeEnumId="AUTHZT_ALWAYS" authzActionEnumId="AUTHZA_ALL"/> 22 authzTypeEnumId="AUTHZT_ALWAYS" authzActionEnumId="AUTHZA_ALL"/>
28 23
29 <!-- Artifact group for all of the Moqui Mjml REST API via the mjml resource (the root resource) --> 24 <!-- Artifact group for all of the Moqui Mjml REST API via the mjml resource (the root resource) -->
30 <moqui.security.ArtifactGroup artifactGroupId="MOQUI_MJML_API" description="Example REST API (via root resource)"/> 25 <moqui.security.ArtifactGroup artifactGroupId="MOQUI_MJML_API" description="Moqui MJML REST API"/>
31 <moqui.security.ArtifactGroupMember artifactGroupId="MOQUI_MJML_API" artifactTypeEnumId="AT_REST_PATH" 26 <moqui.security.ArtifactGroupMember artifactGroupId="MOQUI_MJML_API" artifactTypeEnumId="AT_REST_PATH"
32 inheritAuthz="Y" artifactName="/moqui-mjml/mjml"/> 27 inheritAuthz="Y" artifactName="/moqui-mjml/mjml"/>
33 <!-- Full permissions for the ADMIN user group --> 28 <!-- Full permissions for the ADMIN user group -->
......
...@@ -20,17 +20,9 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -20,17 +20,9 @@ along with this software (see the LICENSE.md file). If not, see
20 <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="50" resourceTypeEnumId="STRT_STYLESHEET" resourceValue="/mjmlstatic/css/grapes.min.css"/> 20 <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="50" resourceTypeEnumId="STRT_STYLESHEET" resourceValue="/mjmlstatic/css/grapes.min.css"/>
21 <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="52" resourceTypeEnumId="STRT_STYLESHEET" resourceValue="/mjmlstatic/css/grapesjs-mjml.css"/> 21 <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="52" resourceTypeEnumId="STRT_STYLESHEET" resourceValue="/mjmlstatic/css/grapesjs-mjml.css"/>
22 22
23 <delete-moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="10" resourceTypeEnumId="STRT_SCRIPT" resourceValue="/js/MoquiLib.js"/>
24 <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="51" resourceTypeEnumId="STRT_SCRIPT" resourceValue="/mjmlstatic/js/grapes.min.js"/> 23 <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="51" resourceTypeEnumId="STRT_SCRIPT" resourceValue="/mjmlstatic/js/grapes.min.js"/>
25 <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="52" resourceTypeEnumId="STRT_SCRIPT" resourceValue="/mjmlstatic/js/grapesjs-mjml.min.js"/> 24 <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="52" resourceTypeEnumId="STRT_SCRIPT" resourceValue="/mjmlstatic/js/grapesjs-mjml.min.js"/>
26 25
27 <!-- <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="100" resourceTypeEnumId="STRT_HEADER_LOGO"-->
28 <!-- resourceValue="/images/MoquiLogoSmall.png"/>-->
29 <!-- <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="101" resourceTypeEnumId="STRT_SHORTCUT_ICON"-->
30 <!-- resourceValue="/favicon.ico"/>-->
31 <!-- <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="102" resourceTypeEnumId="STRT_BODY_CLASS"-->
32 <!-- resourceValue="bg-light"/>-->
33
34 <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="110" resourceTypeEnumId="STRT_HEADER_TITLE" 26 <moqui.screen.ScreenThemeResource screenThemeId="MJML_DEFAULT" sequenceNum="110" resourceTypeEnumId="STRT_HEADER_TITLE"
35 resourceValue="Email Editor"/> 27 resourceValue="Email Editor"/>
36 28
......
...@@ -15,8 +15,8 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -15,8 +15,8 @@ along with this software (see the LICENSE.md file). If not, see
15 <entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-definition-3.xsd"> 15 <entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-definition-3.xsd">
16 16
17 <extend-entity entity-name="EmailTemplate" package="moqui.basic.email"> 17 <extend-entity entity-name="EmailTemplate" package="moqui.basic.email">
18 <field name="resourceId" type="id"/> 18 <field name="grapesLocation" type="text-medium"/>
19 <relationship type="one" related="moqui.resource.DbResource" short-alias="dbResource"/> 19 <field name="htmlLocation" type="text-medium"/>
20 </extend-entity> 20 </extend-entity>
21 <view-entity entity-name="ProductStoreEmailDetail" package="mantle.product.store"> 21 <view-entity entity-name="ProductStoreEmailDetail" package="mantle.product.store">
22 <member-entity entity-alias="PSE" entity-name="mantle.product.store.ProductStoreEmail"/> 22 <member-entity entity-alias="PSE" entity-name="mantle.product.store.ProductStoreEmail"/>
......
...@@ -23,7 +23,7 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -23,7 +23,7 @@ along with this software (see the LICENSE.md file). If not, see
23 23
24 <form-list name="StoreEmailsForm"> 24 <form-list name="StoreEmailsForm">
25 <field name="editEmailTemplate" align="center"><default-field> 25 <field name="editEmailTemplate" align="center"><default-field>
26 <link url="/mjml" parameter-map="[resourceId:resourceId,emailTemplateId:emailTemplateId]" url-type="plain" text="Edit Template"/> 26 <link url="/mjml" parameter-map="[grapesLocation:grapesLocation,htmlLocation:htmlLocation,emailTemplateId:emailTemplateId]" url-type="plain" text="Edit Template"/>
27 </default-field></field> 27 </default-field></field>
28 </form-list> 28 </form-list>
29 29
......
...@@ -16,20 +16,8 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -16,20 +16,8 @@ along with this software (see the LICENSE.md file). If not, see
16 xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/xml-screen-3.xsd" 16 xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/xml-screen-3.xsd"
17 menu-image="fa fa-flash" menu-image-type="icon" standalone="true" screen-theme-type-enum-id="STT_MJML" > 17 menu-image="fa fa-flash" menu-image-type="icon" standalone="true" screen-theme-type-enum-id="STT_MJML" >
18 18
19 <parameter name="resourceId"/> 19 <parameter name="grapesLocation"/>
20 20 <parameter name="htmlLocation"/>
21 <transition name="handleGrapeJs" read-only="true" method="get">
22 <actions>
23 <log level="warn" message="context.toString() ${context.toString()}"/>
24 <service-call name="moqui.MjmlServices.get#GrapeJs" in-map="[resourceId:resourceId]" out-map="context"/>
25 </actions>
26 <default-response url="."/></transition>
27 <transition name="handleGrapeJs" read-only="true" method="post">
28 <actions>
29 <log level="warn" message="context.toString() ${context.toString()}"/>
30 <service-call name="moqui.MjmlServices.store#GrapeJs" in-map="context" out-map="context"/>
31 </actions>
32 <default-response url="."/></transition>
33 21
34 <actions> 22 <actions>
35 <set field="baseLinkUrl" from="!'production'.equals(System.getProperty('instance_purpose')) ? 'http://localhost:8080' : ec.web.getWebappRootUrl(true,true)"/> 23 <set field="baseLinkUrl" from="!'production'.equals(System.getProperty('instance_purpose')) ? 'http://localhost:8080' : ec.web.getWebappRootUrl(true,true)"/>
...@@ -178,11 +166,12 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -178,11 +166,12 @@ along with this software (see the LICENSE.md file). If not, see
178 <script type="text/javascript"> 166 <script type="text/javascript">
179 // Wait for the plugin to be injected by the dev server 167 // Wait for the plugin to be injected by the dev server
180 window.onload = () => { 168 window.onload = () => {
181 window.resourceId = new URLSearchParams(window.location.search).get('resourceId'); 169 window.htmlLocation = new URLSearchParams(window.location.search).get('htmlLocation');
170 window.grapesLocation = new URLSearchParams(window.location.search).get('grapesLocation');
182 window.emailTemplateId = new URLSearchParams(window.location.search).get('emailTemplateId'); 171 window.emailTemplateId = new URLSearchParams(window.location.search).get('emailTemplateId');
183 172
184 const request = new XMLHttpRequest(); 173 const request = new XMLHttpRequest();
185 request.open("GET", ("${baseLinkUrl}/rest/s1/moqui-mjml/mjml?resourceId="+window.resourceId+"&emailTemplateId="+window.emailTemplateId), false); // `false` makes the request synchronous 174 request.open("GET", ("${baseLinkUrl}/rest/s1/moqui-mjml/mjml?grapesLocation="+window.grapesLocation+"&htmlLocation="+window.htmlLocation+"&emailTemplateId="+window.emailTemplateId), false); // `false` makes the request synchronous
186 request.send(null); 175 request.send(null);
187 176
188 let response; 177 let response;
...@@ -212,8 +201,8 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -212,8 +201,8 @@ along with this software (see the LICENSE.md file). If not, see
212 // Default storage options 201 // Default storage options
213 options: { 202 options: {
214 remote: { 203 remote: {
215 urlLoad: "${baseLinkUrl}/rest/s1/moqui-mjml/mjml?resourceId=" + window.resourceId, 204 urlLoad: "${baseLinkUrl}/rest/s1/moqui-mjml/mjml?grapesLocation="+window.grapesLocation+"&htmlLocation="+window.htmlLocation,
216 urlStore: "${baseLinkUrl}/rest/s1/moqui-mjml/mjml?resourceId=" + window.resourceId, 205 urlStore: "${baseLinkUrl}/rest/s1/moqui-mjml/mjml?grapesLocation="+window.grapesLocation+"&htmlLocation="+window.htmlLocation,
217 headers: { 206 headers: {
218 "X-CSRF-Token": document.getElementById('confMoquiSessionToken').value 207 "X-CSRF-Token": document.getElementById('confMoquiSessionToken').value
219 }, 208 },
...@@ -224,14 +213,16 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -224,14 +213,16 @@ along with this software (see the LICENSE.md file). If not, see
224 // we have to properly update the body before the store and extract the 213 // we have to properly update the body before the store and extract the
225 // project data from the response result. 214 // project data from the response result.
226 onStore: data => { 215 onStore: data => {
227 return { id: window.resourceId, data, html:window.editor.runCommand('mjml-code-to-html')?.html } 216 return { id: window.grapesLocation, data, html:window.editor.runCommand('mjml-code-to-html')?.html }
228 }, 217 },
229 onLoad: result => { 218 onLoad: result => {
230 if (result.resourceId !== null) { 219 if (result.resourceId !== null) {
231 const url = new URL(window.location.href) 220 const url = new URL(window.location.href)
232 url.searchParams.set('resourceId', result.resourceId); 221 url.searchParams.set('grapesLocation', result.grapesLocation);
222 url.searchParams.set('htmlLocation', result.htmlLocation);
233 window.history.pushState({}, '', url) 223 window.history.pushState({}, '', url)
234 window.resourceId = result.resourceId; 224 window.grapesLocation = result.grapesLocation;
225 window.htmlLocation = result.htmlLocation;
235 } 226 }
236 // console.log('onLoad ', result) 227 // console.log('onLoad ', result)
237 return result.data 228 return result.data
......
...@@ -17,78 +17,62 @@ along with this software (see the LICENSE.md file). If not, see ...@@ -17,78 +17,62 @@ along with this software (see the LICENSE.md file). If not, see
17 <service verb="load" noun="GrapeJs"> 17 <service verb="load" noun="GrapeJs">
18 <description>Create MJML</description> 18 <description>Create MJML</description>
19 <in-parameters> 19 <in-parameters>
20 <parameter name="resourceId"/> 20 <parameter name="grapesLocation"/>
21 <parameter name="htmlLocation"/>
21 <parameter name="emailTemplateId"/> 22 <parameter name="emailTemplateId"/>
22 </in-parameters> 23 </in-parameters>
23 <out-parameters> 24 <out-parameters>
24 <parameter name="resourceId"/> 25 <parameter name="grapesLocation"/>
26 <parameter name="htmlLocation"/>
25 <parameter name="data"/> 27 <parameter name="data"/>
26 </out-parameters> 28 </out-parameters>
27 <actions> 29 <actions>
28 <if condition="resourceId == 'null'"><set field="resourceId" from="null"/></if> 30 <if condition="grapesLocation == 'null'"><set field="grapesLocation" from="null"/></if>
31 <if condition="htmlLocation == 'null'"><set field="htmlLocation" from="null"/></if>
29 <!-- <log level="warn" message="resourceId is ${resourceId} resourceId.getClass().getName() ${resourceId.getClass().getName()} resourceId == 'null' ${resourceId == 'null'} resourceId == null ${resourceId == null}"/>--> 32 <!-- <log level="warn" message="resourceId is ${resourceId} resourceId.getClass().getName() ${resourceId.getClass().getName()} resourceId == 'null' ${resourceId == 'null'} resourceId == null ${resourceId == null}"/>-->
30 <!-- <log level="warn" message="load context.toString() ${context.toString()}"/>--> 33 <!-- <log level="warn" message="load context.toString() ${context.toString()}"/>-->
31 <if condition="emailTemplateId"> 34 <if condition="emailTemplateId">
32 <entity-find-one entity-name="moqui.basic.email.EmailTemplate" value-field="emailTemplate" auto-field-map="[emailTemplateId:emailTemplateId]"/> 35 <entity-find-one entity-name="moqui.basic.email.EmailTemplate" value-field="emailTemplate" auto-field-map="[emailTemplateId:emailTemplateId]"/>
33 <if condition="!resourceId"><set field="resourceId" from="emailTemplate?.resourceId"/></if> 36 <if condition="!grapesLocation"><set field="grapesLocation" from="emailTemplate?.grapesLocation"/></if>
34 <if condition="resourceId != emailTemplate?.resourceId"> 37 <if condition="grapesLocation &amp;&amp; grapesLocation != emailTemplate?.grapesLocation">
38 <!-- This should almost never happen, but if it does it basically creates a resource leak for the previously used resource -->
39 <log message="Changing resource id from ${grapesLocation} to ${emailTemplate?.grapesLocation} for email template ${emailTemplateId}"/>
40 <service-call name="update#moqui.basic.email.EmailTemplate" in-map="[emailTemplateId:emailTemplateId,grapesLocation:grapesLocation]"/>
41 </if>
42 <if condition="!htmlLocation"><set field="htmlLocation" from="emailTemplate?.htmlLocation"/></if>
43 <if condition="htmlLocation &amp;&amp; htmlLocation != emailTemplate?.htmlLocation">
35 <!-- This should almost never happen, but if it does it basically creates a resource leak for the previously used resource --> 44 <!-- This should almost never happen, but if it does it basically creates a resource leak for the previously used resource -->
36 <log message="Changing resource id from ${resourceId} to ${emailTemplate?.resourceId} for email template ${emailTemplateId}"/> 45 <log message="Changing resource id from ${htmlLocation} to ${emailTemplate?.htmlLocation} for email template ${emailTemplateId}"/>
37 <service-call name="update#moqui.basic.email.EmailTemplate" in-map="[emailTemplateId:emailTemplateId,resourceId:resourceId]"/> 46 <service-call name="update#moqui.basic.email.EmailTemplate" in-map="[emailTemplateId:emailTemplateId,htmlLocation:htmlLocation]"/>
38 </if> 47 </if>
39 </if> 48 </if>
40 49
41 <if condition="!resourceId"> 50 <set field="grapesJsResource" from="ec.resource.getLocationReference('dbresource://grapesjs/project')"/>
51 <if condition="!grapesLocation &amp;&amp; htmlLocation">
42 <then> 52 <then>
43 <set field="grapesJsResource" from="ec.resource.getLocationReference('dbresource://grapesjs/project')"/> 53 <set field="htmlFile" from="project.makeFile(java.util.UUID.randomUUID().toString()+'.html')"/>
44 <service-call name="create#moqui.resource.DbResource" in-map="[parentResourceId:grapesJsResource.getDbResourceId(),isFile:'Y']" out-map="dbResource"/> 54 <set field="grapesFile" from="project.makeFile(java.util.UUID.randomUUID().toString()+'.json')"/>
45 <service-call name="update#moqui.resource.DbResource" in-map="[resourceId:dbResource.resourceId,filename:dbResource.resourceId+'.json']" out-map="dbResource"/> 55
46 <set field="versionName" value="01"/> 56 <set field="data" from="ec.resource.getLocationReference('dbresource://grapesjs/template/default.json').getText()"/>
47 <set field="defaultFile" from="ec.resource.getLocationReference('dbresource://grapesjs/template/default.json')"/> 57 <script><![CDATA[
48 <set field="data" from="defaultFile.getText()"/> 58 htmlFile.move(project.location + "/" + htmlFile.dbResourceId + ".html")
49 <service-call name="create#moqui.resource.DbResourceFile" in-map="[resourceId: dbResource.resourceId,mimeType: 'text/json',versionName: versionName,rootVersionName: versionName,fileData:data]"/> 59 grapesFile.putText(data)
50 <service-call name="create#moqui.resource.DbResourceFileHistory" in-map="[resourceId: dbResource.resourceId,versionDate: ec.user.nowTimestamp,userId: ec.user.userId,isDiff: 'N']"/> 60 grapesFile.move(project.location + "/" + grapesFile.dbResourceId + ".json")
51 <set field="resourceId" from="dbResource.resourceId"/> 61 ]]></script>
62 <set field="htmlLocation" from="htmlFile.location"/>
63 <set field="grapesLocation" from="grapesFile.location"/>
52 64
53 <if condition="emailTemplateId"> 65 <if condition="emailTemplateId">
54 <service-call name="update#moqui.basic.email.EmailTemplate" in-map="[emailTemplateId:emailTemplateId,resourceId:resourceId]"/> 66 <service-call name="update#moqui.basic.email.EmailTemplate" in-map="[emailTemplateId:emailTemplateId,grapesLocation:grapesLocation,htmlLocation:htmlLocation]"/>
55 </if> 67 </if>
56 <!-- <set field="resourceId" from="null"/>-->
57 <!-- <set field="data" from="null"/>-->
58 </then> 68 </then>
59 <else> 69 <else>
60 <entity-find-one entity-name="moqui.resource.DbResource" value-field="dbResource" auto-field-map="[resourceId:resourceId]"/> 70 <set field="putDbResource" from="ec.resource.getLocationReference(grapesLocation)"/>
61 <!-- <log level="warn" message="dbResource ${dbResource}"/>--> 71 <if condition="!putDbResource || putDbResource.parent?.dbResourceId != grapesJsResource.dbResourceId">
62 <if condition="!dbResource">
63 <return error="true" message="Resource not found"/>
64 </if>
65 <set field="actualDbResourcePath" from="null"/>
66 <set field="dbResourcePath" from="dbResource.filename"/>
67 <set field="lastDbResource" from="dbResource"/>
68 <!-- <log level="warn" message="lastDbResource ${lastDbResource}"/>-->
69 <script>
70 while (actualDbResourcePath == null) {
71 // ec.logger.warn('dbResourcePath: '+dbResourcePath)
72 if (lastDbResource.parentResourceId == null) {
73 dbResourcePath = 'dbresource://'+dbResourcePath
74 actualDbResourcePath = dbResourcePath
75 // ec.logger.warn('actualDbResourcePath: '+actualDbResourcePath)
76 } else {
77 lastDbResource = ec.entity.fastFindOne("moqui.resource.DbResource", true, false, lastDbResource.parentResourceId)
78 dbResourcePath = lastDbResource.filename+'/'+dbResourcePath
79 }
80 }
81 </script>
82 <set field="putDbResource" from="ec.resource.getLocationReference(actualDbResourcePath)"/>
83 <entity-find entity-name="moqui.resource.DbResourceFileHistory" list="dbResourceHistoryList" limit="1">
84 <econdition field-name="resourceId" from="resourceId"/>
85 <order-by field-name="-versionName"/>
86 </entity-find>
87 <if condition="dbResourceHistoryList.size() == 0">
88 <return error="true" message="Resource not found"/> 72 <return error="true" message="Resource not found"/>
89 </if> 73 </if>
90 74
91 <set field="data" from="putDbResource.getText(dbResourceHistoryList.getFirst().versionName)"/> 75 <set field="data" from="putDbResource.getText()"/>
92 </else> 76 </else>
93 </if> 77 </if>
94 </actions> 78 </actions>
......
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 This software is in the public domain under CC0 1.0 Universal plus a
4 Grant of Patent License.
5
6 To the extent possible under law, the author(s) have dedicated all
7 copyright and related and neighboring rights to this software to the
8 public domain worldwide. This software is distributed without any
9 warranty.
10
11 You should have received a copy of the CC0 Public Domain Dedication
12 along with this software (see the LICENSE.md file). If not, see
13 <http://creativecommons.org/publicdomain/zero/1.0/>.
14 -->
15 <services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/service-definition-3.xsd">
16
17 <service verb="get" noun="GrapeJs">
18 <description>Create MJML</description>
19 <in-parameters>
20 <parameter name="resourceId"/>
21 </in-parameters>
22 <out-parameters>
23 <parameter name="data"/>
24 </out-parameters>
25 <actions>
26 <set field="file" from="ec.resource.getLocationReference('dbresource://grapesjs/project/'+resourceId)"/>
27 <set field="data" from="file.getText()"/>
28 </actions>
29 </service>
30 <service verb="store" noun="GrapeJs">
31 <description>Create MJML</description>
32 <in-parameters>
33 <parameter name="resourceId"/>
34 <parameter name="data" type="String"/>
35 </in-parameters>
36 <out-parameters>
37 <parameter name="resourceId"/>
38 </out-parameters>
39 <actions>
40 <!-- <log level="warn" message="context.toString() ${context.toString()}"/>-->
41 <!-- <log level="warn" message="store#GrapeJs ec.web.secureRequestParameters.data ${ec.web.secureRequestParameters.data}"/>-->
42
43 <log level="warn" message="store#GrapeJs ec.web.secureRequestParameters._requestBodyText ${ec.web.secureRequestParameters._requestBodyText}"/>
44 <log level="warn" message="store#GrapeJs data ${data} typeof data ${data.getClass().getName()}"/>
45
46 <!-- <set field="data" from="groovy.json.JsonOutput.toJson(data)"/>-->
47
48 <set field="project" from="ec.resource.getLocationReference('dbresource://grapesjs/project')"/>
49 <set field="file" from="project.makeFile(java.util.UUID.randomUUID().toString())"/>
50 <script><![CDATA[
51 file.putText(data)
52 file.move(project.location + "/" + file.dbResourceId)
53 ]]></script>
54 <set field="resourceId" from="context.resourceId"/>
55
56 </actions>
57 </service>
58
59
60 </services>