X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=server%2Fcompbio%2Fcontrollers%2FBasicController.java;h=26123600da9467cc36d03af439654f3adcbd2cdd;hb=e715cf0b45f377f5b0965f212a2ef32fb8d7c5ed;hp=2a715022abb7a23a4cfe5cb12a937fc41b0791d4;hpb=e8b88c0c8e432f8bc1aefdbd81df81e9ef706242;p=proteocache.git diff --git a/server/compbio/controllers/BasicController.java b/server/compbio/controllers/BasicController.java index 2a71502..2612360 100644 --- a/server/compbio/controllers/BasicController.java +++ b/server/compbio/controllers/BasicController.java @@ -11,13 +11,20 @@ import org.springframework.security.core.userdetails.UserDetails; import compbio.cassandra.DateFormatter; import compbio.cassandra.readers.CassandraReader; +/** + * + * + * @author Alexander Sherstnev + * @version 1.0 + * @since Dec 2013 + */ public class BasicController { final protected SimpleDateFormat formaterDDMMYY = DateFormatter.getFormatDDMMYY(); final protected SimpleDateFormat formaterYYMMDD = DateFormatter.getFormatYYMMDD(); 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 +71,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; } }