use of org.onehippo.cms7.crisp.api.broker.ResourceServiceBroker in project hippo by NHS-digital-website.
the class PostcodeRule method validate.
@Override
public boolean validate(Map<String, String[]> map) {
String postcode = map.get(map.keySet().stream().findFirst().get())[0];
String postcodeUrl = null;
if (StringUtils.isNotBlank(postcode)) {
if (postcode.length() >= 5) {
postcodeUrl = postcode.replaceAll("\\s+", "").toUpperCase();
postcodeUrl = postcodeUrl.substring(0, postcodeUrl.length() - 3) + "/" + postcodeUrl.substring(postcodeUrl.length() - 3);
ResourceServiceBroker broker = CrispHstServices.getDefaultResourceServiceBroker(HstServices.getComponentManager());
try {
broker.findResources("postcodeApi", postcodeUrl + ".json");
} catch (Exception e) {
return false;
}
} else {
return false;
}
}
return true;
}
use of org.onehippo.cms7.crisp.api.broker.ResourceServiceBroker in project hippo by NHS-digital-website.
the class SubscriptionResourceTest method setUp.
@Before
public void setUp() {
final Map<String, ResourceResolver> resourceResolverMap = new HashMap<>();
resourceResolverMap.put("govDeliveryApi", new MockJdomResourceResolverAdapter() {
@Override
public Resource resolve(String absPath, Map<String, Object> pathVariables, ExchangeHint exchangeHint) throws ResourceException {
return urlToResource(SubscriptionResourceTest.class.getResource("/subscriber-output.xml"));
}
});
final ResourceServiceBroker mockBroker = new MockResourceServiceBroker(resourceResolverMap);
MockCrispHstServices.setDefaultResourceServiceBroker(mockBroker);
}
use of org.onehippo.cms7.crisp.api.broker.ResourceServiceBroker in project hippo by NHS-digital-website.
the class RemoteContentServiceTest method before.
@Before
public void before() {
Map<String, ResourceResolver> resourceResolverMap = new HashMap<>();
resourceResolverMap.put("testResourceResolver", testResourceResolver);
ResourceServiceBroker mockBroker = new MockResourceServiceBroker(resourceResolverMap);
MockCrispHstServices.setDefaultResourceServiceBroker(mockBroker);
}
Aggregations