Skip to content

Commit

Permalink
Fixed: Added support to use default oms user when oms apis are called…
Browse files Browse the repository at this point in the history
… from a scheduled job (#22).
  • Loading branch information
ravilodhi committed Jun 20, 2024
1 parent b0e4f14 commit e2652bd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions MoquiConf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<moqui-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/moqui-conf-3.xsd">

<default-property name="webapp_require_session_token" value="false"/>
<default-property name="default.oms.user" value=""/>
</moqui-conf>
4 changes: 3 additions & 1 deletion service/co/hotwax/common/CommonServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
<service verb="autoComplete" noun="SolrFacet" transaction-timeout="3600">
<implements service="co.hotwax.common.CommonServices.autoComplete#OmsSolrFacetApi"/>
<actions>
<!-- In case of schedule job run no user logged in, use system user to get the token-->
<set field="userName" from="ec.user.username" default-value="${System.getProperty('default.oms.user')}"/>
<script>
omsBaseUrl = co.hotwax.util.MaargUtil.getOmsInstanceUrl(ec.ecfi);
token = co.hotwax.util.MaargUtil.getOmsJwtToken(ec.ecfi);
token = co.hotwax.util.MaargUtil.getOmsJwtToken(ec.ecfi, userName);
</script>
<if condition="!token">
<return error="true" message="Unable to generate oms token, check JWT configuration"/>
Expand Down
4 changes: 3 additions & 1 deletion service/co/hotwax/product/ProductFacilityServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,11 @@
<parameter name="productDetail" type="Map"/>
</out-parameters>
<actions>
<!-- In case of schedule job run no user logged in, use system user to get the token-->
<set field="userName" from="ec.user.username" default-value="${System.getProperty('default.oms.user')}"/>
<script>
omsBaseUrl = co.hotwax.util.MaargUtil.getOmsInstanceUrl(ec.ecfi);
token = co.hotwax.util.MaargUtil.getOmsJwtToken(ec.ecfi);
token = co.hotwax.util.MaargUtil.getOmsJwtToken(ec.ecfi, userName);
</script>
<if condition="!token">
<return error="true" message="Unable to generate oms token, check JWT configuration"/>
Expand Down

0 comments on commit e2652bd

Please sign in to comment.