Skip to content

Instantly share code, notes, and snippets.

@kareblak
Created January 30, 2013 15:47
Show Gist options
  • Save kareblak/4674149 to your computer and use it in GitHub Desktop.
Save kareblak/4674149 to your computer and use it in GitHub Desktop.
lolcat
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