//--------------------------------------------------------------------------
public Element serviceSpecificExec(Element params, ServiceContext context) throws Exception
{
GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
DataManager dataMan = gc.getBean(DataManager.class);
UserSession session = context.getUserSession();
Set<Integer> metadata = new HashSet<Integer>();
Set<Integer> notFound = new HashSet<Integer>();
Set<Integer> notOwner = new HashSet<Integer>();
Set<Integer> subtemplates = new HashSet<Integer>();
// Get xpath, extract-title XSLT name, category and test from args
String xpath = Util.getParam(params, Params.XPATH);
String getTit = Util.getParam(params, Params.EXTRACT_TITLE, "");
String xpathTit = Util.getParam(params, Params.XPATH_TITLE, "");
if (getTit.length() > 0) {
if (!(new File(getTit).exists())) {
throw new IllegalArgumentException("Cannot find xslt "+getTit+" to extract a title field from a subtemplate");
}
} else {
if (xpathTit.length() == 0) {
throw new IllegalArgumentException("Must specify an xpath parameter "+Params.XPATH_TITLE+" or an XSLT file as parameter "+Params.EXTRACT_TITLE+" to select a title field from a subtemplate");
}
}
String uuid = Util.getParam(params, Params.UUID, "");
String category = Util.getParam(params, Params.CATEGORY);
String changeParam = Util.getParam(params, Params.DOCHANGES, "off");
boolean doChanges = changeParam.equals("on");
if (!(category.equals("_none_")) && category.startsWith("_")) {
category = category.substring(1);
} else {
category = null;
}
Element response = new Element(Jeeves.Elem.RESPONSE);
// --- see if we need to process selected set or just uuid
if (uuid.length() == 0) { // no uuid so process selected set
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();) {
uuid = (String) iter.next();
processRecord(context, uuid, category, xpath, getTit, xpathTit, doChanges, metadata, notFound, notOwner, subtemplates, response);
}
}
// Clear the selection after extraction
SelectionManager.updateSelection("metadata", session, params.addContent(new Element("selected").setText("remove-all")), context);
} else { // just process the uuid passed in
processRecord(context, uuid, category, xpath, getTit, xpathTit, doChanges, metadata, notFound, notOwner, subtemplates, response);
}
dataMan.flush();
// -- reindex metadata
context.info("Re-indexing metadata");
Set<Integer> indexers = new HashSet<Integer>();
indexers.addAll(metadata);