EndpointResponse response = phaseContext.getEndpointResponse();
ApiVersionPlugin<ApiObject,PersistentObject> apiVersionPlugin = phaseContext.getVersionPlugin();
EntityPlugin plugin = phaseContext.getEntityPlugin();
ApiObject clientObject = marshaller.unmarshall(request.getInputStream(),apiVersionPlugin.getApiClass());
clientObject.setId(null);
PersistenceContext persistenceContext = buildPersistenceContext(phaseContext);
Set<String> fieldSet = persistenceContext.getRequestedFields();
if(fieldSet != null)
fieldSet.add("id");
ApiObject saved = plugin.getPersistenceOperations().createOrUpdateItem(clientObject, persistenceContext);
if(saved != null)
{
processChangeEvents(phaseContext,persistenceContext);
if(persistenceContext.getWriteContext() == WriteContext.create)
{
response.setResponseCode(201);
String location = String.format("%s%s/%s",request.getBaseUrl(),request.getRequestUri(),saved.getId());
response.setHeader("Location", location);
}
else
{
response.setResponseCode(200);