Author: jsorel
Date: Fri Feb 23 14:44:11 2018
New Revision: 1825131
URL: http://svn.apache.org/viewvc?rev=1825131&view=rev
Log:
Naming : rename FileSystemResource, remove default writable resource method
implementations
Added:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceOnFileSystem.java
- copied, changed from r1825130,
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FileSystemResource.java
Removed:
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/FileSystemResource.java
Modified:
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/WritableStore.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableAggregate.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableFeatureSet.java
Copied:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceOnFileSystem.java
(from r1825130,
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FileSystemResource.java)
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceOnFileSystem.java?p2=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceOnFileSystem.java&p1=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FileSystemResource.java&r1=1825130&r2=1825131&rev=1825131&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FileSystemResource.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceOnFileSystem.java
[UTF-8] Fri Feb 23 14:44:11 2018
@@ -40,11 +40,8 @@ import org.apache.sis.storage.Resource;
* @version 1.0
* @since 1.0
* @module
- *
- * @todo Current name suggests resources provided by the file system (i.e.
files and directories).
- * Rename as {@code FileBackedResource}, {@code ResourceBackedByFiles}
or {@code ResourceOnFileSystem}?
*/
-public interface FileSystemResource extends Resource {
+public interface ResourceOnFileSystem extends Resource {
/**
* Gets the paths to files potentially used by this resource.
* This is typically the files opened by a {@linkplain
org.apache.sis.storage.DataStore data store}.
@@ -67,10 +64,6 @@ public interface FileSystemResource exte
*
* @return files used by this resource. Should never be {@code null}.
* @throws DataStoreException if an error on the file system prevent the
creation of the list.
- *
- * @todo Rename {@code getComponentFiles()}? The reason is that it is not
returning the paths of
- * multiple resources, but paths to components of this single
resources. The use of "Files"
- * is for emphasing that this method should not return path to
directories.
*/
- Path[] getResourcePaths() throws DataStoreException;
+ Path[] getComponentFiles() throws DataStoreException;
}
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=1825131&r1=1825130&r2=1825131&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 Feb 23 14:44:11 2018
@@ -101,7 +101,7 @@ public abstract class URIDataStore exten
* @since 0.8
* @module
*/
- public abstract static class Provider extends DataStoreProvider implements
FileSystemProvider {
+ public abstract static class Provider extends DataStoreProvider {
/**
* Description of the location parameter.
*/
@@ -170,7 +170,6 @@ public abstract class URIDataStore exten
*
* @return the filename suffixes, case insensitive. Never null but can
be empty.
*/
- @Override
public final List<String> getSuffix() {
return Collections.unmodifiableList(suffix);
}
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/WritableStore.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/WritableStore.java?rev=1825131&r1=1825130&r2=1825131&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/WritableStore.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/WritableStore.java
[UTF-8] Fri Feb 23 14:44:11 2018
@@ -34,10 +34,10 @@ import org.apache.sis.storage.FeatureSet
import org.apache.sis.storage.WritableAggregate;
import org.apache.sis.storage.WritableFeatureSet;
import org.apache.sis.internal.storage.StoreUtilities;
-import org.apache.sis.internal.storage.FileSystemProvider;
-import org.apache.sis.internal.storage.FileSystemResource;
import org.apache.sis.internal.storage.Resources;
import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.internal.storage.ResourceOnFileSystem;
+import org.apache.sis.internal.storage.URIDataStore;
/**
@@ -82,8 +82,8 @@ final class WritableStore extends Store
if (filename == null) {
throw new
DataStoreException(message(Resources.Keys.MissingResourceIdentifier_1,
StoreUtilities.getLabel(resource)));
}
- if (componentProvider instanceof FileSystemProvider) {
- final Iterator<String> suffixes = ((FileSystemProvider)
componentProvider).getSuffix().iterator();
+ if (componentProvider instanceof URIDataStore.Provider) {
+ final Iterator<String> suffixes = ((URIDataStore.Provider)
componentProvider).getSuffix().iterator();
if (suffixes.hasNext()) {
filename += '.' + suffixes.next();
}
@@ -129,8 +129,8 @@ final class WritableStore extends Store
try {
if (store instanceof Store) {
deleteRecursively(((Store) store).location, true);
- } else if (store instanceof FileSystemResource) {
- for (Path c : ((FileSystemResource)
store).getResourcePaths()) {
+ } else if (store instanceof ResourceOnFileSystem) {
+ for (Path c : ((ResourceOnFileSystem)
store).getComponentFiles()) {
Files.delete(c);
}
}
@@ -163,8 +163,8 @@ final class WritableStore extends Store
children.remove(path);
return;
}
- } else if (resource instanceof FileSystemResource) {
- final Path[] componentPaths = ((FileSystemResource)
resource).getResourcePaths().clone();
+ } else if (resource instanceof ResourceOnFileSystem) {
+ final Path[] componentPaths = ((ResourceOnFileSystem)
resource).getComponentFiles().clone();
for (final Path root : componentPaths) {
if (Files.isSameFile(root.getParent(), location)) {
for (final Path path : componentPaths) {
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableAggregate.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableAggregate.java?rev=1825131&r1=1825130&r2=1825131&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableAggregate.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableAggregate.java
[UTF-8] Fri Feb 23 14:44:11 2018
@@ -16,8 +16,6 @@
*/
package org.apache.sis.storage;
-import org.apache.sis.internal.storage.Resources;
-
/**
* An {@linkplain Aggregate} with writing capabilities.
@@ -49,16 +47,11 @@ public interface WritableAggregate exten
* <p>The {@link Capability#WRITABLE} flag if presents in the {@link
#getCapabilities()} set
* indicates that this method should be implemented.</p>
*
- * <p>The default implementation throws {@link
ReadOnlyStorageException}.</p>
- *
* @param resource the resource to copy in this {@code Aggregate}.
* @return the effectively added resource. May be {@code resource} itself
if it has been added verbatim.
- * @throws ReadOnlyStorageException if this instance does not support
write operations.
* @throws DataStoreException if the given resource can not be stored in
this {@code Aggregate} for another reason.
*/
- default Resource add(Resource resource) throws ReadOnlyStorageException,
DataStoreException {
- throw new ReadOnlyStorageException(this,
Resources.Keys.StoreIsReadOnly);
- }
+ Resource add(Resource resource) throws DataStoreException;
/**
* Removes a {@code Resource} from this {@code Aggregate}.
@@ -67,13 +60,8 @@ public interface WritableAggregate exten
* <p>The {@link Capability#WRITABLE} flag if presents in the {@link
#getCapabilities()} set
* indicates that this method should be implemented.</p>
*
- * <p>The default implementation throws {@link
ReadOnlyStorageException}.</p>
- *
* @param resource child resource to remove, should not be null.
- * @throws ReadOnlyStorageException if this instance does not support
write operations.
* @throws DataStoreException if the given resource could not be removed
for another reason.
*/
- default void remove(Resource resource) throws ReadOnlyStorageException,
DataStoreException {
- throw new ReadOnlyStorageException(this,
Resources.Keys.StoreIsReadOnly);
- }
+ void remove(Resource resource) throws DataStoreException;
}
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableFeatureSet.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableFeatureSet.java?rev=1825131&r1=1825130&r2=1825131&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableFeatureSet.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableFeatureSet.java
[UTF-8] Fri Feb 23 14:44:11 2018
@@ -19,7 +19,6 @@ package org.apache.sis.storage;
import java.util.Iterator;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
-import org.apache.sis.internal.storage.Resources;
// Branch-dependent imports
import org.opengis.feature.Feature;
@@ -45,16 +44,11 @@ public interface WritableFeatureSet exte
* <p>Feature sets may restrict the kind of changes that are allowed. An
{@link IllegalFeatureTypeException}
* will be thrown if the given type contains incompatible property
changes.</p>
*
- * <p>The default implementation throws a {@linkplain
ReadOnlyStorageException}.</p>
- *
* @param newType new feature type definition (not {@code null}).
- * @throws ReadOnlyStorageException if this instance does not support
schema update.
* @throws IllegalFeatureTypeException if the given type is not compatible
with the types supported by the store.
* @throws DataStoreException if another error occurred while changing the
feature type.
*/
- default void updateType(FeatureType newType) throws
ReadOnlyStorageException, IllegalFeatureTypeException, DataStoreException {
- throw new ReadOnlyStorageException(this,
Resources.Keys.StoreIsReadOnly);
- }
+ void updateType(FeatureType newType) throws IllegalFeatureTypeException,
DataStoreException;
/**
* Inserts new features in this {@code FeatureSet}.
@@ -69,15 +63,10 @@ public interface WritableFeatureSet exte
* <p>The {@link Capability#WRITABLE} flag if presents in the {@link
#getCapabilities()} set
* indicates that this method should be implemented.</p>
*
- * <p>The default implementation throws {@link
ReadOnlyStorageException}.</p>
- *
* @param features features to insert in this {@code FeatureSet}.
- * @throws ReadOnlyStorageException if this instance does not support
write operations.
* @throws DataStoreException if another error occurred while storing new
features.
*/
- default void add(Iterator<? extends Feature> features) throws
ReadOnlyStorageException, DataStoreException {
- throw new ReadOnlyStorageException(this,
Resources.Keys.StoreIsReadOnly);
- }
+ void add(Iterator<? extends Feature> features) throws DataStoreException;
/**
* Removes all features from this {@code FeatureSet} which matches the
given predicate.
@@ -85,16 +74,11 @@ public interface WritableFeatureSet exte
* <p>The {@link Capability#WRITABLE} flag if presents in the {@link
#getCapabilities()} set
* indicates that this method should be implemented.</p>
*
- * <p>The default implementation throws {@link
ReadOnlyStorageException}.</p>
- *
* @param filter a predicate which returns true for resources to be
removed.
* @return {@code true} if any elements were removed.
- * @throws ReadOnlyStorageException if this instance does not support
write operations.
* @throws DataStoreException if another error occurred while removing
features.
*/
- default boolean removeIf(Predicate<? super Feature> filter) throws
ReadOnlyStorageException, DataStoreException {
- throw new ReadOnlyStorageException(this,
Resources.Keys.StoreIsReadOnly);
- }
+ boolean removeIf(Predicate<? super Feature> filter) throws
DataStoreException;
/**
* Updates all features from this {@code FeatureSet} which matches the
given predicate.
@@ -111,16 +95,10 @@ public interface WritableFeatureSet exte
* <p>The {@link Capability#WRITABLE} flag if presents in the {@link
#getCapabilities()} set
* indicates that this method should be implemented.</p>
*
- * <p>The default implementation throws {@link
ReadOnlyStorageException}.</p>
- *
* @param filter a predicate which returns true for resources to be
updated.
* @param updater operation called for each matching {@link Feature}.
- * @throws ReadOnlyStorageException if this instance does not support
write operations.
* @throws DataStoreException if another error occurred while replacing
features.
*/
- default void replaceIf(Predicate<? super Feature> filter,
UnaryOperator<Feature> updater)
- throws ReadOnlyStorageException, DataStoreException
- {
- throw new ReadOnlyStorageException(this,
Resources.Keys.StoreIsReadOnly);
- }
+ void replaceIf(Predicate<? super Feature> filter, UnaryOperator<Feature>
updater)
+ throws DataStoreException;
}