Commit 3188e9b3 authored by Rafael Monnerat's avatar Rafael Monnerat

erp5_maileva_connector: Use property sheet rather them arbitrary store property

    Move tracking and submit URLs to proper settings using Link sub-object for store the values like in Payment Services when multiple urls are defined for a given service.
parent 756879f3
...@@ -46,13 +46,13 @@ class MailevaSOAPConnector(XMLObject): ...@@ -46,13 +46,13 @@ class MailevaSOAPConnector(XMLObject):
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
# Default Properties # Default Properties
property_sheets = ( PropertySheet.Base property_sheets = (PropertySheet.Base
, PropertySheet.XMLObject , PropertySheet.XMLObject
, PropertySheet.CategoryCore , PropertySheet.CategoryCore
) )
def processResponse(self, response, maileva_exchange, failed=False): def processResponse(self, response, maileva_exchange, failed=False):
maileva_exchange.edit( maileva_exchange.edit(
response = response response=response
) )
maileva_exchange.confirm() maileva_exchange.confirm()
# change state, no need to wait alarm check # change state, no need to wait alarm check
...@@ -61,28 +61,29 @@ class MailevaSOAPConnector(XMLObject): ...@@ -61,28 +61,29 @@ class MailevaSOAPConnector(XMLObject):
maileva_exchange.getFollowUpValue().fail() maileva_exchange.getFollowUpValue().fail()
def submitRequest(self, maileva_exchange): def submitRequest(self, maileva_exchange):
authenticated = HttpAuthenticated(username=self.getUserId(), password=self.getPassword()) authenticated = HttpAuthenticated(username=self.getUserId(),
password=self.getPassword())
runtime_environment = self.getActivityRuntimeEnvironment() runtime_environment = self.getActivityRuntimeEnvironment()
if runtime_environment: if runtime_environment:
runtime_environment.edit( runtime_environment.edit(
conflict_retry=False, conflict_retry=False,
max_retry=0) max_retry=0)
try: try:
response = suds.client.Client(url = self.getProperty('submit_url_string'), transport=authenticated).service.submit(__inject={'msg': maileva_exchange.getRequest()}) response = suds.client.Client(
url=self.getSubmitLinkUrlString(),
transport=authenticated
).service.submit(__inject={'msg': maileva_exchange.getRequest()})
maileva_exchange.activate().MailevaExchange_processResponse(response) maileva_exchange.activate().MailevaExchange_processResponse(response)
except socket.error as e: except socket.error as e:
if e.errno == socket.errno.ECONNREFUSED: if e.errno == socket.errno.ECONNREFUSED:
if runtime_environment: if runtime_environment:
runtime_environment.edit(max_retry=None) runtime_environment.edit(max_retry=None)
except Exception as e: except Exception as e:
maileva_exchange.activate().MailevaExchange_processResponse(str(e), failed = True) maileva_exchange.activate().MailevaExchange_processResponse(str(e), failed=True)
def checkPendingNotifications(self): def checkPendingNotifications(self):
authenticated = HttpAuthenticated(username=self.getUserId(), password=self.getPassword()) authenticated = HttpAuthenticated(username=self.getUserId(), password=self.getPassword())
client = suds.client.Client(url = self.getProperty("tracking_url_string"), transport=authenticated) client = suds.client.Client(url=self.getTrackingLinkUrlString(), transport=authenticated)
notification_dict = {} notification_dict = {}
for notification in client.service.checkPendingNotifications("GENERAL"): for notification in client.service.checkPendingNotifications("GENERAL"):
notification_dict[notification.reqTrackId] = { notification_dict[notification.reqTrackId] = {
...@@ -95,7 +96,8 @@ class MailevaSOAPConnector(XMLObject): ...@@ -95,7 +96,8 @@ class MailevaSOAPConnector(XMLObject):
def getPendingNotificationDetails(self, request_id, debug=False): def getPendingNotificationDetails(self, request_id, debug=False):
authenticated = HttpAuthenticated(username=self.getUserId(), password=self.getPassword()) authenticated = HttpAuthenticated(username=self.getUserId(), password=self.getPassword())
result = suds.client.Client(url = self.getProperty("tracking_url_string"), transport=authenticated).service.getPendingNotificationDetails(request_id) result = suds.client.Client(url=self.getTrackingLinkUrlString(),
transport=authenticated).service.getPendingNotificationDetails(request_id)
return { return {
"status": str(result.status), "status": str(result.status),
"notification_status": str(result.notificationStatus), "notification_status": str(result.notificationStatus),
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
</portal_type> </portal_type>
<portal_type id="Maileva SOAP Connector"> <portal_type id="Maileva SOAP Connector">
<item>Login</item> <item>Login</item>
<item>MailevaSOAPConnector</item>
<item>Reference</item> <item>Reference</item>
<item>Url</item> <item>Url</item>
</portal_type> </portal_type>
......
...@@ -38,6 +38,12 @@ ...@@ -38,6 +38,12 @@
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Base Type</string> </value> <value> <string>Base Type</string> </value>
</item> </item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>type_class</string> </key> <key> <string>type_class</string> </key>
<value> <string>MailevaSOAPConnector</string> </value> <value> <string>MailevaSOAPConnector</string> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>MailevaSOAPConnector</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Acquired Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>acquisition_base_category</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>acquisition_object_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>alt_accessor_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/content</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_acquired_property_id</string> </key>
<value>
<tuple>
<string>url_string</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_portal_type</string> </key>
<value> <string>python: (\'Link\',)</string> </value>
</item>
<item>
<key> <string>content_translation_acquired_property_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Include link URL</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>submit_link_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string>w</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Acquired Property</string> </value>
</item>
<item>
<key> <string>storage_id</string> </key>
<value> <string>submit_link</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Acquired Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>acquisition_base_category</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>acquisition_object_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>alt_accessor_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/content</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_acquired_property_id</string> </key>
<value>
<tuple>
<string>url_string</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_portal_type</string> </key>
<value> <string>python: (\'Link\',)</string> </value>
</item>
<item>
<key> <string>content_translation_acquired_property_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Link for tracking url</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>tracking_link_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string>w</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Acquired Property</string> </value>
</item>
<item>
<key> <string>storage_id</string> </key>
<value> <string>tracking_link</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="String Attribute Match Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>message_property_not_set</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_property</string> </key>
<value>
<tuple>
<string>user_id</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>user_id_constraint</string> </value>
</item>
<item>
<key> <string>message_attribute_not_match</string> </key>
<value> <string>User ID have to be set</string> </value>
</item>
<item>
<key> <string>message_no_such_property</string> </key>
<value> <string>User ID have to be set</string> </value>
</item>
<item>
<key> <string>message_property_not_set</string> </key>
<value> <string>vads_site_id have to be set</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>String Attribute Match Constraint</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -115,8 +115,8 @@ ...@@ -115,8 +115,8 @@
<key> <string>right</string> </key> <key> <string>right</string> </key>
<value> <value>
<list> <list>
<string>my_submit_url_string</string> <string>my_submit_link_url_string</string>
<string>my_tracking_url_string</string> <string>my_tracking_link_url_string</string>
<string>my_translated_validation_state_title</string> <string>my_translated_validation_state_title</string>
</list> </list>
</value> </value>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_submit_url_string</string> </value> <value> <string>my_submit_link_url_string</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_tracking_url_string</string> </value> <value> <string>my_tracking_link_url_string</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
......
...@@ -3,5 +3,6 @@ Maileva Exchange | Arrow ...@@ -3,5 +3,6 @@ Maileva Exchange | Arrow
Maileva Exchange | Event Maileva Exchange | Event
Maileva Exchange | HttpExchange Maileva Exchange | HttpExchange
Maileva SOAP Connector | Login Maileva SOAP Connector | Login
Maileva SOAP Connector | MailevaSOAPConnector
Maileva SOAP Connector | Reference Maileva SOAP Connector | Reference
Maileva SOAP Connector | Url Maileva SOAP Connector | Url
\ No newline at end of file
MailevaSOAPConnector
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment