{
if (!XMLRepresentationParser.isXML(entity.getMediaType())) {
getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
return new StringRepresentation("Non-XML media type for entity body: "+entity.getMediaType().getName());
}
Document doc = null;
try {
DocumentDestination dest = new DocumentDestination();
parser.parse(entity,dest);
doc = dest.getDocument();
} catch (Exception ex) {
getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
return new StringRepresentation("XML parse error: "+ex.getMessage());
}
try {
RealmUser user = fetch();
if (user!=null) {
Element top = doc.getDocumentElement();
String alias = top.getAttributeValue("alias");
Element name = top.getFirstElementNamed(XML.NAME_NAME);
Element email = top.getFirstElementNamed(XML.EMAIL_NAME);
if (alias!=null && !User.isAlias(alias)) {
getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);