protected void assertFids(Set fids) throws FeatureLockException {
   InProcessLockingManager lockingManager = getInProcessLockingManager();
   if (lockingManager == null) {
     return; // subclass is doing its own thing
   }
   Transaction t = getTransaction();
   String typeName = getSchema().getTypeName();
   String fid;
   for (Iterator i = fids.iterator(); i.hasNext(); ) {
     fid = (String) i.next();
     lockingManager.assertAccess(typeName, fid, transaction);
   }
 }
Beispiel #2
0
  /* (non-Javadoc)
   * @see org.geotools.data.DataStore#getFeatureWriter(java.lang.String, org.geotools.filter.Filter, org.geotools.data.Transaction)
   */
  public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(
      String typeName, Filter filter, Transaction transaction) throws IOException {
    if (filter == null) {
      throw new NullPointerException(
          "getFeatureReader requires Filter: " + "did you mean Filter.INCLUDE?");
    }

    if (filter == Filter.EXCLUDE) {
      SimpleFeatureType featureType = getSchema(typeName);

      return new EmptyFeatureWriter(featureType);
    }

    if (transaction == null) {
      throw new NullPointerException(
          "getFeatureWriter requires Transaction: "
              + "did you mean to use Transaction.AUTO_COMMIT?");
    }

    FeatureWriter<SimpleFeatureType, SimpleFeature> writer;

    if (transaction == Transaction.AUTO_COMMIT) {
      try {
        writer = createFeatureWriter(typeName, transaction);
      } catch (UnsupportedOperationException e) {
        throw e;
      }
    } else {
      TransactionStateDiff state = state(transaction);
      if (state != null) {
        writer = state.writer(typeName, filter);
      } else {
        throw new UnsupportedOperationException("Subclass sould implement");
      }
    }

    if (lockingManager != null) {
      // subclass has not provided locking so we will
      // fake it with InProcess locks
      writer = lockingManager.checkedWriter(writer, transaction);
    }

    if (filter != Filter.INCLUDE) {
      writer = new FilteringFeatureWriter(writer, filter);
    }

    return writer;
  }