@Override public boolean isNullable(final String name) { final int index = Integer.parseInt(name.substring(5)) - 1; final ObjectActionParameter param = action.getParameters().get(index); return param.isOptional(); } };
private static List<JsonRepresentation> argListFor(final ObjectAction action, final JsonRepresentation arguments) { final List<JsonRepresentation> argList = Lists.newArrayList(); // ensure that we have no arguments that are not parameters for (final Map.Entry<String, JsonRepresentation> arg : arguments.mapIterable()) { final String argName = arg.getKey(); if(argName.startsWith("x-ro")) { continue; } if (action.getParameterById(argName) == null) { String reason = String.format("Argument '%s' found but no such parameter", argName); arguments.mapPut("x-ro-invalidReason", reason); throw RestfulObjectsApplicationException.createWithBody(RestfulResponse.HttpStatusCode.BAD_REQUEST, arguments, reason); } } // 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()) { String reason = String.format("No argument found for (mandatory) parameter '%s'", paramId); arguments.mapPut("x-ro-invalidReason", reason); throw RestfulObjectsApplicationException.createWithBody(RestfulResponse.HttpStatusCode.BAD_REQUEST, arguments, reason); } argList.add(argRepr); } return argList; }
private static List<JsonRepresentation> argListFor(final ObjectAction action, final JsonRepresentation arguments) { final List<JsonRepresentation> argList = Lists.newArrayList(); // ensure that we have no arguments that are not parameters for (final Entry<String, JsonRepresentation> arg : arguments.mapIterable()) { final String argName = arg.getKey(); if (action.getParameterById(argName) == null) { String reason = String.format("Argument '%s' found but no such parameter", argName); arguments.mapPut("x-ro-invalidReason", reason); throw RestfulObjectsApplicationException.createWithBody(HttpStatusCode.BAD_REQUEST, arguments, reason); } } // 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()) { String reason = String.format("No argument found for (mandatory) parameter '%s'", paramId); arguments.mapPut("x-ro-invalidReason", reason); throw RestfulObjectsApplicationException.createWithBody(HttpStatusCode.BAD_REQUEST, arguments, reason); } argList.add(argRepr); } return argList; }
private static void initializeFields(final RequestContext context, final ObjectAdapter object, final ObjectAction action, final InputField[] fields) { final List<ObjectActionParameter> parameters = action.getParameters(); for (int i = 0; i < fields.length; i++) { final InputField field = fields[i]; final ObjectActionParameter param = parameters.get(i); if (action.isContributed() && i == 0) { // fields[i].setValue(context.mapObject(object, // Scope.INTERACTION)); fields[i].setType(InputField.REFERENCE); fields[i].setHidden(true); } else { fields[i].setHelpReference("xxxhelp"); final ObjectAdapter[] optionsForParameter = action.getChoices(object)[i]; FieldFactory.initializeField(context, object, param, optionsForParameter, !param.isOptional(), field); } } }
private static List<JsonRepresentation> argListFor(final ObjectAction action, final JsonRepresentation arguments) { final List<JsonRepresentation> argList = Lists.newArrayList(); // ensure that we have no arguments that are not parameters for (final Entry<String, JsonRepresentation> arg : arguments.mapIterable()) { final String argName = arg.getKey(); if (action.getParameterById(argName) == null) { throw RestfulObjectsApplicationException.create(HttpStatusCode.BAD_REQUEST, "Action '%s' does not have a parameter %s but an argument of that name was provided", action.getId(), argName); } } // 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 RestfulObjectsApplicationException.create(HttpStatusCode.BAD_REQUEST, "Action '%s', no argument found for (mandatory) parameter '%s'", action.getId(), paramId); } argList.add(argRepr); } return argList; }
@Override protected void addPropertiesSpecificToFeature() { representation.mapPut("name", getObjectFeature().getName()); representation.mapPut("number", getObjectFeature().getNumber()); representation.mapPut("optional", getObjectFeature().isOptional()); final MaxLengthFacet maxLength = getObjectFeature().getFacet(MaxLengthFacet.class); if (maxLength != null && !maxLength.isNoop()) { representation.mapPut("maxLength", maxLength.value()); } }
@Override protected void addPropertiesSpecificToFeature() { representation.mapPut("name", getObjectFeature().getName()); representation.mapPut("number", getObjectFeature().getNumber()); representation.mapPut("optional", getObjectFeature().isOptional()); final MaxLengthFacet maxLength = getObjectFeature().getFacet(MaxLengthFacet.class); if (maxLength != null && !maxLength.isNoop()) { representation.mapPut("maxLength", maxLength.value()); } }
@Override protected void addPropertiesSpecificToFeature() { representation.mapPut("name", getObjectFeature().getName()); representation.mapPut("number", getObjectFeature().getNumber()); representation.mapPut("optional", getObjectFeature().isOptional()); final MaxLengthFacet maxLength = getObjectFeature().getFacet(MaxLengthFacet.class); if (maxLength != null && !maxLength.isNoop()) { representation.mapPut("maxLength", maxLength.value()); } }
Consent consent = null; if (!parameters2.get(i).isOptional() && newEntry.equals("")) { consent = new Veto(parameters2.get(i).getName() + " required"); formState.setError("Not all fields have been set");