@Override
  public void acceptRepresentation(Representation representation) throws ResourceException {
    if (delegate.acceptsUpload()) {
      upload(representation);
    } else {
      Object payloadInstance = delegate.getPayloadInstance(Method.POST);
      if (payloadInstance == null) {
        payloadInstance = delegate.getPayloadInstance();
      }
      Object payload = deserialize(payloadInstance);

      Object result = null;

      try {
        result = delegate.post(getContext(), getRequest(), getResponse(), payload);

        // This is a post, so set the status correctly
        // but only if the status was not changed to be something else, like a 202
        if (getResponse().getStatus() == Status.SUCCESS_OK) {
          getResponse().setStatus(Status.SUCCESS_CREATED);
        }
      } catch (PlexusResourceException e) {
        // set the status
        getResponse().setStatus(e.getStatus());
        // try to get the responseObject
        result = e.getResultObject();
      }

      if (result != null) {
        getResponse().setEntity(doRepresent(result, representation, getResponse()));
      }
    }
  }