Created
January 30, 2013 15:47
-
-
Save kareblak/4674149 to your computer and use it in GitHub Desktop.
lolcat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def load(id: Long)(profile: ProfileWrapper): Either[Exception, StoredSearch] = { | |
try { | |
val alert = Option(alertService.getAlert(id)) | |
alert.map { | |
a: AlertBeanSpringJDBC => | |
if (a.getLoginId != profile.id) { | |
Left(new SecurityException("This is not owned by the logged in user.")) | |
} | |
Right(StoredSearch( | |
Some(a.getAlertId), | |
a.getDescription, | |
searchValueService.getSearchKey(a.getSearchId.toString), | |
getCriteria(Option(a.getSearchUrl), a.getAlertId.toInt), | |
a.getEndDateAsDays | |
)) | |
}.getOrElse(Left(new IllegalArgumentException("Not found"))) | |
} | |
catch { | |
case e: Exception => Left(e) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment