public String getReasonDisabledIfAny() { final ObjectAdapter targetAdapter = getTargetAdapter(); final ObjectAction objectAction = getAction(); final Consent usability = objectAction.isUsable( targetAdapter, InteractionInitiatedBy.USER, Where.OBJECT_FORMS); final String disabledReasonIfAny = usability.getReason(); return disabledReasonIfAny; }
public static String isUsable(final ObjectAdapter object, final ObjectAction action) { final Consent usable = action.isUsable(getAuthenticationSession(), object); final boolean isUsable = getSession() != null && usable.isAllowed(); return isUsable ? null : usable.getReason(); }
@Override boolean test(final Request request, final String attributeName, final String targetId) { final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), targetId); // TODO needs to work irrespective of parameters final ObjectAction objectAction = object.getSpecification().getObjectAction(ActionType.USER, attributeName, ObjectSpecification.EMPTY_LIST); final Consent usable = objectAction.isUsable(IsisContext.getAuthenticationSession(), object); return usable.isAllowed(); } }
public static boolean isVisibleAndUsable(final ObjectAdapter object, final ObjectAction action) { final boolean isVisible = action.isVisible(getAuthenticationSession(), object).isAllowed(); final boolean isUsable = getSession() != null && action.isUsable(getAuthenticationSession(), object).isAllowed(); final boolean isVisibleAndUsable = isVisible && isUsable; return isVisibleAndUsable; }
protected Object homePageIfUsable(ObjectAdapter serviceAdapter, ObjectAction objectAction) { if (!objectAction.containsDoOpFacet(HomePageFacet.class)) { return null; } final Consent visibility = objectAction.isVisible( serviceAdapter, InteractionInitiatedBy.USER, Where.ANYWHERE); if (visibility.isVetoed()) { return null; } final Consent usability = objectAction.isUsable( serviceAdapter, InteractionInitiatedBy.USER, Where.ANYWHERE ); if (usability.isVetoed()) { return null; } final ObjectAdapter mixedInAdapter = null; final ObjectAdapter[] parameters = {}; final ObjectAdapter objectAdapter = objectAction.executeWithRuleChecking( serviceAdapter, mixedInAdapter, parameters, InteractionInitiatedBy.USER, WHERE_FOR_ACTION_INVOCATION); return objectAdapter != null ? objectAdapter.getObject(): null; }
public void isUsable(final ObjectAction mockAction, final boolean returns) { context.checking(new Expectations() { { allowing(mockAction).isUsable(with(any(AuthenticationSession.class)), with(any(ObjectAdapter.class))); will(returnValue(ConsentAbstract.allowIf(returns))); } }); }
*/} else if (action.isUsable(IsisContext.getAuthenticationSession(), adapter).isVetoed()) { request.appendHtml("<span class=\"disabled\" title=\"" + action.isUsable(IsisContext.getAuthenticationSession(), adapter).getReason() + "\">"); request.appendAsHtmlEncoded(action.getName()); request.appendHtml("</span>");
return; final Consent usable = action.isUsable(IsisContext.getAuthenticationSession(), object); if (usable.isVetoed()) { LOG.info("action not available: " + usable.getReason());
final Consent usable = action.isUsable(IsisContext.getAuthenticationSession(), object); if (usable.isVetoed()) { final String notUsable = usable.getReason();