//--------------------------------------------------------------------------
public Element serviceSpecificExec(Element params, ServiceContext context) throws Exception {
GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
DataManager dataMan = gc.getBean(DataManager.class);
AccessManager accessMan = gc.getBean(AccessManager.class);
UserSession session = context.getUserSession();
Set<Integer> metadata = new HashSet<Integer>();
Set<Integer> notFound = new HashSet<Integer>();
Set<Integer> notOwner = new HashSet<Integer>();
boolean backupFile = Util.getParam(params, Params.BACKUP_FILE, true);
if(context.isDebugEnabled())
context.debug("Get selected metadata");
SelectionManager sm = SelectionManager.getManager(session);
synchronized(sm.getSelection("metadata")) {
for (Iterator<String> iter = sm.getSelection("metadata").iterator(); iter.hasNext();) {
String uuid = (String) iter.next();
if(context.isDebugEnabled())
context.debug("Deleting metadata with uuid:"+ uuid);
String id = dataMan.getMetadataId(uuid);
//--- Metadata may have been deleted since selection
if (id != null) {
//-----------------------------------------------------------------------
//--- check access
Metadata info = context.getBean(MetadataRepository.class).findOne(id);
if (info == null) {
notFound.add(Integer.valueOf(id));
} else if (!accessMan.isOwner(context, id)) {
notOwner.add(Integer.valueOf(id));
} else {
//--- backup metadata in 'removed' folder
if (backupFile && info.getDataInfo().getType() != MetadataType.SUB_TEMPLATE) {