How do Jersey endpoints call each other?

73 Views Asked by At

I investigate source code code of guacamole-client:

I try to understand how /api/session/data/postgresql/activeConnections

I was able to run the application, call the endpoint and I debug it.

I was able to put breakpoint here:

@Path("activeConnections")
public DirectoryResource<ActiveConnection, APIActiveConnection>
    getActiveConnectionDirectoryResource() throws GuacamoleException {
    return activeConnectionDirectoryResourceFactory.create(authenticatedUser,
            userContext, userContext.getActiveConnectionDirectory());
}

and I stoped here.

Also I see that after that method call another method is called to prepare response:

@GET
public Map<String, ExternalType> getObjects(
        @QueryParam("permission") List<ObjectPermission.Type> permissions)
        throws GuacamoleException {

    // An admin user has access to all objects
    Permissions effective = userContext.self().getEffectivePermissions();
    SystemPermissionSet systemPermissions = effective.getSystemPermissions();
    boolean isAdmin = systemPermissions.hasPermission(SystemPermission.Type.ADMINISTER);

    // Filter objects, if requested
    Collection<String> identifiers = directory.getIdentifiers();
    if (!isAdmin && permissions != null && !permissions.isEmpty()) {
        ObjectPermissionSet objectPermissions = getObjectPermissions(effective);
        identifiers = objectPermissions.getAccessibleObjects(permissions, identifiers);
    }

    // Translate each retrieved object into the corresponding external object
    Map<String, ExternalType> apiObjects = new HashMap<String, ExternalType>();
    for (InternalType object : directory.getAll(identifiers))
        apiObjects.put(object.getIdentifier(), translator.toExternalObject(object));

    return apiObjects;

}

But I don't see relation of those method in stacktrace.

Could anyone explain connection/relation/dependency between of those methods ?

0

There are 0 best solutions below