19 package cz.vutbr.fit.knot.annotations.comet.protocolV1;
 
   48 import java.security.MessageDigest;
 
   49 import java.security.NoSuchAlgorithmException;
 
   50 import java.util.ArrayList;
 
   51 import java.util.Arrays;
 
   52 import java.util.Date;
 
   53 import java.util.HashMap;
 
   54 import java.util.Iterator;
 
   55 import java.util.List;
 
   56 import java.util.logging.Level;
 
   57 import java.util.logging.Logger;
 
   58 import org.w3c.dom.CharacterData;
 
   59 import org.w3c.dom.DOMException;
 
   60 import org.w3c.dom.Element;
 
   61 import org.w3c.dom.Node;
 
   62 import org.w3c.dom.NodeList;
 
   83     NodeList loginMsg = docEl.getElementsByTagName(
"login");
 
   84     Element loginEl = (Element) loginMsg.item(0);
 
   85     if (loginEl != null) {  
 
   87       requestInfo.setLoggedIn(user);
 
   88       session.setUser(user);
 
   89       session.actualizeAllCachedSettings();
 
   91         AppBean.getSessionsCleaner().setSessionConfirm(session.
getSessionId());
 
   92         requestInfo.appendToReply(
"<logged id=\"" + user.getURI() + 
"\" name=\"" + user.getName() + 
"\"/>");
 
   95         NodeList disconnMsg = docEl.getElementsByTagName(
"disconnect");
 
   96         Element disconnEl = (Element) disconnMsg.item(0);
 
   97         if (disconnEl != null) {  
 
  100             AppBean.decrementDocumentUsage(session.getSyncDocument().getId());
 
  102           AppBean.removeSession(session);  
 
  103           requestInfo.setDisconnect(
true);
 
  108       requestInfo.getSession().addSource(
new SubscribedSource(
"*", user.getURI(), null));
 
  111         Iterator<UserGroup> ownGroupsIt = user.getGroups().iterator();
 
  112         while (ownGroupsIt.hasNext()) {  
 
  120       user = session.getUser();
 
  125       NodeList disconnMsg = docEl.getElementsByTagName(
"disconnect");
 
  126       Element disconnEl = (Element) disconnMsg.item(0);
 
  127       int lod = session.getProtocolLOD();
 
  130         String msg = 
"User is not logged in.";
 
  131         Logger.getLogger(MessageProcessor.class.getName()).log(Level.WARNING, msg);
 
  133       if (disconnEl != null) {
 
  137           AppBean.decrementDocumentUsage(session.getSyncDocument().getId());
 
  140         AppBean.removeSession(session);  
 
  141         requestInfo.setDisconnect(
true);
 
  149     NodeList queryUserGroupsMsg = docEl.getElementsByTagName(
"queryUserGroups");
 
  150     int qGCount = queryUserGroupsMsg.getLength();
 
  151     for (
int i = 0; i < qGCount; i++) {  
 
  152       Element queryUserGroupsEl = (Element) queryUserGroupsMsg.item(i);
 
  153       Boolean withP = Boolean.parseBoolean(queryUserGroupsEl.getAttribute(
"withPersons"));
 
  154       String filter = queryUserGroupsEl.getAttribute(
"filter");
 
  155       if (filter == null || filter.isEmpty()) {
 
  159         requestInfo.addQueryUserGroupsWP(filter);  
 
  161         requestInfo.addQueryUserGroups(filter);
 
  166     NodeList joinMsgs = docEl.getElementsByTagName(
"join");
 
  167     if (joinMsgs.getLength() > 0) {  
 
  170     NodeList leaveMsgs = docEl.getElementsByTagName(
"leave");
 
  171     if (leaveMsgs.getLength() > 0) {  
 
  176       int lod = requestInfo.getSession().getProtocolLOD();
 
  179         String msg = 
"User is not in any group.";
 
  180         Logger.getLogger(MessageProcessor.class.getName()).log(Level.SEVERE, msg);
 
  185       NodeList typesMsg = docEl.getElementsByTagName(
"types");
 
  186       Element typesEl = (Element) typesMsg.item(0);
 
  187       if (typesEl != null) {  
 
  192       NodeList suggestMsg = docEl.getElementsByTagName(
"suggestAnnotations");
 
  193       if (suggestMsg.getLength() > 0) {  
 
  198       NodeList refSuggestMsg = docEl.getElementsByTagName(
"refusedSuggestions");
 
  199       Element refSuggestEl = (Element) refSuggestMsg.item(0);
 
  200       if (refSuggestEl != null) {  
 
  207     NodeList settingsMsg = docEl.getElementsByTagName(
"settings");
 
  208     Element settingsEl = (Element) settingsMsg.item(0);
 
  209     if (settingsEl != null) {  
 
  214     NodeList entityRequestMsg = docEl.getElementsByTagName(
"queryEntities");
 
  215     Element entityRequestEl = (Element) entityRequestMsg.item(0);
 
  216     if (entityRequestEl != null) {  
 
  221     NodeList subscribeMsg = docEl.getElementsByTagName(
"subscribe");
 
  222     Element subscribeEl = (Element) subscribeMsg.item(0);
 
  223     if (subscribeEl != null) {  
 
  228     NodeList unsubscribeMsg = docEl.getElementsByTagName(
"unsubscribe");
 
  229     Element unsubscribeEl = (Element) unsubscribeMsg.item(0);
 
  230     if (unsubscribeEl != null) {  
 
  235     NodeList synchronizeMsg = docEl.getElementsByTagName(
"synchronize");
 
  236     Element synchronizeEl = (Element) synchronizeMsg.item(0);
 
  237     if (synchronizeEl != null) {  
 
  242     NodeList resynchronizeMsg = docEl.getElementsByTagName(
"resynchronize");
 
  243     Element resynchronizeEl = (Element) resynchronizeMsg.item(0);
 
  244     if (resynchronizeEl != null) {  
 
  249     NodeList textModificationMsg = docEl.getElementsByTagName(
"textModification");
 
  250     if (textModificationMsg.getLength() > 0) {  
 
  255     NodeList reloadMsg = docEl.getElementsByTagName(
"reload");
 
  256     if (reloadMsg.getLength() > 0) {  
 
  261     NodeList queryTypesMsg = docEl.getElementsByTagName(
"queryTypes");
 
  262     Element queryTypesEl = (Element) queryTypesMsg.item(0);
 
  263     if (queryTypesEl != null) {  
 
  264       String filter = queryTypesEl.getAttribute(
"filter");
 
  265       if (filter == null || filter.isEmpty()) {
 
  268       requestInfo.addQueryTypes(filter);
 
  269       session.addQueriedTypes(filter);
 
  273     NodeList queryAttrFromOntoMsg = docEl.getElementsByTagName(
"queryAttrFromOnto");
 
  274     Element queryAttrFromOntoEl = (Element) queryAttrFromOntoMsg.item(0);
 
  275     if (queryAttrFromOntoEl != null) {  
 
  276       String attrGr = queryAttrFromOntoEl.getAttribute(
"group");
 
  277       if (attrGr == null || attrGr.isEmpty()) {
 
  280       requestInfo.setQueryTypeAttOnto(attrGr);
 
  284     NodeList queryPersonsMsg = docEl.getElementsByTagName(
"queryPersons");
 
  285     int qPCount = queryPersonsMsg.getLength();
 
  286     for (
int i= 0; i < qPCount; i++) {
 
  287       Element queryPersonsEl = (Element) queryPersonsMsg.item(i);
 
  288       Boolean withG = Boolean.parseBoolean(queryPersonsEl.getAttribute(
"withGroups"));
 
  289       String filter = queryPersonsEl.getAttribute(
"filter");
 
  290       if (filter == null || filter.isEmpty()) {
 
  294         requestInfo.addQueryPersonsWG(filter);  
 
  296         requestInfo.addQueryPersons(filter);
 
  302       NodeList annotationsMsg = docEl.getElementsByTagName(
"annotations");
 
  303       Element annotationsEl = (Element) annotationsMsg.item(0);
 
  304       if (annotationsEl != null) {  
 
  310     NodeList logoutMsg = docEl.getElementsByTagName(
"logout");
 
  311     Element logoutEl = (Element) logoutMsg.item(0);
 
  312     if (logoutEl != null) {
 
  315         AppBean.decrementDocumentUsage(session.getSyncDocument().getId());
 
  317       session.setUser(null);  
 
  318       requestInfo.setLogout(
true);
 
  322     NodeList disconnMsg = docEl.getElementsByTagName(
"disconnect");
 
  323     Element disconnEl = (Element) disconnMsg.item(0);
 
  324     if (disconnEl != null) {
 
  327         AppBean.decrementDocumentUsage(session.getSyncDocument().getId());
 
  329       AppBean.removeSession(session);  
 
  330       requestInfo.setDisconnect(
true);
 
  346     int tmCnt = tmMsg.getLength();
 
  347     for (
int i = 0; i < tmCnt; i++) {  
 
  348       Element tmEl = (Element) tmMsg.item(i);
 
  349       String path = tmEl.getAttribute(
"path");
 
  350       String offsetString = tmEl.getAttribute(
"offset");
 
  351       String lengthString = tmEl.getAttribute(
"length");
 
  354       Integer offset = null;
 
  355       if (offsetString != null) {
 
  356         if (!offsetString.isEmpty()) {
 
  358             offset = Integer.parseInt(offsetString);
 
  359           } 
catch (NumberFormatException nfe) {  
 
  360             int langNum = requestInfo.getSession().getLanguageNum();
 
  361             int lod = requestInfo.getSession().getProtocolLOD();
 
  362             String info = 
"<textModification path=\"" + path + 
"\" offset=\"" + offsetString + 
"\" length=\"" + lengthString + 
"\"/>";
 
  365               String msg = 
"Bad offset in text modification: " + offsetString;
 
  366               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  373       Integer length = null;
 
  374       if (lengthString != null) {
 
  375         if (!lengthString.isEmpty()) {
 
  377             length = Integer.parseInt(lengthString);
 
  378           } 
catch (NumberFormatException nfe) {  
 
  379             int langNum = requestInfo.getSession().getLanguageNum();
 
  380             int lod = requestInfo.getSession().getProtocolLOD();
 
  381             String info = 
"<textModification path=\"" + path + 
"\" offset=\"" + offsetString + 
"\" length=\"" + lengthString + 
"\"/>";
 
  384               String msg = 
"Bad length in text modification: " + lengthString;
 
  385               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  392       String newContent = MessageProcessor.getElementContent(tmEl);
 
  404       path = UpdatableFragment.improveXPath(path);
 
  407       requestInfo.addTextModification(newMod);
 
  419     int reloadCnt = reloadMsg.getLength();
 
  420     for (
int i = 0; i < reloadCnt; i++) {  
 
  421       Element reloadEl = (Element) reloadMsg.item(i);
 
  422       String all = reloadEl.getAttribute(
"all");
 
  423       boolean reloadAllAnnots = 
false;
 
  425       if (all != null && all.equalsIgnoreCase(
"true")) {
 
  426         requestInfo.setReloadAll(
true);
 
  427         reloadAllAnnots = 
true;
 
  429       String reloadedUri = reloadEl.getAttribute(
"uri");
 
  430       if (reloadedUri == null) {
 
  434       String reloadIdStr = reloadedUri.replace(AppBean.getBaseAnnotUri(), 
"");
 
  436       Integer reloadId = null;
 
  437       if (!reloadIdStr.isEmpty()) {
 
  439           reloadId = Integer.parseInt(reloadIdStr);
 
  440         } 
catch (NumberFormatException nfe) {
 
  442             String msg = 
"Bad id of reloaded annotation: " + reloadIdStr;
 
  443             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  448       if (reloadId != null) {  
 
  450         Object[] params = 
new Object[2];
 
  452         params[1] = reloadId;
 
  453         List rList = AppBean.getPersistenceManager().queryDB(
"Annotation.findById", params);
 
  454         if (rList != null && !rList.isEmpty()) {  
 
  456           requestInfo.addReloadAnnotations(relAnnot);  
 
  458           int langNum = requestInfo.getSession().getLanguageNum();
 
  459           int lod = requestInfo.getSession().getProtocolLOD();
 
  460           String info = 
"<reload uri=\"" + reloadedUri + 
"\"/>";
 
  463             String msg = 
"Reloaded annotation was not found: " + reloadId;
 
  464             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  468         if(!reloadAllAnnots){
 
  469           int langNum = requestInfo.getSession().getLanguageNum();
 
  470           int lod = requestInfo.getSession().getProtocolLOD();
 
  471           String info = 
"<reload uri=\"" + reloadedUri + 
"\"/>";
 
  474             String msg = 
"Id of reloaded annotation missing.";
 
  475             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  491     int joinCnt = joinMsgs.getLength();
 
  492     User user = requestInfo.getSession().getUser();
 
  493     for (
int i = 0; i < joinCnt; i++) {  
 
  494       Element joinEl = (Element) joinMsgs.item(i);
 
  495       String groupUri = joinEl.getAttribute(
"group");
 
  496       if (groupUri == null) {
 
  500       String groupIdStr = groupUri.replace(AppBean.getBaseGroupUri(), 
"");
 
  502       Integer groupId = null;
 
  503       if (!groupIdStr.isEmpty()) {
 
  505           groupId = Integer.parseInt(groupIdStr);
 
  506         } 
catch (NumberFormatException nfe) {
 
  508             String msg = 
"Bad id of joined group: " + groupIdStr;
 
  509             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  514       if (groupId != null) {  
 
  516         Object[] params = 
new Object[2];
 
  519         List gList = AppBean.getPersistenceManager().queryDB(
"UserGroup.findById", params);
 
  520         if (gList != null && !gList.isEmpty()) {  
 
  522           if (!user.getGroups().contains(jGroup)) {  
 
  524               int langNum = requestInfo.getSession().getLanguageNum();
 
  525               int lod = requestInfo.getSession().getProtocolLOD();
 
  526               String info = 
"<group uri=\"" + groupUri + 
"\"/>";
 
  529                 String msg = 
"User is trying to join to administrators: " + user.getName();
 
  530                 Logger.getLogger(MessageProcessor.class.getName()).log(Level.WARNING, msg);
 
  533               user.addGroup(jGroup);  
 
  534               jGroup.addUser(user);  
 
  535               requestInfo.addJoinedGroup(jGroup);  
 
  539           int langNum = requestInfo.getSession().getLanguageNum();
 
  540           int lod = requestInfo.getSession().getProtocolLOD();
 
  541           String info = 
"<group uri=\"" + groupUri + 
"\"/>";
 
  544             String msg = 
"Group to join was not found.";
 
  545             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  549         int langNum = requestInfo.getSession().getLanguageNum();
 
  550         int lod = requestInfo.getSession().getProtocolLOD();
 
  551         String info = 
"<group uri=\"" + groupUri + 
"\"/>";
 
  554           String msg = 
"Join to group without group id.";
 
  555           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  570     int leaveCnt = leaveMsgs.getLength();
 
  571     User user = requestInfo.getSession().getUser();
 
  572     for (
int i = 0; i < leaveCnt; i++) {  
 
  573       Element leaveEl = (Element) leaveMsgs.item(i);
 
  574       String groupUri = leaveEl.getAttribute(
"group");
 
  575       if (groupUri == null) {
 
  579       String groupIdStr = groupUri.replace(AppBean.getBaseGroupUri(), 
"");
 
  581       Integer groupId = null;
 
  582       if (!groupIdStr.isEmpty()) {
 
  584           groupId = Integer.parseInt(groupIdStr);
 
  585         } 
catch (NumberFormatException nfe) {
 
  588             String msg = 
"Bad id of leaved group: " + groupIdStr;
 
  589             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  593       if (groupId != null) {  
 
  595         Object[] params = 
new Object[2];
 
  598         List gList = AppBean.getPersistenceManager().queryDB(
"UserGroup.findById", params);
 
  599         if (gList != null && !gList.isEmpty()) {
 
  601           if (user.getGroups().contains(lGroup)) {  
 
  603               int langNum = requestInfo.getSession().getLanguageNum();
 
  604               int lod = requestInfo.getSession().getProtocolLOD();
 
  605               String info = 
"<group uri=\"" + groupUri + 
"\"/>";
 
  608                 String msg = 
"Last administrator is trying to leave group.";
 
  609                 Logger.getLogger(MessageProcessor.class.getName()).log(Level.WARNING, msg);
 
  612               user.getGroups().
remove(lGroup);  
 
  613               lGroup.getUsers().
remove(user);  
 
  614               requestInfo.addLeavedGroup(lGroup);  
 
  617             int langNum = requestInfo.getSession().getLanguageNum();
 
  618             int lod = requestInfo.getSession().getProtocolLOD();
 
  619             String info = 
"<group uri=\"" + groupUri + 
"\"/>";
 
  622               String msg = 
"Group to leave is not in joined groups.";
 
  623               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  627           int langNum = requestInfo.getSession().getLanguageNum();
 
  628           int lod = requestInfo.getSession().getProtocolLOD();
 
  629           String info = 
"<group uri=\"" + groupUri + 
"\"/>";
 
  632             String msg = 
"Group to leave was not found.";
 
  633             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  637         int langNum = requestInfo.getSession().getLanguageNum();
 
  638         int lod = requestInfo.getSession().getProtocolLOD();
 
  639         String info = 
"<group uri=\"" + groupUri + 
"\"/>";
 
  642           String msg = 
"Leave without group id.";
 
  643           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  657     Flier flier = requestInfo.getFlier();
 
  658     if (requestInfo.
getSession().getSyncDocument() == null) {  
 
  660       int langNum = requestInfo.getSession().getLanguageNum();
 
  661       int lod = requestInfo.getSession().getProtocolLOD();
 
  664         String msg = 
"Not synchronized and trying to create annotations.";
 
  665         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  670     NodeList addedNL = annotationsEl.getElementsByTagName(
"add");
 
  671     if (addedNL.getLength() == 0) {  
 
  672       addedNL = annotationsEl.getElementsByTagName(
"added");
 
  674     Element addEl = (Element) addedNL.item(0);
 
  677       NodeList addAnnotNodes = addEl.getElementsByTagName(
"annotation");
 
  678       int addedAnnotCnt = addAnnotNodes.getLength();
 
  679       for (
int i = 0; i < addedAnnotCnt; i++) {  
 
  680         Element addedAnnotEl = (Element) addAnnotNodes.item(i);
 
  681         if (addedAnnotEl.getParentNode() != addEl) {
 
  687         if (addedAnnot != null) {  
 
  688           flier.AddAddedAnnotation(addedAnnot);  
 
  693     NodeList editedNL = annotationsEl.getElementsByTagName(
"change");
 
  694     if (editedNL.getLength() == 0) {  
 
  695       editedNL = annotationsEl.getElementsByTagName(
"edited");
 
  697     Element editedEl = (Element) editedNL.item(0);
 
  698     if (editedEl != null) {  
 
  700       NodeList updateAnnotNodes = editedEl.getElementsByTagName(
"annotation");
 
  701       int updatedAnnotCnt = updateAnnotNodes.getLength();
 
  702       for (
int i = 0; i < updatedAnnotCnt; i++) {  
 
  703         Element updatedAnnotEl = (Element) updateAnnotNodes.item(i);
 
  704         if (updatedAnnotEl.getParentNode() != editedEl) {
 
  710         if (editedAnnot != null) {  
 
  711           flier.AddEditedAnnotation(editedAnnot);  
 
  716     NodeList removedNL = annotationsEl.getElementsByTagName(
"remove");
 
  717     if (removedNL.getLength() == 0) {  
 
  718       removedNL = annotationsEl.getElementsByTagName(
"removed");
 
  720     Element removedEl = (Element) removedNL.item(0);
 
  721     if (removedEl != null) {
 
  723       NodeList remAnnotNodes = removedEl.getElementsByTagName(
"annotation");
 
  724       int remAnnotCnt = remAnnotNodes.getLength();
 
  725       for (
int i = 0; i < remAnnotCnt; i++) {  
 
  726         Element remAnnotEl = (Element) remAnnotNodes.item(i);
 
  727         if (remAnnotEl.getParentNode() != removedEl) {
 
  733         if (removedAnnot != null) {  
 
  734           flier.AddRemovedAnnotation(removedAnnot);  
 
  751     String confirmed = addedAnnotEl.getAttribute(
"confirmed");
 
  752     String tmpId = addedAnnotEl.getAttribute(
"tmpId");
 
  757     NodeList annotDescNL = addedAnnotEl.getElementsByTagName(
"rdf:Description");
 
  758     int nCount = annotDescNL.getLength();
 
  760     Element annotDescEl = (Element) annotDescNL.item(ni);
 
  761     if (tmpId.isEmpty()) {
 
  762       tmpId = annotDescEl.getAttribute(
"tmpId");
 
  768     if (annotDescEl == null) {
 
  769       int langNum = requestInfo.getSession().getLanguageNum();
 
  770       int lod = requestInfo.getSession().getProtocolLOD();
 
  773         String msg = 
"Annotation description element is missing.";
 
  774         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  778     while (annotDescEl.getParentNode() != addedAnnotEl && ni < nCount) {
 
  780       annotDescEl = (Element) annotDescNL.item(ni);
 
  783     if (annotDescEl.getParentNode() != addedAnnotEl) {  
 
  785       int langNum = requestInfo.getSession().getLanguageNum();
 
  786       int lod = requestInfo.getSession().getProtocolLOD();
 
  789         String msg = 
"Annotation description element is missing.";
 
  790         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  794     Integer cMethod = Constants.CONFIRM_METHODS.indexOf(confirmed);
 
  800     if (retAnnot == null) {  
 
  802         String msg = 
"Bad annotation description: " + annotDescEl.toString();
 
  803         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  809       User user = requestInfo.getSession().getUser();
 
  810       retAnnot.setAuthorIdStr(AppBean.getBaseAuthorUri() + user.
getId());
 
  811       retAnnot.setAuthorName(user.getName());
 
  812       retAnnot.setAuthorAddress(user.getEmail());
 
  814     if (!tmpId.isEmpty()) {  
 
  816       Integer method = Constants.CONFIRM_METHODS.indexOf(confirmed);
 
  818         int langNum = requestInfo.getSession().getLanguageNum();
 
  819         int lod = requestInfo.getSession().getProtocolLOD();
 
  822           String msg = 
"Bad confirmation method: ";
 
  823           if (confirmed != null) {
 
  824             msg = msg + confirmed;
 
  826           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  835          if (requestInfo.
getSession().getSendedSuggestions() != null && !requestInfo.
getSession().getSendedSuggestions().isEmpty()) {
 
  838             id = Integer.parseInt(tmpId);
 
  839           } 
catch (NumberFormatException nfe) {
 
  841               String msg = 
"The ID of the confirmed suggestion is not a number: " + tmpId;
 
  842               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  846           if (
id != null && requestInfo.
getSession().isSuggInSendedSuggestions(id)) {
 
  849             retAnnot.setTmpId(tmpId);
 
  850             retAnnot.setId(null);
 
  851             newEntry.setConfirmMethod(method);
 
  852             newEntry.setConfirmedVersion(retAnnot);
 
  855               requestInfo.addConfirmedSuggestion(newEntry);
 
  859               String msg = 
"Suggestion with the following ID not found: " + tmpId;
 
  860               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  880     NodeList annotDescNL = updatedAnnotEl.getElementsByTagName(
"rdf:Description");
 
  881     int nCount = annotDescNL.getLength();
 
  883     Element annotDescEl = (Element) annotDescNL.item(ni);
 
  885     if (annotDescEl == null) {
 
  886       int langNum = requestInfo.getSession().getLanguageNum();
 
  887       int lod = requestInfo.getSession().getProtocolLOD();
 
  890         String msg = 
"Annotation description element of edited annotation is missing.";
 
  891         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  895     while (annotDescEl.getParentNode() != updatedAnnotEl && ni < nCount) {
 
  897       annotDescEl = (Element) annotDescNL.item(ni);
 
  900     if (annotDescEl.getParentNode() != updatedAnnotEl) {  
 
  902       int langNum = requestInfo.getSession().getLanguageNum();
 
  903       int lod = requestInfo.getSession().getProtocolLOD();
 
  906         String msg = 
"Annotation description element of edited annotation is missing.";
 
  907         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  912     String annotUri = annotDescEl.getAttribute(
"rdf:about");
 
  914     String annotIdStr = annotUri.replace(AppBean.getBaseAnnotUri(), 
"");
 
  916     Integer annotId = null;
 
  918       annotId = Integer.parseInt(annotIdStr);
 
  919     } 
catch (NumberFormatException nfe) {  
 
  920       int langNum = requestInfo.getSession().getLanguageNum();
 
  921       int lod = requestInfo.getSession().getProtocolLOD();
 
  922       String info = 
"<reload uri=\"" + annotUri + 
"\"/>";
 
  925         String msg = 
"Bad id of edited annotation: " + annotIdStr;
 
  926         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  932     Object[] params = 
new Object[2];
 
  935     List aList = AppBean.getPersistenceManager().queryDB(
"Annotation.findById", params);
 
  936     if (aList != null && !aList.isEmpty()) {  
 
  939       int langNum = requestInfo.getSession().getLanguageNum();
 
  940       int lod = requestInfo.getSession().getProtocolLOD();
 
  941       String info = 
"<reload uri=\"" + annotUri + 
"\"/>";
 
  944         String msg = 
"Edited annotation was not found.";
 
  945         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  952     if (annotFromEl != null) {  
 
  953       annotFromEl.setId(retAnnot.getId());  
 
  956         String msg = 
"Bad edited annotation description: " + annotDescEl.toString();
 
  957         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  975     NodeList annotDescNL = remAnnotEl.getElementsByTagName(
"rdf:Description");
 
  976     int nCount = annotDescNL.getLength();
 
  978     Element annotDescEl = (Element) annotDescNL.item(ni);
 
  980     if (annotDescEl == null) {
 
  981       int langNum = requestInfo.getSession().getLanguageNum();
 
  982       int lod = requestInfo.getSession().getProtocolLOD();
 
  985         String msg = 
"Annotation description element of removed annotation is missing.";
 
  986         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
  990     while (annotDescEl.getParentNode() != remAnnotEl && ni < nCount) {
 
  992       annotDescEl = (Element) annotDescNL.item(ni);
 
  995     if (annotDescEl.getParentNode() != remAnnotEl) {  
 
  996       int langNum = requestInfo.getSession().getLanguageNum();
 
  997       int lod = requestInfo.getSession().getProtocolLOD();
 
 1000         String msg = 
"Annotation description element of removed annotation is missing.";
 
 1001         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1006     String annotUri = annotDescEl.getAttribute(
"rdf:about");
 
 1008     String annotIdStr = annotUri.replace(AppBean.getBaseAnnotUri(), 
"");
 
 1010     Integer annotId = null;
 
 1012       annotId = Integer.parseInt(annotIdStr);
 
 1013     } 
catch (NumberFormatException nfe) {  
 
 1014       String info = 
"<reload uri=\"" + annotUri + 
"\"/>";
 
 1015       int langNum = requestInfo.getSession().getLanguageNum();
 
 1016       int lod = requestInfo.getSession().getProtocolLOD();
 
 1019         String msg = 
"Bad id of removed annotation: " + annotIdStr;
 
 1020         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1026     Object[] params = 
new Object[2];
 
 1028     params[1] = annotId;
 
 1029     List aList = AppBean.getPersistenceManager().queryDB(
"Annotation.findById", params);
 
 1030     if (aList != null && !aList.isEmpty()) {  
 
 1033       int langNum = requestInfo.getSession().getLanguageNum();
 
 1034       int lod = requestInfo.getSession().getProtocolLOD();
 
 1035       String info = 
"<reload uri=\"" + annotUri + 
"\"/>";
 
 1038         String msg = 
"Removed annotation was not found.";
 
 1039         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1059     Flier flier = requestInfo.getFlier();
 
 1062     String annotUri = annotationEl.getAttribute(
"rdf:about");
 
 1063     if (annotUri == null) {
 
 1066     String tmpId = annotationEl.getAttribute(
"tmpId");
 
 1068     String errInfo = 
"";
 
 1069     if (!annotUri.isEmpty()) {
 
 1070       errInfo = 
"<reload uri=\"" + annotUri + 
"\"/>";
 
 1074     NodeList typeNL = annotationEl.getElementsByTagName(
"rdf:type");
 
 1075     Element typeEl = (Element) typeNL.item(0);
 
 1076     if (typeEl == null) {
 
 1077       int langNum = session.getLanguageNum();
 
 1078       int lod = requestInfo.getSession().getProtocolLOD();
 
 1081         String msg = 
"Annotation type element is missing.";
 
 1082         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1087     String annotTypeStr = typeEl.getAttribute(
"rdf:resource");
 
 1090     Object[] params = 
new Object[2];
 
 1092     params[1] = annotTypeStr;
 
 1093     List aList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri", params);
 
 1094     if (aList != null && !aList.isEmpty()) {  
 
 1097       Iterator<AnnotType> atIter = (Iterator<AnnotType>) flier.getAddedTypes().iterator();
 
 1098       while (atIter.hasNext() && annotType == null) {  
 
 1100         if (addedT.
getUri().equals(annotTypeStr)) {  
 
 1109       String baseWG = AppBean.getBaseTypeUri() + 
"g" + requestInfo.
getSession().getDefaultGroup().getId() + 
"/";
 
 1111       String pomTypeStr = annotTypeStr.replace(AppBean.getBaseTypeUri(), baseWG);
 
 1113       params[1] = pomTypeStr;
 
 1114       aList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri", params);
 
 1115       if (aList != null && !aList.isEmpty()) {  
 
 1118         Iterator<AnnotType> atIter = (Iterator<AnnotType>) flier.getAddedTypes().iterator();
 
 1119         while (atIter.hasNext() && annotType == null) {  
 
 1121           if (addedT.
getUri().equals(pomTypeStr)) {  
 
 1127     if (annotType == null) {  
 
 1128       int langNum = requestInfo.getSession().getLanguageNum();
 
 1129       int lod = requestInfo.getSession().getProtocolLOD();
 
 1132         String msg = 
"Annotation type not found: " + annotTypeStr;
 
 1133         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1139     NodeList dateNL = annotationEl.getElementsByTagName(
"a:dateTime");
 
 1140     Element dateEl = (Element) dateNL.item(0);
 
 1141     Date annotDate = null;
 
 1142     if (dateEl == null) {  
 
 1143       annotDate = 
new Date();  
 
 1146       String dateString = dateEl.getAttribute(
"rdf:value");
 
 1149         annotDate = Util.parseRFC3339Date(dateString);
 
 1150       } 
catch (Exception e) {  
 
 1151         int langNum = requestInfo.getSession().getLanguageNum();
 
 1152         int lod = requestInfo.getSession().getProtocolLOD();
 
 1155           String msg = 
"Bad date of annotation creation: " + dateString;
 
 1156           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1158         annotDate = 
new Date();  
 
 1163     NodeList authorNL = annotationEl.getElementsByTagName(
"a:author");
 
 1164     Element authorEl = (Element) authorNL.item(0);
 
 1165     if (authorEl == null) {
 
 1166       int langNum = requestInfo.getSession().getLanguageNum();
 
 1167       int lod = requestInfo.getSession().getProtocolLOD();
 
 1172     String authorName = authorEl.getAttribute(
"name");  
 
 1173     String authorAddress = authorEl.getAttribute(
"address");  
 
 1174     String authorIdStr = authorEl.getAttribute(
"id");  
 
 1175     if (authorIdStr == null) {
 
 1178       authorIdStr = authorIdStr.replace(AppBean.getBaseAuthorUri(), 
"");
 
 1181     Integer authorId = null;
 
 1182     if (!authorIdStr.isEmpty()) {
 
 1184         authorId = Integer.parseInt(authorIdStr);
 
 1185       } 
catch (NumberFormatException nfe) {  
 
 1186         int langNum = requestInfo.getSession().getLanguageNum();
 
 1187         int lod = requestInfo.getSession().getProtocolLOD();
 
 1190           String msg = 
"Bad id of annotation author: " + authorIdStr;
 
 1191           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1198     NodeList sourceNL = annotationEl.getElementsByTagName(
"a:source");
 
 1199     Element sourceEl = (Element) sourceNL.item(0);
 
 1200     if (sourceEl == null) {
 
 1201       int langNum = requestInfo.getSession().getLanguageNum();
 
 1202       int lod = requestInfo.getSession().getProtocolLOD();
 
 1205         String msg = 
"Source element is missing in annotation.";
 
 1206         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1211     String annotSource = sourceEl.getAttribute(
"rdf:resource");
 
 1212     if (annotSource == null) {
 
 1215     if (annotSource.isEmpty()) {  
 
 1216       annotSource = session.getSyncDocument().getUri();
 
 1217     } 
else if (!annotSource.equals(session.
getSyncDocument().getUriForAnnot())) {
 
 1219       int langNum = requestInfo.getSession().getLanguageNum();
 
 1220       int lod = requestInfo.getSession().getProtocolLOD();
 
 1223         String msg = 
"Source in annotation is not matching to synchronized document.";
 
 1224         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1230     NodeList contentNL = annotationEl.getElementsByTagName(
"a:content");
 
 1231     Element contentEl = (Element) contentNL.item(0);
 
 1232     String content = MessageProcessor.getElementContent(contentEl);
 
 1233     if (content == null) {
 
 1238     retAnnot = 
new Annotation(annotType, annotDate, authorIdStr, authorName, authorAddress, session.
getSyncDocument(), content, nestedIn);
 
 1240     retAnnot.setTmpId(tmpId);
 
 1242     if (nestedIn != null) {
 
 1243       if (requestInfo.
getSession().getSendedSuggestions() != null && !requestInfo.
getSession().getSendedSuggestions().isEmpty()) {
 
 1246           id = Integer.parseInt(tmpId);
 
 1247         } 
catch (NumberFormatException nfe) {
 
 1249             String msg = 
"The ID of the refused suggestion is not a number: " + tmpId;
 
 1250             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1254         if (cMethod != null) {
 
 1258         if (
id != null && requestInfo.
getSession().isSuggInSendedSuggestions(id)) {
 
 1261           newEntry.setConfirmMethod(method);
 
 1262           newEntry.setConfirmedVersion(retAnnot);
 
 1265             requestInfo.addConfirmedSuggestion(newEntry);
 
 1270           String msg = 
"Suggestion with the following ID not found: " + tmpId;
 
 1271           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1276     if (!annotUri.isEmpty()) {  
 
 1278       String annotIdInStr = annotUri.replace(AppBean.getBaseAnnotUri(), 
"");
 
 1281         id = Integer.parseInt(annotIdInStr);
 
 1282       } 
catch (NumberFormatException nfe) {
 
 1286           String msg = 
"Bad id of annotation: " + annotIdInStr;
 
 1287           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1295     if (authorId != null) {  
 
 1298       params[1] = authorId;
 
 1299       List uList = AppBean.getPersistenceManager().queryDB(
"User.findById", params);
 
 1300       if (uList != null && !uList.isEmpty()) {  
 
 1301         retAnnot.setUser((
User) uList.get(0));  
 
 1303     } 
else if (authorAddress != null && !authorAddress.isEmpty()) {
 
 1306       params[0] = 
"email";
 
 1307       params[1] = authorAddress;
 
 1308       List uList = AppBean.getPersistenceManager().queryDB(
"User.findByEmail", params);
 
 1309       if (uList != null && !uList.isEmpty()) {  
 
 1310         retAnnot.setUser((
User) uList.get(0));  
 
 1313       if (retAnnot.getUser() != null) {  
 
 1314         retAnnot.setAuthorIdStr(AppBean.getBaseAuthorUri() + retAnnot.getUser().getId());
 
 1316         int langNum = requestInfo.getSession().getLanguageNum();
 
 1317         int lod = requestInfo.getSession().getProtocolLOD();
 
 1320           String msg = 
"Unknowwn author address in annotation and id is not set: " + authorAddress;
 
 1321           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1327     if (retAnnot.getUser() != null && (authorAddress == null || authorAddress.isEmpty())) {
 
 1329       retAnnot.setAuthorAddress(retAnnot.getUser().getEmail());  
 
 1331     if (retAnnot.getUser() != null && (authorName == null || authorName.isEmpty())) {
 
 1333       retAnnot.setAuthorName(retAnnot.getUser().getName());  
 
 1337     NodeList fragmentNodes = annotationEl.getElementsByTagName(
"a:fragment");
 
 1338     int fragmentCnt = fragmentNodes.getLength();
 
 1339     for (
int i = 0; i < fragmentCnt; i++) {  
 
 1340       Element fragmentEl = (Element) fragmentNodes.item(i);
 
 1341       if (fragmentEl.getParentNode() != annotationEl) {
 
 1347       if (fragment != null) {  
 
 1348         retAnnot.addFragment(fragment);  
 
 1350         int langNum = requestInfo.getSession().getLanguageNum();
 
 1351         int lod = requestInfo.getSession().getProtocolLOD();
 
 1354           String msg = 
"Bad annotated fragment description.";
 
 1355           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1361     NodeList attributeNodes = annotationEl.getElementsByTagName(
"a:attribute");
 
 1362     int attribCnt = attributeNodes.getLength();
 
 1363     for (
int i = 0; i < attribCnt; i++) {  
 
 1364       Element attributeEl = (Element) attributeNodes.item(i);
 
 1365       if (attributeEl.getParentNode() != annotationEl) {
 
 1371       if (attribute != null) {  
 
 1372         retAnnot.addAttribute(attribute);  
 
 1377       requestInfo.addConfirmedSuggestion(newEntry);
 
 1394     int langNum = requestInfo.getSession().getLanguageNum();
 
 1395     int lod = requestInfo.getSession().getProtocolLOD();
 
 1396     String info = errAnnotInfo
 
 1397             + 
"<attribute name=\"" + name + 
"\" type=\"" + type + 
"\"/>";
 
 1398     requestInfo.addError(lod, langNum, errorCode, info);
 
 1400       Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, message);
 
 1420     String errAnnotInfo = 
"";
 
 1421     if (!(annot.
getId() == null)) {
 
 1422       errAnnotInfo = 
"<reload uri=\"" + annot.getId() + 
"\"/>";
 
 1425     String name = attributeEl.getAttribute(
"name");
 
 1426     String type = attributeEl.getAttribute(
"type");
 
 1427     String priorityStr = attributeEl.getAttribute(
"priority");
 
 1434     if (name.isEmpty()) {  
 
 1437                         "Name of attribute of annotation is missing.");
 
 1441     if (type.isEmpty()) {  
 
 1444                        "Type of atribute of annotation is missing.");
 
 1448     Integer priority = null;
 
 1449     if (priorityStr != null) {
 
 1451         priority = Integer.parseInt(priorityStr);
 
 1452       } 
catch (NumberFormatException ex) {
 
 1456     if (priority == null) {
 
 1461     String attrComment = null;
 
 1462     NodeList attrCommentNL = attributeEl.getElementsByTagName(
"a:comment");
 
 1463     if (attrCommentNL.getLength() != 0) {
 
 1464       Element attrCommentEl = (Element) attrCommentNL.item(0);
 
 1465       attrComment = MessageProcessor.getElementContent(attrCommentEl);
 
 1471     if (type.contentEquals(
"person") || type.contentEquals(
"Person")) {
 
 1476       NodeList personNL = attributeEl.getElementsByTagName(
"a:person");
 
 1477       Element personEl = (Element) personNL.item(0);
 
 1478       if (personEl != null) {  
 
 1480         String userIdStr = 
"";
 
 1481         String idInAtt = personEl.getAttribute(
"id");
 
 1483         if (idInAtt != null) {  
 
 1485             userIdStr = idInAtt.replace(AppBean.getBaseAuthorUri(), 
"");
 
 1491         if (email.isEmpty()) {  
 
 1493           email = personEl.getAttribute(
"address");
 
 1494           if (email == null) {
 
 1499         if (email.isEmpty() && userIdStr.isEmpty()) {  
 
 1502                   "Bad attribute of type Person (identificator is missing).");
 
 1506         Integer userId = null;
 
 1507         if (!userIdStr.isEmpty()) {
 
 1510             userId = Integer.parseInt(userIdStr);
 
 1511           } 
catch (NumberFormatException nfe) {  
 
 1514                               "Bad id of Person in attribute of type Person: " + userIdStr);
 
 1520         Object[] params = 
new Object[2];
 
 1521         params[0] = 
"email";
 
 1523         String queryName = 
"User.findByEmail";
 
 1525         if (userId != null) {  
 
 1528           queryName = 
"User.findById";
 
 1532         List uList = AppBean.getPersistenceManager().queryDB(queryName, params);
 
 1533         if (uList != null && !uList.isEmpty()) {  
 
 1537           String msg = 
"Unknown person in attribute of type Person: ";
 
 1538           if (email != null) {
 
 1541           if (userId != null) {
 
 1553     } 
else if (type.contentEquals(
"NestedAnnotation") || type.contentEquals(
"nestedAnnotation")) {
 
 1557       NodeList nestedNL = attributeEl.getElementsByTagName(
"rdf:Description");
 
 1558       int nCount = nestedNL.getLength();
 
 1560       Element nestedEl = (Element) nestedNL.item(ni);
 
 1562       if (nestedEl != null) {
 
 1563         while (nestedEl.getParentNode() != attributeEl && ni < nCount) {
 
 1565           nestedEl = (Element) nestedNL.item(ni);
 
 1568         if (nestedEl.getParentNode() != attributeEl) {  
 
 1572       if (nestedEl == null) {  
 
 1574         NodeList nestedANL = attributeEl.getElementsByTagName(
"annotation");
 
 1575         nCount = nestedANL.getLength();
 
 1577         Element nestedAEl = (Element) nestedANL.item(ni);
 
 1579         if (nestedAEl != null) {
 
 1580           while (nestedAEl.getParentNode() != attributeEl && ni < nCount) {
 
 1582             nestedAEl = (Element) nestedANL.item(ni);
 
 1585           if (nestedAEl.getParentNode() != attributeEl) {  
 
 1589         if (nestedAEl != null) {  
 
 1591           NodeList nestedDNL = nestedAEl.getElementsByTagName(
"rdf:Description");
 
 1592           nCount = nestedDNL.getLength();
 
 1594           nestedEl = (Element) nestedDNL.item(ni);
 
 1596           if (nestedEl != null) {
 
 1597             while (nestedEl.getParentNode() != nestedAEl && ni < nCount) {
 
 1599               nestedEl = (Element) nestedDNL.item(ni);
 
 1602             if (nestedEl.getParentNode() != nestedAEl) {  
 
 1609       if (nestedEl != null) {  
 
 1612         if (nestedAnnot != null) {  
 
 1615             retAttribute = AttributeManager.createAttribute(name, 
"NestedAnnotation", 
 
 1616                                 nestedAnnot.getAnnotType(), nestedAnnot, annot);
 
 1617             retAttribute.setAttributeType(nestedAnnot.getAnnotType());
 
 1618           } 
catch (Exception e) {
 
 1619             String message = e.getMessage();
 
 1624           int langNum = requestInfo.getSession().getLanguageNum();
 
 1625           int lod = requestInfo.getSession().getProtocolLOD();
 
 1626           String info = errAnnotInfo
 
 1627                   + 
"<attribute name=\"" + name + 
"\" type=\"" + type + 
"\"/>";
 
 1630             String msg = 
"Bad nested annotation.";
 
 1631             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1638           retAttribute = AttributeManager.createAttribute(name, 
"NestedAnnotation", (
Annotation) null, annot);
 
 1639         } 
catch (Exception e) {
 
 1640           String message = e.getMessage();
 
 1645     } 
else if (type.contentEquals(
"AnnotationLink") || type.contentEquals(
"annotationLink")) {
 
 1649         retAttribute = AttributeManager.createAttribute(name, type, annot);
 
 1650         String value = attributeEl.getAttribute(
"uri");
 
 1653         boolean onlyDigit = 
true;
 
 1654         if(value != null && !value.equals(
"")){
 
 1656           int size = value.length();
 
 1658           for(
int i = 0; i < size; i++){
 
 1659               if(!Character.isDigit(value.charAt(i))){ 
 
 1671         if (value != null && !value.equals(
"") && !onlyDigit) {
 
 1675             Object[] params = 
new Object[2];
 
 1678               String tmpValue = value.replace(AppBean.getBaseAnnotUri(), 
"");
 
 1680               params[1] = Long.decode(tmpValue);
 
 1684               String message = e.getMessage();
 
 1690               @SuppressWarnings(
"unchecked")
 
 1691               List<Annotation> annotList = AppBean.getPersistenceManager().queryDB(
"Annotation.findById",params);
 
 1692               if(annotList == null || annotList.isEmpty()){
 
 1693                 String message = 
"Unknown annotation uri: " + value + 
".";
 
 1699           retAttribute.setRawValue(value);
 
 1701           value = attributeEl.getAttribute(
"tmpId");
 
 1702           if (value != null && !value.equals(
"")) {
 
 1705             retAttribute = AttributeManager.createAttribute(name, 
"AnyAnnotation", annot);
 
 1708       } 
catch (NumberFormatException e) {
 
 1709         String message = 
"Bad tmpId in annotation link.";
 
 1712       } 
catch (ClassNotFoundException e) {
 
 1713         String message = e.getMessage();
 
 1716       } 
catch (IllegalArgumentException e) {
 
 1717         String message = e.getMessage();
 
 1720       } 
catch (UnsupportedOperationException e) {
 
 1721         int langNum = requestInfo.getSession().getLanguageNum();
 
 1722         int lod = requestInfo.getSession().getProtocolLOD();
 
 1725           String msg = 
"UnsupportedOperationException for setting of attribute value.";
 
 1726           Logger.getLogger(MessageProcessor.class.getName()).log(Level.SEVERE, msg);
 
 1728       } 
catch (RuntimeException e) {
 
 1729         String message = e.getMessage();
 
 1734     else if(type.contentEquals(
"Text")){
 
 1736       NodeList textNodes = attributeEl.getElementsByTagName(
"a:Content");
 
 1740       if(textNodes.getLength() != 1){
 
 1741         String msg = 
"Zero or more than one CDATA sections in Text attribute.";
 
 1748         Node contentNode = textNodes.item(0);
 
 1749         Node cdataNode = contentNode.getFirstChild();
 
 1750         if (cdataNode != null && cdataNode instanceof CharacterData) {
 
 1751           CharacterData cd = (CharacterData) cdataNode;
 
 1753             data = cd.getData();
 
 1755           catch(DOMException e){
 
 1762         retAttribute = AttributeManager.createAttribute(name, type, annot);
 
 1763         if (data != null && !data.isEmpty()) {
 
 1764           retAttribute.setRawValue(data);
 
 1766       } 
catch (ClassNotFoundException e) {
 
 1767         String message = e.getMessage();
 
 1770       } 
catch (IllegalArgumentException e) {
 
 1771         String message = e.getMessage();
 
 1774       } 
catch (UnsupportedOperationException e) {
 
 1775         int langNum = requestInfo.getSession().getLanguageNum();
 
 1776         int lod = requestInfo.getSession().getProtocolLOD();
 
 1779           String msg = 
"UnsupportedOperationException for setting of attribute value.";
 
 1780           Logger.getLogger(MessageProcessor.class.getName()).log(Level.SEVERE, msg);
 
 1782       } 
catch (RuntimeException e) {
 
 1783         String message = e.getMessage();
 
 1792         retAttribute = AttributeManager.createAttribute(name, type, annot);
 
 1796           String value = attributeEl.getAttribute(
"rdf:value");
 
 1797           if (!value.isEmpty()) {
 
 1798             retAttribute.setRawValue(value);
 
 1805           Node nested = ((Element) attributeEl).getElementsByTagName(structAttr.getXmlAttributeName()).item(0);
 
 1807           if (nested != null) {
 
 1808             HashMap<String, String> values = 
new HashMap<String, String>();
 
 1809             NodeList elemValues = ((Element) nested).getChildNodes();
 
 1810             String valueOfAttribute = MessageProcessor.getElementContent(((Element) nested));
 
 1812             int attrLength = ((Element)nested).getAttributes().getLength();
 
 1813             HashMap<String, String> attributesMap = 
new HashMap<String, String>();
 
 1814             for(
int index = 0; index < attrLength; index++){
 
 1815               String attrName = ((Element)nested).getAttributes().item(index).getNodeName();
 
 1816               String attrValue = ((Element)nested).getAttributes().item(index).getNodeValue();
 
 1817               attributesMap.put(attrName, attrValue);
 
 1821             for (
int i = 0; i < elemValues.getLength(); i++) {
 
 1822               if (elemValues.item(i).getNodeType() == Node.ELEMENT_NODE) {
 
 1823                 values.put(elemValues.item(i).getNodeName(), MessageProcessor.getElementContent((Element) elemValues.item(i)));
 
 1827             ArrayList<Object> newParam = 
new ArrayList<Object>(3);
 
 1828             newParam.add(values);
 
 1829             newParam.add(attributesMap);
 
 1830             newParam.add(valueOfAttribute);
 
 1835       } 
catch (ClassNotFoundException e) {
 
 1836         String message = e.getMessage();
 
 1839       } 
catch (IllegalArgumentException e) {
 
 1840         String message = e.getMessage();
 
 1843       } 
catch (UnsupportedOperationException e) {
 
 1844         int langNum = requestInfo.getSession().getLanguageNum();
 
 1845         int lod = requestInfo.getSession().getProtocolLOD();
 
 1848           String msg = 
"UnsupportedOperationException for setting of attribute value.";
 
 1849           Logger.getLogger(MessageProcessor.class.getName()).log(Level.SEVERE, msg);
 
 1851       } 
catch (RuntimeException e) {
 
 1852         String message = e.getMessage();
 
 1862           type = type.replace(AppBean.getBaseTypeUri(), 
"");
 
 1863           type = AppBean.getBaseTypeUri() + 
"g" + requestInfo.
getSession().getDefaultGroup().getId() + 
"/" + type;
 
 1866       Flier flier = requestInfo.getFlier();
 
 1869       Object[] params = 
new Object[2];
 
 1872       List tList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri", params);
 
 1873       if (tList != null && !tList.isEmpty()) {  
 
 1876       else if (flier.
getAddedTypes() != null && !flier.getAddedTypes().isEmpty()) {
 
 1877         Iterator<AnnotType> newTypesIt = flier.getAddedTypes().iterator();
 
 1878         while (newTypesIt.hasNext()) {
 
 1880           if (newType.
getUri().equals(type)) {  
 
 1885       if (aType != null) {  
 
 1888           retAttribute = AttributeManager.createAttribute(name, 
"nestedAnnotation", aType, (
Annotation)null, annot);
 
 1890         catch(ClassNotFoundException e){
 
 1891           int langNum = requestInfo.getSession().getLanguageNum();
 
 1892           int lod = requestInfo.getSession().getProtocolLOD();
 
 1893           String info = errAnnotInfo
 
 1894                   + 
"<attribute name=\"" + name + 
"\" type=\"" + type + 
"\"/>";
 
 1897             String msg = 
"Unknown type of attribute: " + type;
 
 1898             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1903         int langNum = requestInfo.getSession().getLanguageNum();
 
 1904         int lod = requestInfo.getSession().getProtocolLOD();
 
 1905         String info = errAnnotInfo
 
 1906                 + 
"<attribute name=\"" + name + 
"\" type=\"" + type + 
"\"/>";
 
 1909           String msg = 
"Unknown type of attribute: " + type;
 
 1910           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1915     retAttribute.setComment(attrComment);
 
 1916     retAttribute.setPriority(priority);
 
 1917     return retAttribute;
 
 1932     String valid = fragmentEl.getAttribute(
"valid");
 
 1933     Boolean isGood = 
true;
 
 1934     if (valid != null) {
 
 1935       if (valid.equalsIgnoreCase(
"false")) {
 
 1941     NodeList pathNL = fragmentEl.getElementsByTagName(
"a:path");
 
 1942     Element pathEl = (Element) pathNL.item(0);
 
 1944     String path = MessageProcessor.getElementContent(pathEl);
 
 1947     NodeList offsetNL = fragmentEl.getElementsByTagName(
"a:offset");
 
 1948     Element offsetEl = (Element) offsetNL.item(0);
 
 1950     String offsetString = MessageProcessor.getElementContent(offsetEl);
 
 1952     Integer offset = null;
 
 1953     if (offsetString != null) {
 
 1954       if (!offsetString.isEmpty()) {  
 
 1956           offset = Integer.parseInt(offsetString);
 
 1957         } 
catch (NumberFormatException nfe) {  
 
 1959             String msg = 
"Bad fragment offset: " + offsetString;
 
 1960             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1966           String msg = 
"Empty offset of the fragment.";
 
 1967           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1974     NodeList lengthNL = fragmentEl.getElementsByTagName(
"a:length");
 
 1975     Element lengthEl = (Element) lengthNL.item(0);
 
 1977     String lengthString = MessageProcessor.getElementContent(lengthEl);
 
 1979     Integer length = null;
 
 1980     if (lengthString != null) {
 
 1981       if (!lengthString.isEmpty()) {  
 
 1983           length = Integer.parseInt(lengthString);
 
 1984         } 
catch (NumberFormatException nfe) {  
 
 1986             String msg = 
"Bad length of the fragment: " + lengthString;
 
 1987             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 1993           String msg = 
"UEmpty length of the fragment.";
 
 1994           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2001     NodeList textNL = fragmentEl.getElementsByTagName(
"a:annotatedText");
 
 2002     Element textEl = (Element) textNL.item(0);
 
 2004     String text = MessageProcessor.getElementContent(textEl);
 
 2007         String msg = 
"Content of the annotated fragment was not presented.";
 
 2008         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2013     if (text.length() != length.intValue()) {  
 
 2015         String msg = 
"Length of the fragment is " + length.intValue() 
 
 2016                      + 
" which is not matching to real length of the text \": " + text + 
"\".";
 
 2017         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2023     path = UpdatableFragment.improveXPath(path);
 
 2025     retFragment = 
new Fragment(path, offset, length, text, annot, isGood);
 
 2040     NodeList contentNL = resynchronizeEl.getElementsByTagName(
"content");
 
 2041     Element contentEl = (Element) contentNL.item(0);
 
 2042     if (contentEl != null) {  
 
 2044       String content = MessageProcessor.getElementContent(contentEl);
 
 2045       if (content == null) {  
 
 2046         int langNum = requestInfo.getSession().getLanguageNum();
 
 2047         int lod = requestInfo.getSession().getProtocolLOD();
 
 2050           String msg = 
"Resynchronization with empty content of the document.";
 
 2051           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2054       requestInfo.setResyncDocContent(content);  
 
 2056       int langNum = requestInfo.getSession().getLanguageNum();
 
 2057       int lod = requestInfo.getSession().getProtocolLOD();
 
 2060         String msg = 
"Resynchronization without content of the document.";
 
 2061         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2075     String resource = synchronizeEl.getAttribute(
"resource");
 
 2076     String linearize = synchronizeEl.getAttribute(
"linearize");
 
 2077     String overwrite = synchronizeEl.getAttribute(
"overwrite");
 
 2078     if (resource == null) {
 
 2081     if (resource.isEmpty()) {  
 
 2082       int langNum = requestInfo.getSession().getLanguageNum();
 
 2083       int lod = requestInfo.getSession().getProtocolLOD();
 
 2086         String msg = 
"Synchronization without URI of the resource.";
 
 2087         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2092     if (linearize.contentEquals(
"true")) {
 
 2093       requestInfo.setSyncLinearized(
true);
 
 2096     if (overwrite.contentEquals(
"true")) {
 
 2097       requestInfo.setSyncWithOverwrite(
true);
 
 2100     NodeList contentNL = synchronizeEl.getElementsByTagName(
"content");
 
 2101     Element contentEl = (Element) contentNL.item(0);
 
 2102     if (contentEl != null) {  
 
 2104       String content = MessageProcessor.getElementContent(contentEl);
 
 2105       if (content == null) {  
 
 2106         int langNum = requestInfo.getSession().getLanguageNum();
 
 2107         int lod = requestInfo.getSession().getProtocolLOD();
 
 2110           String msg = 
"Synchronization with empty content of the document.";
 
 2111           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2116       requestInfo.setSyncDocumentData(syncDoc);  
 
 2118       int langNum = requestInfo.getSession().getLanguageNum();
 
 2119       int lod = requestInfo.getSession().getProtocolLOD();
 
 2122         String msg = 
"Synchronization without content of the document.";
 
 2123         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2139     NodeList sourceNL = unsubscribeEl.getElementsByTagName(
"source");
 
 2140     int sourceCnt = sourceNL.getLength();
 
 2141     for (
int i = 0; i < sourceCnt; i++) {  
 
 2142       Element sourceEl = (Element) sourceNL.item(i);
 
 2143       String type = sourceEl.getAttribute(
"type");
 
 2144       String user = sourceEl.getAttribute(
"user");
 
 2145       String uri = sourceEl.getAttribute(
"uri");
 
 2148       if(!session.
containsSource(source) && !session.containsUnsubscribedSource(source)){   
 
 2149           session.addUnsubscribeSource(source); 
 
 2151         if(session.
containsSource(source) && !session.containsUnsubscribedSource(source)){  
 
 2152             session.removeSource(source); 
 
 2169     NodeList sourceNL = subscribeEl.getElementsByTagName(
"source");
 
 2170     int sourceCnt = sourceNL.getLength();
 
 2171     for (
int i = 0; i < sourceCnt; i++) {  
 
 2172       Element sourceEl = (Element) sourceNL.item(i);
 
 2173       String type = sourceEl.getAttribute(
"type");
 
 2174       String user = sourceEl.getAttribute(
"user");
 
 2175       String uri = sourceEl.getAttribute(
"uri");
 
 2176       if (user != null && !user.isEmpty()) {  
 
 2180           Object[] params = 
new Object[2];
 
 2181           params[0] = 
"email";
 
 2183           List uList = AppBean.getPersistenceManager().queryDB(
"User.findByEmail", params);
 
 2184           if (uList != null && !uList.isEmpty()) {  
 
 2189               String msg = 
"Subscribe to unknown user's annotations: " + user;
 
 2190               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2198           session.addSource(source);  
 
 2201             session.removeUnsubscribeSource(source);  
 
 2202             session.addSource(source);  
 
 2218     ArrayList<Settings> settings = 
new ArrayList<Settings>();
 
 2220     NodeList paramNL = settingsEl.getElementsByTagName(
"param");
 
 2221     int paramCnt = paramNL.getLength();
 
 2222     for (
int i = 0; i < paramCnt; i++) {  
 
 2223       Element paramEl = (Element) paramNL.item(i);
 
 2224       String name = paramEl.getAttribute(
"name");
 
 2225       String value = paramEl.getAttribute(
"value");
 
 2229       if (name.isEmpty()) {  
 
 2230         int langNum = requestInfo.getSession().getLanguageNum();
 
 2231         int lod = requestInfo.getSession().getProtocolLOD();
 
 2236         requestInfo.setSettings(requestInfo.getSession().getSettings());
 
 2238           String msg = 
"Empty name of parameter of settings.";
 
 2239           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2245       settings.add(param);  
 
 2248     requestInfo.setSettings(settings);
 
 2260     NodeList rSugNL = refSuggestEl.getElementsByTagName(
"suggestion");
 
 2261     int rSugNLCnt = rSugNL.getLength();
 
 2262     for (
int i = 0; i < rSugNLCnt; i++) {  
 
 2263       Element rSugEl = (Element) rSugNL.item(i);
 
 2265       String tmpId = rSugEl.getAttribute(
"tmpId");
 
 2267       String methodStr = rSugEl.getAttribute(
"method");
 
 2270       int method = Constants.REFUSE_METHODS.indexOf(methodStr);
 
 2273           String msg = 
"Unknown refuse method: " + methodStr;
 
 2274           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2281        if (requestInfo.
getSession().getSendedSuggestions() != null && !requestInfo.
getSession().getSendedSuggestions().isEmpty()) {
 
 2284           id = Integer.parseInt(tmpId);
 
 2285         } 
catch (NumberFormatException nfe) {
 
 2287             String msg = 
"The ID of the refused suggestion is not a number: " + tmpId;
 
 2288             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2292         if (
id != null && requestInfo.
getSession().isSuggInSendedSuggestions(id)) {
 
 2295           refused.setRefuseMethod(method);
 
 2297           requestInfo.addRefusedSuggestion(refused);
 
 2301           String msg = 
"Suggestion with the following ID not found: " + tmpId;
 
 2302           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2326     session.getSuggestionsFr().clear();
 
 2327     session.clearSuggestionsTypes();
 
 2328     boolean isFirst = 
true;  
 
 2329     int sugCnt = suggestMsg.getLength();
 
 2330     for (
int i = 0; i < sugCnt; i++) {  
 
 2331       Element suggestEl = (Element) suggestMsg.item(i);
 
 2335       String sPath = suggestEl.getAttribute(
"path");
 
 2336       String sOffset = suggestEl.getAttribute(
"offset");
 
 2337       String sLength = suggestEl.getAttribute(
"length");
 
 2339       if (sOffset == null) {  
 
 2342       if (sLength == null) {
 
 2345       Integer iSOffset = null;
 
 2346       Integer iSLength = null;
 
 2348         if (!sOffset.isEmpty()) {  
 
 2349           iSOffset = Integer.decode(sOffset);
 
 2351         if (!sLength.isEmpty()) {  
 
 2352           iSLength = Integer.decode(sLength);
 
 2355         sPath = UpdatableFragment.improveXPath(sPath);
 
 2357         fragment = 
new Fragment(sPath, iSOffset, iSLength);
 
 2358       } 
catch (NumberFormatException nfe) {  
 
 2359         int langNum = requestInfo.getSession().getLanguageNum();
 
 2360         int lod = requestInfo.getSession().getProtocolLOD();
 
 2363           String msg = 
"Bad offset or length of fragment for suggestions.";
 
 2364           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg, nfe);
 
 2368       if (fragment != null) {  
 
 2369         session.addSuggestionsFr(fragment);  
 
 2372         session.getSuggestionsFr().clear();
 
 2373         session.clearSuggestionsTypes();
 
 2375         requestInfo.setSuggFragmentChanged(
true);
 
 2381         String sType = suggestEl.getAttribute(
"type");
 
 2383         if (sType != null && sType.isEmpty()) {  
 
 2387         if (sType != null) {  
 
 2389           Object[] params = 
new Object[2];
 
 2392           List tList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri", params);
 
 2393           if (tList != null && !tList.isEmpty()) {  
 
 2398             session.getSuggestionsFr().clear();
 
 2399             session.clearSuggestionsTypes();
 
 2401             requestInfo.setSuggFragmentChanged(
true);
 
 2403             int langNum = requestInfo.getSession().getLanguageNum();
 
 2404             int lod = requestInfo.getSession().getProtocolLOD();
 
 2407               String msg = 
"Request for suggestions of unknown type: " + sType;
 
 2408               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2413         if (sType != null) {
 
 2414           session.addSuggestionType(sType);  
 
 2418               && (sPath.contentEquals(
"") || sPath.contentEquals(
"/"))
 
 2419               && iSOffset != null && iSLength != null
 
 2420               && (iSOffset == 0 && iSLength == 0)) {  
 
 2422             session.getSuggestionsFr().clear();
 
 2423             session.clearSuggestionsTypes();
 
 2429     requestInfo.setSuggFragmentChanged(
true);  
 
 2443     PersistM persistMan = AppBean.getPersistenceManager();
 
 2444     String userAtt = loginEl.getAttribute(
"user");
 
 2445     String passAtt = loginEl.getAttribute(
"password");
 
 2446     String tokenAtt = loginEl.getAttribute(
"token");
 
 2447     String systemAtt = loginEl.getAttribute(
"system");
 
 2448     if (userAtt == null) {  
 
 2451     if (passAtt == null) {
 
 2454     if (tokenAtt == null) {
 
 2457     if (systemAtt == null) {
 
 2461     if (!userAtt.isEmpty() && (!tokenAtt.isEmpty() && !systemAtt.isEmpty())) {
 
 2463       String storedToken = AppBean.getExtAuthData(systemAtt, userAtt);
 
 2464       if (storedToken == null) {  
 
 2465         int langNum = requestInfo.getSession().getLanguageNum();
 
 2466         int lod = requestInfo.getSession().getProtocolLOD();
 
 2469           String msg = 
"Unknown authentication token received.";
 
 2470           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2474       if (!tokenAtt.equals(storedToken)) {  
 
 2475         int langNum = requestInfo.getSession().getLanguageNum();
 
 2476         int lod = requestInfo.getSession().getProtocolLOD();
 
 2479           String msg = 
"Bad authentication token received.";
 
 2480           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2484       Object[] params = 
new Object[4];
 
 2485       params[0] = 
"login";
 
 2486       params[1] = userAtt;
 
 2487       params[2] = 
"comeFrom";
 
 2488       params[3] = systemAtt;      
 
 2489       List uList = persistMan.queryDB(
"User.findByLoginAndSystem", params);
 
 2490       if (uList != null && !uList.isEmpty()) {  
 
 2491         user = (
User) uList.get(0);
 
 2498     if (userAtt.isEmpty() || passAtt.isEmpty()) {  
 
 2499       int langNum = requestInfo.getSession().getLanguageNum();
 
 2500       int lod = requestInfo.getSession().getProtocolLOD();
 
 2503         String msg = 
"Login or password is missing.";
 
 2504         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2513         md5 = MessageDigest.getInstance(
"MD5");
 
 2514         md5.update(passAtt.getBytes());
 
 2515         hash = MessageProcessor.getHexString(md5.digest());
 
 2516       } 
catch (NoSuchAlgorithmException ex) {
 
 2517         int langNum = requestInfo.getSession().getLanguageNum();
 
 2518         int lod = requestInfo.getSession().getProtocolLOD();
 
 2521           String msg = 
"NoSuchAlgorithmException for MD5 algorithm.";
 
 2522           Logger.getLogger(MessageProcessor.class.getName()).log(Level.SEVERE, msg, ex);
 
 2527       Object[] params = 
new Object[4];
 
 2528       params[0] = 
"login";
 
 2529       params[1] = userAtt;
 
 2530       params[2] = 
"password";
 
 2532       List uList = persistMan.queryDB(
"User.findByCredentials", params);
 
 2533       if (uList != null && !uList.isEmpty()) {  
 
 2534         user = (
User) uList.get(0);
 
 2539         params[3] = passAtt;
 
 2540         uList = persistMan.queryDB(
"User.findByCredentials", params);
 
 2541         if (uList != null && !uList.isEmpty()) {  
 
 2542           user = (
User) uList.get(0);
 
 2547         params[0] = 
"email";
 
 2548         params[1] = userAtt;
 
 2550         uList = persistMan.queryDB(
"User.findByEmailAndPassword", params);
 
 2551         if (uList != null && !uList.isEmpty()) {  
 
 2552           user = (
User) uList.get(0);
 
 2557         params[3] = passAtt;
 
 2558         uList = persistMan.queryDB(
"User.findByEmailAndPassword", params);
 
 2559         if (uList != null && !uList.isEmpty()) {  
 
 2560           user = (
User) uList.get(0);
 
 2565         int langNum = requestInfo.getSession().getLanguageNum();
 
 2566         int lod = requestInfo.getSession().getProtocolLOD();
 
 2569           String msg = 
"Authentication by login and password failed (bad login or password).";
 
 2570           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2586     Flier flier = requestInfo.getFlier();
 
 2588     NodeList addTN = typesEl.getElementsByTagName(
"add");
 
 2589     Element addEl = (Element) addTN.item(0);
 
 2590     if (addEl != null) {  
 
 2592       NodeList addTypeNodes = addEl.getElementsByTagName(
"type");
 
 2593       int addedTypesCnt = addTypeNodes.getLength();
 
 2594       for (
int i = 0; i < addedTypesCnt; i++) {  
 
 2595         Element addedTypeEl = (Element) addTypeNodes.item(i);
 
 2598         if (addedType != null) {  
 
 2600           Object[] params = 
new Object[2];
 
 2602           params[1] = addedType.getUri();
 
 2603           List tList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri", params);
 
 2604           if (tList != null && !tList.isEmpty()) {  
 
 2605             int langNum = requestInfo.getSession().getLanguageNum();
 
 2606             int lod = requestInfo.getSession().getProtocolLOD();
 
 2607             String info = addedType.toXMLStringWA(
false);
 
 2610               String msg = 
"Attempt to create of duplicit type of annotation.";
 
 2611               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2618             flier.AddAddedType(addedType);  
 
 2625     NodeList updateTN = typesEl.getElementsByTagName(
"change");
 
 2626     if (updateTN.getLength() == 0) {  
 
 2627       updateTN = typesEl.getElementsByTagName(
"update");
 
 2629     Element updateEl = (Element) updateTN.item(0);
 
 2630     if (updateEl != null) {  
 
 2631       NodeList updateTypeNodes = updateEl.getElementsByTagName(
"type");
 
 2632       int updatedTypesCnt = updateTypeNodes.getLength();
 
 2633       for (
int i = 0; i < updatedTypesCnt; i++) {  
 
 2634         Element updatedTypeEl = (Element) updateTypeNodes.item(i);
 
 2637         if (updatedType != null) {  
 
 2638           flier.AddEditedType(updatedType);  
 
 2644     NodeList deleteTN = typesEl.getElementsByTagName(
"remove");
 
 2645     if (deleteTN.getLength() == 0) {  
 
 2646       deleteTN = typesEl.getElementsByTagName(
"delete");
 
 2648     Element deleteEl = (Element) deleteTN.item(0);
 
 2649     if (deleteEl != null) {  
 
 2650       NodeList delTypeNodes = deleteEl.getElementsByTagName(
"type");
 
 2651       int delTypesCnt = delTypeNodes.getLength();
 
 2652       for (
int i = 0; i < delTypesCnt; i++) {  
 
 2653         Element delTypeEl = (Element) delTypeNodes.item(i);
 
 2654         String delName = delTypeEl.getAttribute(
"name");
 
 2655         String delAncestor = delTypeEl.getAttribute(
"ancestor");
 
 2656         String delUri = delTypeEl.getAttribute(
"uri");
 
 2657         if (delName == null) {  
 
 2660         if (delUri == null) {
 
 2663         if (delName.isEmpty() || delUri.isEmpty()) {  
 
 2666           if (!delName.isEmpty()) {
 
 2667             info = 
"<type name=\"" + delName + 
"\"/>";
 
 2668           } 
else if (!delUri.isEmpty()) {
 
 2669             info = 
"<type uri=\"" + delUri + 
"\"/>";
 
 2671           int langNum = requestInfo.getSession().getLanguageNum();
 
 2672           int lod = requestInfo.getSession().getProtocolLOD();
 
 2675             String msg = 
"Attempt to remove type of annotation without name or URI: " + info;
 
 2676             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2680           Object[] params = 
new Object[2];
 
 2683           List dList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri", params);
 
 2684           if (dList != null && !dList.isEmpty()) {  
 
 2688             params[1] = dType.getId();
 
 2689             List aList = AppBean.getPersistenceManager().queryDB(
"Annotation.findByType", params);
 
 2690             if (aList != null && !aList.isEmpty()) {  
 
 2692               int langNum = requestInfo.getSession().getLanguageNum();
 
 2693               int lod = requestInfo.getSession().getProtocolLOD();
 
 2694               String info = 
"<type name=\"" + delName + 
"\" ancestor=\"" + delAncestor + 
"\" uri=\"" + delUri + 
"\"/>";
 
 2697                 String msg = 
"Attempt to delete used type of annotation: " + delUri;
 
 2698                 Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2702               params[0] = 
"ancestor";
 
 2703               params[1] = dType.getId();
 
 2704               List aTList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByAncestor", params);
 
 2705               if (aTList != null && !aTList.isEmpty()) {  
 
 2707                 int langNum = requestInfo.getSession().getLanguageNum();
 
 2708                 int lod = requestInfo.getSession().getProtocolLOD();
 
 2709                 String info = 
"<type name=\"" + delName + 
"\" ancestor=\"" + delAncestor + 
"\" uri=\"" + delUri + 
"\"/>";
 
 2712                   String msg = 
"Attempt to delete type of annotation with subtypes: " + delUri;
 
 2713                   Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2716                 flier.AddRemovedType(dType);  
 
 2720             int langNum = requestInfo.getSession().getLanguageNum();
 
 2721             int lod = requestInfo.getSession().getProtocolLOD();
 
 2722             String info = 
"<type name=\"" + delName + 
"\" ancestor=\"" + delAncestor + 
"\" uri=\"" + delUri + 
"\"/>";
 
 2725               String msg = 
"Attempt to delete unknown type of annotation: " + delUri;
 
 2726               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2745     Flier flier = requestInfo.getFlier();
 
 2751     String[] namesArr = namesStr.split(
"/");
 
 2752     ArrayList<String> names = 
new ArrayList<String>(Arrays.asList(namesArr));
 
 2753     int nSize = names.size();  
 
 2756       String typeName = names.remove(nSize - 1);
 
 2758       type.setName(typeName);  
 
 2762         String nextName = nextType.getName();
 
 2764         String prevName = names.remove(nSize - 1);
 
 2767         String nUri = nextType.getUri();
 
 2770         String prevUri = nUri.substring(0, nUri.lastIndexOf(
"/"));
 
 2772         boolean foundInNewTypes = 
false;
 
 2775         Object[] params = 
new Object[2];
 
 2777         params[1] = prevUri;
 
 2778         List tList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri", params);
 
 2779         if (tList != null && !tList.isEmpty()) {  
 
 2781           nextType.setAncestorType(prevType);  
 
 2782           nextType.addAncestorType(prevType);
 
 2785         else if (flier.
getAddedTypes() != null && !flier.getAddedTypes().isEmpty()) {
 
 2786           Iterator<AnnotType> newTypesIt = flier.getAddedTypes().iterator();
 
 2787           while (newTypesIt.hasNext()) {
 
 2789             if (newType.
getUri().equals(prevUri)) {
 
 2790               nextType.setAncestorType(newType);  
 
 2791               nextType.addAncestorType(newType);
 
 2792               foundInNewTypes = 
true;
 
 2799         if (!foundInNewTypes) {
 
 2802           nextType.setAncestorType(newType);  
 
 2803           nextType.addAncestorType(newType);
 
 2804           flier.AddAddedType(newType);  
 
 2819       String type = entityReqEl.getAttribute(
"type");
 
 2820       String filter = entityReqEl.getAttribute(
"filter");
 
 2822       if(filter.isEmpty()){
 
 2823         int langNum = requestInfo.getSession().getLanguageNum();
 
 2824         int lod = requestInfo.getSession().getProtocolLOD();
 
 2827         requestInfo.setSettings(requestInfo.getSession().getSettings());
 
 2829           String msg = 
"Empty filter of parameter of dictionary request.";
 
 2830           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2835       requestInfo.setEntityRequest(
new RequestInfo.EntityRequest(type,filter));
 
 2849     String name = typeEl.getAttribute(
"name");
 
 2850     String ancestor = typeEl.getAttribute(
"ancestor");
 
 2851     String uri = typeEl.getAttribute(
"uri");
 
 2852     String group = typeEl.getAttribute(
"group");
 
 2859     if (ancestor == null) {
 
 2862     if (name.isEmpty()) {  
 
 2863       int langNum = requestInfo.getSession().getLanguageNum();
 
 2864       int lod = requestInfo.getSession().getProtocolLOD();
 
 2868           String msg = 
"Empty name of updated type of annotation.";
 
 2869           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2874           String msg = 
"New type of annotation without name.";
 
 2875           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 2881     PersistM pm = AppBean.getPersistenceManager();
 
 2882     Object[] params = 
new Object[2];  
 
 2884     Integer groupId = null;
 
 2885     if (group != null && !group.isEmpty()) {  
 
 2887       String groupIdStr = group.replace(AppBean.getBaseGroupUri(), 
"");
 
 2890         groupId = Integer.parseInt(groupIdStr);
 
 2891       } 
catch (NumberFormatException nfe) {  
 
 2893         int langNum = requestInfo.getSession().getLanguageNum();
 
 2894         int lod = requestInfo.getSession().getProtocolLOD();
 
 2895         String info = 
"<group id=\"" + group + 
"\"/>";
 
 2898           String msg = 
"Bad group in type of annotation: " + groupIdStr;
 
 2899           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg, nfe);
 
 2906     if (groupId == null) {  
 
 2909         String groupIdStr = uri.replace(AppBean.getBaseTypeUri() + 
"g", 
"");
 
 2911         int index = groupIdStr.indexOf(
"/");
 
 2914           groupIdStr = groupIdStr.substring(0,index);
 
 2917             groupId = Integer.parseInt(groupIdStr);
 
 2918           } 
catch (NumberFormatException nfe) {  
 
 2920             int langNum = requestInfo.getSession().getLanguageNum();
 
 2921             int lod = requestInfo.getSession().getProtocolLOD();
 
 2922             String info = 
"<group id=\"" + group + 
"\"/>";
 
 2925               String msg = 
"Bad group in URI of type of annotation: " + groupIdStr;
 
 2926               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg, nfe);
 
 2936     if (groupId == null && ancestor != null && !ancestor.isEmpty()) {
 
 2939         String groupIdStr = ancestor.replace(AppBean.getBaseTypeUri() + 
"g", 
"");
 
 2941         int index = groupIdStr.indexOf(
"/");
 
 2944           groupIdStr = groupIdStr.substring(0,index);
 
 2947             groupId = Integer.parseInt(groupIdStr);
 
 2948           } 
catch (NumberFormatException nfe) {  
 
 2950             int langNum = requestInfo.getSession().getLanguageNum();
 
 2951             int lod = requestInfo.getSession().getProtocolLOD();
 
 2952             String info = 
"<group id=\"" + group + 
"\"/>";
 
 2955               String msg = 
"Bad group in ancestor type of annotation: " + groupIdStr;
 
 2956               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg, nfe);
 
 2965     if (groupId == null) {  
 
 2968         String groupIdStr = uri.replace(
"g", 
"");
 
 2970         groupIdStr = MessageProcessor.replaceArrows(groupIdStr);
 
 2972         int index = groupIdStr.indexOf(
"/");
 
 2975           groupIdStr = groupIdStr.substring(0,index);
 
 2978             groupId = Integer.parseInt(groupIdStr);
 
 2979             int index1 = name.indexOf(
"-> ");
 
 2980             int index2 = name.indexOf(
"->");
 
 2981             if (index1 < index2 && index1 > 0) {  
 
 2983               name = name.substring(index1 + 3);
 
 2984             } 
else if (index2 > 0) {  
 
 2986               name = name.substring(name.indexOf(
"->") + 2);
 
 2991           } 
catch (NumberFormatException nfe) {  
 
 2994           } 
catch (Exception e) {  
 
 3003     if (groupId != null) {  
 
 3006       params[1] = groupId;
 
 3007       List gList = AppBean.getPersistenceManager().queryDB(
"UserGroup.findById", params);
 
 3009       if (gList != null && !gList.isEmpty()) {  
 
 3015         int langNum = requestInfo.getSession().getLanguageNum();
 
 3016         int lod = requestInfo.getSession().getProtocolLOD();
 
 3017         String info = 
"<group id=\"" + AppBean.getBaseGroupUri() + groupId + 
"\"/>";
 
 3020           String msg = 
"Unknown user group in the type of annotation: " + info;
 
 3021           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3026     if (uGroup == null) {  
 
 3027       uGroup = requestInfo.getSession().getDefaultGroup();
 
 3030     if (uGroup == null) {  
 
 3032       int langNum = requestInfo.getSession().getLanguageNum();
 
 3033       int lod = requestInfo.getSession().getProtocolLOD();
 
 3034       String info = 
"<type name=\"" + name + 
"\"/>";
 
 3037         String msg = 
"All attempts to getting of user group for type of annotation failed.";
 
 3038         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3044     if (!ancestor.isEmpty()) {  
 
 3047         ancestor = ancestor.substring(0, AppBean.getBaseTypeUri().length()) 
 
 3048           + 
"g" + requestInfo.
getSession().getDefaultGroup().getId() + 
"/"  
 3049           + ancestor.substring(AppBean.getBaseTypeUri().length(),ancestor.length());
 
 3053       params[1] = ancestor;
 
 3054       List aList = pm.queryDB(
"AnnotType.findByUri", params);
 
 3055       if (aList != null && !aList.isEmpty()) {  
 
 3056         ancestorType = (
AnnotType) aList.get(0);
 
 3059         Iterator<AnnotType> atIter = (Iterator<AnnotType>) requestInfo.
getFlier().getAddedTypes().iterator();
 
 3060         while (atIter.hasNext() && ancestorType == null) {  
 
 3062           if (addedT.
getUri().equals(ancestor)) {  
 
 3063             ancestorType = addedT;
 
 3066         if (ancestorType == null) {  
 
 3068           int langNum = requestInfo.getSession().getLanguageNum();
 
 3069           int lod = requestInfo.getSession().getProtocolLOD();
 
 3070           String info = 
"<type name=\"" + name + 
"\" uri=\"" + uri + 
"\"/>";
 
 3074               String msg = 
"Bad ancestor type in updated type of annotation: " + info;
 
 3075               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3080               String msg = 
"Bad ancestor type in new type of annotation: " + info;
 
 3081               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3089     if (uri.isEmpty() && update) {  
 
 3091       int langNum = requestInfo.getSession().getLanguageNum();
 
 3092       int lod = requestInfo.getSession().getProtocolLOD();
 
 3093       String info = 
"<type name=\"" + name + 
"\"/>";
 
 3096         String msg = 
"Attempt to update type of annotation without URI.";
 
 3097         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3107       List utList = pm.queryDB(
"AnnotType.findByUri", params);
 
 3108       if (utList != null && !utList.isEmpty()) {  
 
 3111         int langNum = requestInfo.getSession().getLanguageNum();
 
 3112         int lod = requestInfo.getSession().getProtocolLOD();
 
 3113         String info = 
"<type name=\"" + name + 
"\" ancestor=\"" + ancestor + 
"\" uri=\"" + uri + 
"\"/>";
 
 3116           String msg = 
"Unknown type of annotation for update: " + info;
 
 3117           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3122       if (!qType.
getName().equals(name)) {
 
 3124         int langNum = requestInfo.getSession().getLanguageNum();
 
 3125         int lod = requestInfo.getSession().getProtocolLOD();
 
 3126         String info = 
"<type name=\"" + name + 
"\" uri=\"" + uri + 
"\"/>";
 
 3129           String msg = 
"Attempt to change name of the type of annotation: "  
 3130                        + qType.getName() + 
" - " + name;
 
 3131           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3137         if (!qType.
getGroup().equals(uGroup)) {
 
 3139           int langNum = requestInfo.getSession().getLanguageNum();
 
 3140           int lod = requestInfo.getSession().getProtocolLOD();
 
 3141           String info = 
"<type name=\"" + name + 
"\" uri=\"" + uri + 
"\"/>";
 
 3144             String msg = 
"Attempt to change group of the type of annotation.";
 
 3145             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3151           String msg = 
"Type of annotation without the user group..";
 
 3152           Logger.getLogger(MessageProcessor.class.getName()).log(Level.SEVERE, msg);
 
 3159           int langNum = requestInfo.getSession().getLanguageNum();
 
 3160           int lod = requestInfo.getSession().getProtocolLOD();
 
 3161           String info = 
"<type name=\"" + name + 
"\"  ancestor=\"" + qType.getAncestorType().getUri() + 
"\" uri=\"" + uri + 
"\"/>";
 
 3164             String msg = 
"Attempt to change ancestor type of annotation.";
 
 3165             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3169       } 
else if (!ancestor.isEmpty()) {  
 
 3171         int langNum = requestInfo.getSession().getLanguageNum();
 
 3172         int lod = requestInfo.getSession().getProtocolLOD();
 
 3173         String info = 
"<type name=\"" + name + 
"\"  ancestor=\"\" uri=\"" + uri + 
"\"/>";
 
 3176           String msg = 
"Attempt to change ancestor type of annotation.";
 
 3177           Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3184     String comment = null;
 
 3185     NodeList commentNL = typeEl.getElementsByTagName(
"comment");
 
 3186     if (commentNL.getLength() != 0) {
 
 3187       Element commentEl = (Element) commentNL.item(0);
 
 3188       comment = MessageProcessor.getElementContent(commentEl);
 
 3193     retType = 
new AnnotType(uri, name, ancestorType, uGroup);
 
 3195     retType.setComment(comment);  
 
 3198     if (!update && uri.isEmpty()) {
 
 3199       uri = retType.getGeneratedURI();
 
 3200       retType.setUri(uri);
 
 3204       int langNum = requestInfo.getSession().getLanguageNum();
 
 3205       int lod = requestInfo.getSession().getProtocolLOD();
 
 3206       String info = 
"<type name=\"" + name + 
"\" uri=\"" + uri + 
"\"/>";
 
 3209         String msg = 
"URI of type of annotation is not matching to generated one: " 
 3210                      + uri + 
" != " + retType.getGeneratedURI();
 
 3211         Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3217     ArrayList<AnnotTypeAttr> newAttrs = 
new ArrayList<AnnotTypeAttr>();
 
 3219     NodeList attNodes = typeEl.getElementsByTagName(
"attribute");
 
 3220     int attNCnt = attNodes.getLength();  
 
 3221     NodeList attNodes2 = typeEl.getElementsByTagName(
"a:attribute");  
 
 3222     int attNCnt2 = attNodes2.getLength();  
 
 3223     if (attNCnt2 > 0 && attNCnt == 0) {  
 
 3225       attNodes = attNodes2;
 
 3228     String groupsS = 
"";
 
 3229     if (uGroup != null) {
 
 3230       groupsS = 
" group=\"" + uGroup.getUri() + 
"\"";
 
 3232     String errInfo = 
"<type name=\"" + name + 
"\" uri=\"" + uri + 
"\"" + groupsS + 
">";
 
 3235     ArrayList<String> namesArr = 
new ArrayList<String>();  
 
 3236     ArrayList<String> namesTypesArr = 
new ArrayList<String>();  
 
 3238     for (
int i = 0; i < attNCnt; i++) {  
 
 3239       Element attrEl = (Element) attNodes.item(i);
 
 3240       String attrName = attrEl.getAttribute(
"name");
 
 3241       String attrType = attrEl.getAttribute(
"type");
 
 3242       String priorityStr = attrEl.getAttribute(
"priority");
 
 3243       String attrRequiredStr = attrEl.getAttribute(
"required");
 
 3244       Boolean attrRequired = Boolean.parseBoolean(attrRequiredStr);
 
 3246       Integer priority = null;
 
 3247       if (priorityStr != null) {
 
 3249           priority = Integer.parseInt(priorityStr);
 
 3250         } 
catch (NumberFormatException ex) {
 
 3254       if (priority == null) {
 
 3259       String attrComment = null;
 
 3260       NodeList attrCommentNL = attrEl.getElementsByTagName(
"comment");
 
 3261       if (attrCommentNL.getLength() != 0) {
 
 3262         Element attrCommentEl = (Element) attrCommentNL.item(0);
 
 3263         attrComment = MessageProcessor.getElementContent(attrCommentEl);
 
 3265       attrCommentNL = attrEl.getElementsByTagName(
"a:comment");
 
 3266       if (attrComment == null && attrCommentNL.getLength() != 0) {
 
 3267         Element attrCommentEl = (Element) attrCommentNL.item(0);
 
 3268         attrComment = MessageProcessor.getElementContent(attrCommentEl);
 
 3274         newAttr.setPriority(priority);
 
 3275         newAttr.setComment(attrComment);  
 
 3276         if (namesArr.contains(attrName)) {  
 
 3277           int index = namesArr.indexOf(attrName);
 
 3278           if (namesTypesArr.get(index).equals(attrName + attrType)) {
 
 3281           errInfo = errInfo.concat(
"<attribute name=\"" + attrName + 
"\" type=\"" 
 3282                   + attrType + 
"\"/>");
 
 3285             String msg = 
"Duplicit attribute of the type of annotation.";
 
 3286             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3289           newAttrs.add(newAttr);  
 
 3290           namesArr.add(attrName);  
 
 3291           namesTypesArr.add(attrName + attrType);
 
 3296         params[1] = attrType;
 
 3297         List tList = pm.queryDB(
"AnnotType.findByUri", params);
 
 3298         if (tList != null && !tList.isEmpty()) {  
 
 3302           newAttr.setPriority(priority);
 
 3303           newAttr.setComment(attrComment);  
 
 3304           if (namesArr.contains(attrName)) {  
 
 3305             int index = namesArr.indexOf(attrName);
 
 3306             if (namesTypesArr.get(index).equals(attrName + attrType)) {
 
 3309             errInfo = errInfo.concat(
"<attribute name=\"" + attrName + 
"\" type=\"" 
 3310                     + attrType + 
"\"/>");
 
 3313               String msg = 
"Duplicit attribute of the type of annotation.";
 
 3314               Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3317             newAttrs.add(newAttr);  
 
 3318             namesArr.add(attrName);  
 
 3319             namesTypesArr.add(attrName + attrType);
 
 3322           errInfo = errInfo.concat(
"<attribute name=\"" + attrName + 
"\" type=\"" 
 3323                   + attrType + 
"\"/>");
 
 3326             String msg = 
"Unknown structured type of attribute of the type of annotation: " + attrType;
 
 3327             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3335     ArrayList<AnnotType> newAncestors = 
new ArrayList<AnnotType>();
 
 3337     NodeList ancNodes = typeEl.getElementsByTagName(
"ancestor");
 
 3338     int ancNCnt = ancNodes.getLength();  
 
 3340     for (
int i = 0; i < ancNCnt; i++) {  
 
 3341       Element ancEl = (Element) ancNodes.item(i);
 
 3342       String ancTypeUri = ancEl.getAttribute(
"uri");
 
 3347       params[1] = ancTypeUri;
 
 3348       List tList = pm.queryDB(
"AnnotType.findByUri", params);
 
 3349       if (tList != null && !tList.isEmpty()) {  
 
 3351         newAncestors.add(ancType);  
 
 3354         Iterator<AnnotType> ancIter = (Iterator<AnnotType>) requestInfo.
getFlier().getAddedTypes().iterator();
 
 3355         while (ancIter.hasNext() && ancestorType == null) {  
 
 3357           if (addedT.
getUri().equals(ancTypeUri)) {  
 
 3361         if (ancType == null) {  
 
 3362           errInfo = errInfo.concat(
"<ancestor uri=\"" + ancTypeUri + 
"\"/>");
 
 3365             String msg = 
"Unknown ancestor in the list of ancestors of the type of annotation: "  
 3367             Logger.getLogger(MessageProcessor.class.getName()).log(Level.ALL, msg);
 
 3370           newAncestors.add(ancType);  
 
 3376     if (!newAncestors.contains(ancestorType) && ancestorType != null) {
 
 3377       newAncestors.add(ancestorType);
 
 3380     if (!newAncestors.isEmpty() && ancestorType == null) {
 
 3381       ancestorType = newAncestors.get(0);
 
 3382       retType.setAncestorType(ancestorType);
 
 3386       if (errCnt > 0 || ancErrCnt > 0) {  
 
 3387         errInfo = errInfo.concat(
"</type>");  
 
 3389         int langNum = requestInfo.getSession().getLanguageNum();
 
 3390         int lod = requestInfo.getSession().getProtocolLOD();
 
 3395         retType.setAttributes(newAttrs);  
 
 3396         retType.setAncestorTypes(newAncestors);  
 
 3397         retType.setId(qType.getId());  
 
 3400       if (errCnt > 0 || ancErrCnt > 0) {  
 
 3401         errInfo = errInfo.concat(
"</type>");  
 
 3405         int langNum = requestInfo.getSession().getLanguageNum();
 
 3406         int lod = requestInfo.getSession().getProtocolLOD();
 
 3409       if (ancErrCnt > 0) {  
 
 3411         int langNum = requestInfo.getSession().getLanguageNum();
 
 3412         int lod = requestInfo.getSession().getProtocolLOD();
 
 3416       retType.setAttributes(newAttrs);
 
 3418       retType.setAncestorTypes(newAncestors);
 
static void processTextModificationMsg(NodeList tmMsg, RequestInfo requestInfo)
static final int ERROR_43_NOT_SYNCHRONIZED
static boolean isGroupIncluded(String gStr)
static final int ERROR_20_TYPE_NAME_MODIFY
static final int ERROR_40_BAD_SUGG_TYPE
static final int ERROR_15_ATTRIBUTE_TYPE_UNAVAILABLE
static final int ERROR_1_BAD_CREDENTIALS
static void processJoin(NodeList joinMsgs, RequestInfo requestInfo)
AnnotDocument getSyncDocument()
static void processSuggestions(NodeList suggestMsg, RequestInfo requestInfo)
static final int LOG_LEVEL_ALL_ERRORS
Persistence manager (database manipulator) 
static final int ERROR_100_UNKNOWN_ERROR
static final int ERROR_24_BAD_SOURCE_IN_ANNOT
Class representing attribute of type of annotation. 
static void processRefSuggestions(Element refSuggestEl, RequestInfo requestInfo)
static void logAttributeError(String errAnnotInfo, String name, String type, RequestInfo requestInfo, int errorCode, String message)
static final int ERROR_54_BAD_ANNOT_DESCRIPTION
boolean containsSource(SubscribedSource source)
Abstract class representing more complex attribute. 
static final int ERROR_23_MISSING_DOCUMENT_CONTENT
static void breakdownType(AnnotType type, RequestInfo requestInfo)
Class representing annotated copy of document. 
static Annotation processAddedAnnotEl(Element addedAnnotEl, RequestInfo requestInfo)
static BaseAttribute processAttributeEl(Element attributeEl, Annotation annot, RequestInfo requestInfo, int order, Integer cMethod)
static final int ERROR_41_BAD_DATE_FORMAT_ANNOT
static boolean containsType(String type)
static void processSynchronize(Element synchronizeEl, RequestInfo requestInfo)
static final int LOG_LEVEL_SERVER_INTERNAL_ERRORS
AnnotType getAncestorType()
Singleton for storing global variables. 
Class which process XML with messages in 4A protocol v 1.x. 
static final boolean AUTO_SUBSCRIBE_OWN_GROUPS
static String getBaseTypeUri()
static final int ERROR_49_DUPLICIT_TYPE
static final int ERROR_45_UNKNOWN_GROUP
static final int REFUSED_AUTOMATICALLY
static void processUnsubscribe(Element unsubscribeEl, EditorSession session, RequestInfo requestInfo)
static final int ERROR_26_ATTRIBUTE_MALFORMED
static final int ERROR_51_TYPE_W_SUBTYPE_DEL
Class representing attribute of type AnnotationLink. 
static User processLogin(Element loginEl, RequestInfo requestInfo)
static final String ADMIN_GROUP
static final int ERROR_30_REM_ANNOT_NOT_FOUND
static final int ERROR_22_MISSING_DOCUMENT_URI
static final int ERROR_97_NOT_IN_GROUP
boolean containsUnsubscribedSource(SubscribedSource source)
static final ArrayList< String > SIMPLE_TYPES
Suggested annotation with informations about suggestion. 
Static class which parses and process XML with messages. 
Class representing user group. 
static final int ERROR_56_BAD_ANNOT_TYPE_URI
static void processReload(NodeList reloadMsg, RequestInfo requestInfo)
Class representing parameter of user settings. 
static final int ERROR_25_BAD_FRAGMENT
RequestInfo processXML(Element docEl, RequestInfo requestInfo)
static final int ERROR_58_LAST_ADMIN
static final int ERROR_47_USED_TYPE_DEL
static final int ERROR_17_TYPE_ATTRIBUTES_MALFORMED
static final int ERROR_57_JOIN_ADMINISTRATORS
Base class representing attribute of annotation. 
Class for XML document fragment. 
static final int LOG_LEVEL
static final int ERROR_46_UNKNOWN_GROUP_TYPE
Class representing type of annotation. 
Class representing modification of annotated document text. 
static void processResynchronize(Element resynchronizeEl, RequestInfo requestInfo)
Flier with informations for comet handlers. 
EditorSession getSession()
static final int LOG_LEVEL_ALL
static final int ERROR_63_EMPTY_ENTITY_FILTER
static final boolean TEST_ANNOT_LINK_URI
static AnnotType processTypeEl(Element typeEl, RequestInfo requestInfo, boolean update)
static String getBaseAuthorUri()
static Annotation processRemAnnotEl(Element remAnnotEl, RequestInfo requestInfo)
UserGroup getDefaultGroup()
static void processAnnotations(Element annotationsEl, RequestInfo requestInfo)
static final int ERROR_50_BAD_MODIFICATION
static final int LOG_LEVEL_SERVER_ERRORS
static final int ERROR_8_SUG_FRAGMENT
ArrayList< SuggestionLogEntry > getConfirmedSuggestions()
static final int ERROR_29_CHANGED_ANNOT_NOT_FOUND
static final int ERROR_27_UNKNOWN_PERSON_ATTRIBUTE
static final int WARNING_5_NOT_LOGGED_IN
Class attribute manager provides a way how to create new attributes. 
static final int ERROR_44_ANNOT_AUTHOR
Processed informations about client request. 
static Fragment processFragmentEl(Element fragmentEl, Annotation annot, RequestInfo requestInfo)
static void processSettings(Element settingsEl, RequestInfo requestInfo)
static void processEntityRequest(Element entityReqEl, RequestInfo requestInfo)
static void processTypes(Element typesEl, RequestInfo requestInfo)
static Annotation processAnnotationDescEl(Element annotationEl, RequestInfo requestInfo, Annotation nestedIn, Integer cMethod)
static final int ERROR_7_ATTRIBUTE_VALUE
Class responsible for localised strings. 
static final int CONFIRMED_AUTOMATICALLY
static Annotation processEditedAnnotEl(Element updatedAnnotEl, RequestInfo requestInfo)
Subscribed source of annotations. 
Informations about client session. 
Utility class (manipulates RFC 3339 dates) 
ArrayList< AnnotType > getAddedTypes()
static final int ERROR_55_TYPE_ANCESTORS_MALFORMED
Class representing annotated fragment. 
static final int ERROR_16_TYPE_MALFORMED
static final int ERROR_34_RELOAD_ANNOT_NOT_FOUND
Class representing attribute of type Person. 
static final int ERROR_21_SETTINGS_MALFORMED
static final int ERROR_19_TYPE_UNKNOWN
Class representing annotation. 
static final int ERROR_28_BAD_CONFIRM
static final int ERROR_18_BAD_EDITED_TYPE
static void processLeave(NodeList leaveMsgs, RequestInfo requestInfo)
static void processSubscribe(Element subscribeEl, EditorSession session, RequestInfo requestInfo)