Skip to content

Commit

Permalink
Merge pull request #182 from acsone/16.0-mig_cmis_web_proxy_mfr
Browse files Browse the repository at this point in the history
[MIG] cmis_web_proxy - Migration to 16.0
  • Loading branch information
FrancoMaxime authored Jun 12, 2024
2 parents 8c32cdc + 68a131d commit 40b21f5
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 151 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
^cmis_web_proxy/|
^cmis_web_proxy_alf/|
^cmis_web_report_write/|
^cmis_web_report_write_alf/|
Expand Down
2 changes: 1 addition & 1 deletion cmis_web_proxy/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ Maintainer
:alt: ACSONE SA/NV
:target: http://www.acsone.eu

This module is maintained by ACSONE SA/NV.
This module is maintained by ACSONE SA/NV.
12 changes: 9 additions & 3 deletions cmis_web_proxy/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
"summary": """
Odoo as proxy server for your cmis requests.""",
"category": "Document Management",
"version": "14.0.1.0.1",
"version": "16.0.1.0.1",
"license": "AGPL-3",
"author": "ACSONE SA/NV",
"website": "https://alfodoo.org",
"depends": ["cmis_web"],
"data": ["views/cmis_backend.xml", "views/cmis_web_proxy.xml"],
"data": ["views/cmis_backend.xml"],
"external_dependencies": {"python": ["requests", "cmislib"]},
"images": ["static/description/main_icon.png"],
"installable": False,
"assets": {
"web.assets_backend": [
"/cmis_web_proxy/static/src/cmis_folder/cmis_folder.js",
"/cmis_web_proxy/static/src/cmis_object_wrapper_service.js",
],
},
"installable": True,
}
105 changes: 51 additions & 54 deletions cmis_web_proxy/controllers/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from odoo.exceptions import AccessError
from odoo.http import request

from odoo.addons.web.controllers import main

_logger = logging.getLogger(__name__)

try:
Expand All @@ -24,68 +22,68 @@
READ_ACCESS_CMIS_ACTIONS = {"query"}

WRITE_ACCESS_CMIS_ACTIONS = {
"createRelationship",
# "createPolicy", method at repository level: not supported
# "createItem", method at repository level: not supported
"bulkUpdate",
# "createType", method at repository level: not supported
# "updateType", method at repository level: not supported
"createDocument",
"createFolder",
"createDocumentFromSource",
# "createPolicy", method at repository level: not supported
"update",
"setContent",
"checkOut",
"cancelCheckOut",
"checkIn",
# "applyPolicy", method at repository level: not supported
# "applyACL", method at repository level: not supported
"createRelationship",
# "createPolicy", method at repository level: not supported
# "createItem", method at repository level: not supported
"bulkUpdate",
# "createType", method at repository level: not supported
# "updateType", method at repository level: not supported
"createDocument",
"createFolder",
"createDocumentFromSource",
# "createPolicy", method at repository level: not supported
"update",
"setContent",
"checkOut",
"cancelCheckOut",
"checkIn",
# "applyPolicy", method at repository level: not supported
# "applyACL", method at repository level: not supported
}

UNLINK_ACCESS_CMIS_ACTIONS = {
"delete",
"deleteContent",
"removeObjectFromFolder",
# "removePolicy", method at repository level: not supported
# "deleteType", method at repository level: not supported
"delete",
"deleteContent",
"removeObjectFromFolder",
# "removePolicy", method at repository level: not supported
# "deleteType", method at repository level: not supported
}

READ_ACCESS_ALLOWABLE_ACTIONS = {
"canGetDescendants",
"canGetChildren",
"canGetFolderParent",
"canGetObjectParents",
"canGetProperties",
"canGetContentStream",
"canGetAllVersions",
"canGetObjectRelationships",
"canGetAppliedPolicies",
"canGetACL",
"canGetDescendants",
"canGetChildren",
"canGetFolderParent",
"canGetObjectParents",
"canGetProperties",
"canGetContentStream",
"canGetAllVersions",
"canGetObjectRelationships",
"canGetAppliedPolicies",
"canGetACL",
}

WRITE_ACCESS_ALLOWABLE_ACTIONS = {
"canCreateDocument",
"canCreateFolder",
# "canCreatePolicy",
"canCreateRelationship",
"canUpdateProperties",
"canMoveObject",
"canSetContentStream",
"canAddObjectToFolder",
"canCheckOut",
"canCancelCheckOut",
"canCheckIn",
# "canApplyPolicy",
# "canApplyACL",
"canCreateDocument",
"canCreateFolder",
# "canCreatePolicy",
"canCreateRelationship",
"canUpdateProperties",
"canMoveObject",
"canSetContentStream",
"canAddObjectToFolder",
"canCheckOut",
"canCancelCheckOut",
"canCheckIn",
# "canApplyPolicy",
# "canApplyACL",
}

UNLINK_ACCESS_ALLOWABLE_ACTIONS = {
"canRemoveObjectFromFolder",
"canDeleteObject",
"canDeleteContentStream",
"canDeleteTree",
# "canRemovePolicy",
"canRemoveObjectFromFolder",
"canDeleteObject",
"canDeleteContentStream",
"canDeleteTree",
# "canRemovePolicy",
}

