Package org.apache.isis.viewer.scimpi.dispatcher

Examples of org.apache.isis.viewer.scimpi.dispatcher.ScimpiException


        String className = request.getOptionalProperty(CLASS);
        className = className == null ? "" : " class=\"" + className + "\"";
        final ObjectAdapter object = request.getContext().getMappedObjectOrVariable(id, ELEMENT);
        final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
        if (field == null) {
            throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
        }
        request.appendHtml("<td" + className + ">");
        if (field.isVisible(IsisContext.getAuthenticationSession(), object).isAllowed()) {
            final ObjectAdapter fieldReference = field.get(object);
            final String source =
View Full Code Here


            if (propertyName.equals("set")) {
                result = request.isPropertySet("set");
            } else {
                final Test test = tests.get(propertyName);
                if (test == null) {
                    throw new ScimpiException("No such test: " + propertyName);
                }
                final String attributeValue = request.getOptionalProperty(propertyName, false);
                result = test.test(request, attributeValue, id);
                if (test.negateResult) {
                    result = !result;
                }
            }
            checkMade = true;
            allConditionsMet &= result;
        }

        /*
         *
         * // Check variables if (request.isPropertySpecified("variable-exists")) { boolean valuePresent =
         * request.isPropertySet("variable-exists"); checkMade = true; allConditionsMet &= valuePresent; }
         *
         * String variable = request.getOptionalProperty("variable-true"); if (variable != null) { String value =
         * (String) request.getContext().getVariable(variable); checkMade = true; allConditionsMet &=
         * Attributes.isTrue(value); }
         *
         * variable = request.getOptionalProperty("variable-equals"); if (variable != null) { String value = (String)
         * request.getContext().getVariable(variable); checkMade = true; allConditionsMet &= variable.equals(value); }
         */
        // Check Object

        /*
         * // Check Collection String collection = request.getOptionalProperty("collection-" + TYPE); if (collection !=
         * null) { ObjectAdapter object = MethodsUtils.findObject(request.getContext(), collection); Class<?> cls =
         * forClass(request); TypeOfFacet facet = object.getSpecification().getFacet(TypeOfFacet.class); boolean hasType
         * = object != null && (cls == null || cls.isAssignableFrom(facet.value())); checkMade = true; allConditionsMet
         * &= hasType;; }
         *
         * collection = request.getOptionalProperty("collection-" + "empty"); if (collection != null) { ObjectAdapter
         * object = MethodsUtils.findObject(request.getContext(), id); CollectionFacet facet =
         * object.getSpecification().getFacet(CollectionFacet.class); boolean isEmpty = facet != null &&
         * facet.size(object) == 0; processTags(isEmpty, request); allConditionsMet &= isEmpty; }
         */

        // Check Methods
        /*
         * String method = request.getOptionalProperty(METHOD + "-exists"); if (method != null) { ObjectAdapter object =
         * MethodsUtils.findObject(request.getContext(), id); List<? extends ObjectAction> objectActions =
         * object.getSpecification().getObjectActions(ActionType.USER); boolean methodExists = false; for (ObjectAction
         * objectAssociation : objectActions) { if (objectAssociation.getId().equals(method)) { methodExists = true;
         * break; } } checkMade = true; allConditionsMet &= methodExists; }
         *
         * method = request.getOptionalProperty(METHOD + "-visible"); if (method != null) { ObjectAdapter object =
         * MethodsUtils.findObject(request.getContext(), id); // TODO needs to work irrespective of parameters
         * ObjectAction objectAction = object.getSpecification().getObjectAction(ActionType.USER, method,
         * ObjectSpecification.EMPTY_LIST); Consent visible =
         * objectAction.isVisible(IsisContext.getAuthenticationSession(), object); checkMade = true; allConditionsMet &=
         * visible.isAllowed(); }
         *
         * method = request.getOptionalProperty(METHOD + "-usable"); if (method != null) { ObjectAdapter object =
         * MethodsUtils.findObject(request.getContext(), id); // TODO needs to work irrespective of parameters
         * ObjectAction objectAction = object.getSpecification().getObjectAction(ActionType.USER, method,
         * ObjectSpecification.EMPTY_LIST); Consent usable =
         * objectAction.isUsable(IsisContext.getAuthenticationSession(), object); checkMade = true; allConditionsMet &=
         * usable.isAllowed(); }
         *
         *
         * // Check Fields String field = request.getOptionalProperty(FIELD + "-exists"); if (field != null) {
         * ObjectAdapter object = MethodsUtils.findObject(request.getContext(), id); List<? extends ObjectAssociation>
         * objectFields = object.getSpecification().getAssociations(); boolean fieldExists = false; for
         * (ObjectAssociation objectAssociation : objectFields) { if (objectAssociation.getId().equals(field)) {
         * fieldExists = true; break; } } checkMade = true; allConditionsMet &= fieldExists; }
         *
         * field = request.getOptionalProperty(FIELD + "-visible"); if (field != null) { ObjectAdapter object =
         * MethodsUtils.findObject(request.getContext(), id); ObjectAssociation objectField =
         * object.getSpecification().getAssociation(field); Consent visible =
         * objectField.isVisible(IsisContext.getAuthenticationSession(), object); checkMade = true; allConditionsMet &=
         * visible.isAllowed(); }
         *
         * field = request.getOptionalProperty(FIELD + "-editable"); if (field != null) { ObjectAdapter object =
         * MethodsUtils.findObject(request.getContext(), id); ObjectAssociation objectField =
         * object.getSpecification().getAssociation(field); Consent usable =
         * objectField.isUsable(IsisContext.getAuthenticationSession(), object); checkMade = true; allConditionsMet &=
         * usable.isAllowed(); }
         *
         * field = request.getOptionalProperty(FIELD + "-empty"); if (field != null) { ObjectAdapter object =
         * MethodsUtils.findObject(request.getContext(), id); ObjectAssociation objectField =
         * object.getSpecification().getAssociation(field); IsisContext.getPersistenceSession().resolveField(object,
         * objectField); ObjectAdapter fld = objectField.get(object); if (fld == null) { checkMade = true;
         * allConditionsMet &= true; } else { CollectionFacet facet =
         * fld.getSpecification().getFacet(CollectionFacet.class); boolean isEmpty = facet != null && facet.size(fld) ==
         * 0; processTags(isEmpty, request); allConditionsMet &= isEmpty; } }
         *
         * field = request.getOptionalProperty(FIELD + "-set"); if (field != null) { ObjectAdapter object =
         * MethodsUtils.findObject(request.getContext(), id); ObjectAssociation objectField =
         * object.getSpecification().getAssociation(field); IsisContext.getPersistenceSession().resolveField(object,
         * objectField); ObjectAdapter fld = objectField.get(object); if (fld == null) { throw new
         * ScimpiException("No object for field-set " + field); } Object fieldValue = fld.getObject(); if (fieldValue
         * instanceof Boolean) { checkMade = true; allConditionsMet &= ((Boolean) fieldValue).booleanValue(); } else {
         * checkMade = true; allConditionsMet &= true; } }
         */

        // Check User
        /*
         * String hasRole = request.getOptionalProperty("has-role"); if (hasRole != null) { AuthenticationSession
         * session = IsisContext.getSession().getAuthenticationSession(); List<String> roles = session.getRoles();
         * boolean hasMatchingRole = false; for (String role : roles) { if (role.equals(hasRole.trim())) {
         * hasMatchingRole = true; break; } } checkMade = true; allConditionsMet &= hasMatchingRole; }
         */

        final String persistent = request.getOptionalProperty("persistent");
        if (persistent != null) {
            final ObjectAdapter object = request.getContext().getMappedObjectOrResult(persistent);
            checkMade = true;
            allConditionsMet &= object.isPersistent();
        }
        /*
         * String type = request.getOptionalProperty(TYPE); if (type != null) { ObjectAdapter object =
         * MethodsUtils.findObject(request.getContext(), id); Class<?> cls = forClass(request); boolean hasType = object
         * != null && (cls == null || cls.isAssignableFrom(object.getObject().getClass())); checkMade = true;
         * allConditionsMet &= hasType;; }
         */
        if (request.isPropertySpecified("empty")) {
            if (request.isPropertySet("empty")) {
                final String collection = request.getOptionalProperty("empty");
                if (collection != null) {
                    final ObjectAdapter object = request.getContext().getMappedObjectOrResult(collection);
                    final CollectionFacet facet = object.getSpecification().getFacet(CollectionFacet.class);
                    checkMade = true;
                    allConditionsMet &= facet.size(object) == 0;
                }
            } else {
                checkMade = true;
                allConditionsMet &= true;
            }
        }

        if (request.isPropertySpecified("set")) {
            final boolean valuePresent = request.isPropertySet("set");
            checkMade = true;
            allConditionsMet &= valuePresent;
        }

        if (checkMade) {
            processTags(allConditionsMet, request);
        } else {
            throw new ScimpiException("No condition in " + getName());
        }
    }
View Full Code Here

        Class<?> cls = null;
        if (className != null) {
            try {
                cls = Class.forName(className);
            } catch (final ClassNotFoundException e) {
                throw new ScimpiException("No class for " + className, e);
            }
        }
        return cls;
    }
View Full Code Here

        try {
            final List<ObjectAdapter> savedObject = new ArrayList<ObjectAdapter>();
            final JSONObject data = encodeTransientData(object, savedObject);
            return "D" + data.toString(4);
        } catch (final JSONException e) {
            throw new ScimpiException(e);
        }
    }
View Full Code Here

            final String aggregatedId = aoid.getId();
            encodedOid = Long.toString(((SerialOid) parentOid).getSerialNo(), 16) + "@" + aggregatedId;
        } else if (oid instanceof SerialOid) {
            encodedOid = Long.toString(((SerialOid) oid).getSerialNo(), 16);
        } else {
            throw new ScimpiException("Unsupportred OID type " + oid);
        }

        data.put("_id", encodedOid);

        for (final ObjectAssociation association : specification.getAssociations()) {
View Full Code Here

            if (scope == Scope.REQUEST) {
                requestTransients.put(transferableId, mapping);
            } else if (scope == Scope.INTERACTION || scope == Scope.SESSION) {
                sessionTransients.put(transferableId, mapping);
            } else {
                throw new ScimpiException("Can't hold globally transient object");
            }
        }
        return transferableId;
    }
