Package org.apache.isis.core.metamodel.consent

Examples of org.apache.isis.core.metamodel.consent.Consent


    @Test
    public void testVisibleWhenTargetTransientAndHiddenFacetSetToUntilPersisted() {
        testMember.addFacet(new HideForContextFacetNone(testMember));
        testMember.addFacet(new HiddenFacetImpl(When.UNTIL_PERSISTED, Where.ANYWHERE, testMember));
       
        final Consent visible = testMember.isVisible(null, transientAdapter, Where.ANYWHERE);
        assertFalse(visible.isAllowed());
    }
View Full Code Here


        assertFalse(testMember.isVisible(null, persistentAdapter, Where.ANYWHERE).isAllowed());
    }

    @Test
    public void testVisibleForSessionByDefault() {
        final Consent visible = testMember.isVisible(null, persistentAdapter, Where.ANYWHERE);
        assertTrue(visible.isAllowed());
    }
View Full Code Here

    @Override
    public ObjectAdapter executeWithRuleChecking(final ObjectAdapter target, final ObjectAdapter[] arguments, final AuthenticationSession authenticationSession, final Where where) {

        // see it?
        final Consent visibility = isVisible(authenticationSession, target, where);
        if (visibility.isVetoed()) {
            throw new AuthorizationException();
        }

        // use it?
        final Consent usability = isUsable(authenticationSession, target, where);
        if(usability.isVetoed()) {
            throw new AuthorizationException();
        }

        // do it?
        final Consent validity = isProposedArgumentSetValid(target, arguments);
        if(validity.isVetoed()) {
            throw new RecoverableException(validity.getReason());
        }

        return execute(target, arguments);
    }
View Full Code Here

        @Deprecated
        public static Filter<ObjectAssociation> dynamicallyVisible(final AuthenticationSession session, final ObjectAdapter target, final Where where) {
            return new Filter<ObjectAssociation>() {
                @Override
                public boolean accept(final ObjectAssociation objectAssociation) {
                    final Consent visible = objectAssociation.isVisible(session, target, where);
                    return visible.isAllowed();
                }
            };
        }
View Full Code Here

        @Deprecated
        public static Filter<ObjectAssociation> enabled(final AuthenticationSession session, final ObjectAdapter adapter, final Where where) {
            return new Filter<ObjectAssociation>() {
                @Override
                public boolean accept(final ObjectAssociation objectAssociation) {
                    final Consent usable = objectAssociation.isUsable(session, adapter, where);
                    return usable.isAllowed();
                }
            };
        }
View Full Code Here

        final ObjectAction action = actionFor(sourceContent);
        if (action == null) {
            return Veto.DEFAULT;
        } else {
            final ObjectAdapter source = sourceContent.getAdapter();
            final Consent parameterSetValid = action.isProposedArgumentSetValid(adapter, new ObjectAdapter[] { source });
            parameterSetValid.setDescription("Execute '" + action.getName() + "' with " + source.titleString());
            return parameterSetValid;
        }
    }
View Full Code Here

        }

        // check visibility and whether enabled
        final AuthenticationSession session = getAuthenticationSession();
       
        final Consent visibility = action.isVisible(session, adapter, Where.OBJECT_FORMS);
        if (visibility.isVetoed()) {
            return null;
        }

       
        final AbstractLink link = newLink(linkId, adapter, action, actionPromptProvider);
       
        final Consent usability = action.isUsable(session, adapter, Where.OBJECT_FORMS);
        final String disabledReasonIfAny = usability.getReason();
        if(disabledReasonIfAny != null) {
            link.setEnabled(false);
        }

        return newLinkAndLabel(action, link, disabledReasonIfAny);
View Full Code Here

    // validation & apply
    // //////////////////////////////////////////////////////////

    public String getReasonInvalidIfAny() {
        final ObjectAdapter adapter = getObjectAdapterMemento().getObjectAdapter(ConcurrencyChecking.CHECK);
        final Consent validity = adapter.getSpecification().isValid(adapter);
        return validity.isAllowed() ? null : validity.getReason();
    }
View Full Code Here

        // same as in TreeNodeBorder
        final OneToManyField internalCollectionContent = (OneToManyField) getContent();
        final OneToManyAssociation field = internalCollectionContent.getOneToManyAssociation();
        final ObjectAdapter target = ((ObjectContent) getParent().getContent()).getObject();

        final Consent valid = field.isValidToAdd(target, result);
        if (valid.isAllowed()) {
            field.addElement(target, result);
        }
        super.objectActionResult(result, placement);
    }
View Full Code Here

    public String getReasonInvalidIfAny() {
        final ObjectAdapter targetAdapter = getTargetAdapter();
        final ObjectAdapter[] proposedArguments = getArgumentsAsArray();
        final ObjectAction objectAction = getActionMemento().getAction();
        final Consent validity = objectAction.isProposedArgumentSetValid(targetAdapter, proposedArguments);
        return validity.isAllowed() ? null : validity.getReason();
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.consent.Consent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.