Package org.apache.isis.viewer.json.applib

Examples of org.apache.isis.viewer.json.applib.JsonRepresentation$HasExtensions


        for (final ObjectAssociation association : properties) {
            final OneToOneAssociation property = (OneToOneAssociation) association;
            final ObjectSpecification propertySpec = property.getSpecification();
            final String id = property.getId();
            final JsonRepresentation propertyRepr = propertiesList.getRepresentation("[id=%s]", id);
            final JsonRepresentation valueRepr = propertyRepr.getRepresentation("value");

            final ObjectAdapter valueAdapter = objectAdapterFor(resourceContext, propertySpec, valueRepr);
            final Consent consent = property.isAssociationValid(objectAdapter, valueAdapter);
            if (consent.isAllowed()) {
                try {
View Full Code Here


        final ActionSemantics actionSemantics = ActionSemantics.determine(resourceContext, action);
        if (!actionSemantics.isIdempotent()) {
            throw JsonApplicationException.create(HttpStatusCode.METHOD_NOT_ALLOWED, "Method not allowed; action '%s' is not idempotent", action.getId());
        }
        final String bodyAsString = asStringUtf8(body);
        final JsonRepresentation arguments = readAsMap(bodyAsString);

        return invokeActionUsingAdapters(action, arguments);
    }
View Full Code Here

    Response invokeAction(final String actionId, final InputStream body) {
        final ObjectAction action = getObjectActionThatIsVisibleAndUsable(actionId, Intent.MUTATE);

        final String bodyAsString = asStringUtf8(body);
        final JsonRepresentation arguments = readAsMap(bodyAsString);

        return invokeActionUsingAdapters(action, arguments);
    }
View Full Code Here

        // reference
        if (!representation.isLink()) {
            throw new ExpectedMapRepresentingLinkException();
        }
        final JsonRepresentation argLink = representation.asLink();
        final String oidFromHref = UrlParserUtils.oidFromLink(argLink);
        if (oidFromHref == null) {
            throw new ExpectedMapRepresentingLinkException();
        }
View Full Code Here

     * @throws JsonParseException
     */
    ObjectAdapter objectAdapterFor(final ObjectSpecification spec, final String urlEncodedJson) throws JsonParseException, JsonMappingException, IOException {

        final String json = UrlDecoderUtils.urlDecode(urlEncodedJson);
        final JsonRepresentation representation = JsonMapper.instance().read(json);
        return objectAdapterFor(resourceContext, spec, representation);
    }
View Full Code Here

     * @param bodyAsString
     *            - as per {@link #asStringUtf8(InputStream)}
     * @return
     */
    ObjectAdapter parseAsMapWithSingleValue(final ObjectSpecification objectSpec, final String bodyAsString) {
        final JsonRepresentation arguments = readAsMap(bodyAsString);

        return parseAsMapWithSingleValue(objectSpec, arguments);
    }
View Full Code Here

        return parseAsMapWithSingleValue(objectSpec, arguments);
    }

    ObjectAdapter parseAsMapWithSingleValue(final ObjectSpecification objectSpec, final JsonRepresentation arguments) {
        final JsonRepresentation representation = arguments.getRepresentation("value");
        if (arguments.size() != 1 || representation == null) {
            throw JsonApplicationException.create(HttpStatusCode.BAD_REQUEST, "Body should be a map with a single key 'value' whose value represents an instance of type '%s'", resourceFor(objectSpec));
        }

        return objectAdapterFor(resourceContext, objectSpec, representation);
View Full Code Here

        final List<ObjectAdapter> argAdapters = Lists.newArrayList();
        final List<ObjectActionParameter> parameters = action.getParameters();
        for (int i = 0; i < argList.size(); i++) {
            final String paramName = parameters.get(i).getName();
            final JsonRepresentation arg = argList.get(i);
            final ObjectSpecification paramSpec = parameters.get(i).getSpecification();
            try {
                final ObjectAdapter objectAdapter = objectAdapterFor(resourceContext, paramSpec, arg);
                argAdapters.add(objectAdapter);
            } catch (final ExpectedStringRepresentingValueException e) {
View Full Code Here

        // ensure that an argument value has been provided for all non-optional
        // parameters
        final List<ObjectActionParameter> parameters = action.getParameters();
        for (final ObjectActionParameter param : parameters) {
            final String paramId = param.getId();
            final JsonRepresentation argRepr = arguments.getRepresentation(paramId);
            if (argRepr == null && !param.isOptional()) {
                throw JsonApplicationException.create(HttpStatusCode.BAD_REQUEST, "Action '%s', no argument found for (mandatory) parameter '%s'", action.getId(), paramId);
            }
            argList.add(argRepr);
        }
View Full Code Here

        }
        return argList;
    }

    public static JsonRepresentation readParameterMapAsMap(final Map<String, String[]> parameterMap) {
        final JsonRepresentation map = JsonRepresentation.newMap();
        for (final Map.Entry<String, String[]> parameter : parameterMap.entrySet()) {
            map.mapPut(parameter.getKey(), parameter.getValue()[0]);
        }
        return map;
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.json.applib.JsonRepresentation$HasExtensions

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.