if (content == null)
{
publish.createResponse(SipServletResponse.SC_BAD_REQUEST).send();
return;
}
SoftState state = presentity.addState(contentType, content, now + expires*1000);
if (_log.isDebugEnabled())
_log.debug("added state {} to presentity {}", state.getETag(), presentity);
SipServletResponse response = publish.createResponse(SipServletResponse.SC_OK);
response.setExpires(expires);
response.setHeader(Constants.SIP_ETAG, state.getETag());
response.send();
}
else
{
SoftState state = presentity.getState(etag);
if (state == null)
{
publish.createResponse(SipServletResponse.SC_CONDITIONAL_REQUEST_FAILED).send();
return;
}
if (expires == 0)
{
if (_log.isDebugEnabled())
_log.debug("removed state {} from presentity {}", state.getETag(), presentity);
presentity.removeState(etag);
}
else
{
if (content != null)
{
presentity.modifyState(state, contentType, content, now + expires*1000);
if (_log.isDebugEnabled())
_log.debug("modified state {} (new etag {}) from presentity {}",
new Object[] {etag, state.getETag(), presentity});
}
else
{
presentity.refreshState(state, now + expires*1000);
if (_log.isDebugEnabled())
_log.debug("refreshed state {} (new etag {}) from presentity {}",
new Object[] {etag, state.getETag(), presentity});
}
}
SipServletResponse response = publish.createResponse(SipServletResponse.SC_OK);
response.setExpires(expires);
response.setHeader(Constants.SIP_ETAG, state.getETag());
response.send();
}
}
finally
{