Search in sources :

Example 1 with OctaneServices

use of com.microfocus.octane.gitlab.services.OctaneServices in project octane-gitlab-service by MicroFocus.

the class Application method main.

public static void main(String[] args) throws GeneralSecurityException, IOException {
    if (args.length > 0 && args[0].equals("encrypt")) {
        if (args.length == 1) {
            System.out.println("Usage: java -jar octane-gitlab-service-<version>.jar encrypt <password>");
            return;
        } else {
            String tokenToEncrypt = args[1];
            String encryptedToken = encrypt(tokenToEncrypt);
            System.out.println("Encrypted token: " + PasswordEncryption.PREFIX + encryptedToken);
            return;
        }
    }
    ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
    context.registerShutdownHook();
    OctaneServices octaneServices = context.getBean("octaneServices", OctaneServices.class);
    try {
        if (octaneServices.getGitLabService().isCleanUpOnly()) {
            System.out.println("clean-up webhooks from Gitlab server process is finished. Stopping the service");
            context.close();
            return;
        }
        tryToConnectToOctane(octaneServices);
        OctaneSDK.addClient(octaneServices.getOctaneConfiguration(), OctaneServices.class);
        MergeRequestHistoryHandler mrHistoryHandler = context.getBean(MergeRequestHistoryHandler.class);
        mrHistoryHandler.executeFirstScan();
        mrHistoryHandler.startListening();
        System.out.println("Connection to Octane was successful. gitlab application is ready...");
    } catch (IllegalArgumentException | OctaneConnectivityException r) {
        log.warn("Connection to Octane failed: " + r.getMessage());
        System.out.println("Connection to Octane failed: " + r.getMessage());
    }
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) OctaneConnectivityException(com.hp.octane.integrations.exceptions.OctaneConnectivityException) OctaneServices(com.microfocus.octane.gitlab.services.OctaneServices) MergeRequestHistoryHandler(com.microfocus.octane.gitlab.api.MergeRequestHistoryHandler)

Aggregations

OctaneConnectivityException (com.hp.octane.integrations.exceptions.OctaneConnectivityException)1 MergeRequestHistoryHandler (com.microfocus.octane.gitlab.api.MergeRequestHistoryHandler)1 OctaneServices (com.microfocus.octane.gitlab.services.OctaneServices)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1