CMSI_ACTIONS_OPERATION_MAP = {}
Expand Down Expand Up @@ -384,7 +382,7 @@ def _check_cmis_content_access(
token_cmis_objectid = getattr(model_inst, field_name)
if not token_cmis_objectid:
_logger.info(
"The referenced model doesn't reference a CMIS " "content (%s, %s)",
"The referenced model doesn't reference a CMIS content (%s, %s)",
model_inst._name,
model_inst.id,
)
Expand Down Expand Up @@ -506,7 +504,6 @@ def _check_access(self, cmis_path, proxy_info, params):
csrf=False,
methods=["GET", "POST"],
)
@main.serialize_exception
def call_cmis_services(self, backend_id, cmis_path="", **kwargs):
"""Call at the root of the CMIS repository. These calls are for
requesting the global services provided by the CMIS Container
Expand Down
6 changes: 1 addition & 5 deletions cmis_web_proxy/models/cmis_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ class CmisBackend(models.Model):

_inherit = "cmis.backend"

def _clear_caches(self):
self.get_by_id.clear_cache(self)

@api.onchange("is_cmis_proxy")
def _onchange_is_cmis_proxy(self):
self.apply_odoo_security = self.is_cmis_proxy
Expand All @@ -27,7 +24,7 @@ def _compute_proxy_location(self):
help="If checked, all the CMIS requests from the client will be "
"done to the Odoo server in place of to a direct call to the"
"CMIS Container. In such a case, Odoo act as a proxy server "
"between the widget and the cmis container and all the requets "
"between the widget and the cmis container and all the requests "
"are done by using the configured account on the backend. ",
)
apply_odoo_security = fields.Boolean(
Expand Down Expand Up @@ -75,7 +72,6 @@ def get_by_id(self, backend_id):
return backend

def write(self, vals):
self.get_proxy_info_by_id.clear_cache(self)
if "is_cmis_proxy" in vals and vals["is_cmis_proxy"] is False:
vals["apply_odoo_security"] = False
return super(CmisBackend, self).write(vals)
41 changes: 41 additions & 0 deletions cmis_web_proxy/static/src/cmis_folder/cmis_folder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/** @odoo-module **/

/* ---------------------------------------------------------
+ * Odoo cmis_web
+ * Authors Laurent Mignon 2016, Maxime Franco 2023 Acsone SA/NV
+ * License in __openerp__.py at root level of the module
+ *---------------------------------------------------------
+*/

import {CmisFolderField} from "@cmis_web/cmis_folder/cmis_folder";
import {patch} from "@web/core/utils/patch";

patch(CmisFolderField.prototype, "open_with_proxy", {
getCmisObjectWrapperParams() {
const params = this._super(...arguments);
params.applyOdooSecurity = this.backend.apply_odoo_security;
return params;
},

genCmisSessionToken() {
return JSON.stringify({
model: this.props.record.resModel,
res_id: this.props.record.resId,
field_name: this.props.name,
});
},

setCmisSessionToken() {
if (this.backend.apply_odoo_security) {
this.cmisSession.setToken(this.genCmisSessionToken());
}
},

async setRootFolderId() {
var self = this;
self.setCmisSessionToken();
this._super(...arguments);
},
});

CmisFolderField.props.backend[0].shape.apply_odoo_security = Boolean;
25 changes: 25 additions & 0 deletions cmis_web_proxy/static/src/cmis_object_wrapper_service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/** @odoo-module **/

/* ---------------------------------------------------------
+ * Odoo cmis_web
+ * Authors Laurent Mignon 2016, Quentin Groulard 2023 Acsone SA/NV
+ * License in __openerp__.py at root level of the module
+ *---------------------------------------------------------
+*/

import {CmisObjectWrapper} from "@cmis_web/cmis_object_wrapper_service";
import {patch} from "@web/core/utils/patch";

patch(CmisObjectWrapper.prototype, "alfresco_proxy_url", {
getPreviewUrl() {
var _url = this._super(...arguments);
if (_url) {
var prefix = "&";
if (_url.indexOf("?") < 0) {
prefix = "?";
}
return _url + prefix + "renderedObjectId=" + this.objectId;
}
return _url;
},
});
66 changes: 0 additions & 66 deletions cmis_web_proxy/static/src/js/form_widget.js

This file was deleted.

8 changes: 4 additions & 4 deletions cmis_web_proxy/tests/test_cmis_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from cmislib.exceptions import NotSupportedException

import odoo.tests.common as common
from odoo.tools import config as odoo_config

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -59,18 +60,17 @@ def setUp(self):
"apply_odoo_security": False,
"username": cmis_user,
"password": cmis_pwd,
"version": "1.0",
}
)
web_descr = self.cmis_backend.get_web_description()[self.cmis_backend.id]
proxy_path = web_descr["cmis_location"]
proxy_path = web_descr["location"]
self.authenticate("admin", "admin")
self.cmis_url = "http://%s:%d%s" % (
common.HOST,
common.PORT,
odoo_config["http_port"],
proxy_path,
)
self.headers = {"Cookie": "session_id=%s" % self.session_id}
self.headers = {"Cookie": "session_id=%s" % self.opener.cookies["session_id"]}
self.cmis_client = CmisClient(
self.cmis_url, "admin", "admin", headers=self.headers
)
Expand Down
17 changes: 0 additions & 17 deletions cmis_web_proxy/views/cmis_web_proxy.xml

This file was deleted.

1 change: 1 addition & 0 deletions setup/cmis_web_proxy/odoo/addons/cmis_web_proxy
Loading

0 comments on commit 40b21f5

Please sign in to comment.