Commit c9c8c996 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Romain Courteaud

slapos_slap_tool: Add getJIOAPIUrl to slapTool

parent 83cefa76
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard 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>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Stores API server URL</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_jio_api_url_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>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: \'\'</string> </value>
</item>
<item>
<key> <string>read_permission</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>write_permission</string> </key>
<value> <string>Manage properties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -434,6 +434,33 @@ class SlapTool(BaseTool): ...@@ -434,6 +434,33 @@ class SlapTool(BaseTool):
[software_release.getUrlString() [software_release.getUrlString()
for software_release in software_release_list]) for software_release in software_release_list])
security.declareProtected(Permissions.AccessContentsInformation,
'getJIOAPIUrl')
def getJIOAPIUrl(self):
"""
Return preferred jIO API URL.
"""
preference_tool = self.getPortalObject().portal_preferences
try:
url = CachingMethod(preference_tool.getPreferredJioApiUrl,
id='getJIOAPIUrl',
cache_factory='slap_cache_factory')()
except AttributeError:
raise NotFound
if not url:
raise NotFound
# Keep in cache server for 1 hour
self.REQUEST.response.setStatus(200)
self.REQUEST.response.setHeader('Cache-Control',
'public, max-age=3600, stale-if-error=604800')
self.REQUEST.response.setHeader('Vary',
'REMOTE_USER')
self.REQUEST.response.setHeader('content-type', 'text; charset=utf-8')
self.REQUEST.response.setHeader('Etag',
calculate_dict_hash({"etag": url}))
self.REQUEST.response.setBody(url)
return self.REQUEST.response
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getHateoasUrl') 'getHateoasUrl')
def getHateoasUrl(self): def getHateoasUrl(self):
......
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