Search in sources :

Example 1 with OkapiData

use of org.folio.holdingsiq.model.OkapiData in project mod-kb-ebsco-java by folio-org.

the class EholdingsProvidersImpl method putEholdingsProvidersTagsByProviderId.

@Override
public void putEholdingsProvidersTagsByProviderId(String providerId, String contentType, ProviderTagsPutRequest entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
    final Tags tags = entity.getData().getAttributes().getTags();
    userKbCredentialsService.findByUser(okapiHeaders).thenCompose(creds -> {
        ProviderTagsDataAttributes attributes = entity.getData().getAttributes();
        providerTagsPutBodyValidator.validate(entity, attributes);
        return updateTags(createDbProvider(providerId, UUID.fromString(creds.getId()), entity.getData().getAttributes()), tags, new OkapiData(okapiHeaders).getTenant()).thenAccept(ob -> asyncResultHandler.handle(Future.succeededFuture(PutEholdingsProvidersTagsByProviderIdResponse.respond200WithApplicationVndApiJson(convertToProviderTags(attributes)))));
    }).exceptionally(e -> {
        new ErrorHandler().addInputValidation422Mapper().handle(asyncResultHandler, e);
        return null;
    });
}
Also used : EholdingsProviders(org.folio.rest.jaxrs.resource.EholdingsProviders) RMAPITemplateFactory(org.folio.rest.util.template.RMAPITemplateFactory) Filter(org.folio.rest.model.filter.Filter) TagRepository(org.folio.repository.tag.TagRepository) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Autowired(org.springframework.beans.factory.annotation.Autowired) ProviderPutRequest(org.folio.rest.jaxrs.model.ProviderPutRequest) Context(io.vertx.core.Context) JSONAPI(org.folio.rest.util.RestConstants.JSONAPI) IdParser.parseProviderId(org.folio.rest.util.IdParser.parseProviderId) ProviderPutDataAttributes(org.folio.rest.jaxrs.model.ProviderPutDataAttributes) HandleValidationErrors(org.folio.rest.aspect.HandleValidationErrors) Map(java.util.Map) OkapiData(org.folio.holdingsiq.model.OkapiData) DbProvider(org.folio.repository.providers.DbProvider) Collections.emptyList(java.util.Collections.emptyList) RowSetUtils.toUUID(org.folio.db.RowSetUtils.toUUID) UUID(java.util.UUID) Future(io.vertx.core.Future) ProviderCollection(org.folio.rest.jaxrs.model.ProviderCollection) Objects(java.util.Objects) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) ProviderTagsItem(org.folio.rest.jaxrs.model.ProviderTagsItem) List(java.util.List) Response(javax.ws.rs.core.Response) ErrorUtil(org.folio.rest.util.ErrorUtil) IdParser.getPackageIds(org.folio.rest.util.IdParser.getPackageIds) RMAPITemplateContext(org.folio.rest.util.template.RMAPITemplateContext) UserKbCredentialsService(org.folio.service.kbcredentials.UserKbCredentialsService) RecordKey(org.folio.repository.RecordKey) FilteredEntitiesLoader(org.folio.service.loader.FilteredEntitiesLoader) RecordType(org.folio.repository.RecordType) PackageCollectionResult(org.folio.rmapi.result.PackageCollectionResult) Tags(org.folio.rest.jaxrs.model.Tags) CompletableFuture(java.util.concurrent.CompletableFuture) Provider(org.folio.rest.jaxrs.model.Provider) VendorPut(org.folio.holdingsiq.model.VendorPut) InputValidationException(org.folio.rest.exception.InputValidationException) SpringContextUtil(org.folio.spring.SpringContextUtil) Value(org.springframework.beans.factory.annotation.Value) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ProviderPutBodyValidator(org.folio.rest.validator.ProviderPutBodyValidator) RelatedEntitiesLoader(org.folio.service.loader.RelatedEntitiesLoader) AsyncResult(io.vertx.core.AsyncResult) RMAPITemplate(org.folio.rest.util.template.RMAPITemplate) VendorById(org.folio.holdingsiq.model.VendorById) Converter(org.springframework.core.convert.converter.Converter) ProviderTagsPutRequest(org.folio.rest.jaxrs.model.ProviderTagsPutRequest) ProviderTags(org.folio.rest.jaxrs.model.ProviderTags) ExceptionMappers.error422InputValidationMapper(org.folio.rest.util.ExceptionMappers.error422InputValidationMapper) Vertx(io.vertx.core.Vertx) ResourceNotFoundException(org.folio.holdingsiq.service.exception.ResourceNotFoundException) ErrorHandler(org.folio.rest.util.ErrorHandler) ProviderTagsPutBodyValidator(org.folio.rest.validator.ProviderTagsPutBodyValidator) VendorResult(org.folio.rmapi.result.VendorResult) Validate(org.folio.rest.annotations.Validate) ProviderTagsDataAttributes(org.folio.rest.jaxrs.model.ProviderTagsDataAttributes) PackageRepository(org.folio.repository.packages.PackageRepository) Packages(org.folio.holdingsiq.model.Packages) TAGS_TYPE(org.folio.rest.util.RestConstants.TAGS_TYPE) Handler(io.vertx.core.Handler) ProviderRepository(org.folio.repository.providers.ProviderRepository) ErrorHandler(org.folio.rest.util.ErrorHandler) ProviderTagsDataAttributes(org.folio.rest.jaxrs.model.ProviderTagsDataAttributes) OkapiData(org.folio.holdingsiq.model.OkapiData) Tags(org.folio.rest.jaxrs.model.Tags) ProviderTags(org.folio.rest.jaxrs.model.ProviderTags)

