@Deprecated public static Object lookupBookmark(Bookmark bookmark, final BookmarkService bookmarkService, DomainObjectContainer container) { try { return bookmarkService != null ? bookmarkService.lookup(bookmark) : null; } catch(RuntimeException ex) { if(ex.getClass().getName().contains("ObjectNotFoundException")) { container.warnUser("Object not found - has it since been deleted?"); return null; } throw ex; } }
@Action( semantics = SemanticsOf.SAFE, domainEvent = BookmarkHolder_object.ActionDomainEvent.class ) @ActionLayout( contributed = Contributed.AS_ASSOCIATION ) public Object prop() { return bookmarkService.lookup(bookmarkHolder); }
@Action( domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.SAFE ) @ActionLayout( contributed = Contributed.AS_ACTION, cssClassFa = "fa-bookmark" ) public Object act() { return bookmarkService.lookup(bookmarkHolder); }
@Override public void execute() { commandContext.setCommand(command); try { command.setStartedAt(Clock.getTimeAsJavaSqlTimestamp()); command.setExecutor(Executor.BACKGROUND); final String memento = command.getMemento(); final ActionInvocationMemento aim = new ActionInvocationMemento(mementoService, memento); final String actionId = aim.getActionId(); final Bookmark targetBookmark = aim.getTarget(); final Object targetObject = bookmarkService.lookup(targetBookmark); final ObjectAdapter targetAdapter = adapterFor(targetObject); final ObjectSpecification specification = targetAdapter.getSpecification(); final ObjectAction objectAction = findAction(specification, actionId); if(objectAction == null) { throw new Exception("Unknown action '" + actionId + "'"); } final ObjectAdapter[] argAdapters = argAdaptersFor(aim); final ObjectAdapter resultAdapter = objectAction.execute(targetAdapter, argAdapters); if(resultAdapter != null) { Bookmark resultBookmark = CommandUtil.bookmarkFor(resultAdapter); command.setResult(resultBookmark); } } catch (Exception e) { command.setException(Throwables.getStackTraceAsString(e)); } finally { command.setCompletedAt(Clock.getTimeAsJavaSqlTimestamp()); } } });