Пример #1
0
 protected <E extends BizEntity> E find(Class<E> type, String id) {
   if (BizEntity.NEW.equals(id)) {
     try {
       return type.newInstance();
     } catch (Throwable e) {
       throw Exceptions.handle()
           .to(LOG)
           .error(e)
           .withSystemErrorMessage("Cannot create a new instance of '%s'", type.getName())
           .handle();
     }
   }
   Optional<E> result = oma.find(type, id);
   if (!result.isPresent()) {
     throw Exceptions.createHandled()
         .withNLSKey("BizController.unknownObject")
         .set("id", id)
         .handle();
   }
   return result.get();
 }
Пример #2
0
 protected <E extends BizEntity> Optional<E> tryFind(Class<E> type, String id) {
   if (BizEntity.NEW.equals(id)) {
     return Optional.empty();
   }
   return oma.find(type, id);
 }