Debug Source Code - Alfresco Content Services - 23.4 - 23.4 - Ready - Alfresco - external

Alfresco Content Services

Platform
Alfresco
Product
Alfresco Content Services
Release
23.4
License

To test out the new debug settings, let’s debug the source code that is called when you call the remote API to get a ticket that can be used for authentication. For more information, seeAuthenticate with the Repository.

Open the alfresco-community-repo project in IntelliJ IDEA and look up the src/main/java/org/alfresco/rest/api/impl/AuthenticationsImpl.java file. Set a breakpoint in this file where a ticket is created, as shown:

The authentication script with authenticationService.authenticate (loginRequest.getUserId() element)

Set up a Remote debugging session in IDEA (Run > Debug… > Edit Configurations… > Remote JVM Debug):

The Debug - Local Alfresco dialog box with Configuration settings, including Debugger mode, host, Port, command line arguments for remote JVM, and Use module classpath

Click Debug to start the debug session:

The message in the Local Afresco that reads Connected to the target VM, address: 'localhost:8000', tranbsport: 'socket'

Now, call the Remote API that is used to log in and get a ticket (using the default admin/admin credentials):

% curl --header "Content-Type: application/json" --request POST --data '{"userId":"admin","password":"admin"}' http://localhost:8080/alfresco/api/-default-/public/authentication/versions/1/tickets

This should make the debugger stop on the breakpoint line in IDEA:

We can see the credentials used to log in, and start debugging the code as we are used to.

This way of debugging works equally well for any custom code that you have applied to Content Services.