/** * Creates an {@code OnlineResource} element if the given URL is not null. Since ISO 19115 * declares the URL as a mandatory attribute, this method will ignore all other attributes * if the given URL is null. * * @param url the URL (mandatory - if {@code null}, no resource will be created). * @return the online resource, or {@code null} if the URL was null. */ private OnlineResource createOnlineResource(final String url) { final URI uri = createURI(url); if (uri == null) { return null; } final DefaultOnlineResource resource = new DefaultOnlineResource(uri); final String protocol = uri.getScheme(); resource.setProtocol(protocol); if ("http".equalsIgnoreCase(protocol) || "https".equalsIgnoreCase(protocol)) { resource.setApplicationProfile("web browser"); } resource.setFunction(OnLineFunction.INFORMATION); return resource; }
/** * Creates an {@code OnlineResource} element if the given URL is not null. Since ISO 19115 * declares the URL as a mandatory attribute, this method will ignore all other attributes * if the given URL is null. * * @param url the URL (mandatory - if {@code null}, no resource will be created). * @return the online resource, or {@code null} if the URL was null. */ private OnlineResource createOnlineResource(final String url) { final URI uri = createURI(url); if (uri == null) { return null; } final DefaultOnlineResource resource = new DefaultOnlineResource(uri); final String protocol = uri.getScheme(); resource.setProtocol(protocol); if ("http".equalsIgnoreCase(protocol) || "https".equalsIgnoreCase(protocol)) { resource.setApplicationProfile("web browser"); } resource.setFunction(OnLineFunction.INFORMATION); return resource; }
/** * Adds a URL to a more complete description of the metadata. * * <ul> * <li>{@code metadata/metadataLinkage/linkage} * with {@code function} set to {@code OnLineFunction.COMPLETE_METADATA}</li> * </ul> * * @param link */ public final void addCompleteMetadata(final URI link) { if (link != null) { final DefaultOnlineResource ln = new DefaultOnlineResource(link); ln.setFunction(OnLineFunction.valueOf("COMPLETE_METADATA")); ln.setProtocol(link.getScheme()); addIfNotPresent(metadata().getMetadataLinkages(), ln); } }
/** * Adds a URL to a more complete description of the metadata. * Storage location is: * * <ul> * <li>{@code metadata/metadataLinkage/linkage} * with {@code function} set to {@code OnLineFunction.COMPLETE_METADATA}</li> * </ul> * * @param link URL to a more complete description of the metadata, or {@code null}. */ public final void addCompleteMetadata(final URI link) { if (link != null) { final DefaultOnlineResource ln = new DefaultOnlineResource(link); ln.setFunction(OnLineFunction.valueOf("COMPLETE_METADATA")); ln.setProtocol(link.getScheme()); addIfNotPresent(metadata().getMetadataLinkages(), ln); } }
unexpectedException("getAuthority", exception); r.setFunction(function); r.setDescription(description); c.getOnlineResources().add(r);
unexpectedException("getAuthority", exception); r.setFunction(function); r.setDescription(description); c.getOnlineResources().add(r);
/** * Tests XML marshalling for the given metadata version. * * @param file file containing the expected metadata. * @param version the metadata version to marshal. */ private void testMarshalling(final String file, final Version version) throws JAXBException { final DefaultOnlineResource rs = new DefaultOnlineResource(URI.create("https://tools.ietf.org/html/rfc1149")); rs.setName("IP over Avian Carriers"); rs.setDescription(new SimpleInternationalString("High delay, low throughput, and low altitude service.")); rs.setFunction(OnLineFunction.OFFLINE_ACCESS); final DefaultContact contact = new DefaultContact(rs); contact.setContactInstructions(new SimpleInternationalString("Send carrier pigeon.")); contact.getIdentifierMap().putSpecialized(IdentifierSpace.ID, "ip-protocol"); final DefaultCitation c = new DefaultCitation("Fight against poverty"); final DefaultResponsibleParty r1 = new DefaultResponsibleParty(Role.ORIGINATOR); final DefaultResponsibleParty r2 = new DefaultResponsibleParty(Role.valueOf("funder")); r1.setParties(Collections.singleton(new DefaultIndividual("Maid Marian", null, contact))); r2.setParties(Collections.singleton(new DefaultIndividual("Robin Hood", null, contact))); c.setCitedResponsibleParties(Arrays.asList(r1, r2)); c.getDates().add(new DefaultCitationDate(TestUtilities.date("2015-10-17 00:00:00"), DateType.valueOf("adopted"))); c.getPresentationForms().add(PresentationForm.valueOf("physicalObject")); /* * Check that XML file built by the marshaller is the same as the example file. */ assertMarshalEqualsFile(file, c, version, "xmlns:*", "xsi:schemaLocation"); }
final DefaultOnlineResource onlines = new DefaultOnlineResource(URI.create("http://www.ifremer.fr/data/something")); onlines.setDescription(new SimpleInternationalString("CTDF02")); onlines.setFunction(OnLineFunction.DOWNLOAD); onlines.setProtocol("http"); transfer.setOnLines(singleton(onlines));