You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2013/06/28 20:02:31 UTC
svn commit: r1497862 - in /sis/branches/JDK6: ./
core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/
core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/
core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/ core/sis...
Author: desruisseaux
Date: Fri Jun 28 18:02:30 2013
New Revision: 1497862
URL: http://svn.apache.org/r1497862
Log:
Merge from the JDK7 branch.
Added:
sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/SourceRepositoryURL.java
- copied, changed from r1497861, sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/SourceRepositoryURL.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/AnchorMarshallingTest.java
- copied unchanged from r1497825, sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/AnchorMarshallingTest.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/CustomMetadataTest.java
- copied, changed from r1497825, sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/CustomMetadataTest.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/ObjectReferenceMarshallingTest.java
- copied unchanged from r1497825, sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/ObjectReferenceMarshallingTest.java
Modified:
sis/branches/JDK6/ (props changed)
sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/FreeTextMarshallingTest.java
sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageMarshallingTest.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/ReferenceResolverMock.java
Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1497587-1497861
Copied: sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/SourceRepositoryURL.java (from r1497861, sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/SourceRepositoryURL.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/SourceRepositoryURL.java?p2=sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/SourceRepositoryURL.java&p1=sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/SourceRepositoryURL.java&r1=1497861&r2=1497862&rev=1497862&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/SourceRepositoryURL.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/SourceRepositoryURL.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -75,13 +75,14 @@ public final class SourceRepositoryURL e
*/
@Override
public String toString(final Tag tag) {
- final StringBuilder url = new StringBuilder("https://svn.apache.org/repos/asf/sis/branches/JDK7");
+ final StringBuilder url = new StringBuilder("http://svn.apache.org/repos/asf/sis/branches/JDK6");
final String keyword = tag.text();
- switch (keyword) {
- case "gmd-data": url.append("/core/sis-metadata/src/test/resources/org/apache/sis/xml"); break;
- default: {
+ /* switch (keyword) */ {
+ if (keyword.equals("gmd-data")) {
+ url.append("/core/sis-metadata/src/test/resources/org/apache/sis/xml");
+ }
+ else {
ConfigurationImpl.getInstance().root.printWarning(tag.position(), "Unknown keyword: " + keyword);
- break;
}
}
return url.toString();
Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java?rev=1497862&r1=1497861&r2=1497862&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -16,19 +16,30 @@
*/
package org.apache.sis.metadata.iso;
+import java.util.UUID;
import java.util.Collection;
import java.util.logging.Logger;
import java.io.Serializable;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import org.opengis.metadata.Identifier;
import org.apache.sis.xml.IdentifierMap;
+import org.apache.sis.xml.IdentifierSpace;
import org.apache.sis.xml.IdentifiedObject;
+import org.apache.sis.xml.ValueConverter;
import org.apache.sis.metadata.MetadataStandard;
import org.apache.sis.metadata.ModifiableMetadata;
import org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCases;
+import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.CharSequences;
import org.apache.sis.util.ThreadSafe;
+import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
+
/**
* The base class of ISO 19115 implementation classes. Each sub-classes implements one
@@ -124,4 +135,62 @@ public class ISOMetadata extends Modifia
*/
return new IdentifierMapWithSpecialCases(identifiers);
}
+
+ /**
+ * Returns an identifier unique for the XML document, or {@code null} if none.
+ * This method is invoked automatically by JAXB and should never be invoked explicitely.
+ */
+ @XmlID
+ @XmlAttribute // Defined in "gco" as unqualified attribute.
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ private String getID() {
+ return isNullOrEmpty(identifiers) ? null : getIdentifierMap().getSpecialized(IdentifierSpace.ID);
+ }
+
+ /**
+ * Sets an identifier unique for the XML document.
+ * This method is invoked automatically by JAXB and should never be invoked explicitely.
+ */
+ private void setID(String id) {
+ id = CharSequences.trimWhitespaces(id);
+ if (id != null && !id.isEmpty()) {
+ getIdentifierMap().putSpecialized(IdentifierSpace.ID, id);
+ }
+ }
+
+ /**
+ * Returns an unique identifier, or {@code null} if none.
+ * This method is invoked automatically by JAXB and should never be invoked explicitely.
+ */
+ @XmlAttribute // Defined in "gco" as unqualified attribute.
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ private String getUUID() {
+ return isNullOrEmpty(identifiers) ? null : getIdentifierMap().get(IdentifierSpace.UUID);
+ }
+
+ /**
+ * Sets an unique identifier.
+ * This method is invoked automatically by JAXB and should never be invoked explicitely.
+ *
+ * @throws IllegalArgumentException If the UUID is already assigned to an other object.
+ */
+ private void setUUID(String id) {
+ final Context context = Context.current();
+ final ValueConverter converter = Context.converter(context);
+ final UUID uuid;
+ try {
+ uuid = converter.toUUID(context, id);
+ } catch (IllegalArgumentException e) {
+ // IF we can not store the value as a UUID, store it as a String.
+ Context.warningOccured(context, this, ISOMetadata.class, "setUUID", e, false);
+ id = CharSequences.trimWhitespaces(id);
+ if (id != null && !id.isEmpty()) {
+ getIdentifierMap().put(IdentifierSpace.UUID, id);
+ }
+ return;
+ }
+ if (uuid != null) {
+ getIdentifierMap().putSpecialized(IdentifierSpace.UUID, uuid);
+ }
+ }
}
Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1497862&r1=1497861&r2=1497862&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -351,7 +351,9 @@ public class ImmutableIdentifier impleme
throw new InvalidParameterValueException(
Errors.format(Errors.Keys.IllegalArgumentValue_2, key, value), exception, key, value);
}
- ensureNonNull(CODE_KEY, code);
+ if (code == null) {
+ throw new IllegalArgumentException(Errors.format(Errors.Keys.MissingValueForProperty_1, CODE_KEY));
+ }
}
/**
Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java?rev=1497862&r1=1497861&r2=1497862&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/gml/TimePeriodTest.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -66,9 +66,11 @@ public final strictfp class TimePeriodTe
* The (un)marshallers locale and timezone will be set to fixed values.
*
* @throws JAXBException If an error occurred while creating the pool.
+ *
+ * @see #disposeMarshallerPool()
*/
@BeforeClass
- public static void createMarshallers() throws JAXBException {
+ public static void createMarshallerPool() throws JAXBException {
final Map<String,Object> properties = new HashMap<String,Object>(4);
assertNull(properties.put(XML.LOCALE, Locale.FRANCE));
assertNull(properties.put(XML.TIMEZONE, "CET"));
@@ -133,18 +135,18 @@ public final strictfp class TimePeriodTe
final TimePeriodBound end = new TimePeriodBound.GML2(new DummyInstant(date("2007-12-31 00:00:00")));
clearContext();
testPeriod(begin, end,
- "<gml:TimePeriod>\n" +
- " <gml:begin>\n" +
- " <gml:TimeInstant>\n" +
- " <gml:timePosition>1992-01-01T01:00:00+01:00</gml:timePosition>\n" +
- " </gml:TimeInstant>\n" +
- " </gml:begin>\n" +
- " <gml:end>\n" +
- " <gml:TimeInstant>\n" +
- " <gml:timePosition>2007-12-31T01:00:00+01:00</gml:timePosition>\n" +
- " </gml:TimeInstant>\n" +
- " </gml:end>\n" +
- "</gml:TimePeriod>\n", true);
+ "<gml:TimePeriod>\n" +
+ " <gml:begin>\n" +
+ " <gml:TimeInstant>\n" +
+ " <gml:timePosition>1992-01-01T01:00:00+01:00</gml:timePosition>\n" +
+ " </gml:TimeInstant>\n" +
+ " </gml:begin>\n" +
+ " <gml:end>\n" +
+ " <gml:TimeInstant>\n" +
+ " <gml:timePosition>2007-12-31T01:00:00+01:00</gml:timePosition>\n" +
+ " </gml:TimeInstant>\n" +
+ " </gml:end>\n" +
+ "</gml:TimePeriod>\n", true);
}
/**
@@ -186,10 +188,10 @@ public final strictfp class TimePeriodTe
final TimePeriodBound end = new TimePeriodBound.GML3(new DummyInstant(date("2007-12-31 00:00:00")), "after");
clearContext();
testPeriod(begin, end,
- "<gml:TimePeriod>\n" +
- " <gml:beginPosition>1992-01-01T01:00:00+01:00</gml:beginPosition>\n" +
- " <gml:endPosition>2007-12-31T01:00:00+01:00</gml:endPosition>\n" +
- "</gml:TimePeriod>\n", true);
+ "<gml:TimePeriod>\n" +
+ " <gml:beginPosition>1992-01-01T01:00:00+01:00</gml:beginPosition>\n" +
+ " <gml:endPosition>2007-12-31T01:00:00+01:00</gml:endPosition>\n" +
+ "</gml:TimePeriod>\n", true);
}
/**
@@ -205,10 +207,10 @@ public final strictfp class TimePeriodTe
final TimePeriodBound end = new TimePeriodBound.GML3(new DummyInstant(date("2007-12-30 23:00:00")), "after");
clearContext();
testPeriod(begin, end,
- "<gml:TimePeriod>\n" +
- " <gml:beginPosition>1992-01-02</gml:beginPosition>\n" +
- " <gml:endPosition>2007-12-31</gml:endPosition>\n" +
- "</gml:TimePeriod>\n", false);
+ "<gml:TimePeriod>\n" +
+ " <gml:beginPosition>1992-01-02</gml:beginPosition>\n" +
+ " <gml:endPosition>2007-12-31</gml:endPosition>\n" +
+ "</gml:TimePeriod>\n", false);
}
/**
@@ -224,10 +226,10 @@ public final strictfp class TimePeriodTe
final TimePeriodBound end = new TimePeriodBound.GML3(new DummyInstant(date("2007-12-30 23:00:00")), "after");
clearContext();
testPeriod(begin, end,
- "<gml:TimePeriod>\n" +
- " <gml:beginPosition indeterminatePosition=\"before\"/>\n" +
- " <gml:endPosition>2007-12-31</gml:endPosition>\n" +
- "</gml:TimePeriod>\n", false);
+ "<gml:TimePeriod>\n" +
+ " <gml:beginPosition indeterminatePosition=\"before\"/>\n" +
+ " <gml:endPosition>2007-12-31</gml:endPosition>\n" +
+ "</gml:TimePeriod>\n", false);
}
/**
@@ -243,9 +245,9 @@ public final strictfp class TimePeriodTe
final TimePeriodBound end = new TimePeriodBound.GML3(null, "after");
clearContext();
testPeriod(begin, end,
- "<gml:TimePeriod>\n" +
- " <gml:beginPosition>1992-01-02</gml:beginPosition>\n" +
- " <gml:endPosition indeterminatePosition=\"after\"/>\n" +
- "</gml:TimePeriod>\n", false);
+ "<gml:TimePeriod>\n" +
+ " <gml:beginPosition>1992-01-02</gml:beginPosition>\n" +
+ " <gml:endPosition indeterminatePosition=\"after\"/>\n" +
+ "</gml:TimePeriod>\n", false);
}
}
Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1497862&r1=1497861&r2=1497862&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -56,11 +56,14 @@ import org.junit.BeforeClass;
org.apache.sis.metadata.iso.AllMetadataTest.class,
// XML marshalling.
- org.apache.sis.xml.NilReasonMarshallingTest.class,
- org.apache.sis.xml.FreeTextMarshallingTest.class,
org.apache.sis.internal.jaxb.code.CodeListMarshallingTest.class,
org.apache.sis.internal.jaxb.gmd.LanguageMarshallingTest.class,
- org.apache.sis.internal.jaxb.gml.TimePeriodTest.class
+ org.apache.sis.internal.jaxb.gml.TimePeriodTest.class,
+ org.apache.sis.xml.FreeTextMarshallingTest.class,
+ org.apache.sis.xml.NilReasonMarshallingTest.class,
+ org.apache.sis.xml.AnchorMarshallingTest.class,
+ org.apache.sis.xml.ObjectReferenceMarshallingTest.class,
+ org.apache.sis.xml.CustomMetadataTest.class
})
public final strictfp class MetadataTestSuite extends TestSuite {
/**
Copied: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/CustomMetadataTest.java (from r1497825, sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/CustomMetadataTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/CustomMetadataTest.java?p2=sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/CustomMetadataTest.java&p1=sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/CustomMetadataTest.java&r1=1497825&r2=1497862&rev=1497862&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/CustomMetadataTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/CustomMetadataTest.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -99,13 +99,13 @@ public final strictfp class CustomMetada
public void testSubtypeAttributes() throws JAXBException {
final DataIdentification identification = new DataIdentification() {
@Override public InternationalString getAbstract() {
- Map<Locale, String> names = new HashMap<>();
+ Map<Locale, String> names = new HashMap<Locale, String>();
names.put(Locale.ENGLISH, "Description");
return DefaultFactories.NAMES.createInternationalString(names);
}
@Override public InternationalString getEnvironmentDescription() {
- Map<Locale, String> names = new HashMap<>();
+ Map<Locale, String> names = new HashMap<Locale, String>();
names.put(Locale.ENGLISH, "Environment");
return DefaultFactories.NAMES.createInternationalString(names);
}
Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/FreeTextMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/FreeTextMarshallingTest.java?rev=1497862&r1=1497861&r2=1497862&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/FreeTextMarshallingTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/FreeTextMarshallingTest.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -60,22 +60,22 @@ public final strictfp class FreeTextMars
@Test
public void testStandard() throws JAXBException {
final String expected =
- "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + "\" xmlns:gco=\"" + Namespaces.GCO + "\" xmlns:xsi=\"" + Namespaces.XSI + "\">\n" +
- " <gmd:title xsi:type=\"gmd:PT_FreeText_PropertyType\">\n" +
- " <gco:CharacterString>OpenSource Project</gco:CharacterString>\n" +
- " <gmd:PT_FreeText>\n" +
- " <gmd:textGroup>\n" +
- " <gmd:LocalisedCharacterString locale=\"#locale-eng\">OpenSource Project</gmd:LocalisedCharacterString>\n" +
- " </gmd:textGroup>\n" +
- " <gmd:textGroup>\n" +
- " <gmd:LocalisedCharacterString locale=\"#locale-ita\">Progetto OpenSource</gmd:LocalisedCharacterString>\n" +
- " </gmd:textGroup>\n" +
- " <gmd:textGroup>\n" +
- " <gmd:LocalisedCharacterString locale=\"#locale-fra\">Projet OpenSource</gmd:LocalisedCharacterString>\n" +
- " </gmd:textGroup>\n" +
- " </gmd:PT_FreeText>\n" +
- " </gmd:title>\n" +
- "</gmd:CI_Citation>\n";
+ "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + "\" xmlns:gco=\"" + Namespaces.GCO + "\" xmlns:xsi=\"" + Namespaces.XSI + "\">\n" +
+ " <gmd:title xsi:type=\"gmd:PT_FreeText_PropertyType\">\n" +
+ " <gco:CharacterString>OpenSource Project</gco:CharacterString>\n" +
+ " <gmd:PT_FreeText>\n" +
+ " <gmd:textGroup>\n" +
+ " <gmd:LocalisedCharacterString locale=\"#locale-eng\">OpenSource Project</gmd:LocalisedCharacterString>\n" +
+ " </gmd:textGroup>\n" +
+ " <gmd:textGroup>\n" +
+ " <gmd:LocalisedCharacterString locale=\"#locale-ita\">Progetto OpenSource</gmd:LocalisedCharacterString>\n" +
+ " </gmd:textGroup>\n" +
+ " <gmd:textGroup>\n" +
+ " <gmd:LocalisedCharacterString locale=\"#locale-fra\">Projet OpenSource</gmd:LocalisedCharacterString>\n" +
+ " </gmd:textGroup>\n" +
+ " </gmd:PT_FreeText>\n" +
+ " </gmd:title>\n" +
+ "</gmd:CI_Citation>\n";
final Citation citation = (Citation) XML.unmarshal(expected);
assertEquals(getExpectedI18N(), citation.getTitle());
@@ -94,18 +94,18 @@ public final strictfp class FreeTextMars
@Test
public void testLegacy() throws JAXBException {
final String legacy =
- "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + "\" xmlns:gco=\"" + Namespaces.GCO + "\" xmlns:xsi=\"" + Namespaces.XSI + "\">\n" +
- " <gmd:title xsi:type=\"gmd:PT_FreeText_PropertyType\">\n" +
- " <gco:CharacterString>OpenSource Project</gco:CharacterString>\n" +
- " <gmd:PT_FreeText>\n" +
- " <gmd:textGroup>\n" +
- " <gmd:LocalisedCharacterString locale=\"#locale-eng\">OpenSource Project</gmd:LocalisedCharacterString>\n" +
- " <gmd:LocalisedCharacterString locale=\"#locale-ita\">Progetto OpenSource</gmd:LocalisedCharacterString>\n" +
- " <gmd:LocalisedCharacterString locale=\"#locale-fra\">Projet OpenSource</gmd:LocalisedCharacterString>\n" +
- " </gmd:textGroup>\n" +
- " </gmd:PT_FreeText>\n" +
- " </gmd:title>\n" +
- "</gmd:CI_Citation>\n";
+ "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + "\" xmlns:gco=\"" + Namespaces.GCO + "\" xmlns:xsi=\"" + Namespaces.XSI + "\">\n" +
+ " <gmd:title xsi:type=\"gmd:PT_FreeText_PropertyType\">\n" +
+ " <gco:CharacterString>OpenSource Project</gco:CharacterString>\n" +
+ " <gmd:PT_FreeText>\n" +
+ " <gmd:textGroup>\n" +
+ " <gmd:LocalisedCharacterString locale=\"#locale-eng\">OpenSource Project</gmd:LocalisedCharacterString>\n" +
+ " <gmd:LocalisedCharacterString locale=\"#locale-ita\">Progetto OpenSource</gmd:LocalisedCharacterString>\n" +
+ " <gmd:LocalisedCharacterString locale=\"#locale-fra\">Projet OpenSource</gmd:LocalisedCharacterString>\n" +
+ " </gmd:textGroup>\n" +
+ " </gmd:PT_FreeText>\n" +
+ " </gmd:title>\n" +
+ "</gmd:CI_Citation>\n";
final Citation citation = (Citation) XML.unmarshal(legacy);
assertEquals(getExpectedI18N(), citation.getTitle());
Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java?rev=1497862&r1=1497861&r2=1497862&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -44,14 +44,14 @@ public final strictfp class NilReasonMar
@Test
public void testMissing() throws JAXBException {
final String expected =
- "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + '"' +
- " xmlns:gco=\"" + Namespaces.GCO + '"' +
- " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" +
- " <gmd:title>\n" +
- " <gco:CharacterString>A title</gco:CharacterString>\n" +
- " </gmd:title>\n" +
- " <gmd:series gco:nilReason=\"missing\"/>\n" +
- "</gmd:CI_Citation>";
+ "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + '"' +
+ " xmlns:gco=\"" + Namespaces.GCO + '"' +
+ " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" +
+ " <gmd:title>\n" +
+ " <gco:CharacterString>A title</gco:CharacterString>\n" +
+ " </gmd:title>\n" +
+ " <gmd:series gco:nilReason=\"missing\"/>\n" +
+ "</gmd:CI_Citation>";
final Citation citation = (Citation) XML.unmarshal(expected);
assertEquals("title", "A title", citation.getTitle().toString());
@@ -80,14 +80,14 @@ public final strictfp class NilReasonMar
@Test
public void testOther() throws JAXBException {
final String expected =
- "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + '"' +
- " xmlns:gco=\"" + Namespaces.GCO + '"' +
- " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" +
- " <gmd:title>\n" +
- " <gco:CharacterString>A title</gco:CharacterString>\n" +
- " </gmd:title>\n" +
- " <gmd:series gco:nilReason=\"other:myReason\"/>\n" +
- "</gmd:CI_Citation>";
+ "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + '"' +
+ " xmlns:gco=\"" + Namespaces.GCO + '"' +
+ " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" +
+ " <gmd:title>\n" +
+ " <gco:CharacterString>A title</gco:CharacterString>\n" +
+ " </gmd:title>\n" +
+ " <gmd:series gco:nilReason=\"other:myReason\"/>\n" +
+ "</gmd:CI_Citation>";
final Citation citation = (Citation) XML.unmarshal(expected);
assertEquals("title", "A title", citation.getTitle().toString());
@@ -115,14 +115,14 @@ public final strictfp class NilReasonMar
@Test
public void testURI() throws JAXBException {
final String expected =
- "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + '"' +
- " xmlns:gco=\"" + Namespaces.GCO + '"' +
- " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" +
- " <gmd:title>\n" +
- " <gco:CharacterString>A title</gco:CharacterString>\n" +
- " </gmd:title>\n" +
- " <gmd:series gco:nilReason=\"http://www.myreason.org\"/>\n" +
- "</gmd:CI_Citation>";
+ "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + '"' +
+ " xmlns:gco=\"" + Namespaces.GCO + '"' +
+ " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" +
+ " <gmd:title>\n" +
+ " <gco:CharacterString>A title</gco:CharacterString>\n" +
+ " </gmd:title>\n" +
+ " <gmd:series gco:nilReason=\"http://www.myreason.org\"/>\n" +
+ "</gmd:CI_Citation>";
final Citation citation = (Citation) XML.unmarshal(expected);
assertEquals("title", "A title", citation.getTitle().toString());
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java?rev=1497862&r1=1497861&r2=1497862&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -17,14 +17,16 @@
package org.apache.sis.internal.jaxb.gco;
import java.util.UUID;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
import org.apache.sis.xml.XLink;
import org.apache.sis.xml.IdentifierMap;
import org.apache.sis.xml.IdentifierSpace;
import org.apache.sis.xml.IdentifiedObject;
import org.apache.sis.xml.ReferenceResolver;
+import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.ArraysExt;
import org.apache.sis.internal.jaxb.Context;
-import org.apache.sis.internal.jaxb.IdentifierMapAdapter;
import org.apache.sis.internal.jaxb.SpecializedIdentifier;
@@ -76,6 +78,9 @@ final class ObjectReference {
/**
* Creates an object reference initialized to the given value.
+ *
+ * @see ReferenceResolver#canSubstituteByReference(MarshalContext, Class, Object, UUID)
+ * @see ReferenceResolver#canSubstituteByReference(MarshalContext, Class, Object, XLink)
*/
ObjectReference(final UUID uuid, final String anyUUID, final XLink link) {
this.uuid = uuid;
@@ -132,34 +137,48 @@ final class ObjectReference {
// However if both are present, assign the identifiers to that instance.
if (metadata instanceof IdentifiedObject) {
final IdentifierMap map = ((IdentifiedObject) metadata).getIdentifierMap();
- if (uuid != null) putInto(map, IdentifierSpace.UUID, uuid);
- if (xlink != null) putInto(map, IdentifierSpace.XLINK, xlink);
+ putInto(context, map, IdentifierSpace.UUID, uuid);
+ putInto(context, map, IdentifierSpace.XLINK, xlink);
}
}
return metadata;
}
/**
- * Adds a new identifier into the given map. This method is a shortcut which bypass the check
- * for previous values associated to same the authority. It is okay only when constructing
- * new instances, for example at XML unmarshalling time.
+ * Adds a new identifier into the given map, if non null. No previous value should exist in normal situation.
+ * However a previous value may exit in unusual (probably not very valid) XML, as in the following example:
+ *
+ * {@preformat xml
+ * <gmd:CI_Citation>
+ * <gmd:series uuidref="f8f5fcb1-d57b-4013-b3a4-4eaa40df6dcf">
+ * <gmd:CI_Series uuid="f8f5fcb1-d57b-4013-b3a4-4eaa40df6dcf">
+ * ...
+ * </gmd:CI_Series>
+ * </gmd:series>
+ * </gmd:CI_Citation>
+ * }
+ *
+ * In such situation, this method is silent if the two identifiers are equal, or logs a warning and restores
+ * the previous value if they are not equal. The previous value is the "{@code uuid}" attribute, which is
+ * assumed more closely tied to the actual metadata than the {@code uuidref} attribute.
*
* @param map The map in which to write the identifier.
* @param authority The identifier authority.
* @param value The identifier value, or {@code null} if not yet defined.
*/
- private static <T> void putInto(final IdentifierMap map, final IdentifierSpace<T> authority, final T value) {
- if (map instanceof IdentifierMapAdapter) {
- final SpecializedIdentifier<T> identifier = new SpecializedIdentifier<T>(authority, value);
- /*
- * If the following assert statement appears to fail in practice, then remove
- * completly this method and use the public putSpecialized(…) method instead.
- * Note: usage of 'put' is for having the compiler to check the key type.
- */
- assert map.put(authority, null) == null : identifier;
- ((IdentifierMapAdapter) map).identifiers.add(identifier);
- } else {
- map.putSpecialized(authority, value);
+ private static <T> void putInto(final Context context, final IdentifierMap map,
+ final IdentifierSpace<T> authority, final T value)
+ {
+ if (value != null) {
+ final T previous = map.putSpecialized(authority, value);
+ if (previous != null && !previous.equals(value)) {
+ final LogRecord record = Errors.getResources((context != null) ? context.getLocale() : null)
+ .getLogRecord(Level.WARNING, Errors.Keys.InconsistentAttribute_2, authority.getName(), value);
+ record.setSourceClassName(IdentifierMap.class.getName());
+ record.setSourceMethodName("putSpecialized");
+ Context.warningOccured(context, map, record);
+ map.putSpecialized(authority, previous);
+ }
}
}
}
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java?rev=1497862&r1=1497861&r2=1497862&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -165,7 +165,12 @@ public abstract class PropertyType<Value
if (uuid == null) {
uuid = ObjectReference.toUUID(context, anyUUID); // May still null.
}
- // Check if the user gives us the permission to use those identifiers.
+ /*
+ * Check if the user gives us the permission to use reference to those identifiers.
+ * If not, forget them. Information will actually not be lost, since the same identifiers
+ * will be provided by private methods in ISOMetadata. If we do nott clear the identifiers
+ * here, they would appear twice in the XML output.
+ */
if (uuid != null && !resolver.canSubstituteByReference(context, type, metadata, uuid)) {
uuid = null;
}
@@ -250,15 +255,9 @@ public abstract class PropertyType<Value
* future implementations.
*
* @return {@code true} if the wrapped metadata should not be marshalled.
- *
- * @see #getElement()
*/
protected final boolean skip() {
- if (metadata instanceof NilObject) {
- return true;
- }
- final Object ref = reference;
- return (ref instanceof ObjectReference) && ((ObjectReference) ref).anyUUID != null;
+ return (metadata instanceof NilObject) || (reference instanceof ObjectReference);
}
/**
@@ -269,7 +268,7 @@ public abstract class PropertyType<Value
* @return the current value, or {@code null} if none.
* @category gco:ObjectReference
*/
- @XmlAttribute(name = "uuidref", namespace = Namespaces.GCO)
+ @XmlAttribute(name = "uuidref") // Defined in "gco" as unqualified attribute.
public final String getUUIDREF() {
final ObjectReference ref = reference(false);
return (ref != null) ? ref.anyUUID : null;
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java?rev=1497862&r1=1497861&r2=1497862&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -130,9 +130,9 @@ public class ReferenceResolver {
* SIS can not know if the metadata shall be fully marshalled or not.
* Such information needs to be provided by the application.
*
- * <p>The default implementation conservatively returns {@code false} in every cases.
- * Subclasses can override this method if they know whether the receiver will be able
- * to resolve such references.</p>
+ * <p>The default implementation conservatively returns {@code false} in every cases except for instances of
+ * {@link NilObject}, since the later exist only for carrying the {@code gco} and {@code xlink} attributes.
+ * Subclasses can override this method if they know whether the receiver will be able to resolve the reference.</p>
*
* @param <T> The compile-time type of the {@code type} argument.
* @param context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
@@ -144,7 +144,7 @@ public class ReferenceResolver {
* instead than marshalling the given metadata.
*/
public <T> boolean canSubstituteByReference(final MarshalContext context, final Class<T> type, final T object, final UUID uuid) {
- return false;
+ return (object instanceof NilObject);
}
/**
@@ -154,9 +154,9 @@ public class ReferenceResolver {
* SIS can not know if the metadata shall be fully marshalled or not.
* Such information needs to be provided by the application.
*
- * <p>The default implementation conservatively returns {@code false} in every cases.
- * Subclasses can override this method if they know whether the receiver will be able
- * to resolve such references.</p>
+ * <p>The default implementation conservatively returns {@code false} in every cases except for instances of
+ * {@link NilObject}, since the later exist only for carrying the {@code gco} and {@code xlink} attributes.
+ * Subclasses can override this method if they know whether the receiver will be able to resolve the reference.</p>
*
* @param <T> The compile-time type of the {@code type} argument.
* @param context Context (GML version, locale, <i>etc.</i>) of the (un)marshalling process.
@@ -168,7 +168,7 @@ public class ReferenceResolver {
* instead than marshalling the given metadata.
*/
public <T> boolean canSubstituteByReference(final MarshalContext context, final Class<T> type, final T object, final XLink link) {
- return false;
+ return (object instanceof NilObject);
}
/**
Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java?rev=1497862&r1=1497861&r2=1497862&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -21,6 +21,7 @@ import org.apache.sis.util.iso.SimpleInt
import org.apache.sis.xml.XLink;
import org.apache.sis.xml.IdentifierSpace;
import org.apache.sis.test.mock.ReferenceResolverMock;
+import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.XMLTestCase;
import org.junit.Test;
@@ -55,6 +56,17 @@ public final strictfp class PropertyType
}
/**
+ * Creates a dummy XLink.
+ */
+ private static XLink createXLink() {
+ final XLink link = new XLink();
+ link.setShow(XLink.Show.REPLACE);
+ link.setActuate(XLink.Actuate.ON_LOAD);
+ link.setTitle(new SimpleInternationalString("myResult"));
+ return link;
+ }
+
+ /**
* Tests the construction of a plain property (no identifier).
*
* @throws Exception Should never happen.
@@ -83,11 +95,12 @@ public final strictfp class PropertyType
/**
* Tests the construction of an object containing {@code UUID} and {@code XLink} references,
- * which shall be discarded because didn't gave us the authorization to use them.
+ * but in a context where the user didn't gave us the authorization to use them.
*
* @throws Exception Should never happen.
*/
@Test
+ @DependsOnMethod({"testWithUUID", "testWithXLink"})
public void testWithDiscardedReferences() throws Exception {
final UUID uuid = UUID.randomUUID();
final XLink link = createXLink();
@@ -100,10 +113,12 @@ public final strictfp class PropertyType
/**
* Tests the construction of an object containing a {@link UUID}.
+ * The {@code XLink} is allowed to replace the object definition in the XML to be marshalled.
*
* @throws Exception Should never happen.
*/
@Test
+ @DependsOnMethod("testWithNoReference")
public void testWithUUID() throws Exception {
final UUID uuid = UUID.randomUUID();
metadata.getIdentifierMap().putSpecialized(IdentifierSpace.UUID, uuid);
@@ -118,25 +133,17 @@ public final strictfp class PropertyType
assertNull ("title", property.getTitle());
assertNull ("show", property.getShow());
assertNull ("actuate", property.getActuate());
- }
-
- /**
- * Creates a dummy XLink.
- */
- private static XLink createXLink() {
- final XLink link = new XLink();
- link.setShow(XLink.Show.REPLACE);
- link.setActuate(XLink.Actuate.ON_LOAD);
- link.setTitle(new SimpleInternationalString("myResult"));
- return link;
+ assertTrue ("skip", property.skip());
}
/**
* Tests the construction of an object containing a {@link XLink}.
+ * The {@code XLink} is allowed to replace the object definition in the XML to be marshalled.
*
* @throws Exception Should never happen.
*/
@Test
+ @DependsOnMethod("testWithNoReference")
public void testWithXLink() throws Exception {
final XLink link = createXLink();
metadata.getIdentifierMap().putSpecialized(IdentifierSpace.XLINK, link);
@@ -151,5 +158,6 @@ public final strictfp class PropertyType
assertEquals("myResult", property.getTitle());
assertEquals(XLink.Show.REPLACE, property.getShow());
assertEquals(XLink.Actuate.ON_LOAD, property.getActuate());
+ assertTrue ("skip", property.skip());
}
}
Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageMarshallingTest.java?rev=1497862&r1=1497861&r2=1497862&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageMarshallingTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gmd/LanguageMarshallingTest.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -99,9 +99,9 @@ public final strictfp class LanguageMars
" xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
" <gmd:language>\n");
if (languageCode) {
- buffer.append(" <gmd:LanguageCode"
- + " codeList=\"http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/ML_gmxCodelists.xml#LanguageCode\""
- + " codeListValue=\"fra\">French</gmd:LanguageCode>\n");
+ buffer.append(" <gmd:LanguageCode" +
+ " codeList=\"http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/ML_gmxCodelists.xml#LanguageCode\"" +
+ " codeListValue=\"fra\">French</gmd:LanguageCode>\n");
} else {
buffer.append(" <gco:CharacterString>fra</gco:CharacterString>\n");
}
Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/ReferenceResolverMock.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/ReferenceResolverMock.java?rev=1497862&r1=1497861&r2=1497862&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/ReferenceResolverMock.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/ReferenceResolverMock.java [UTF-8] Fri Jun 28 18:02:30 2013
@@ -53,6 +53,9 @@ public final strictfp class ReferenceRes
* }
* }
*
+ * Alternatively, the {@code finally} block can be replaced by a call to {@code context.finish()}
+ * in a method annotated by {@link org.junit.After}.
+ *
* @param marshalling {@code true} for marshalling, or {@code false} for unmarshalling.
* @return The (un)marshalling context.
*/