Author: desruisseaux
Date: Fri Sep  8 11:11:31 2017
New Revision: 1807712

URL: http://svn.apache.org/viewvc?rev=1807712&view=rev
Log:
Try harder to add a title or an identifier to metadata indentification 
information, using the filename (without extension) if we have nothing else.

Modified:
    
sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatReader.java
    
sis/branches/JDK8/storage/sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/LandsatReaderTest.java
    
sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
    
sis/branches/JDK8/storage/sis-geotiff/src/test/java/org/apache/sis/storage/geotiff/CRSBuilderTest.java
    
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
    
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
    
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
    
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
    
sis/branches/JDK8/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/ConformanceTest.java
    
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
    
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
    
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
    
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelData.java
    
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
    
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java
    
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
    
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
    
sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/IOUtilitiesTest.java

Modified: 
sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatReader.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatReader.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatReader.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatReader.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -465,7 +465,7 @@ final class LandsatReader {
              * Example: "LC81230522014071LGN00".
              */
             case "LANDSAT_SCENE_ID": {
-                metadata.addIdentifier(null, value, MetadataBuilder.Scope.ALL);
+                metadata.addTitleOrIdentifier(value, 
MetadataBuilder.Scope.ALL);
                 break;
             }
             /*

Modified: 
sis/branches/JDK8/storage/sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/LandsatReaderTest.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/LandsatReaderTest.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/LandsatReaderTest.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-earth-observation/src/test/java/org/apache/sis/storage/earthobservation/LandsatReaderTest.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -113,10 +113,9 @@ public class LandsatReaderTest extends T
                 + "  │   └─Check point availability……………………………………… false\n"
                 + "  ├─Reference system info………………………………………………………… EPSG:WGS 84 
/ UTM zone 49N\n"
                 + "  ├─Identification info\n"
-                + "  │   ├─Citation\n"
-                + "  │   │   ├─Date………………………………………………………………………………… 2016-06-27 
16:48:12\n"
-                + "  │   │   │   └─Date type………………………………………………………… Creation\n"
-                + "  │   │   └─Identifier………………………………………………………………… 
LandsatTest\n"
+                + "  │   ├─Citation………………………………………………………………………………… 
LandsatTest\n"
+                + "  │   │   └─Date………………………………………………………………………………… 2016-06-27 
16:48:12\n"
+                + "  │   │       └─Date type………………………………………………………… Creation\n"
                 + "  │   ├─Credit……………………………………………………………………………………… Derived 
from U.S. Geological Survey data\n"
                 + "  │   ├─Resource format\n"
                 + "  │   │   └─Format specification citation……………… GeoTIFF 
Coverage Encoding Profile\n"

Modified: 
sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -34,6 +34,7 @@ import org.apache.sis.storage.DataStoreE
 import org.apache.sis.storage.DataStoreContentException;
 import org.apache.sis.storage.UnsupportedStorageException;
 import org.apache.sis.internal.storage.io.ChannelDataInput;
+import org.apache.sis.internal.storage.io.IOUtilities;
 import org.apache.sis.internal.storage.MetadataBuilder;
 import org.apache.sis.internal.storage.URIDataStore;
 import org.apache.sis.internal.util.Constants;
@@ -130,12 +131,21 @@ public class GeoTiffStore extends DataSt
                 while ((dir = reader.getImageFileDirectory(n++)) != null) {
                     dir.completeMetadata(builder, locale);
                 }
-                metadata = builder.build(true);
             } catch (IOException e) {
                 throw new 
DataStoreException(errors().getString(Errors.Keys.CanNotRead_1, 
reader.input.filename), e);
             } catch (FactoryException | ArithmeticException e) {
                 throw new DataStoreContentException(getLocale(), 
Constants.GEOTIFF, reader.input.filename, null).initCause(e);
             }
+            /*
+             * Add the filename as an identifier only if the input was 
something convertible to URI (URL, File or Path),
+             * otherwise reader.input.filename may not be useful; it may be 
just the InputStream classname. If the TIFF
+             * file did not specified any ImageDescription tag, then we will 
had the filename as a title instead than an
+             * identifier because the title is mandatory in ISO 19115 metadata.
+             */
+            if (location != null) {
+                
builder.addTitleOrIdentifier(IOUtilities.filenameWithoutExtension(reader.input.filename),
 MetadataBuilder.Scope.ALL);
+            }
+            metadata = builder.build(true);
         }
         return metadata;
     }

