public Entry createEntry(String xml)
throws StatusException,IOException,XMLException
{
Request request = new Request(Method.POST,editURI.toString());
if (identity!=null) {
request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
}
if (cookie!=null) {
request.getCookies().add(cookie);
}
request.setEntity(new StringRepresentation(xml,MediaType.APPLICATION_ATOM_XML));
Response response = new Response(request);
editClient.handle(request,response);
Status status = response.getStatus();
if (response.isEntityAvailable()) {
response.getEntity().release();
}
if (!status.isSuccess()) {
throw new StatusException("Cannot create entry due to status "+status.getCode(),status);
}
Reference location = response.getLocationRef();
request = new Request(Method.GET,location);
if (identity!=null) {
request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
}
Response entryResponse = locClient.handle(request);
if (!entryResponse.getStatus().isSuccess()) {
if (entryResponse.isEntityAvailable()) {
entryResponse.getEntity().release();