X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=server%2Fcompbio%2Fcontrollers%2FBasicController.java;h=57459d64e26edc6ba39832898768c8c0224f466e;hb=8d79b62eec3e82b185fa2dea9d18b9f620149779;hp=a714c4d34cf57f99936052d47db51334249f26b3;hpb=00e522e98b3a55bb0ee05438c20c0f6f30bd411a;p=proteocache.git diff --git a/server/compbio/controllers/BasicController.java b/server/compbio/controllers/BasicController.java index a714c4d..57459d6 100644 --- a/server/compbio/controllers/BasicController.java +++ b/server/compbio/controllers/BasicController.java @@ -8,8 +8,8 @@ import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; -import compbio.cassandra.CassandraReader; import compbio.cassandra.DateFormatter; +import compbio.cassandra.readers.CassandraReader; public class BasicController { final protected SimpleDateFormat formaterDDMMYY = DateFormatter.getFormatDDMMYY(); @@ -17,7 +17,7 @@ public class BasicController { protected Calendar cal = Calendar.getInstance(); protected String theEaerlistDate = DateFormatter.DateLongToString(CassandraReader.earliestDate(), formaterYYMMDD); protected String theCurrentDate = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); - + protected String getPrincipalName() { Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); if (principal instanceof UserDetails) { @@ -64,20 +64,21 @@ public class BasicController { } return false; } - + protected String DateChecking(String trimmeddate1, String trimmeddate2, long longDate1, long longDate2) { Calendar cal2 = Calendar.getInstance(); - if (trimmeddate1.equalsIgnoreCase("") || trimmeddate2.equalsIgnoreCase("")) + if (trimmeddate1.equalsIgnoreCase("") || trimmeddate2.equalsIgnoreCase("")) return "The date cann't be empty"; - else if (!DateFormatter.isThisDateValid(trimmeddate1, formaterYYMMDD) || !DateFormatter.isThisDateValid(trimmeddate2, formaterYYMMDD)) + else if (!DateFormatter.isThisDateValid(trimmeddate1, formaterYYMMDD) + || !DateFormatter.isThisDateValid(trimmeddate2, formaterYYMMDD)) return "The date format in invalid. Try format yyyy/mm/dd"; - else if (longDate2 < CassandraReader.earliestDate()) + else if (longDate2 < CassandraReader.earliestDate()) return "The date2 is after the earlestDate " + theEaerlistDate; else if (longDate1 > cal2.getTimeInMillis()) return "The date1 is before the current date " + theCurrentDate; - else if (longDate1 > longDate2) + else if (longDate1 > longDate2) return "Wrong date's diaposon. The date1 is more than date2."; - else + else return null; } }