String xmlData = metadata.getData();
Element metadataXml = Xml.loadString(xmlData, false);
if (!isIndexingTask) {
ServiceContext context = ServiceContext.get();
MetadataSchema mds = _dataManager.getSchema(metadata.getDataInfo().getSchemaId());
// Check if a filter is defined for this schema
// for the editing operation ie. user who can not edit
// will not see those elements.
Pair<String, Element> editXpathFilter = mds.getOperationFilter(ReservedOperation.editing);
boolean filterEditOperationElements = editXpathFilter != null;
List<Namespace> namespaces = mds.getNamespaces();
if(context != null) {
GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
AccessManager am = gc.getBean(AccessManager.class);
if (editXpathFilter != null) {
boolean canEdit = am.canEdit(context, id);
if(canEdit) {
filterEditOperationElements = false;