use of org.geotoolkit.se.xml.v110.DescriptionType in project mod-oai-pmh by folio-org.
the class GetOaiRepositoryInfoHelper method buildOaiIdentifierDescription.
/**
* Creates oai-identifier description
*
* @param request the OAI-PMH request holder
* @return oai-identifier {@link DescriptionType} elements
*/
private DescriptionType buildOaiIdentifierDescription(Request request) throws MalformedURLException {
OaiIdentifier oaiIdentifier = new OaiIdentifier();
oaiIdentifier.setRepositoryIdentifier(new URL(request.getOaiRequest().getValue()).getHost());
oaiIdentifier.setSampleIdentifier(getIdentifier(request.getIdentifierPrefix(), STORAGE_IDENTIFIER_SAMPLE));
return new DescriptionType().withAny(oaiIdentifier);
}
use of org.geotoolkit.se.xml.v110.DescriptionType in project geotoolkit by Geomatys.
the class ProvidersXmlTest method testMarshallingWithSLD.
/**
* Test for the marshalling process of a {@link MapContext}.
*
* @throws JAXBException
*/
@Test
public void testMarshallingWithSLD() throws JAXBException, Exception {
final List<MapItem> mapLayers2 = new ArrayList<>();
final StyledLayerDescriptor sld = new StyledLayerDescriptor();
final UserStyle us = new UserStyle();
final DescriptionType title = new DescriptionType();
title.setTitle("test_sld");
us.setDescription(title);
final FeatureTypeStyleType fts = new FeatureTypeStyleType();
fts.setName("ft_test");
us.getFeatureTypeStyleOrCoverageStyleOrOnlineResource().add(fts);
final UserLayer ul = new UserLayer();
ul.getUserStyle().add(us);
sld.getNamedLayerOrUserLayer().add(ul);
mapLayers2.add(new MapLayer(new DataReference("postgis_test:my_otherlayer"), sld));
mapLayers2.add(new MapLayer(new DataReference("coverage:my_thirdlayer"), new StyleReference("my_newstyle")));
final List<MapItem> mapItems = new ArrayList<>();
mapItems.add(new MapItem(mapLayers2));
final MapLayer ml = new MapLayer(new DataReference("postgis_test:my_layer"), new StyleReference("my_style"));
mapItems.add(new MapItem());
mapItems.add(ml);
final MapItem mapItem = new MapItem(mapItems);
final MapContext mapContext = new MapContext(mapItem);
final StringWriter sw = new StringWriter();
marshaller.marshal(mapContext, sw);
final String result = sw.toString();
try {
sw.close();
} catch (IOException e) {
fail("Unable to close the writer");
}
assertNotNull(result);
assertFalse(result.isEmpty());
DocumentComparator comparator = new DocumentComparator(RESULT_MARSHALLING_WITH_SLD, result.trim());
comparator.ignoredAttributes.add("http://www.w3.org/2000/xmlns:*");
comparator.compare();
}
use of org.geotoolkit.se.xml.v110.DescriptionType in project openaire-cris-validator by EuroCRIS.
the class FileLoggingConnectionStreamFactory method check000_Identify.
/**
* Ask for ?verb=Identity and test it for consistence – checks (1).
* @throws Exception on any unexpected circumstance
*/
@Test
public void check000_Identify() throws Exception {
final IdentifyType identify = endpoint.callIdentify();
CheckingIterable<DescriptionType> checker = CheckingIterable.over(identify.getDescription());
checker = checker.checkContainsOne(new Predicate<DescriptionType>() {
@Override
public boolean test(final DescriptionType description) {
final Object obj = description.getAny();
if (obj instanceof JAXBElement<?>) {
final JAXBElement<?> jaxbEl = (JAXBElement<?>) obj;
final Object obj1 = jaxbEl.getValue();
if (obj1 instanceof OaiIdentifierType) {
final OaiIdentifierType oaiIdentifier = (OaiIdentifierType) obj1;
sampleIdentifier = Optional.ofNullable(oaiIdentifier.getSampleIdentifier());
return true;
}
}
return false;
}
}, "the Identify descriptions list (1b)", "an 'oai-identifier' element");
checker = checker.checkContainsOne(new Predicate<DescriptionType>() {
@Override
public boolean test(final DescriptionType description) {
final Object obj = description.getAny();
if (obj instanceof Element) {
final Element el = (Element) obj;
if ("Service".equals(el.getLocalName()) && OPENAIRE_CERIF_XMLNS.equals(el.getNamespaceURI())) {
serviceAcronym = XmlUtils.getTextContents(XmlUtils.getFirstMatchingChild(el, "Acronym", el.getNamespaceURI()));
validateMetadataPayload(el);
return true;
}
}
return false;
}
}, "the Identify descriptions list (1a)", "a 'Service' element");
checker.run();
if (!endpoint.getBaseUrl().startsWith("file:")) {
assertEquals("Identify response has a different endpoint base URL (1d)", endpoint.getBaseUrl(), identify.getBaseURL());
}
final Optional<String> repoIdentifier = endpoint.getRepositoryIdentifer();
if (serviceAcronym.isPresent() && repoIdentifier.isPresent()) {
assertEquals("Service acronym is not the same as the repository identifier (1c)", serviceAcronym.get(), repoIdentifier.get());
}
}
use of org.geotoolkit.se.xml.v110.DescriptionType in project openaire-cris-validator by EuroCRIS.
the class OAIPMHEndpoint method extractRepoIdentifier.
/**
* Extracts the OAI identifier's repository identifier value.
* @param identifyResponse the response to an Identify request
* @param the repository identifier if one is provided, an empty {@link Optional} otherwise.
*/
private Optional<String> extractRepoIdentifier(final IdentifyType identifyResponse) {
for (final DescriptionType description : identifyResponse.getDescription()) {
final Object obj = description.getAny();
if (obj instanceof JAXBElement<?>) {
final JAXBElement<?> jaxbEl = (JAXBElement<?>) obj;
final Object obj1 = jaxbEl.getValue();
if (obj1 instanceof OaiIdentifierType) {
final OaiIdentifierType oaiIdentifier = (OaiIdentifierType) obj1;
return Optional.ofNullable(oaiIdentifier.getRepositoryIdentifier());
}
}
}
return Optional.empty();
}
Aggregations