How to get Crowd Base Url in Order to use the REST API in a Java Class?

Hi!

I am writing a custom directory connector class and I need to use the Crowd REST API within. I didnt find a way to get the Crowd Base Url e.g. by using ApplicationProperties Interface.

Any hints on how to achieve that would be greatly appreciated!

Regards,
Hans

Hi @computerpraxis,

Crowd provides implementation of AplicationProperties that contains getBaseUrl method. I am not sure how you are using it. I assume that this is not in a plugin, since it is a custom directory implementation?
You’ve already mentioned ApplicationProperties, but is that you cannot find such method there or it is throwing an error or you are getting into some class loader issues?

Best Regards,
Marcin Kempa

Hi!
Thanx for replying!
I couldnt find a class which implements the ApplicationProperties Interface which I could create an instance.
Beause I am not writing a plugin but Java classes, I am not able to use Spring Scanner and all the magic annotatiobs like @Inject, @Componentimport and the likes.
Any further hints ?
Thanx,
Hans

Hi @computerpraxis,

Sorry for getting to you that late.
Whenever Crowd loads a custom directory it also uses Spring’s autowire factory so you could try using following:

import com.atlassian.sal.api.ApplicationProperties;
import org.springframework.beans.factory.annotation.Autowired;
// other imports

public class MyCustomDirectory implements RemoteDirectory {

    private final ApplicationProperties applicationProperties;

    @Autowired
    public MyCustomDirectory(ApplicationProperties applicationProperties){
        this.applicationProperties = applicationProperties;
    }

    // implementation of methods required by RemoteDirectory

Hope that helps!
Marcin Kempa

Hi @computerpraxis

Was that answer helpful?

Cheers,
Marcin Kempa

HI!

Thank You, I was able to implement it with Your hint!

I added @ComponentImport to the ApplicationProperties Ctor param and I had to make a full plugin by adding the spring-scanner dependencies in order to build my Classes sucessfully.

I am trying to use an CrowdClient Interface Object to be used within my RemoteDirectory Interface implementation functions like findUserByName, but I am running into
java.net.SocketTimeoutException: Read timed out exceptions.

Unfortunately the documentation on building Custom Directory Connectors based on RemoteDirectory is VERY poor…

Were You able to create an custom directory connector ?

Regards,
Hans