Modified: 
sis/branches/JDK8/storage/sis-geotiff/src/test/java/org/apache/sis/storage/geotiff/CRSBuilderTest.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/test/java/org/apache/sis/storage/geotiff/CRSBuilderTest.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-geotiff/src/test/java/org/apache/sis/storage/geotiff/CRSBuilderTest.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-geotiff/src/test/java/org/apache/sis/storage/geotiff/CRSBuilderTest.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -41,9 +41,9 @@ public final strictfp class CRSBuilderTe
     @Test
     public void testSplitName() {
         final String[] names = CRSBuilder.splitName("GCS Name = wgs84|Datum = 
unknown|Ellipsoid = WGS_1984|Primem = Greenwich|");
-        assertEquals("GCRS",      "wgs84",    names[CRSBuilder.GCRS]);
-        assertEquals("DATUM",     "unknown",  names[CRSBuilder.DATUM]);
-        assertEquals("ELLIPSOID", "WGS_1984", names[CRSBuilder.ELLIPSOID]);
+        assertEquals("GCRS",      "wgs84",     names[CRSBuilder.GCRS]);
+        assertEquals("DATUM",     "unknown",   names[CRSBuilder.DATUM]);
+        assertEquals("ELLIPSOID", "WGS_1984",  names[CRSBuilder.ELLIPSOID]);
         assertEquals("PRIMEM",    "Greenwich", names[CRSBuilder.PRIMEM]);
     }
 

Modified: 
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -63,7 +63,8 @@ public abstract class Decoder implements
     }
 
     /**
-     * Returns a filename for information purpose only. This is used for 
formatting error messages.
+     * Returns a filename for formatting error message and for information 
purpose.
+     * The filename should not contain path.
      *
      * @return a filename to report in warning or error messages.
      */

Modified: 
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -574,7 +574,8 @@ public final class ChannelDecoder extend
     // 
--------------------------------------------------------------------------------------------
 
     /**
-     * Returns a filename for information purpose only. This is used for 
formatting error messages.
+     * Returns a filename for formatting error message and for information 
purpose.
+     * The filename does not contain path.
      *
      * @return a filename to report in warning or error messages.
      */

Modified: 
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.internal.netcdf.ucar;
 
+import java.io.File;
 import java.util.Date;
 import java.util.List;
 import java.util.EnumSet;
