sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1750174 - in /sis/branches/JDK8: core/sis-utility/src/main/java/org/apache/sis/util/resources/ storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/
Date Sat, 25 Jun 2016 00:29:07 GMT
Author: desruisseaux
Date: Sat Jun 25 00:29:02 2016
New Revision: 1750174

URL: http://svn.apache.org/viewvc?rev=1750174&view=rev
Log:
NetCDF reader should check the validity of input argument.

Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1750174&r1=1750173&r2=1750174&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] Sat Jun 25 00:29:02 2016
@@ -201,6 +201,11 @@ public final class Errors extends Indexe
         public static final short CloneNotSupported_1 = 13;
 
         /**
+         * This {0} reader is closed.
+         */
+        public static final short ClosedReader_1 = 231;
+
+        /**
          * Axis directions {0} and {1} are colinear.
          */
         public static final short ColinearAxisDirections_2 = 14;
@@ -408,6 +413,11 @@ public final class Errors extends Indexe
         public static final short IllegalIdentifierForCodespace_2 = 208;
 
         /**
+         * The {0} reader does not accept inputs of type ‘{1}’.
+         */
+        public static final short IllegalInputTypeForReader_2 = 230;
+
+        /**
          * The “{0}” language is not recognized.
          */
         public static final short IllegalLanguageCode_1 = 36;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1750174&r1=1750173&r2=1750174&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] Sat Jun 25 00:29:02 2016
@@ -51,6 +51,7 @@ CanNotUseGeodeticParameters_2     = Can
 CircularReference                 = Circular reference.
 ClassNotFinal_1                   = Class \u2018{0}\u2019 is not final.
 CloneNotSupported_1               = Can not clone an object of type \u2018{0}\u2019.
+ClosedReader_1                    = This {0} reader is closed.
 ColinearAxisDirections_2          = Axis directions {0} and {1} are colinear.
 CoordinateOperationNotFound_2     = Coordinate conversion of transformation from system \u201c{0}\u201d
to \u201c{1}\u201d has not been found.
 DatabaseError_2                   = Database error while creating a \u2018{0}\u2019 object
for code \u201c{1}\u201d.
@@ -91,6 +92,7 @@ IllegalCoordinateSystem_1         = Coor
 IllegalCRSType_1                  = Coordinate reference system can not be of type \u2018{0}\u2019.
 IllegalFormatPatternForClass_2    = The \u201c{1}\u201d pattern can not be applied to formating
of objects of type \u2018{0}\u2019.
 IllegalIdentifierForCodespace_2   = \u201c{1}\u201d is not a valid identifier for the \u201c{0}\u201d
code space.
+IllegalInputTypeForReader_2       = The {0} reader does not accept inputs of type \u2018{1}\u2019.
 IllegalLanguageCode_1             = The \u201c{0}\u201d language is not recognized.
 IllegalMemberType_2               = Member \u201c{0}\u201d can not be associated to type
\u201c{1}\u201d.
 IllegalOperationDimension_3       = Dimensions of \u201c{0}\u201d operation can not be ({1}
\u2192 {2}).

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1750174&r1=1750173&r2=1750174&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] Sat Jun 25 00:29:02 2016
@@ -48,6 +48,7 @@ CanNotUseGeodeticParameters_2     = Ne p
 CircularReference                 = R\u00e9f\u00e9rence circulaire.
 ClassNotFinal_1                   = La classe \u2018{0}\u2019 n\u2019est pas finale.
 CloneNotSupported_1               = Un objet de type \u2018{0}\u2019 ne peut pas \u00eatre
clon\u00e9.
+ClosedReader_1                    = Ce lecteur {0} est ferm\u00e9.
 ColinearAxisDirections_2          = Les directions d\u2019axes {0} et {1} sont colin\u00e9aires.
 CoordinateOperationNotFound_2     = La conversion ou transformation des coordonn\u00e9es
du syst\u00e8me \u00ab\u202f{0}\u202f\u00bb vers \u00ab\u202f{1}\u202f\u00bb n\u2019a pas
\u00e9t\u00e9 trouv\u00e9e.
 DatabaseError_2                   = Erreur de base de donn\u00e9es lors de la cr\u00e9ation
d\u2019un objet \u2018{0}\u2019 pour le code \u00ab\u202f{1}\u202f\u00bb.
@@ -88,6 +89,7 @@ IllegalCoordinateSystem_1         = Le s
 IllegalCRSType_1                  = Le syst\u00e8me de r\u00e9f\u00e9rence des coordonn\u00e9es
ne peut pas \u00eatre de type \u2018{0}\u2019.
 IllegalFormatPatternForClass_2    = Le mod\u00e8le \u00ab\u202f{1}\u202f\u00bb ne peut pas
\u00eatre appliqu\u00e9 au formatage d\u2019objets de type \u2018{0}\u2019.
 IllegalIdentifierForCodespace_2   = \u00ab\u202f{1}\u202f\u00bb n\u2019est pas un identifiant
valide pour l\u2019espace de codes \u00ab\u202f{0}\u202f\u00bb.
+IllegalInputTypeForReader_2       = Le lecteur {0} n\u2019accepte pas des entr\u00e9s de
type \u2018{1}\u2019.
 IllegalLanguageCode_1             = Le code de langue \u00ab\u202f{0}\u202f\u00bb n\u2019est
