cancel
Showing results for 
Search instead for 
Did you mean: 

Using Authority.ftl

malikaasen
Champ on-the-rise
Champ on-the-rise

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 11

angelborroy
Community Manager Community Manager
Community Manager

DataTypeDefinition (Alfresco 5.1.4.1 Public Java API) 

Try NODE_REF

Hyland Developer Evangelist

douglascrp
World-Class Innovator
World-Class Innovator

This is exactly the way I use it.

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?

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

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

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

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

Hyland Developer Evangelist

Ah ok, i did add that on the previous version, but thought that the name you got from NODE_REF was GROUP_X. Will test by tomorrow. Thanks for all the help so far! Been stuck for ages on this one.

douglascrp
World-Class Innovator
World-Class Innovator

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.

Getting started

Explore our Alfresco products with the links below. Use labels to filter content by product module.