/** * @param ar abstract resource * @param am abstract method * @param p parameter * @return parameter * @see * org.glassfish.jersey.server.wadl.WadlGenerator#createParam(org.glassfish.jersey.server.model.Resource, * org.glassfish.jersey.server.model.ResourceMethod, * org.glassfish.jersey.server.model.Parameter) */ public Param createParam( org.glassfish.jersey.server.model.Resource ar, org.glassfish.jersey.server.model.ResourceMethod am, Parameter p) { final Param param = wadlGeneratorDelegate.createParam(ar, am, p); // If the paramter is an entity we probably want to convert this to XML // if (p.getSource() == Parameter.Source.ENTITY) { nameCallbacks.add( new TypeCallbackPair( new GenericType(p.getType()), new NameCallbackSetter() { public void setName(QName name) { param.setType(name); } })); } return param; }
@Override public Object provide() { final ContainerRequest requestContext = getContainerRequest(); final Class<?> rawType = parameter.getRawType(); Object value; if ((Request.class.isAssignableFrom(rawType) || ContainerRequestContext.class.isAssignableFrom(rawType)) && rawType.isInstance(requestContext)) { value = requestContext; } else { value = requestContext.readEntity(rawType, parameter.getType(), parameter.getAnnotations()); if (rawType.isPrimitive() && value == null) { throw new BadRequestException( Response.status(Response.Status.BAD_REQUEST) .entity(LocalizationMessages.ERROR_PRIMITIVE_TYPE_NULL()) .build()); } } return value; }
/** * @param ar abstract resource * @param arm abstract resource method * @param mt media type * @return respresentation type * @see org.glassfish.jersey.server.wadl.WadlGenerator# createRequestRepresentation * (org.glassfish.jersey.server.model.Resource, * org.glassfish.jersey.server.model.ResourceMethod, javax.ws.rs.core.MediaType) */ public Representation createRequestRepresentation( org.glassfish.jersey.server.model.Resource ar, org.glassfish.jersey.server.model.ResourceMethod arm, MediaType mt) { final Representation rt = wadlGeneratorDelegate.createRequestRepresentation(ar, arm, mt); for (Parameter p : arm.getInvocable().getParameters()) { if (p.getSource() == Parameter.Source.ENTITY) { nameCallbacks.add( new TypeCallbackPair( new GenericType(p.getType()), new NameCallbackSetter() { @Override public void setName(QName name) { rt.setElement(name); } })); } } return rt; }