-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from ursais/10.0-mig-cmis_web_proxy_alf
[ADD] cmis_web_proxy_alf
- Loading branch information
Showing
14 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
======================= | ||
Cmis Web Proxy Alfresco | ||
======================= | ||
|
||
This module allows Odoo to proxy requests from cmis_web to the Alfresco API. | ||
|
||
Documentation: `alfodoo.org <http://alfodoo.org>`_ | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Laurent Mignon <laurent.mignon@acsone.eu> | ||
* Sandip Mangukiya <smangukiya@ursainfosystems.com> | ||
* Maxime Chambreuil <mchambreuil@ursainfosystems.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://www.acsone.eu/logo.png | ||
:alt: ACSONE SA/NV | ||
:target: http://www.acsone.eu | ||
|
||
This module is maintained by ACSONE SA/NV. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import controllers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Cmis Web Proxy Alf', | ||
'description': """ | ||
""", | ||
'version': '10.0.1.0.0', | ||
'license': 'AGPL-3', | ||
'author': 'ACSONE SA/NV', | ||
'website': 'https://alfodoo.org/', | ||
'depends': [ | ||
'cmis_web_proxy' | ||
], | ||
'data': [ | ||
'views/cmis_backend.xml', | ||
'views/cmis_web_proxy_alf.xml' | ||
], | ||
'demo': [ | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import alfresco |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import _, http | ||
from odoo.http import request | ||
from odoo.exceptions import AccessError | ||
from odoo.addons.web.controllers import main | ||
|
||
from odoo.addons.cmis_web_proxy.controllers import cmis | ||
|
||
ALFRESCO_API_PROXY_PATH = '/alfresco/s/api' | ||
|
||
|
||
class AlfrescoProxy(cmis.CmisProxy): | ||
|
||
def _check_alfresco_access(self, cmis_backend, params): | ||
token = self._check_provided_token("/", cmis_backend, params) | ||
if not token: | ||
raise AccessError(_("Bad request")) | ||
# check access to object from token | ||
model_inst, field_name = self._decode_token( | ||
"/", cmis_backend, params, token) | ||
if not self._check_cmis_content_access( | ||
"/", cmis_backend, params, model_inst, field_name): | ||
raise AccessError(_("Bad request")) | ||
if not self._check_access_operation(model_inst, "read"): | ||
raise AccessError(_("Bad request")) | ||
return True | ||
|
||
@http.route([ | ||
ALFRESCO_API_PROXY_PATH + | ||
'/<string:backend_id>' | ||
'/content/thumbnails/pdf/' + | ||
'<string:cmis_name>', | ||
], type='http', auth="user", csrf=False, methods=['GET']) | ||
@main.serialize_exception | ||
def get_thumnails(self, backend_id, cmis_name, | ||
**kwargs): | ||
"""Call at the root of the CMIS repository. These calls are for | ||
requesting the global services provided by the CMIS Container | ||
""" | ||
# use a dedicated cache to get the backend | ||
cmis_backend = request.env['cmis.backend'].get_by_id(backend_id) | ||
if cmis_backend.apply_odoo_security: | ||
self._check_alfresco_access(cmis_backend, kwargs) | ||
url = (cmis_backend.alfresco_api_location + | ||
'/node/workspace/SpacesStore/' + | ||
kwargs['versionSeriesId'] + | ||
'/content/thumbnails/pdf/' + | ||
cmis_name) | ||
params = { | ||
'c': kwargs['c'], | ||
'lastModified': kwargs['lastModified'] | ||
} | ||
return self._forward_get_file(url, cmis_backend, params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import cmis_backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
from odoo.addons.cmis_web_proxy_alf.controllers import alfresco | ||
|
||
|
||
class CmisBackend(models.Model): | ||
|
||
_inherit = 'cmis.backend' | ||
|
||
@api.depends('alfresco_api_location') | ||
@api.multi | ||
def _compute_proxy_api_location(self): | ||
for record in self: | ||
record.proxy_api_location = ( | ||
alfresco.ALFRESCO_API_PROXY_PATH + '/%s' % record.id) | ||
|
||
alfresco_api_location = fields.Char( | ||
string='Alfresco Api Url', | ||
required=True) | ||
proxy_api_location = fields.Char( | ||
readonly=True, compute='_compute_proxy_api_location') | ||
|
||
@api.model | ||
def _get_web_description(self, record): | ||
""" Return the desciption of backend record to be included into the | ||
field description of alfresco fields that reference the backend. | ||
""" | ||
descr = super(CmisBackend, self)._get_web_description(record) | ||
descr.update({ | ||
'alfresco_api_location': record.proxy_api_location | ||
}) | ||
return descr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/*--------------------------------------------------------- | ||
+ * Odoo web_cmis_viewer | ||
+ * Author Laurent Mignon 2016 Acsone SA/NV | ||
+ * License in __openerp__.py at root level of the module | ||
+ *--------------------------------------------------------- | ||
+*/ | ||
|
||
odoo.define('cmis_web_proxy_alf.form_widgets', function( require) { | ||
"use strict"; | ||
|
||
var core = require('web.core'); | ||
var form_widgets = require('cmis_web.form_widgets'); | ||
var Model = require('web.Model'); | ||
|
||
var _t = core._t; | ||
|
||
|
||
form_widgets.CmisObjectWrapper.include({ | ||
|
||
init: function(){ | ||
this._super.apply(this, arguments); | ||
this.alfresco_api_location = null; | ||
this.token = null; | ||
}, | ||
|
||
get_preview_url : function(){ | ||
var _url = this._super.apply(this, arguments); | ||
if (_url) { | ||
return _url; | ||
} | ||
// By default, review are generated in alfresco the first time it's requested by share | ||
// Before this first access, the renditions on the cmis object is empty. | ||
// Use the alfresco API to trigger a first rendition of the document. | ||
var params = { | ||
'c': 'force', | ||
'lastModified': 'pdf%' + new Date().getUTCMilliseconds(), | ||
'token': this.token, | ||
'objectId': this.objectId, | ||
'versionSeriesId': this.versionSeriesId | ||
|
||
} | ||
return this.alfresco_api_location + '/content/thumbnails/pdf/' + this.name + '?' + $.param(params); | ||
}, | ||
|
||
}); | ||
|
||
form_widgets.FieldCmisFolder.include({ | ||
|
||
wrap_cmis_object: function(cmisObject) { | ||
var obj = this._super.apply(this, arguments); | ||
obj.alfresco_api_location = this.alfresco_api_location; | ||
obj.token = this.gen_cmis_session_token(); | ||
return obj; | ||
}, | ||
|
||
bind_cmis_config: function(backend){ | ||
this._super.apply(this, arguments); | ||
this.alfresco_api_location = backend.alfresco_api_location; | ||
}, | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2016 ACSONE SA/NV | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
|
||
<odoo> | ||
|
||
<record model="ir.ui.view" id="cmis_backend_form_view"> | ||
<field name="name">cmis.backend.form (in cmis_web_proxy_alf)</field> | ||
<field name="model">cmis.backend</field> | ||
<field name="inherit_id" ref="cmis_web_proxy.cmis_backend_form_view"/> | ||
<field name="arch" type="xml"> | ||
<field name="location" position="after"> | ||
<field name="alfresco_api_location" placeholder="e.g. http://localhost:8080/alfresco/s/api" colspan="4"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<template id="assets_backend" name="cmis_web assets" inherit_id="cmis_web.assets_backend"> | ||
<xpath expr="." position="inside"> | ||
<script type="text/javascript" src="/cmis_web_proxy_alf/static/src/js/form_widgets.js"/> | ||
</xpath> | ||
</template> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../cmis_web_proxy_alf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |