try {
DocumentDestination dest = new DocumentDestination();
parser.parse(entity,AdminApplication.createAdminDocumentDestination(dest,AdminXML.NM_TARGET));
doc = dest.getDocument();
SyncTarget target = new SyncTarget(db,doc.getDocumentElement());
if (target.exists()) {
getResponse().setStatus(Status.CLIENT_ERROR_CONFLICT);
return new StringRepresentation("Target with name "+target.getName()+" already exists.");
}
if (target.create()) {
getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
Reference ref = new Reference(getRequest().getResourceRef().toString()+"/"+target.getName());
getResponse().setLocationRef(ref);
return null;
} else {
getContext().getLogger().severe("Cannot store XML for target");
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);