Example 2 with OkapiData

use of org.folio.holdingsiq.model.OkapiData in project mod-kb-ebsco-java by folio-org.

the class RMAPITemplate method getRmapiTemplateContext.

public CompletableFuture<RMAPITemplateContext> getRmapiTemplateContext() {
    headerValidator.validate(okapiHeaders);
    return CompletableFuture.completedFuture(null).thenCompose(o -> {
        OkapiData okapiData = new OkapiData(okapiHeaders);
        contextBuilder.okapiData(okapiData);
        return userKbCredentialsService.findByUser(okapiHeaders);
    }).thenAccept(contextBuilder::kbCredentials).thenApply(unused -> contextBuilder.build());
}
Also used : OkapiData(org.folio.holdingsiq.model.OkapiData)

Example 3 with OkapiData

use of org.folio.holdingsiq.model.OkapiData in project mod-kb-ebsco-java by folio-org.

the class LocaleSettingsServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    Map<String, String> headers = new HashMap<>();
    headers.put(XOkapiHeaders.TOKEN, STUB_TOKEN);
    headers.put(XOkapiHeaders.TENANT, STUB_TENANT);
    headers.put(XOkapiHeaders.URL, getWiremockUrl());
    okapiParams = new OkapiData(headers);
}
Also used : HashMap(java.util.HashMap) OkapiData(org.folio.holdingsiq.model.OkapiData) Before(org.junit.Before)

Example 4 with OkapiData

use of org.folio.holdingsiq.model.OkapiData in project mod-kb-ebsco-java by folio-org.

the class KbCredentialsServiceImpl method verifyCredentials.

private CompletableFuture<Void> verifyCredentials(DbKbCredentials dbKbCredentials, Map<String, String> okapiHeaders) {
    Configuration configuration = convertToConfiguration(dbKbCredentials);
    return configurationService.verifyCredentials(configuration, context, new OkapiData(okapiHeaders)).thenCompose(errors -> {
        if (!errors.isEmpty()) {
            CompletableFuture<Void> future = new CompletableFuture<>();
            future.completeExceptionally(new ConfigurationInvalidException(errors));
            return future;
        }
        return completedFuture(null);
    });
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Configuration(org.folio.holdingsiq.model.Configuration) ConfigurationInvalidException(org.folio.holdingsiq.service.exception.ConfigurationInvalidException) OkapiData(org.folio.holdingsiq.model.OkapiData)

Aggregations

OkapiData (org.folio.holdingsiq.model.OkapiData)4 CompletableFuture (java.util.concurrent.CompletableFuture)2 AsyncResult (io.vertx.core.AsyncResult)1 Context (io.vertx.core.Context)1 Future (io.vertx.core.Future)1 Handler (io.vertx.core.Handler)1 Vertx (io.vertx.core.Vertx)1 Collections.emptyList (java.util.Collections.emptyList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 UUID (java.util.UUID)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 Response (javax.ws.rs.core.Response)1 RowSetUtils.toUUID (org.folio.db.RowSetUtils.toUUID)1 Configuration (org.folio.holdingsiq.model.Configuration)1 Packages (org.folio.holdingsiq.model.Packages)1 VendorById (org.folio.holdingsiq.model.VendorById)1 VendorPut (org.folio.holdingsiq.model.VendorPut)1