Using Authority.ftl

cancel
Showing results for 
Search instead for 
Did you mean: 
malikaasen
Active Member

Using Authority.ftl

I am trying to use authority.ftl to select a group that is going to be used in an action for editing group roles. How do i write the java action so that there are no erros? Tried this

protected void addParameterDefinitions(List<ParameterDefinition> list) {
    list.add(new ParameterDefinitionImpl(
X, DataTypeDefinition.TEXT, true,getParamDisplayLabel(X)));

}

But i got the error that the types were different, think it was field.endpointtype. What is this, and how do i get it in the addParameterDefinitions, what type does the authority.ftl return, a string? I assume that you can use AuthorityService afterwards to get the group name or something similar.

Thanks in advance for the help.

11 Replies
angelborroy
Alfresco Employee

Re: Using Authority.ftl

DataTypeDefinition (Alfresco 5.1.4.1 Public Java API) 

Try NODE_REF

Hyland Developer Evangelist
douglascrp
Advanced II

Re: Using Authority.ftl

This is exactly the way I use it.

malikaasen
Active Member

Re: Using Authority.ftl

How do i extract the groupname from node_ref?

This is what i used when i used textfield instead of authority. 

Just changed the Strings to NodeRef as stupid me didnt notice that could be done, but what class is used to get the name of the authority?

angelborroy
Alfresco Employee

Re: Using Authority.ftl

There are other ways, this is one of them:

NodeRef groupNodeRef = (NodeRef) action.getParameterValue(PARAM_GROUP_NAME);
String groupName = nodeService.getProperty(groupNodeRef, ContentModel.PROP_NAME).toString();
Hyland Developer Evangelist
malikaasen
Active Member

Re: Using Authority.ftl

I tried that, but i still get the error, maybe there is something wrong with how i added the form?

malikaasen
Active Member

Re: Using Authority.ftl

Here is the whole class, probably makes it easier to notice where things go wrong...

The class takes the groupname, makes a folder of it, and gives permissions to the group

douglascrp
Advanced II

Re: Using Authority.ftl

You can do something like:

final NodeRef group = (NodeRef) action.getParameterValue(PARAM_GROUP_NAME); // your parameter should be simply PARAM_GROUP, as there is no real name in it
Map<QName, Serializable> groupProperties = nodeService.getProperties(group);‍‍‍

And then you can read the property you want from the groupProperties object.

I have not tested the code, but I guess you will be able to fix it if required.

douglascrp
Advanced II

Re: Using Authority.ftl

My bad... I left the tab open when I went to have lunch, and then sent the answer without checking if someone had answered

angelborroy
Alfresco Employee

Re: Using Authority.ftl

Probably you have to add "GROUP_" to the name of the group to set permissions.

Hyland Developer Evangelist