use of dk.dbc.vipcore.marshallers.ProfileServiceResponse in project solr-document-store by DBCDK.
the class ProfileProviderBean method profileFor.
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@CacheResult(cacheName = "vipProfile", exceptionCacheName = "vipProfileError", cachedExceptions = { IllegalStateException.class, ClientErrorException.class, ServerErrorException.class })
public VipCoreProfile profileFor(String agencyId, String profile) {
try {
String vipCoreResponse = vipCoreHttpClient.getFromVipCore(config.getVipCoreEndpoint(), VipCoreHttpClient.PROFILE_SERVICE_PATH + "/search/" + agencyId + "/" + profile);
log.debug("vipCoreResponse was: {}", vipCoreResponse);
ProfileServiceResponse profileServiceResponse = O.readValue(vipCoreResponse, ProfileServiceResponse.class);
if (profileServiceResponse.getError() != null)
throw new IllegalStateException("profile service: " + profileServiceResponse.getError().value());
return new VipCoreProfile(profileServiceResponse);
} catch (OpenAgencyException ex) {
log.error("Error when fetching profile {} for agencyId {}", profile, agencyId);
throw new IllegalStateException("profile service: " + ex.getMessage());
} catch (JsonProcessingException ex) {
log.error("Error when processing response from VipCore profileservice for agency {} and profile {}: {}", agencyId, profile, ex.getMessage());
log.debug("Error when processing response from VipCore profileservice for agency {} and profile {}: {}", agencyId, profile, ex);
throw new IllegalStateException("profile service: " + ex.getMessage());
}
}
use of dk.dbc.vipcore.marshallers.ProfileServiceResponse in project solr-document-store by DBCDK.
the class VipCoreProfileTest method testFromVipCore.
@Test(timeout = 2_000L)
public void testFromVipCore() throws Exception {
System.out.println("testFromVipCore");
String content = "{'collectionIdentifiers':['150005-analyse','150005-artikel','150005-portraet','150021-bibliotek','150021-fjern','150052-ekurser','150053-turteori','150061-ebog','150061-netlydbog','800000-bibdk','870970-bibdk','870970-lokalbibl','870970-udland','870971-avis','870971-faktalink','870971-forfweb','870971-tsart','870978-artikel','870978-avis','870978-tsart','911116-katalog'],'includeOwnHoldings':false}";
ProfileServiceResponse profileServiceResponse = O.readValue(content.replaceAll("'", "\""), ProfileServiceResponse.class);
VipCoreProfile vipCoreProfile = new VipCoreProfile(profileServiceResponse);
assertThat(vipCoreProfile.hasIncludeOwnHoldings(), is(false));
assertThat(vipCoreProfile.getCollectionIdentifiers(), containsInAnyOrder("150005-analyse", "150005-artikel", "150005-portraet", "150021-bibliotek", "150021-fjern", "150052-ekurser", "150053-turteori", "150061-ebog", "150061-netlydbog", "800000-bibdk", "870970-bibdk", "870970-lokalbibl", "870970-udland", "870971-avis", "870971-faktalink", "870971-forfweb", "870971-tsart", "870978-artikel", "870978-avis", "870978-tsart", "911116-katalog"));
}
Aggregations