Question

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. 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???

Was it helpful?

Solution

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

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.

you can use

<authentication>employee</authentication>

in page descriptors or

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

on the navigation.

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}

miss and works through the response.

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
};

OTHER TIPS

you could try (in JavaScript I managed something like) this:

user = Application.getCurrentUser(context);
       String userName = user.getUserName();
       user.isAdmin() >>> result return true if user logining is admin

or in JSP:

#{NavigationBean.currentUser.admin == true}

Sorry, i noticed now you was talking about Surf Platform root objects, but the link you put there, is deprecated for Alfresco versions above 3.3. You still use something so old? If you manage to use JavaScript API's you could use "person" root object, with boolean isAdmin().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top