* @param request
* @return
*/
public static Element getDefaultSearch(ServiceContext srvContext,
Element request) {
UserSession session = srvContext.getUserSession();
Element elData = new Element(Jeeves.Elem.REQUEST);
Element elSession = (Element) session
.getProperty(Geonet.Session.MAIN_SEARCH);
// If request use request info else default info
if (request != null) {
for (String[] p : DEFAULT_PARAMS) {
String pr = request.getChildText(p[0]);
if (pr != null) {
elData.addContent(new Element(p[0]).setText(pr));
} else {
elData.addContent(new Element(p[0]).setText(p[1]));
}
// Remove child for append the non default one later
request.removeChild(p[0]);
}
// Add other elements send by the request
// It could be extra parameters handle by Lucene in lucene.xsl
// and not set by default
@SuppressWarnings("unchecked")
List<Element> otherEl = request.getChildren();
for (Element e : otherEl) {
if(!e.getName().equalsIgnoreCase("_content_type")) {
elData.addContent(new Element(e.getName()).setText(e.getText()));
}
}
} else if (elSession != null) {
// If no request and session exist use session info
elData = elSession;
} else {
// else use default values
for (String[] p : DEFAULT_PARAMS)
elData.addContent(new Element(p[0]).setText(p[1]));
}
// Set params in session for future use
session.setProperty(Geonet.Session.MAIN_SEARCH, elData);
return elData;
}