code: private static Response createResponse(Object object) {
      if (object == null) {
        return Response.ok().build();
      }
  
      if (object instanceof Response) {
        return (Response) object;
      }
  
      if (object instanceof Response.Status) {
        Response.Status s = (Response.Status) object;
        switch (s) {
          case OK:
            return Response.ok().build();
          case ACCEPTED:
            return Response.accepted().build();
          case NO_CONTENT:
            return Response.noContent().build();
          default:
            return createErrorResponse(
                new S3Exception("Response status is invalid", S3ErrorCode.INTERNAL_ERROR));
        }
      }
  
      // Need to explicitly encode the string as XML because Jackson will not do it automatically.
      XmlMapper mapper = new XmlMapper();
      try {
        return Response.ok(mapper.writeValueAsString(object)).build();
      } catch (JsonProcessingException e) {
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
            .entity("Failed to encode XML: " + e.getMessage()).build();
      }
    }
docs: Creates a response using the given object.
  
  @param object the object to respond with
  @return the response