@@ -121,13 +122,24 @@ public final class DecoderWrapper extend
     }
 
     /**
-     * Returns a filename for information purpose only. This is used for 
formatting error messages.
+     * Returns a filename for formatting error message and for information 
purpose.
+     * The filename should not contain path.
      *
      * @return a filename to report in warning or error messages.
      */
     @Override
     public String getFilename() {
-        return file.getLocation();
+        String filename = file.getLocation();
+        if (filename != null) {
+            int s = filename.lastIndexOf(File.separatorChar);
+            if (s < 0 && File.separatorChar != '/') {
+                s = filename.lastIndexOf('/');
+            }
+            if (s >= 0) {
+                filename = filename.substring(s+1);
+            }
+        }
+        return filename;
     }
 
     /**

Modified: 
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -59,6 +59,7 @@ import org.apache.sis.internal.netcdf.Ax
 import org.apache.sis.internal.netcdf.Decoder;
 import org.apache.sis.internal.netcdf.Variable;
 import org.apache.sis.internal.netcdf.GridGeometry;
+import org.apache.sis.internal.storage.io.IOUtilities;
 import org.apache.sis.internal.storage.MetadataBuilder;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.internal.util.CollectionsExt;
@@ -861,18 +862,32 @@ split:  while ((start = CharSequences.sk
      *
      * <ul>
      *   <li>{@value AttributeNames#NAMING_AUTHORITY} used as the {@linkplain 
Identifier#getAuthority() authority}.</li>
-     *   <li>{@value AttributeNames#IDENTIFIER}, or {@link 
ucar.nc2.NetcdfFile#getId()} if no identifier attribute was found.</li>
+     *   <li>{@value AttributeNames#IDENTIFIER}, or {@link 
ucar.nc2.NetcdfFile#getId()} if no identifier attribute was found,
+     *       or the filename without extension if {@code getId()} returned 
nothing.</li>
      * </ul>
+     *
+     * This method should be invoked last, after we made our best effort to 
set the title.
      */
     private void addFileIdentifier() {
         String identifier = stringValue(IDENTIFIER);
-        if (identifier == null) {
+        String authority;
+        if (identifier != null) {
+            authority = stringValue(NAMING_AUTHORITY);
+        } else {
             identifier = decoder.getId();
             if (identifier == null) {
-                return;
+                identifier = 
IOUtilities.filenameWithoutExtension(decoder.getFilename());
+                if (identifier == null) {
+                    return;
+                }
             }
+            authority = null;
+        }
+        if (authority == null) {
+            addTitleOrIdentifier(identifier, Scope.ALL);
+        } else {
+            addIdentifier(authority, identifier, Scope.ALL);
         }
-        addIdentifier(stringValue(NAMING_AUTHORITY), identifier, Scope.ALL);
     }
 
     /**
@@ -883,7 +898,6 @@ split:  while ((start = CharSequences.sk
      * @throws DataStoreException if a logical error occurred.
      */
     public Metadata read() throws IOException, DataStoreException {
-        addFileIdentifier();
         addResourceScope(ScopeCode.DATASET, null);
         Set<InternationalString> publisher = addCitation();
         addIdentificationInfo(publisher);
@@ -905,6 +919,7 @@ split:  while ((start = CharSequences.sk
                 addSpatialRepresentationInfo(cs);
             }
         }
+        addFileIdentifier();
         /*
          * Add history in Metadata.dataQualityInfo.lineage.statement as 
specified by UnidataDD2MI.xsl.
          * However Metadata.resourceLineage.statement could be a more 
appropriate place.

Modified: 
sis/branches/JDK8/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/ConformanceTest.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/ConformanceTest.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/ConformanceTest.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/ConformanceTest.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -175,7 +175,10 @@ public final strictfp class ConformanceT
     @Test
     @Override
     public void testLandsat() throws IOException {
-        addCommonProperties(expectedProperties, false);
+        final Map<String,Object> expected = expectedProperties;
+        addCommonProperties(expected, false);
+        assertNull(expected.put("identificationInfo.citation.title", 
"Landsat-GDAL"));
+        assertNull(expected.put("metadataIdentifier.code", "Landsat-GDAL"));
         super.testLandsat();
         assertSame("metadataScope", ScopeCode.DATASET, 
getSingleton(metadata.getMetadataScopes()).getResourceScope());
 
@@ -193,6 +196,8 @@ public final strictfp class ConformanceT
     public void testCIP() throws IOException {
         final Map<String,Object> expected = expectedProperties;
         addCommonProperties(expected, true);
+        assertNull(expected.put("identificationInfo.citation.title", "CIP"));
+        assertNull(expected.put("metadataIdentifier.code", "CIP"));
         super.testCIP();
         assertSame("metadataScope", ScopeCode.DATASET, 
getSingleton(metadata.getMetadataScopes()).getResourceScope());
         /*

Modified: 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -875,6 +875,7 @@ public class MetadataBuilder {
      * @param  scope      whether the date applies to data, to metadata or to 
both.
      *
      * @see #addTitle(CharSequence)
+     * @see #addTitleOrIdentifier(String, Scope)
      */
     public final void addIdentifier(final CharSequence authority, String code, 
final Scope scope) {
         ArgumentChecks.ensureNonNull("scope", scope);
@@ -1072,7 +1073,7 @@ public class MetadataBuilder {
      * Storage location is:
      *
      * <ul>
-     *   <li>{@code metadata/identificationInfo/citation/title} if 
available</li>
+     *   <li>{@code metadata/identificationInfo/citation/title} if not yet 
used</li>
      *   <li>{@code metadata/identificationInfo/citation/alternateTitle} 
otherwise</li>
      * </ul>
      *
@@ -1094,6 +1095,31 @@ public class MetadataBuilder {
     }
 
     /**
+     * Adds the given code as a title if the current citation has no title, or 
as an identifier otherwise.
+     * This method is invoked when adding an identifier to a metadata that may 
have no title. Because the
+     * title is mandatory, adding only an identifier would make an invalid 
metadata.
+     *
+     * @param  code   the identifier code, or {@code null} for no-operation.
+     * @param  scope  whether the date applies to data, to metadata or to both.
+     *
+     * @see #addTitle(CharSequence)
+     * @see #addIdentifier(CharSequence, String, Scope)
+     */
+    public final void addTitleOrIdentifier(final String code, Scope scope) {
+        ArgumentChecks.ensureNonNull("scope", scope);
+        if (scope != Scope.METADATA) {
+            if (citation == null || citation.getTitle() == null) {
+                addTitle(code);
+                if (scope == Scope.RESOURCE) {
+                    return;
+                }
+                scope = Scope.METADATA;
+            }
+        }
+        addIdentifier(null, code, scope);
+    }
+
+    /**
      * Adds a brief narrative summary of the resource(s).
      * If a summary already existed, the new one will be appended after a new 
line.
      * Storage location is:

Modified: 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -25,6 +25,7 @@ import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.DataStoreProvider;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.StorageConnector;
+import org.apache.sis.internal.storage.io.IOUtilities;
 
 
 /**
@@ -160,4 +161,23 @@ public abstract class URIDataStore exten
             return new 
ParameterBuilder().addName(name).createGroup(LOCATION_PARAM);
         }
     }
+
+    /**
+     * Adds the filename (without extension) as the citation title if there is 
no title, or as the identifier otherwise.
+     * This method should be invoked last, after {@code DataStore} 
implementation did its best effort for adding a title.
+     * The intend is actually to provide an identifier, but since the title is 
mandatory in ISO 19115 metadata, providing
+     * only an identifier without title would be invalid.
+     *
+     * @param  builder  where to add the title or identifier.
+     */
+    protected final void addTitleOrIdentifier(final MetadataBuilder builder) {
+        if (location != null) {
+            /*
+             * The getDisplayName() contract does not allow us to use it as an 
identifier. However current implementation
+             * in super.getDisplayName() returns the filename provided that 
the input was a URI, URL, File or Path. Since
+             * all those types are convertibles to URI, we can use (location 
!= null) as a criterion.
+             */
+            
builder.addTitleOrIdentifier(IOUtilities.filenameWithoutExtension(super.getDisplayName()),
 MetadataBuilder.Scope.ALL);
+        }
+    }
 }

Modified: 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -618,6 +618,7 @@ public final class Store extends URIData
                 listeners.warning(null, e);
             }
             builder.addFeatureType(featureType, null);
+            addTitleOrIdentifier(builder);
             metadata = builder.build(true);
         }
         return metadata;

Modified: 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelData.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelData.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelData.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelData.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -49,7 +49,8 @@ public abstract class ChannelData implem
     private static final int BIT_OFFSET_SIZE = 3;
 
     /**
-     * A file identifier used only for formatting error message.
+     * A short identifier (typically a filename without path) used for 
formatting error message.
+     * This is often the value given by {@link 
org.apache.sis.storage.StorageConnector#getStorageName()}.
      */
     public final String filename;
 
@@ -114,7 +115,7 @@ public abstract class ChannelData implem
      * Creates a new instance for the given channel and using the given buffer.
      * The channel is not stored by this class - it shall be stored by the 
subclass.
      *
-     * @param  filename  a file identifier used only for formatting error 
message.
+     * @param  filename  a short identifier (typically a filename without 
path) used for formatting error message.
      * @param  channel   the channel from where data are read or where to 
wrote.
      * @param  buffer    the buffer where to store the data.
      * @throws IOException if an error occurred while reading the channel.

Modified: 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -76,7 +76,7 @@ public class ChannelDataInput extends Ch
      * If the buffer already contains some data, then the {@code filled} 
argument shall be {@code true}.
      * Otherwise (e.g. if it is a newly created buffer), then {@code filled} 
shall be {@code false}.
      *
-     * @param  filename  a file identifier used only for formatting error 
message.
+     * @param  filename  a short identifier (typically a filename without 
path) used for formatting error message.
      * @param  channel   the channel from where data are read.
      * @param  buffer    the buffer where to copy the data.
      * @param  filled    {@code true} if the buffer already contains data, or 
{@code false} if it needs

Modified: 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -161,6 +161,29 @@ public final class IOUtilities extends S
     }
 
     /**
+     * Returns the given path without the directories and without the 
extension.
+     * For example if the given path is {@code "/Users/name/Map.png"}, then 
this
+     * method returns {@code "Map"}.
+     *
+     * @param  path  the path from which to get the filename without 
extension, or {@code null}.
+     * @return the filename without extension, or {@code null} if none.
+     */
+    public static String filenameWithoutExtension(String path) {
+        if (path != null) {
+            int s = path.lastIndexOf(File.separatorChar);
+            if (s < 0 && File.separatorChar != '/') {
+                s = path.lastIndexOf('/');
+            }
+            int e = path.lastIndexOf('.');
+            if (e <= ++s) {
+                e = path.length();
+            }
+            path = path.substring(s, e);
+        }
+        return path;
+    }
+
+    /**
      * Encodes the characters that are not legal for the {@link 
URI#URI(String)} constructor.
      * Note that in addition to unreserved characters ("{@code _-!.~'()*}"), 
the reserved
      * characters ("{@code ?/[]@}") and the punctuation characters ("{@code 
,;:$&+=}")

Modified: 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -189,6 +189,7 @@ final class Store extends URIDataStore {
                     builder.addReferenceSystem((ReferenceSystem) object);
                 }
             }
+            addTitleOrIdentifier(builder);
             metadata = builder.build(true);
         }
         return metadata;

Modified: 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -592,8 +592,10 @@ public class StorageConnector implements
     }
 
     /**
-     * Returns a short name of the input/output object. The default 
implementation performs
-     * the following choices based on the type of the {@linkplain 
#getStorage() storage} object:
+     * Returns a short name of the input/output object. For example if the 
storage is a file,
+     * this method returns the filename without the path (but including the 
file extension).
+     * The default implementation performs the following choices based on the 
type of the
+     * {@linkplain #getStorage() storage} object:
      *
      * <ul>
      *   <li>For {@link java.nio.file.Path}, {@link java.io.File}, {@link 
java.net.URI} or {@link java.net.URL}

Modified: 
sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/IOUtilitiesTest.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/IOUtilitiesTest.java?rev=1807712&r1=1807711&r2=1807712&view=diff
==============================================================================
--- 
sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/IOUtilitiesTest.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/IOUtilitiesTest.java
 [UTF-8] Fri Sep  8 11:11:31 2017
@@ -35,7 +35,7 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Johann Sorel (Geomatys)
- * @version 0.4
+ * @version 0.8
  * @since   0.3
  * @module
  */
@@ -112,6 +112,17 @@ public final strictfp class IOUtilitiesT
     }
 
     /**
+     * Tests {@link IOUtilities#filenameWithoutExtension(String)}.
+     */
+    @Test
+    public void testFilenameWithoutExtension() {
+        assertEquals("Map",     
IOUtilities.filenameWithoutExtension("/Users/name/Map.png"));
+        assertEquals("Map",     
IOUtilities.filenameWithoutExtension("/Users/name/Map"));
+        assertEquals("Map",     
IOUtilities.filenameWithoutExtension("Map.png"));
+        assertEquals(".hidden", 
IOUtilities.filenameWithoutExtension("/Users/name/.hidden"));
+    }
+
+    /**
      * Tests {@link IOUtilities#encodeURI(String)}.
      */
     @Test


Reply via email to