FeatureType featureType = null;
MapServiceInstance instance = (MapServiceInstance) mapService
.getMapServicePool().checkoutIdleInstance();
try {
Layer layer = instance.getMap().getLayer(nLayerId);
featureType = layer.getMapLayer().getFeatureSource()
.getSchema();
} finally {
if (instance != null) {
mapService.getMapServicePool().checkinIdelInstance(
instance);
}
}
// Handle features
FeatureCollection<SimpleFeatureType, SimpleFeature> addsFeatureCollection = null;
if (adds != null) {
addsFeatureCollection = EsriJsonUtil
.json2FeatureCollection(adds,
(SimpleFeatureType) featureType);
}
FeatureCollection<SimpleFeatureType, SimpleFeature> updatesFeatureCollection = null;
if (updates != null) {
updatesFeatureCollection = EsriJsonUtil
.json2FeatureCollection(updates,
(SimpleFeatureType) featureType);
}
String[] deleteFeatureIds = null;
if (deletes != null) {
deleteFeatureIds = deletes.split(",");
}
instance = (MapServiceInstance) mapService.getMapServicePool()
.checkoutIdleInstance();
List<FeatureId> addFeatureIds = null;
HashMap<FeatureId, Boolean> updateFeatureIds = null;
boolean deleteSuccess = false;
try {
Layer layer = instance.getMap().getLayer(nLayerId);
try {
addFeatureIds = layer.add(addsFeatureCollection);
} catch (Exception ex) {
ex.printStackTrace();
}
try {
updateFeatureIds = layer
.update(updatesFeatureCollection);
} catch (Exception ex) {
ex.printStackTrace();
}
try {
deleteSuccess = layer.delete(deleteFeatureIds);
} catch (Exception ex) {
ex.printStackTrace();
}
} finally {
if (instance != null) {