自定义 Surf 平台根范围 API [英] Customizing Surf Platform Root-Scoped API

查看:22
本文介绍了自定义 Surf 平台根范围 API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自定义Surf Platform Root-Scoped API 特别是用户对象.这意味着向用户对象添加新的属性或方法以检查用户是否在header.inc.ftl [in share] 中的某个组中,例如`<#if user.isAdmin>

I want to customize Surf Platform Root-Scoped API specifically user object. That means add new property or method to user object to check the user is in certain group in header.inc.ftl [in share] like `<#if user.isAdmin>

  1. 我该如何实施?
  2. Alfresco Root Scoped Objects 是否可以用作 Surf Platform Root Scoped 对象?
  1. How can I implement this?
  2. Is Alfresco Root Scoped Objects can be used as Surf Platform Root-Scoped object?

我不知道自定义冲浪平台根对象.谁能帮帮我???

I have no idea of customizing surf platform root object. Can anyone help me???

推荐答案

不太确定您要实现的目标,但角色安全模型已硬编码在 spring-surf/spring webscripts 中.有访客、用户和管理员.如果您想要的是另一个类似的角色,您将不得不破解 spring-surf 库,即:

Not quite sure what you are trying to accomplish, but the role security model is hardcoded in spring-surf/spring webscripts. There is guest, user and admin. If what you want is another analogous role you'll have to hack the spring-surf libaries, namely:

org/springframework/extensions/surf/mvc/PageView.java
org/springframework/extensions/webscripts/ScriptUser.java
org/springframework/extensions/webscripts/Description.java
org/springframework/extensions/webscripts/connector/User.java

这是我实现user.isEmployee 所必须做的.这种方法可以让您真正像对待其他角色一样对待您的新角色.

This is what I had to do to implement user.isEmployee. This approach allows you to literally treat your new role just as the others.

你可以使用

<authentication>employee</authentication>

在页面描述符中或

<item type="link" permission="employee" id="people">/people-finder</item>

在导航上.

仅检查用户是否在某个 webscript 中的某个组中是完全不同的故事,并且不提供相同的功能.

Just checking whether the user is in a certain group in a certain webscript is a whole diffrent story and does not provide the same functionality.

如果你想要的是后者,你应该打电话给

If what you want is the latter, you should make a call to

/alfresco/service/api/groups/{shortName}

想念并处理响应.

更新: 项目权限属性需要稍微调整一下.在 header.get.js 中,将新角色传播给它在 header.inc.ftl 中得到正确处理:

Update: The item permission attribute requires a little more tweaking. In header.get.js, propagate the new role to it gets processed properly in header.inc.ftl:

model.permissions =
{
    guest: user.isGuest,
    admin: user.isAdmin,
    employee : user.isEmployee
};

这篇关于自定义 Surf 平台根范围 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