Commit ba20d36c authored by Jie Yuan's avatar Jie Yuan
Browse files

add esoc site filter and its names

parent 8fd95e1d
......@@ -7,8 +7,10 @@ package svmon.endpoints;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -25,7 +27,7 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javassist.bytecode.Descriptor.Iterator;
import svmon.controllers.SiteController;
import svmon.exceptions.SiteException;
import svmon.model.Site;
......@@ -97,6 +99,36 @@ public class SiteEndpoint {
return this.siteController.getAllGOCDBSites();
}
/**
* This returns a JSON with all the GOCDB sites
* @return
*/
@RequestMapping(value="/eosc/all", method=GET)
public @ResponseBody Iterable<Site> getAllEOSCSites() {
log.info("Detected endpoint /sites/eosc/all for getAllEOSCSites() at {}",dateFormat.format(new Date()));
Iterable<Site> gocdbSites = this.siteController.getAllGOCDBSites();
Iterator<Site> siteIt = gocdbSites.iterator();
List<Site> resList = new ArrayList<Site> ();
while (siteIt.hasNext()) {
Site tmp = siteIt.next();
if (tmp.getScopeList().isEmpty() == false && tmp.getScopeList().contains("cms")) {
resList.add(tmp);
}
}
if (resList.isEmpty() == true) {
return null;
}
Iterable<Site> res = resList;
return res;
}
/**
* Updates the local db sites with the information of the DPMT API sites
* Using the siteName parameter
......@@ -301,6 +333,32 @@ public class SiteEndpoint {
return res;
}
/**
* This returns a JSON with all the GOCDB sites
* @return
*/
@RequestMapping(value="/siteNames/eosc/all", method=GET)
public @ResponseBody List<String> getAllEOSCSiteNames() {
log.info("Detected endpoint /sites/sitenames/eosc/all for getAllEOSCSites() at {}",dateFormat.format(new Date()));
Iterable<Site> gocdbSites = this.siteController.getAllGOCDBSites();
Iterator<Site> siteIt = gocdbSites.iterator();
List<String> resList = new ArrayList<String> ();
while (siteIt.hasNext()) {
Site tmp = siteIt.next();
if (tmp.getScopeList().isEmpty() == false && tmp.getScopeList().contains("cms")) {
resList.add(tmp.getIdName());
}
}
if (resList.isEmpty() == true) {
return null;
}
return resList;
}
/**
*
* get brief reports of all sites
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment