@POST @Consumes(MediaType.APPLICATION_XML) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response addOne(JAXBElement<MdmiNetDatatype> dataType, @QueryParam("token") String token) { if (!AppListener.IsValid(token)) { return Response.status(Response.Status.FORBIDDEN) .type("text/html") .entity("<h3>Bad token!</h3>") .build(); } MdmiNetDatatype o = dataType.getValue(); String err = isDataTypeValid(o, true); if (err != null) { return Response.status(Response.Status.BAD_REQUEST).type("text/html").entity(err).build(); } if (!collection.append(o)) { return Response.status(Response.Status.BAD_REQUEST) .type("text/html") .entity("<h3>Duplicate name!</h3>") .build(); } return Response.ok(o).build(); }