Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alfresco REST API, NodesApi.listNodeChildren not processing include parameter correctly (missing @CollectionFormat(feign.CollectionFormat.CSV)) #3034

Open
Verdoso opened this issue Nov 13, 2024 · 0 comments

Comments

@Verdoso
Copy link

Verdoso commented Nov 13, 2024

Hi there,
I'm implement a service that accesses Alfresco 23.1.0 using alfresco-java-rest-api-spring-boot-starter:5.0.0. We also have the Alfresco Explorer, so I can verify the operations and check unexpected results. Now, to the point:

When accessing the endpoint "#/nodes/listNodeChildren", one can specify the fields to be included in the response using the include parameter, that allows you to specify multiple fields. Using the explorer, and specifying the fields (properties, aspectNames, and path) the request sent looks something like this:
.../children?skipCount=0&maxItems=100&include=properties,aspectNames,path

In code, one has to use the NodesApi class that has the corresponding nodesApi.listNodeChildren that accepts a List in the include parameter. But, if you specify the parameter with a list, as expected:
List<String> include = List.of("path", "aspectNames", "properties");
and then check the resulting HTTP request being sent, you will see that it sends a request like this:
.../children?skipCount=0&maxItems=100&include=properties&include=aspectNames&include=path
treating the parameter as multiple. The server does not process that request correctly and just takes into account the last value of the parameter, so you don't see, in this example, the aspectNames or the properties of the resulting nodes.

If, on the other hand, you declare the parameter as a List with one value where the fields are concatenated:
List<String> include = List.of(String.join(",", new String[] {"path", "aspectNames", "properties"}));
you can finally see all the requested fields included.

This problem is caused by Feign and the way the List parameters are handled (see for example this S.O. question: https://stackoverflow.com/questions/41744542/spring-cloud-feign-client-requestparam-with-list-parameter-creates-a-wrong-requ) and it seems that the solution would be to simply specify that the parameters have to be passed as CSV using @CollectionFormat(feign.CollectionFormat.CSV) in the method in the interface.

Cheers!
D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant