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

remove site validation check from dpmt

parent f6b03eb4
......@@ -209,7 +209,10 @@ public class SiteController implements Serializable{
@Transactional
public void addNewSite(Site site) throws SiteException{
try{
this.siteRepository.save(site);
Site tmp = this.siteRepository.save(site);
// if ( tmp.getIdName().equals("PDC")) {
// System.out.println("PDC+++++++++++++++++++++++++++++");
// }
}
catch(Exception e){
log.error("An exception ocurren when adding new site on db at {} \n exception msg: "+e.getMessage(), dateFormat.format(new Date()));
......@@ -222,7 +225,15 @@ public class SiteController implements Serializable{
String idName;
log.info("Adding new sites to DB from "+sourceOfInfo+" and checking validity of names at {}",dateFormat.format(new Date()));
for(Site siteIterator:listSites){
idName = siteIterator.getIdName();
/** idName = siteIterator.getIdName();
if (idName.equals("PDC") ){
System.out.println("*******************");
System.out.println(idName);
System.out.println(siteIterator.getPrimaryKeyOnGocdb());
System.out.println(siteIterator.getSourceInformation());
System.out.println("*******************");
}*/
/**
* Before adding the new site, we check if the idName is correct or should be
* checked, for example, if the correct id is on lowercases (looks solve the bug of the cocdb api)
......@@ -231,18 +242,18 @@ public class SiteController implements Serializable{
*
* WE ONLY CHECK THE VALIDITY OF THE NAME ON DPMT SITES
*/
if(sourceOfInfo.equals("DPMT")){
/** if(sourceOfInfo.equals("DPMT")){
if(!this.checkIfSiteIdNameIsValid(idName)){
if(this.checkIfSiteIdNameIsValid(idName.toLowerCase())){
siteIterator.setIdName(idName.toLowerCase());
this.addNewSite(siteIterator);
}
else{
else{ */
/**
* If with lower cases is still invalid,
* is because it contains not allowed characters, so we dont save it
**/
log.warn("The site with name: "+idName+" is invalid, save on db ignored at {}", dateFormat.format(new Date()));
/** log.warn("The site with name: "+idName+" is invalid, save on db ignored at {}", dateFormat.format(new Date()));
}
}
else{
......@@ -251,7 +262,8 @@ public class SiteController implements Serializable{
}
else{
this.addNewSite(siteIterator);
}
} */
this.addNewSite(siteIterator);
}
}
......@@ -312,10 +324,10 @@ public class SiteController implements Serializable{
try{
remoteSite = this.restXMLClient.getSiteFromDPMTBySiteName(siteName);
/** We check that the external site is really valid and then we save the site **/
if(remoteSite.isSiteValid()){
// if(remoteSite.isSiteValid()){
this.addNewSite(remoteSite);
resultMsg = "Site "+siteName+" successfully saved";
}
// }
}
catch(SiteException e){
resultMsg=e.getMessage();
......@@ -408,6 +420,7 @@ public class SiteController implements Serializable{
ArrayList<Site> dpmtSites = (ArrayList<Site>) this.getAllSitesDetailedFromDPMTApi();
try{
/** Then we add them to the DB **/
this.addNewSites(dpmtSites, "DPMT");
resultMsg = "Sites list successfully saved";
log.info("Updating local db with dpmt sites finished at {}", dateFormat.format(new Date()));
......
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