Editor tracking
The ArcGIS Runtime SDK for Java supports the tracking of edits made to features. Editor tracking records:
- which user created the feature
- the date and time the feature was created
- which user was the last editor
- the date and time the last edit took place
querying a feature layer's EditFieldsInfo
featureLayer.addLayerInitializeCompleteListener(new LayerInitializeCompleteListener() {
@Override
public void layerInitializeComplete(LayerInitializeCompleteEvent e) {
// get the EditFieldsInfo from the initialized feature layer
EditFieldsInfo efinfo = featureLayer.getEditFieldsInfo();
// the relevant editor tracking field names can be obtained/stored as below
String creatorField = efinfo.getCreatorField();
String creationDateField = efinfo.getCreationDateField();
String editorField = efinfo.getEditorField();
String editDateField = efinfo.getEditDateField();
}
});
In a secure feature service, meaning one which you can only access with a username and password, the relevant editor tracking fields will be populated automatically, with the editor and/or creator field matching the username. If no authenticated user is provided and anonymous access is enabled on the feature service, the creator and editor fields are left set to null. When you edit a feature in your Java application and apply the edits to the server, the time at which you have created or edited the feature gets stored in the relevant field.
Ownership-based access can be enabled on a feature service to for example limit the ability of users to update or delete features they did not create. For a given user and a given graphic, you can programatically have access to whether this user can create, update, or delete the graphic. You can then incorporate this into your editing workflow if desired. An example workflow is shown in the code below:
// user accesses the secure feature service as 'user1'
UserCredentials credentials = new UserCredentials();
credentials.setUserAccount("user1", password);
//Supply the credentials when you create the ArcGISFeatureLayer
ArcGISFeatureLayer featureLayer = new ArcGISFeatureLayer(
"http://sampleserver6.arcgisonline.com/arcgis/rest/services/SaveTheBay/FeatureServer/0",
credentials);
// Control the editing environment. For example, 'user1' selects 'graphic' via a mouse-click to delete it
if (featureLayer.getEditCapabilities(graphic).isDelete()) {
// 'user1' is allowed to delete this graphic so delete the graphic
} else {
// 'user1' is not allowed to delete this graphic so inform user of this restriction
}
To see edit tracking in action, please have a look at the interactive 'Editor Tracking' sample in the Java Sample Application, under the table of content heading 'Editing'.