pas reconnu.
 IllegalMemberType_2               = Le membre \u00ab\u202f{0}\u202f\u00bb ne peut pas \u00eatre
associ\u00e9 au type \u00ab\u202f{1}\u202f\u00bb.
 IllegalOperationDimension_3       = Les dimensions de l\u2019op\u00e9ration \u00ab\u202f{0}\u202f\u00bb
ne peuvent pas \u00eatre ({1} \u2192 {2}).

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java?rev=1750174&r1=1750173&r2=1750174&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
[UTF-8] Sat Jun 25 00:29:02 2016
@@ -19,7 +19,9 @@ package org.apache.sis.storage.netcdf;
 import java.io.IOException;
 import org.opengis.metadata.Metadata;
 import org.apache.sis.util.Debug;
+import org.apache.sis.util.Classes;
 import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.resources.Errors;
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.StorageConnector;
@@ -33,7 +35,7 @@ import org.apache.sis.metadata.Modifiabl
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.8
  * @module
  *
  * @see NetcdfStoreProvider
@@ -56,7 +58,7 @@ public class NetcdfStore extends DataSto
      * needed resource.
      *
      * @param  storage Information about the storage (URL, stream, {@link ucar.nc2.NetcdfFile}
instance, <i>etc</i>).
-     * @throws DataStoreException If an error occurred while opening the NetCDF file.
+     * @throws DataStoreException if an error occurred while opening the NetCDF file.
      */
     public NetcdfStore(final StorageConnector storage) throws DataStoreException {
         ArgumentChecks.ensureNonNull("storage", storage);
@@ -65,6 +67,10 @@ public class NetcdfStore extends DataSto
         } catch (IOException e) {
             throw new DataStoreException(e);
         }
+        if (decoder == null) {
+            throw new DataStoreException(Errors.format(Errors.Keys.IllegalInputTypeForReader_2,
+                    "NetCDF", Classes.getClass(storage.getStorage())));
+        }
     }
 
     /**
@@ -73,7 +79,7 @@ public class NetcdfStore extends DataSto
      * data quality, usage constraints and more.
      *
      * @return Information about the dataset.
-     * @throws DataStoreException If an error occurred while reading the data.
+     * @throws DataStoreException if an error occurred while reading the data.
      */
     @Override
     public Metadata getMetadata() throws DataStoreException {
@@ -92,7 +98,7 @@ public class NetcdfStore extends DataSto
     /**
      * Closes this NetCDF store and releases any underlying resources.
      *
-     * @throws DataStoreException If an error occurred while closing the NetCDF file.
+     * @throws DataStoreException if an error occurred while closing the NetCDF file.
      */
     @Override
     public void close() throws DataStoreException {

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java?rev=1750174&r1=1750173&r2=1750174&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
[UTF-8] Sat Jun 25 00:29:02 2016
@@ -205,7 +205,7 @@ public class NetcdfStoreProvider extends
      *
      * @param  storage Information about the storage (URL, stream, {@link ucar.nc2.NetcdfFile}
instance, <i>etc</i>).
      * @return A data store implementation associated with this provider for the given storage.
-     * @throws DataStoreException If an error occurred while creating the data store instance.
+     * @throws DataStoreException if an error occurred while creating the data store instance.
      */
     @Override
     public DataStore open(final StorageConnector storage) throws DataStoreException {
@@ -218,9 +218,9 @@ public class NetcdfStoreProvider extends
      *
      * @param  listeners Where to send the warnings.
      * @param  storage Information about the input (file, input stream, <i>etc.</i>)
-     * @return The decoder for the given input.
-     * @throws IOException If an error occurred while opening the NetCDF file.
-     * @throws DataStoreException If a logical error (other than I/O) occurred.
+     * @return The decoder for the given input, or {@code null} if the input type is not
recognized.
+     * @throws IOException if an error occurred while opening the NetCDF file.
+     * @throws DataStoreException if a logical error (other than I/O) occurred.
      */
     static Decoder decoder(final WarningListeners<?> listeners, final StorageConnector
storage)
             throws IOException, DataStoreException
@@ -257,9 +257,9 @@ public class NetcdfStoreProvider extends
      * @param  input  The NetCDF file object of filename string from which to read data.
      * @param  isUCAR {@code true} if {@code input} is an instance of the UCAR {@link ucar.nc2.NetcdfFile}
object,
      *                or {@code false} if it is the filename as a {@code String}.
-     * @return The {@link DecoderWrapper} instance for the given input.
-     * @throws IOException If an error occurred while opening the NetCDF file.
-     * @throws DataStoreException If a logical error (other than I/O) occurred.
+     * @return The {@link DecoderWrapper} instance for the given input, or {@code null} if
the input type is not recognized.
+     * @throws IOException if an error occurred while opening the NetCDF file.
+     * @throws DataStoreException if a logical error (other than I/O) occurred.
      */
     private static Decoder createByReflection(final WarningListeners<?> listeners,
final Object input, final boolean isUCAR)
             throws IOException, DataStoreException



Mime
View raw message