@Override public void removeSchema(Name typeName) throws IOException { throw notifyUnsupportedOperation(); }
@Test public void testDisallowedAPI() throws Exception { ReadOnlyDataStore ro = new ReadOnlyDataStore(ds, WrapperPolicy.hide(null)); ro.createSchema(null); fail("Should have failed with an unsupported operation exception"); } catch (UnsupportedOperationException e) { ro.updateSchema((String) null, null); fail("Should have failed with an unsupported operation exception"); } catch (UnsupportedOperationException e) { ro.updateSchema((Name) null, null); fail("Should have failed with an unsupported operation exception"); } catch (UnsupportedOperationException e) { ro.getFeatureWriter("states", Transaction.AUTO_COMMIT); fail("Should have failed with an unsupported operation exception"); } catch (UnsupportedOperationException e) { ro.getFeatureWriter("states", Filter.INCLUDE, Transaction.AUTO_COMMIT); fail("Should have failed with an unsupported operation exception"); } catch (UnsupportedOperationException e) { ro.getFeatureWriterAppend("states", Transaction.AUTO_COMMIT); fail("Should have failed with an unsupported operation exception"); } catch (UnsupportedOperationException e) {
@Test public void testReadOnlySource() throws Exception { ReadOnlyDataStore ro = new ReadOnlyDataStore( ds, WrapperPolicy.readOnlyHide( new WorkspaceAccessLimits(CatalogMode.HIDE, true, false, false))); SimpleFeatureSource fs = ro.getFeatureSource("blah"); // used to go boom here SimpleFeatureCollection fc = fs.getFeatures(Query.ALL); assertEquals(0, fc.size()); }
return new ReadOnlyDataStore((DataStore) object, policy); } else if (DataAccess.class.isAssignableFrom(clazz)) { return new ReadOnlyDataAccess((DataAccess) object, policy);
@Override public SimpleFeatureSource getFeatureSource(Name typeName) throws IOException { final SimpleFeatureSource fs = super.getFeatureSource(typeName); return wrapFeatureSource(fs); }
@SuppressWarnings("unchecked") SimpleFeatureSource wrapFeatureSource(final SimpleFeatureSource fs) { if (fs == null) return null; WrapperPolicy childPolicy = buildPolicyForFeatureSource(); return DataUtilities.simple((FeatureSource) SecuredObjects.secure(fs, childPolicy)); }
@Test public void testChallenge() throws Exception { ReadOnlyDataStore ro = new ReadOnlyDataStore(ds, WrapperPolicy.readOnlyChallenge(null)); ro.createSchema(null); fail("Should have failed with a security exception"); } catch (Exception e) { ro.updateSchema((String) null, null); fail("Should have failed with a security exception"); } catch (Exception e) { ro.updateSchema((Name) null, null); fail("Should have failed with a security exception"); } catch (Exception e) { ro.getFeatureWriter("states", Transaction.AUTO_COMMIT); fail("Should have failed with a security exception"); } catch (Exception e) { ro.getFeatureWriter("states", Filter.INCLUDE, Transaction.AUTO_COMMIT); fail("Should have failed with a security exception"); } catch (Exception e) { ro.getFeatureWriterAppend("states", Transaction.AUTO_COMMIT); fail("Should have failed with a security exception"); } catch (Exception e) {
@Override public SimpleFeatureSource getFeatureSource(String typeName) throws IOException { final SimpleFeatureSource fs = super.getFeatureSource(typeName); return wrapFeatureSource(fs); }
@Override public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter( String typeName, Filter filter, Transaction transaction) throws IOException { throw notifyUnsupportedOperation(); }
@Override public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter( String typeName, Transaction transaction) throws IOException { throw notifyUnsupportedOperation(); }
@Override public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend( String typeName, Transaction transaction) throws IOException { throw notifyUnsupportedOperation(); }
@Override public void updateSchema(Name typeName, SimpleFeatureType featureType) throws IOException { throw notifyUnsupportedOperation(); }
@Override public void updateSchema(String typeName, SimpleFeatureType featureType) throws IOException { throw notifyUnsupportedOperation(); }
@Override public void removeSchema(String typeName) throws IOException { throw notifyUnsupportedOperation(); }
@Override public void createSchema(SimpleFeatureType featureType) throws IOException { throw notifyUnsupportedOperation(); }