View Full Code Here

        try {
            final JSONObject jsonObject = new JSONObject(objectData);
            final ObjectAdapter object = restoreTransientObject(jsonObject);
            return object;
        } catch (final JSONException e) {
            throw new ScimpiException("Problem reading data: " + data, e);
        }
    }
View Full Code Here

                if (nextTag.getType() == SwfTag.EMPTY) {
                    return;
                }
            }
        }
        throw new ScimpiException("Empty tag not closed");
    }
View Full Code Here

            final ObjectAdapter row = context.getMappedObject(rowId);

            final String fieldName = context.getParameter(FIELD);
            final ObjectAssociation field = parent.getSpecification().getAssociation(fieldName);
            if (field == null) {
                throw new ScimpiException("No field " + fieldName + " in "
                    + parent.getSpecification().getFullIdentifier());
            }
            if (field.isVisible(IsisContext.getAuthenticationSession(), parent).isVetoed()) {
                throw new ForbiddenException(field, ForbiddenException.VISIBLE);
            }
View Full Code Here

        return runMethod(context, action, target, parameters, null, null);
    }

    public static ObjectAction findAction(final ObjectAdapter object, final String methodName) {
        if (object == null) {
            throw new ScimpiException("Object not specified when looking for " + methodName);
        }

        final List<ObjectAction> actions =
            object.getSpecification().getObjectActions(ActionType.USER, ActionType.EXPLORATION, ActionType.PROTOTYPE,
                ActionType.DEBUG);
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.scimpi.dispatcher.ScimpiException

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.