Author: desruisseaux
Date: Tue Feb 20 18:41:45 2018
New Revision: 1824899
URL: http://svn.apache.org/viewvc?rev=1824899&view=rev
Log:
Partial revision of FileStoreProvider changes.
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-storage/src/main/java/org/apache/sis/internal/storage/FileSystemProvider.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
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/folder/FolderStoreProvider.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/package-info.java
sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/folder/StoreTest.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=1824899&r1=1824898&r2=1824899&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] Tue Feb 20 18:41:45 2018
@@ -936,6 +936,11 @@ public final class Errors extends Indexe
public static final short UnsupportedFormatVersion_2 = 159;
/**
+ * Format “{0}” is unsupported.
+ */
+ public static final short UnsupportedFormat_1 = 181;
+
+ /**
* Can not handle this instance of ‘{0}’ because arbitrary
implementations are not yet
* supported.
*/
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=1824899&r1=1824898&r2=1824899&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] Tue Feb 20 18:41:45 2018
@@ -193,6 +193,7 @@ UnparsableStringForClass_3 = Text
UnparsableStringInElement_2 = Can not parse \u201c{1}\u201d in element
\u201c{0}\u201d.
UnspecifiedCRS = Coordinate reference system has not been
specified.
UnspecifiedFormatForClass_1 = No format is specified for objects of
class \u2018{0}\u2019.
+UnsupportedFormat_1 = Format \u201c{0}\u201d is unsupported.
UnsupportedFormatVersion_2 = Version {1} of {0} format is not supported.
UnsupportedImplementation_1 = Can not handle this instance of
\u2018{0}\u2019 because arbitrary implementations are not yet supported.
UnsupportedInterpolation_1 = The \u201c{0}\u201d interpolation is
unsupported.
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=1824899&r1=1824898&r2=1824899&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] Tue Feb 20 18:41:45 2018
@@ -189,6 +189,7 @@ UnspecifiedFormatForClass_1 = Aucu
UnparsableStringForClass_2 = Le texte \u00ab\u202f{1}\u202f\u00bb
n\u2019est pas reconnu comme un objet de type \u2018{0}\u2019.
UnparsableStringForClass_3 = Le texte \u00ab\u202f{1}\u202f\u00bb
n\u2019est pas reconnu comme un objet de type \u2018{0}\u2019, \u00e0 cause des
caract\u00e8res \u00ab\u202f{2}\u202f\u00bb.
UnparsableStringInElement_2 = Le texte \u00ab\u202f{1}\u202f\u00bb dans
l\u2019\u00e9l\u00e9ment \u00ab\u202f{0}\u202f\u00bb ne peut pas \u00eatre lu.
+UnsupportedFormat_1 = Le format \u00ab\u202f{0}\u202f\u00bb
n\u2019est pas support\u00e9.
UnsupportedFormatVersion_2 = La version {1} du format {0} n\u2019est
pas support\u00e9e.
UnsupportedImplementation_1 = Cette instance de \u2018{0}\u2019 ne peut
pas \u00eatre g\u00e9r\u00e9e parce que les impl\u00e9mentations arbitraires ne
sont pas encore support\u00e9es.
UnsupportedInterpolation_1 = L\u2019interpolation \u201c{0}\u201d
n\u2019est pas support\u00e9e.
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FileSystemProvider.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FileSystemProvider.java?rev=1824899&r1=1824898&r2=1824899&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FileSystemProvider.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FileSystemProvider.java
[UTF-8] Tue Feb 20 18:41:45 2018
@@ -25,17 +25,21 @@ import org.apache.sis.storage.DataStoreP
import org.apache.sis.storage.ProbeResult;
import org.apache.sis.storage.StorageConnector;
+
/**
* Files-related {@linkplain org.apache.sis.storage.DataStoreProvider
provider}.
* This interface provides additional descriptive informations on the supported
* file types.
*
- * @author Johann Sorel (Geomatys)
- * @since 1.0
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
* @module
+ *
+ * @todo Rename, as this interface may be confused with {@link
java.nio.file.spi.FileSystemProvider}.
+ * Do we need this interface or can we rely on {@link
URIDataStore.Provider} only?
*/
public interface FileSystemProvider {
-
/**
* Get the list of this format mainly used file suffixes.
* If the provider uses multiple files, this method should return
@@ -63,7 +67,7 @@ public interface FileSystemProvider {
* @return collection of signatures, never null, can be empty.
*/
default Collection<byte[]> getSignature() {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
/**
@@ -102,5 +106,4 @@ public interface FileSystemProvider {
}
return ProbeResult.UNSUPPORTED_STORAGE;
}
-
}
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java?rev=1824899&r1=1824898&r2=1824899&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
[UTF-8] Tue Feb 20 18:41:45 2018
@@ -158,16 +158,11 @@ public final class Resources extends Ind
public static final short FeatureNotFound_2 = 17;
/**
- * Restricted store provider identifier to use for resource discovery
and creation.
+ * Name of the format to use for reading or writing the directory
content.
*/
public static final short FolderStoreProviderParameter = 40;
/**
- * Unknown provider identifier {0}.
- */
- public static final short FolderStoreProviderUnknown_1 = 41;
-
- /**
* Whether to assemble trajectory fragments (lines in CSV file) in a
single feature instance.
*/
public static final short FoliationRepresentation = 38;
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties?rev=1824899&r1=1824898&r2=1824899&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
[ISO-8859-1] Tue Feb 20 18:41:45 2018
@@ -37,8 +37,7 @@ DataStoreTimeZone = Time
DirectoryContent_1 = Content of \u201c{0}\u201d directory.
FeatureAlreadyPresent_2 = A feature named \u201c{1}\u201d is already
present in the \u201c{0}\u201d data store.
FeatureNotFound_2 = Feature \u201c{1}\u201d has not been found
in the \u201c{0}\u201d data store.
-FolderStoreProviderParameter = Restricted store provider identifier to
use for resource discovery and creation.
-FolderStoreProviderUnknown_1 = Unknown provider identifier {0}.
+FolderStoreProviderParameter = Name of the format to use for reading or
writing the directory content.
FoliationRepresentation = Whether to assemble trajectory fragments
(lines in CSV file) in a single feature instance.
ExcessiveStringSize_3 = Character string in the \u201c{0}\u201d
file is too long. The string has {2} characters while the limit is {1}.
IllegalFeatureType_2 = The {0} data store does not accept
features of type \u201c{1}\u201d.
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties?rev=1824899&r1=1824898&r2=1824899&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
[ISO-8859-1] Tue Feb 20 18:41:45 2018
@@ -43,12 +43,11 @@ DirectoryContent_1 = Cont
ExcessiveStringSize_3 = La cha\u00eene de caract\u00e8res dans le
fichier \u00ab\u202f{0}\u202f\u00bb est trop longue. La cha\u00eene fait {2}
caract\u00e8res alors que la limite est {1}.
FeatureAlreadyPresent_2 = Une entit\u00e9 nomm\u00e9e
\u00ab\u202f{1}\u202f\u00bb est d\u00e9j\u00e0 pr\u00e9sente dans les
donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
FeatureNotFound_2 = L\u2019entit\u00e9
\u00ab\u202f{1}\u202f\u00bb n\u2019a pas \u00e9t\u00e9 trouv\u00e9e dans les
donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
-FolderStoreProviderParameter = Identifiant du fournisseur de donn\u00e9es
unique \u00e0 utiliser pour la d\u00e9tection et la cr\u00e9ation.
-FolderStoreProviderUnknown_1 = L'identifiant de fournisseur de
donn\u00e9es {0} est inconnu.
+FolderStoreProviderParameter = Nom du format ou de la source de
donn\u00e9es \u00e0 utiliser pour lire ou \u00e9crire le contenu du
r\u00e9pertoire.
FoliationRepresentation = Indique s\u2019il faut assembler les
fragments de trajectoires (lignes dans un fichier CSV) dans une entit\u00e9
unique.
IllegalFeatureType_2 = Le format {0} ne stocke pas de
donn\u00e9es de type \u00ab\u202f{1}\u202f\u00bb.
IllegalInputTypeForReader_2 = Le lecteur {0} n\u2019accepte pas des
entr\u00e9s de type \u2018{1}\u2019.
-IllegalOutputTypeForWriter_2 = Le l\u2019encodeur {0} n\u2019accepte pas
des sorties de type \u2018{1}\u2019.
+IllegalOutputTypeForWriter_2 = L\u2019encodeur {0} n\u2019accepte pas des
sorties de type \u2018{1}\u2019.
InconsistentNameComponents_2 = Les \u00e9l\u00e9ments qui composent le
nom \u00ab\u202f{1}\u202f\u00bb ne sont pas coh\u00e9rents avec ceux du nom qui
avait \u00e9t\u00e9 pr\u00e9c\u00e9demment li\u00e9 dans les donn\u00e9es de
\u00ab\u202f{0}\u202f\u00bb.
MissingSchemeInURI_1 = Il manque le sch\u00e9ma dans l\u2019URI
\u00ab\u202f{0}\u202f\u00bb.
ProcessingExecutedOn_1 = Traitement ex\u00e9cut\u00e9 sur {0}.
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=1824899&r1=1824898&r2=1824899&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] Tue Feb 20 18:41:45 2018
@@ -32,7 +32,6 @@ import org.apache.sis.storage.DataStoreP
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.IllegalOpenParameterException;
import org.apache.sis.internal.storage.io.IOUtilities;
-import org.apache.sis.internal.util.UnmodifiableArrayList;
/**
@@ -127,10 +126,10 @@ public abstract class URIDataStore exten
private volatile ParameterDescriptorGroup openDescriptor;
/**
- * List of main file suffixes used.
+ * The suffixes that may be used with the name of the "main" file.
+ * This is the collection to be returned by {@link #getSuffix()}.
*/
protected final List<String> suffix = new ArrayList<>();
- private final List<String> unSuffix =
Collections.unmodifiableList(suffix);
/**
* Creates a new provider.
@@ -155,12 +154,24 @@ public abstract class URIDataStore exten
}
/**
- * Get the list of this format mainly used file suffixes.
+ * Returns the suffixes that may be used with the name of the "main"
file.
+ * The "main" file is the file that users specify when opening the
dataset.
+ * The returned collection should <em>not</em> include the suffixes of
auxiliary files.
*
- * @return list of suffix, case insensitive, never null, can be empty.
+ * <div class="note"><b>Example:</b>
+ * GeoTIFF data are contained in files with the {@code ".tif"} or
{@code ".tiff"} suffix,
+ * sometime accompanied by auxiliary files with {@code ".prj"} and
{@code ".tfw"} suffixes.
+ * This method should return a collection containing only {@code
"tif"} or {@code "tiff"}
+ * strings, without the leading dot.</div>
+ *
+ * The suffixes are case-insensitive (no need to declare both
lower-case and upper-case variants)
+ * and shall not contain the leading dot.
+ *
+ * @return the filename suffixes, case insensitive. Never null but can
be empty.
*/
+ @Override
public final List<String> getSuffix() {
- return unSuffix;
+ return Collections.unmodifiableList(suffix);
}
/**
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java?rev=1824899&r1=1824898&r2=1824899&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
[UTF-8] Tue Feb 20 18:41:45 2018
@@ -39,7 +39,7 @@ import org.apache.sis.util.logging.Loggi
import org.apache.sis.internal.system.Modules;
import org.apache.sis.internal.storage.Resources;
import org.apache.sis.internal.storage.URIDataStore;
-import org.apache.sis.internal.storage.io.IOUtilities;
+import org.apache.sis.setup.OptionKey;
/**
@@ -49,7 +49,7 @@ import org.apache.sis.internal.storage.i
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.8
* @module
*/
@@ -60,43 +60,40 @@ public final class FolderStoreProvider e
private static final String NAME = "folder";
/**
- * Description of the parameter for folder location.
- */
- static final ParameterDescriptor<Path> LOCATION;
-
- /**
* Description of the parameter for formating conventions of dates and
numbers.
*/
- static final ParameterDescriptor<Locale> LOCALE;
+ private static final ParameterDescriptor<Locale> LOCALE;
/**
* Description of the parameter for timezone of dates in the data store.
*/
- static final ParameterDescriptor<TimeZone> TIMEZONE;
+ private static final ParameterDescriptor<TimeZone> TIMEZONE;
/**
* Description of the parameter for character encoding used by the data
store.
*/
- static final ParameterDescriptor<Charset> ENCODING;
+ private static final ParameterDescriptor<Charset> ENCODING;
/**
- * Description of the parameter for restricting searched factories.
+ * Description of the parameter for name of format or {@code
DataStoreProvider}
+ * to use for reading or writing the directory content.
*/
- static final ParameterDescriptor<String> PROVIDER;
+ private static final ParameterDescriptor<String> FORMAT;
/**
* The group of parameter descriptors to be returned by {@link
#getOpenParameters()}.
*/
static final ParameterDescriptorGroup PARAMETERS;
static {
+ final ParameterDescriptor<Path> location;
final ParameterBuilder builder = new ParameterBuilder();
final InternationalString remark =
Resources.formatInternational(Resources.Keys.UsedOnlyIfNotEncoded);
ENCODING = annotate(builder, URIDataStore.Provider.ENCODING, remark);
LOCALE = builder.addName("locale"
).setDescription(Resources.formatInternational(Resources.Keys.DataStoreLocale
)).setRemarks(remark).create(Locale.class, null);
TIMEZONE =
builder.addName("timezone").setDescription(Resources.formatInternational(Resources.Keys.DataStoreTimeZone)).setRemarks(remark).create(TimeZone.class,
null);
- PROVIDER =
builder.addName("provider").setDescription(Resources.formatInternational(Resources.Keys.FolderStoreProviderParameter)).create(String.class,
null);
- LOCATION = new
ParameterBuilder(URIDataStore.Provider.LOCATION_PARAM).create(Path.class, null);
- PARAMETERS = builder.addName(NAME).createGroup(LOCATION, LOCALE,
TIMEZONE, ENCODING, PROVIDER);
+ FORMAT =
builder.addName("provider").setDescription(Resources.formatInternational(Resources.Keys.FolderStoreProviderParameter)).create(String.class,
null);
+ location = new
ParameterBuilder(URIDataStore.Provider.LOCATION_PARAM).create(Path.class, null);
+ PARAMETERS = builder.addName(NAME).createGroup(location, LOCALE,
TIMEZONE, ENCODING, FORMAT);
}
/**
@@ -164,6 +161,8 @@ public final class FolderStoreProvider e
/**
* Returns a data store implementation associated with this provider.
+ * The data store created by this method will try to auto-detect the
format of every files in the directory.
+ * For exploring only the file of a known format, use {@link
#open(ParameterValueGroup)} instead.
*
* @param connector information about the storage (URL, path,
<i>etc</i>).
* @return a data store implementation associated with this provider for
the given storage.
@@ -172,7 +171,7 @@ public final class FolderStoreProvider e
@Override
public DataStore open(final StorageConnector connector) throws
DataStoreException {
try {
- return new Store(this, connector);
+ return new Store(this, connector, null);
} catch (IOException e) {
throw new
DataStoreException(Resources.format(Resources.Keys.CanNotReadDirectory_1,
connector.getStorageName()), e);
@@ -188,16 +187,21 @@ public final class FolderStoreProvider e
@Override
public DataStore open(final ParameterValueGroup parameters) throws
DataStoreException {
ArgumentChecks.ensureNonNull("parameter", parameters);
- final Parameters params = Parameters.castOrWrap(parameters);
+ final StorageConnector connector =
URIDataStore.Provider.connector(this, parameters);
+ final Parameters pg = Parameters.castOrWrap(parameters);
+ connector.setOption(OptionKey.LOCALE, pg.getValue(LOCALE));
+ connector.setOption(OptionKey.TIMEZONE, pg.getValue(TIMEZONE));
+ connector.setOption(OptionKey.ENCODING, pg.getValue(ENCODING));
+ final String format = pg.getValue(FORMAT);
try {
- if (params.getValue(PROVIDER) != null) {
- return new Store.Writable(this, params);
+ if (format != null) {
+ return new Store.Writable(this, connector, format);
} else {
- return new Store(this, params);
+ return new Store(this, connector, format);
}
} catch (IOException e) {
throw new
DataStoreException(Resources.format(Resources.Keys.CanNotReadDirectory_1,
- IOUtilities.filename(params.getValue(LOCATION))), e);
+ connector.getStorageName()), e);
}
}
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java?rev=1824899&r1=1824898&r2=1824899&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java
[UTF-8] Tue Feb 20 18:41:45 2018
@@ -36,10 +36,10 @@ import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Stream;
-import org.apache.sis.internal.storage.FileSystemResource;
import org.opengis.metadata.Metadata;
import org.opengis.metadata.maintenance.ScopeCode;
import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.metadata.identification.Identification;
import org.apache.sis.setup.OptionKey;
import org.apache.sis.storage.Resource;
import org.apache.sis.storage.Aggregate;
@@ -54,15 +54,17 @@ import org.apache.sis.internal.util.Unmo
import org.apache.sis.internal.storage.MetadataBuilder;
import org.apache.sis.internal.storage.Resources;
import org.apache.sis.internal.storage.URIDataStore;
+import org.apache.sis.internal.storage.FileSystemResource;
import org.apache.sis.metadata.iso.citation.Citations;
-import org.apache.sis.parameter.Parameters;
import org.apache.sis.storage.FeatureSet;
import org.apache.sis.storage.ProbeResult;
import org.apache.sis.storage.ReadOnlyStorageException;
import org.apache.sis.storage.WritableAggregate;
import org.apache.sis.storage.WritableFeatureSet;
+import org.apache.sis.util.resources.Errors;
+
+// Branch-dependent imports
import org.opengis.feature.Feature;
-import org.opengis.metadata.identification.Identification;
/**
@@ -83,12 +85,11 @@ import org.opengis.metadata.identificati
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.8
* @module
*/
class Store extends DataStore implements Aggregate,
DirectoryStream.Filter<Path> {
-
/**
* File walker to delete file and folder recursively.
*/
@@ -170,26 +171,17 @@ class Store extends DataStore implements
* @throws DataStoreException if an error occurred while opening the
stream.
*/
@SuppressWarnings("ThisEscapedInObjectConstruction") // Okay because
'folders' does not escape.
- Store(final DataStoreProvider provider, final StorageConnector connector)
throws DataStoreException, IOException {
+ Store(final DataStoreProvider provider, final StorageConnector connector,
final String format)
+ throws DataStoreException, IOException
+ {
super(provider, connector);
location = connector.getStorageAs(Path.class);
locale = connector.getOption(OptionKey.LOCALE);
timezone = connector.getOption(OptionKey.TIMEZONE);
encoding = connector.getOption(OptionKey.ENCODING);
+ providerName = format;
children = new ConcurrentHashMap<>();
children.put(location.toRealPath(), this);
- providerName = null;
- }
-
- Store(final DataStoreProvider provider, final Parameters params) throws
DataStoreException, IOException {
- super(provider, new StorageConnector(params));
- location = params.getValue(FolderStoreProvider.LOCATION);
- locale = params.getValue(FolderStoreProvider.LOCALE);
- timezone = params.getValue(FolderStoreProvider.TIMEZONE);
- encoding = params.getValue(FolderStoreProvider.ENCODING);
- providerName = params.getValue(FolderStoreProvider.PROVIDER);
- children = new ConcurrentHashMap<>();
- children.put(location.toRealPath(), this);
}
/**
@@ -357,11 +349,12 @@ class Store extends DataStore implements
}
}
if (searchProvider == null) {
- throw new
DataStoreException(message(Resources.Keys.FolderStoreProviderUnknown_1,
providerName));
+ throw new
DataStoreException(Errors.getResources(getLocale()).getString(Errors.Keys.UnsupportedFormat_1,
providerName));
}
}
return searchProvider;
}
+
/**
* Builds an error message for an error occurring while reading files in
the directory.
*/
@@ -426,8 +419,10 @@ class Store extends DataStore implements
*/
static class Writable extends Store implements WritableAggregate {
- public Writable(DataStoreProvider provider, Parameters params) throws
DataStoreException, IOException {
- super(provider, params);
+ public Writable(final DataStoreProvider provider, final
StorageConnector connector, final String format)
+ throws DataStoreException, IOException
+ {
+ super(provider, connector, format);
}
/**
@@ -570,7 +565,5 @@ class Store extends DataStore implements
}
}
}
-
}
-
}
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/package-info.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/package-info.java?rev=1824899&r1=1824898&r2=1824899&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/package-info.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/package-info.java
[UTF-8] Tue Feb 20 18:41:45 2018
@@ -19,7 +19,7 @@
* {@link org.apache.sis.storage.DataStore} implementation for a folder
containing an arbitrary amount of data files.
*
* @author Johann Sorel (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.8
* @module
*/
Modified:
sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/folder/StoreTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/folder/StoreTest.java?rev=1824899&r1=1824898&r2=1824899&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/folder/StoreTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/folder/StoreTest.java
[UTF-8] Tue Feb 20 18:41:45 2018
@@ -43,7 +43,7 @@ import static org.junit.Assume.assumeTru
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.8
* @module
*/
@@ -70,7 +70,7 @@ public final strictfp class StoreTest ex
@Test
public void testComponents() throws URISyntaxException,
DataStoreException, IOException {
final Set<String> identifiers = new HashSet<>(Arrays.asList("proj",
"Sample 1", "Sample 2", "Sample 3", "data4"));
- try (Store store = new Store(null, new
StorageConnector(testDirectory()))) {
+ try (Store store = new Store(null, new
StorageConnector(testDirectory()), null)) {
assertEquals("Expected three data stores.", 4,
store.components().size());
verifyContent(store, identifiers);
}
@@ -88,19 +88,16 @@ public final strictfp class StoreTest ex
*/
@Test
public void testSearchProviderParameter() throws URISyntaxException,
DataStoreException, IOException {
-
- {
- final Set<String> identifiers = new
HashSet<>(Arrays.asList("Sample 1", "Sample 2", "Sample 3", "data4"));
- final Parameters params =
Parameters.castOrWrap(FolderStoreProvider.PARAMETERS.createValue());
- params.parameter("location").setValue(testDirectory());
- params.parameter("provider").setValue("XML");
- try (Store store = new Store(null, params)) {
- assertEquals("Expected three data stores.", 3,
store.components().size());
- verifyContent(store, identifiers);
- }
- if (!identifiers.isEmpty()) {
- fail("Missing resources: " + identifiers);
- }
+ final Set<String> identifiers = new HashSet<>(Arrays.asList("Sample
1", "Sample 2", "Sample 3", "data4"));
+ final Parameters params =
Parameters.castOrWrap(FolderStoreProvider.PARAMETERS.createValue());
+ params.parameter("location").setValue(testDirectory());
+ params.parameter("provider").setValue("XML");
+ try (Store store = (Store) FolderStoreProvider.INSTANCE.open(params)) {
+ assertEquals("Expected three data stores.", 3,
store.components().size());
+ verifyContent(store, identifiers);
+ }
+ if (!identifiers.isEmpty()) {
+ fail("Missing resources: " + identifiers);
}
}