Search in sources :

Example 1 with ApigeeService

use of uk.nhs.digital.apispecs.apigee.ApigeeService in project hippo by NHS-digital-website.

the class ApiSpecSyncFromApigeeJob method execute.

// @formatter:on
@Override
public void execute(final RepositoryJobExecutionContext context) {
    log.debug("API Specifications sync from Apigee: start.");
    Session session = null;
    try {
        final String apigeeAllSpecUrl = requireParameter(APIGEE_ALL_SPEC_URL, System.getProperty(APIGEE_ALL_SPEC_URL));
        final String apigeeSingleSpecUrl = requireParameter(APIGEE_SINGLE_SPEC_URL, System.getProperty(APIGEE_SINGLE_SPEC_URL));
        final ResourceServiceBroker resourceServiceBroker = resourceServiceBroker();
        final ApigeeService apigeeService = new ApigeeService(resourceServiceBroker, apigeeAllSpecUrl, apigeeSingleSpecUrl);
        session = context.createSystemSession();
        final ApiSpecificationPublicationService apiSpecificationPublicationService = new ApiSpecificationPublicationService(apigeeService, new ApiSpecificationDocumentJcrRepository(session), new ApiSpecificationImportImportMetadataJcrRepository(session));
        apiSpecificationPublicationService.syncEligibleSpecifications();
        log.debug("API Specifications sync from Apigee: done.");
    } catch (final Exception ex) {
        log.error("Failed to sync specifications from Apigee.", ex);
    } finally {
        Optional.ofNullable(session).ifPresent(Session::logout);
    }
}
Also used : ApigeeService(uk.nhs.digital.apispecs.apigee.ApigeeService) ApiSpecificationImportImportMetadataJcrRepository(uk.nhs.digital.apispecs.jcr.ApiSpecificationImportImportMetadataJcrRepository) ApiSpecificationDocumentJcrRepository(uk.nhs.digital.apispecs.jcr.ApiSpecificationDocumentJcrRepository) ResourceServiceBroker(org.onehippo.cms7.crisp.api.broker.ResourceServiceBroker) Session(javax.jcr.Session) ApiSpecificationPublicationService(uk.nhs.digital.apispecs.ApiSpecificationPublicationService)

Aggregations

Session (javax.jcr.Session)1 ResourceServiceBroker (org.onehippo.cms7.crisp.api.broker.ResourceServiceBroker)1 ApiSpecificationPublicationService (uk.nhs.digital.apispecs.ApiSpecificationPublicationService)1 ApigeeService (uk.nhs.digital.apispecs.apigee.ApigeeService)1 ApiSpecificationDocumentJcrRepository (uk.nhs.digital.apispecs.jcr.ApiSpecificationDocumentJcrRepository)1 ApiSpecificationImportImportMetadataJcrRepository (uk.nhs.digital.apispecs.jcr.ApiSpecificationImportImportMetadataJcrRepository)1