17 package cz.vutbr.fit.knot.annotations.modules;
23 import cz.vutbr.fit.knot.annotations.comet.*;
27 import cz.vutbr.fit.knot.annotations.entity.*;
42 import java.net.URISyntaxException;
44 import java.util.concurrent.locks.ReentrantLock;
45 import java.util.logging.Level;
46 import java.util.logging.Logger;
47 import javax.persistence.EntityManager;
48 import javax.persistence.Query;
49 import javax.xml.xpath.XPathExpressionException;
50 import org.w3c.dom.Document;
149 }
catch(Exception ex){
151 AppBean.getLockMaster().getDocumentLock(requestInfo.
getSession().getSyncDocument().getId()).unlockForChange();
152 Logger.getLogger(DrupAuthServlet.class.getName()).log(Level.SEVERE,
"Exception during document update:", ex.getMessage());
170 Flier flier = requestInfo.getFlier();
173 List<Integer> IDs =
new ArrayList<Integer>();
174 Iterator<Annotation> removedAnnotIt = flier.getRemovedAnnotations().iterator();
175 while (removedAnnotIt.hasNext()) {
179 if (!IDs.isEmpty()) {
180 remAnnot.addAllLinkedByBeforeRemove(IDs);
208 if (requestInfo.
getSettings() != null && !requestInfo.getSettings().isEmpty()) {
209 requestInfo.getSession().actualizeAllCachedSettings();
215 requestInfo.getSession().initDocumentUsageAndTMNumber();
217 retStr = retStr +
"<synchronized resource=\"" + AppBean.getBaseDocumentUri() + doc.
getId()
220 retStr = retStr +
"<synchronized resource=\"" + AppBean.getBaseDocumentUri() + doc.
getId()
221 +
"\" lastModification=\"" + AppBean.getLastDocModification(doc.getId()) +
"\"/>";
226 if (!persistFailed && requestInfo.
getSession().getUser() != null
228 AppBean.refreshUsersInSessions(requestInfo.getSession().getUser());
238 if (requestInfo.
getFlier() != null && requestInfo.getFlier().getAutoUpdatedAnnotations() != null
239 && !requestInfo.getFlier().getAutoUpdatedAnnotations().isEmpty()) {
241 boolean pFailed = Persister.persistAUpdAnnot(requestInfo);
243 int langNum = requestInfo.getSession().getLanguageNum();
244 int lod = requestInfo.getSession().getProtocolLOD();
247 requestInfo.getFlier().setAutoUpdatedAnnotations(
new ArrayList<Annotation>());
255 if (requestInfo.
getSyncDocument() != null || requestInfo.getReloadAll()) {
256 if (requestInfo.
getSession().getSyncDocument() != null) {
262 if (!requestInfo.
getFlier().getAddedTypes().isEmpty()
264 boolean withAnc =
true;
268 Iterator<AnnotType> tIter = requestInfo.getFlier().getAddedTypes().iterator();
270 retStr = retStr +
"<types><add>";
271 while (tIter.hasNext()) {
273 retStr = retStr + annotType.toXMLString(withAnc);
275 retStr = retStr +
"</add></types>";
289 if(requestInfo.
getUnsubscribeList() != null && !requestInfo.getUnsubscribeList().isEmpty()){
291 Iterator<Subscription> chngedSubsIt = requestInfo.getUpdatedSubscriptions().iterator();
292 while(chngedSubsIt.hasNext()){
298 if(requestInfo.
getUnsubscribeList() != null && !requestInfo.getUnsubscribeList().isEmpty()){
300 Iterator<Subscription> deletedSubsIt = requestInfo.getUnsubscribeList().iterator();
301 while(deletedSubsIt.hasNext()){
304 if(requestInfo.
getSession().isInSubscribeList(actualSubscription)){
305 requestInfo.getSession().deleteFromSubscribes(actualSubscription);
306 requestInfo.getSession().deleteFromSubscribeList(actualSubscription);
312 if(requestInfo.
getNewSubscriptions() != null && !requestInfo.getNewSubscriptions().isEmpty()){
314 Iterator <Subscription> subsIt = requestInfo.getNewSubscriptions().iterator();
315 while(subsIt.hasNext()){
318 StringBuilder newSubs =
new StringBuilder();
319 newSubs.append(
"<subscriptionCreated tmpId=\"");
320 newSubs.append(currentSubs.getTmpId().toString());
321 newSubs.append(
"\" uri=\"");
322 newSubs.append(AppBean.getBaseSubscriptionUri());
323 newSubs.append(currentSubs.getId());
324 newSubs.append(
"\"/>");
325 retStr = retStr + newSubs.toString();
330 if(requestInfo.
getSubscribeList() != null && !requestInfo.getSubscribeList().isEmpty()){
332 Iterator <Subscription> subsIt = requestInfo.getSubscribeList().iterator();
333 while(subsIt.hasNext()){
335 if(!requestInfo.
getSession().isInSubscribeList(currentSubs)){
336 requestInfo.getSession().addToSubscribes(currentSubs);
337 requestInfo.getSession().addToSubscribeList(currentSubs);
343 ArrayList<Annotation> confirmedSugs =
new ArrayList<Annotation>();
346 Iterator<SuggestionLogEntry> slIt = requestInfo.getConfirmedSuggestions().iterator();
347 while (slIt.hasNext()) {
349 Annotation confirmed = sle.getConfirmedVersion();
350 confirmedSugs.add(confirmed);
356 && requestInfo.
getFlier().getAddedAnnotations() != null
357 && !requestInfo.
getFlier().getAddedAnnotations().isEmpty()){
359 String addedStr =
"";
360 ArrayList<Annotation> addApprovedAnnotations =
new ArrayList<Annotation>();
361 ArrayList<Annotation> unapprovedAnnotations =
new ArrayList<Annotation>();
362 Iterator<Annotation> annotIter = requestInfo.getFlier().getAddedAnnotations().iterator();
365 while (annotIter.hasNext()) {
368 addApprovedAnnotations.add(annot);
370 unapprovedAnnotations.add(annot);
374 addApprovedAnnotations =
getRelatedAnnotations(addApprovedAnnotations, unapprovedAnnotations, session);
377 Iterator<Annotation> approvedIter = addApprovedAnnotations.iterator();
378 ArrayList<Annotation> printedAn =
new ArrayList<Annotation>();
380 while (approvedIter.hasNext()) {
382 if (printedAn.contains(annot)) {
385 if (confirmedSugs.contains(annot)) {
388 printedAn.add(annot);
389 if(requestInfo.
getFlier().isInJustAdded(annot.getURIV2())){
390 String tmpUri = requestInfo.getFlier().getTmpUri(annot.
getURIV2());
392 addedStr = addedStr +
"<annotation tempUri=\"" + tmpUri +
"\" servUri=\"" + annot.getURIV2() +
"\"/>";
396 Iterator<String> nestedAnnotURIIt = nestedAnnotURIs.iterator();
397 while(nestedAnnotURIIt.hasNext()){
398 String nestedUri = nestedAnnotURIIt.next();
399 String tmpNestedUri = requestInfo.getFlier().getTmpUri(nestedUri);
401 if(tmpNestedUri != null){
402 addedStr = addedStr +
"<annotation tempUri=\"" + tmpNestedUri +
"\" servUri=\"" + nestedUri +
"\"/>";
408 if(!addedStr.isEmpty()){
409 retStr = retStr +
"<annotationsCreated>" + addedStr +
"</annotationsCreated>";
416 String autoConfStr =
"";
417 String removeSugsStr =
"";
418 Iterator<Annotation> csIt = confirmedSugs.iterator();
419 ArrayList<String> attFilter = requestInfo.getSession().getAttFilter();
420 int lNum = requestInfo.getSession().getLanguageNum();
421 Boolean KBRefMode = requestInfo.getSession().getKBRefMode();
422 while (csIt.hasNext()) {
425 confStr = confStr + confirmed.toXMLStringV2(attFilter, lNum, KBRefMode);
428 autoConfStr = autoConfStr + confirmed.toXMLStringV2(attFilter, lNum, KBRefMode);
429 removeSugsStr = removeSugsStr +
"<suggestion uri=\"" + AppBean.getBaseUri() +
"/sugg/" + confirmed.
getTmpId() +
"\"/>";
431 confStr = confStr +
"<suggestion suggUri=\"" + AppBean.getBaseUri() +
"/sugg/"
432 + confirmed.
getTmpId() +
"\" servUri=\"" + confirmed.getURIV2() +
"\"/>";
436 if (!confStr.isEmpty()) {
438 retStr = retStr +
"<addAnnotations>" + confStr +
"</addAnnotations>";
440 retStr = retStr +
"<suggestionsConfirmed>" + confStr +
"</suggestionsConfirmed>";
441 if (!autoConfStr.isEmpty()) {
442 String cometStr =
"<addAnnotations>" + autoConfStr +
"</addAnnotations>"
443 +
"<removeSuggestions>" + removeSugsStr +
"</removeSuggestions>";
444 requestInfo.getSession().addMessageTS(cometStr);
445 requestInfo.getSession().notifyComet();
468 boolean proto11 = session.getProtocolLOD() > 1;
469 boolean normalTMadded =
false;
473 && flier.getCreatedInSessId() != session.
getSessionId() &&
474 !flier.getTextModifications().isEmpty()) {
478 normalTMadded =
true;
479 tModStr =
"<modification id=\"" + flier.getTextModificationSetID() +
"\">";
481 Iterator<TextModification> modIter = flier.getTextModifications().iterator();
483 while (modIter.hasNext()) {
485 tModStr = tModStr + tMod.toXMLString();
489 while (modIter.hasNext()) {
491 tModStr = tModStr + tMod.toXMLStringV2();
494 retStr = retStr + tModStr;
500 && !flier.getReverseTextModifications().isEmpty()) {
503 tModStr =
"<modification id=\"" + flier.getTextModificationSetID() +
"\">";
505 Iterator<TextModification> modIter = flier.getReverseTextModifications().iterator();
507 while (modIter.hasNext()) {
509 tModStr = tModStr + tMod.toXMLString();
513 while (modIter.hasNext()) {
515 tModStr = tModStr + tMod.toXMLStringV2();
518 retStr = retStr + tModStr;
520 normalTMadded =
false;
521 retStr = retStr +
"</modification>";
526 retStr = retStr +
"</modification>";
530 boolean withAnc =
true;
535 if (session.
getQueriedTypes() == null || session.getQueriedTypes().isEmpty()) {
536 String addedTStr =
"";
537 Iterator<AnnotType> typeIter = flier.getAddedTypes().iterator();
538 while (typeIter.hasNext()) {
543 if (session.
getSessionId() != flier.getCreatedInSessId()){
544 addedTStr = addedTStr + type.toXMLStringV2(withAnc);
547 addedTStr = addedTStr + type.toXMLString(withAnc);
552 if (!addedTStr.isEmpty()) {
554 addedTStr =
"<addTypes>" + addedTStr +
"</addTypes>";
556 addedTStr =
"<add>" + addedTStr +
"</add>";
560 String updatedTStr =
"";
561 typeIter = flier.getEditedTypes().iterator();
562 while (typeIter.hasNext()) {
567 if (session.
getSessionId() != flier.getCreatedInSessId()){
568 updatedTStr = updatedTStr + type.toXMLStringV2(withAnc);
571 updatedTStr = updatedTStr + type.toXMLString(withAnc);
576 if (!updatedTStr.isEmpty()) {
578 updatedTStr =
"<modifyTypes>" + updatedTStr +
"</modifyTypes>";
580 updatedTStr =
"<change>" + updatedTStr +
"</change>";
584 String deletedTStr =
"";
585 typeIter = flier.getRemovedTypes().iterator();
586 while (typeIter.hasNext()) {
587 if(session.
getSessionId() != flier.getCreatedInSessId()){
591 deletedTStr = deletedTStr + type.toXMLStringWA(withAnc);
595 if (!deletedTStr.isEmpty()) {
598 deletedTStr =
"<removeTypes>" + deletedTStr +
"</removeTypes>";
600 deletedTStr =
"<remove>" + deletedTStr +
"</remove>";
604 String typesStr = addedTStr + updatedTStr + deletedTStr;
605 if (!typesStr.isEmpty()) {
609 retStr =
"<types>" + typesStr +
"</types>";
619 String removedStr =
makeDeletedAnnotMsg(flier.getRemovedAnnotations(),flier.getRemovedNestedAnnotations(),session,proto11);
623 ArrayList<Annotation> changedAndAutoUpd =
addWithoutDuplicity(flier.getEditedAnnotations(), flier.getAutoUpdatedAnnotations());
627 String annotStr = addedStr + editedStr + removedStr;
628 if (!annotStr.isEmpty()) {
630 retStr = retStr +
"<annotations>" + annotStr +
"</annotations>";
632 && session.
getSessionId() != flier.getCreatedInSessId()){
633 if(addedStr != null && !addedStr.isEmpty()){
637 if(removedStr != null && !removedStr.isEmpty()){
638 retStr += removedStr;
641 if(editedStr != null && !editedStr.isEmpty()){
649 if(session != null && flier.getCreatedInSessId() != null
650 && !flier.getCreatedInSessId().equals(session.
getSessionId())
651 && flier.getChangedSubscriptions() != null
652 && !flier.getChangedSubscriptions().isEmpty()){
654 StringBuilder chngedSubsMesg =
new StringBuilder();
657 Iterator<Subscription> changedSubsIt = flier.getChangedSubscriptions().iterator();
658 while(changedSubsIt.hasNext()){
661 Subscription oldSubscription = session.getSubscriptionFromList(actualSubscription.getId());
663 session.deleteFromSubscribes(oldSubscription);
664 session.addToSubscribes(actualSubscription);
667 chngedSubsMesg.append(actualSubscription.toXMLStringV2(
"modifySubscription"));
671 retStr += chngedSubsMesg.toString();
687 Object[] params = {
"linked", remAnnot.getId()};
688 @SuppressWarnings(
"unchecked")
689 List<LinkedAnnotationAttribute> attrList = AppBean.getPersistenceManager().queryDB(
"Attribute.findByLinked", params);
691 if (attrList != null) {
692 Iterator<LinkedAnnotationAttribute> linkedAttIt = attrList.iterator();
693 while (linkedAttIt.hasNext()) {
694 found = linkedAttIt.next();
696 closed.add(found.getAnnotation());
717 if (queries.contains(
"*") || queries.contains(
"**")) {
724 String typeName = type.getLinearizedName();
725 String typeUri = type.getUri();
727 Iterator queriedTypesIt = queries.iterator();
729 while (queriedTypesIt.hasNext()) {
730 queriedType = (String)queriedTypesIt.next();
731 if (queriedType.startsWith(
"http://") || queriedType.startsWith(
"https://")) {
735 if (typeUri.matches(queriedType.replace(
"*",
".*"))) {
738 }
else if (queriedType.endsWith(
"*")) {
741 if (typeUri.startsWith(queriedType.replace(
"*",
""))) {
746 if (typeUri.matches(queriedType.replace(
"*",
".*"))) {
753 if (typeName.matches(queriedType.replace(
"*",
".*"))) {
773 return pattern.length() - wildcard.replace(
"*",
"").length() >= 2;
787 String addedStr =
"";
788 ArrayList<Annotation> addApprovedAnnotations =
new ArrayList<Annotation>();
789 ArrayList<Annotation> unapprovedAnnotations =
new ArrayList<Annotation>();
790 Iterator<Annotation> annotIter = addedAnnotations.iterator();
792 while (annotIter.hasNext()) {
795 addApprovedAnnotations.add(annot);
797 unapprovedAnnotations.add(annot);
801 addApprovedAnnotations =
getRelatedAnnotations(addApprovedAnnotations, unapprovedAnnotations, session);
804 Iterator<Annotation> approvedIter = addApprovedAnnotations.iterator();
805 ArrayList<Annotation> printedAn =
new ArrayList<Annotation>();
806 ArrayList<String> attFilter = session.getAttFilter();
807 int lNum = session.getLanguageNum();
808 Boolean KBRefMode = session.getKBRefMode();
810 while (approvedIter.hasNext()) {
812 if (printedAn.contains(annot)) {
815 printedAn.add(annot);
818 addedStr = addedStr + annot.toXMLStringV2(attFilter, lNum, KBRefMode);
821 addedStr = addedStr + annot.toXMLString(proto11);
824 if (!addedStr.isEmpty()) {
826 addedStr =
"<addAnnotations>" + addedStr +
"</addAnnotations>";
828 addedStr =
"<add>" + addedStr +
"</add>";
846 String removedStr =
"";
847 Iterator<Annotation> deletedIter = deletedAnnotations.iterator();
849 while (deletedIter.hasNext()) {
854 removedStr = removedStr +
"<annotation uri=\"" + annot.getURIV2() +
"\"/>";
856 removedStr = removedStr + annot.toXMLString(proto11);
861 deletedIter = deletedNestedAnnotations.iterator();
862 while (deletedIter.hasNext()) {
866 removedStr = removedStr +
"<annotation uri=\"" + annot.getURIV2() +
"\"/>";
868 removedStr = removedStr + annot.toXMLString(proto11);
874 if (!removedStr.isEmpty()) {
876 removedStr =
"<removeAnnotations>" + removedStr +
"</removeAnnotations>";
878 removedStr =
"<remove>" + removedStr +
"</remove>";
899 Iterator<Integer> linkingAnnotIdIt = remAnnot.getLinkedByBeforeRemove().iterator();
900 while (linkingAnnotIdIt.hasNext()) {
901 Integer
id = linkingAnnotIdIt.next();
902 Object[] params = {
"id",
id};
903 @SuppressWarnings(
"unchecked")
904 List<Annotation> annotList = AppBean.getPersistenceManager().queryDB(
"Annotation.findById", params);
906 if (annotList != null && !annotList.isEmpty()) {
914 if (deletedAnnotations != null && !deletedAnnotations.isEmpty()) {
915 Iterator<Annotation> deletedAnnotIt = deletedAnnotations.iterator();
916 while (deletedAnnotIt.hasNext()) {
918 if (delAnnot.
getId() == id) {
940 String cahngedStr =
"";
941 ArrayList<Annotation> chngApprovedAnnotations =
new ArrayList<Annotation>();
942 ArrayList<Annotation> unapprovedAnnotations =
new ArrayList<Annotation>();
943 Iterator<Annotation> annotIter = changedAnnotations.iterator();
945 while (annotIter.hasNext()) {
948 chngApprovedAnnotations.add(annot);
950 unapprovedAnnotations.add(annot);
954 chngApprovedAnnotations =
getRelatedAnnotations(chngApprovedAnnotations, unapprovedAnnotations, session);
957 ArrayList<String> attFilter = session.getAttFilter();
958 int lNum = session.getLanguageNum();
959 Boolean KBRefMode = session.getKBRefMode();
962 annotIter = chngApprovedAnnotations.iterator();
964 while (annotIter.hasNext()) {
967 cahngedStr = cahngedStr + annot.toXMLStringV2(attFilter, lNum, KBRefMode);
969 cahngedStr = cahngedStr + annot.toXMLString(proto11);
972 if (!cahngedStr.isEmpty()) {
974 cahngedStr =
"<modifyAnnotations>" + cahngedStr +
"</modifyAnnotations>";
976 cahngedStr =
"<change>" + cahngedStr +
"</change>";
991 private ArrayList<Annotation>
addWithoutDuplicity(ArrayList<Annotation> listOfOld,ArrayList<Annotation> listOfNew){
992 if(listOfNew != null && !listOfNew.isEmpty()){
994 if(listOfOld.isEmpty()){
996 listOfOld.addAll(listOfNew);
999 Iterator<Annotation> listOfNewIter = listOfNew.iterator();
1002 while(listOfNewIter.hasNext()){
1003 Annotation actualAnnotation = listOfNewIter.next();
1004 if(!listOfOld.contains(actualAnnotation)){
1006 listOfOld.add(actualAnnotation);
1023 for (Iterator<BaseAttribute> aIt = annot.
getAttributes().iterator(); aIt.hasNext();) {
1027 removedNested.add(attr.getNestedAnnotation());
1042 Object[] params =
new Object[2];
1044 params[1] = requestInfo.getQueryTypeAttOnto();
1047 aList = AppBean.getPersistenceManager().queryDB(
"TypeAttrOnto.findAll");
1049 aList = AppBean.getPersistenceManager().queryDB(
"TypeAttrOnto.findByUserGroup", params);
1051 if (aList != null && !aList.isEmpty()) {
1052 Iterator aListIt = aList.iterator();
1055 while (aListIt.hasNext()) {
1057 retStr = retStr + attr.toXMLString();
1062 while (aListIt.hasNext()) {
1064 retStr = retStr + attr.toXMLStringV2();
1071 if (!retStr.isEmpty()) {
1072 retStr =
"<attrsFromOntology>" + retStr +
"</attrsFromOntology>";
1076 retStr =
"<ontologyAttributes>" + retStr +
"</ontologyAttributes>";
1091 if (session.
getUser() == null) {
1094 if (annotType.
getGroup() == null) {
1097 Iterator<UserGroup> grIter = session.getUser().getGroups().iterator();
1098 while (grIter.hasNext()) {
1100 if (annotType.
getGroup().equals(userGroup)) {
1117 String retQStr =
"";
1125 User user = requestInfo.getSession().getUser();
1130 Iterator<String> subIt = requestInfo.getSubscriptionQuery().iterator();
1134 while(subIt.hasNext()){
1135 String tmpStr = subIt.next();
1136 if(!tmpStr.isEmpty()){
1137 tmpStr = tmpStr.substring(tmpStr.lastIndexOf(
'/')+1);
1138 tmpStr = tmpStr.replaceAll(
"\\s+",
"");
1142 parsedIds.add(tmpStr);
1147 return "<subscriptions>" + retQStr +
"</subscriptions>";
1160 String retQStr =
"";
1164 EntityManager em = AppBean.getPersistenceManager().getEM();
1166 Query query = em.createQuery(
"SELECT s FROM Subscription s WHERE " +
1170 query.setHint(
"javax.persistence.cache.storeMode",
"REFRESH");
1171 sList = query.getResultList();
1172 }
catch (Exception e) {
1174 String msg =
"Exception in database query in getQueriedTypeLike.";
1175 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg, e);
1182 if (sList != null && !sList.isEmpty()) {
1183 Iterator sListIt = sList.iterator();
1184 while (sListIt.hasNext()) {
1186 retQStr = retQStr + sub.toXMLStringV2();
1201 String retQTStr =
"";
1205 User user = requestInfo.getSession().getUser();
1209 Iterator<String> qIter = requestInfo.getQueryTypes().iterator();
1210 while (qIter.hasNext()) {
1211 String qString = qIter.next();
1212 if (!qString.contains(
"*") && qString.contains(AppBean.getBaseTypeUri())) {
1215 }
else if (qString.contains(
"*") && qString.contains(AppBean.getBaseTypeUri())) {
1218 qString = qString.replace(
"*",
"%");
1221 }
else if (!qString.contains(
"*")) {
1224 qString = MessageProcessor.replaceArrows(qString);
1227 qString = AppBean.getBaseTypeUri() + qString;
1231 Iterator<UserGroup> gIter = user.getGroups().iterator();
1232 while (gIter.hasNext()) {
1235 String qStringWG = AppBean.getBaseTypeUri() +
"g" + userGroup.
getId() +
"/" + qString;
1242 qString = qString.replace(
"*",
"%");
1243 qString = MessageProcessor.replaceArrows(qString);
1246 qString = AppBean.getBaseTypeUri() + qString;
1250 Iterator<UserGroup> gIter = user.getGroups().iterator();
1251 while (gIter.hasNext()) {
1254 String qStringWG = AppBean.getBaseTypeUri() +
"g" + userGroup.
getId() +
"/" + qString;
1262 retQTStr =
"<addTypes>" + retQTStr +
"</addTypes>";
1264 retQTStr =
"<types><add>" + retQTStr +
"</add></types>";
1278 boolean withAnc =
true;
1282 String retQTStr =
"";
1284 Object[] params =
new Object[2];
1286 params[1] = qString;
1287 List tList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri", params);
1288 if (tList != null && !tList.isEmpty()) {
1291 retQTStr = retQTStr + aType.toXMLStringV2(withAnc);
1293 retQTStr = retQTStr + aType.toXMLString(withAnc);
1309 boolean withAnc =
true;
1313 String retQTStr =
"";
1316 EntityManager em = AppBean.getPersistenceManager().getEM();
1318 Query query = em.createQuery(
"SELECT a FROM AnnotType a WHERE a.uri LIKE '" + qString +
"'");
1319 query.setHint(
"javax.persistence.cache.storeMode",
"REFRESH");
1320 tList = query.getResultList();
1321 }
catch (Exception e) {
1323 String msg =
"Exception in database query in getQueriedTypeLike.";
1324 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg, e);
1331 if (tList != null && !tList.isEmpty()) {
1332 Iterator tListIt = tList.iterator();
1333 while (tListIt.hasNext()) {
1336 retQTStr = retQTStr + aType.toXMLStringV2(withAnc);
1338 retQTStr = retQTStr + aType.toXMLString(withAnc);
1355 boolean proto11 = requestInfo.getSession().getProtocolLOD() > 1;
1356 ArrayList<Annotation> approvedAnnotations =
new ArrayList<Annotation>();
1357 ArrayList<Annotation> unapprovedAnnotations =
new ArrayList<Annotation>();
1359 Object[] params =
new Object[2];
1360 params[0] =
"sourceDocumentId";
1361 params[1] = requestInfo.getSession().getSyncDocument().getId();
1362 List aList = AppBean.getPersistenceManager().queryDB(
"Annotation.findBySourceDocumentIDNoNested", params);
1363 if (aList != null && !aList.isEmpty()) {
1364 Iterator aListIt = aList.iterator();
1365 while (aListIt.hasNext()) {
1370 approvedAnnotations.add(annot);
1372 unapprovedAnnotations.add(annot);
1376 int langNum = requestInfo.getSession().getLanguageNum();
1377 int lod = requestInfo.getSession().getProtocolLOD();
1384 ArrayList<String> attFilter = requestInfo.getSession().getAttFilter();
1385 int lNum = requestInfo.getSession().getLanguageNum();
1386 Boolean KBRefMode = requestInfo.getSession().getKBRefMode();
1388 Iterator<Annotation> approvedIter = approvedAnnotations.iterator();
1390 while (approvedIter.hasNext()) {
1393 retStr = retStr + annot.toXMLStringV2(attFilter, lNum, KBRefMode);
1395 retStr = retStr + annot.toXMLString(proto11);
1399 if (!retStr.isEmpty()) {
1401 retStr =
"<addAnnotations>" + retStr +
"</addAnnotations>";
1403 retStr =
"<annotations><add>" + retStr +
"</add></annotations>";
1425 if (requestInfo.
getSession().getSyncDocument() == null) {
1430 Flier flier = requestInfo.getFlier();
1431 Object[] params =
new Object[2];
1432 params[0] =
"sourceDocumentId";
1433 params[1] = requestInfo.getSession().getSyncDocument().getId();
1434 List aList = AppBean.getPersistenceManager().queryDB(
"Annotation.findBySourceDocumentID", params);
1435 if (aList != null && !aList.isEmpty()) {
1436 Iterator aListIt = aList.iterator();
1437 while (aListIt.hasNext()) {
1442 flier.addAutoUpdatedAnnotation(annot);
1463 AnnotDocument annotDoc = requestInfo.getSession().getSyncDocument();
1464 Document parsedDoc = requestInfo.getSession().getParsedSyncDocument();
1465 if (parsedDoc == null) {
1466 int langNum = requestInfo.getSession().getLanguageNum();
1467 int lod = requestInfo.getSession().getProtocolLOD();
1472 String msg =
"Bad document for update of the annotation.";
1473 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg);
1479 int nowOrphFragCnt = 0;
1480 int updatedFragCnt = 0;
1481 Iterator<Fragment> fragIt = annotation.getFragments().iterator();
1482 while (fragIt.hasNext()) {
1486 UpdatableFragment uf = exactMatcherProvider.match(parsedDoc, fragment.toUpdatableFragment());
1489 fragment.setIsGood(
true);
1495 ArrayList<UpdatableFragment> ufl;
1497 ufl = nearestMatcherProvider.matchIn3ClosestNodes(parsedDoc, fragment.toUpdatableFragment());
1498 if (ufl.isEmpty()) {
1500 ufl = sequenceMatcherProvider.matchAllIncrementally(parsedDoc, fragment.toUpdatableFragment());
1502 if (ufl.size() == 1) {
1504 Iterator<UpdatableFragment> ufIt = ufl.iterator();
1506 fragment.updateWithUpdatableFragment(uf);
1509 fragment.setIsGood(
true);
1511 }
else if (ufl.isEmpty()) {
1513 fragment.setIsGood(
false);
1519 int minBadness = Integer.MAX_VALUE;
1521 String origPath = fragment.getPath();
1522 String origText = fragment.getAnnotatedText();
1523 int origOffset = fragment.getOffset();
1524 for (Iterator<UpdatableFragment> uflIt = ufl.iterator(); uflIt.hasNext();) {
1526 int lD = Util.levenshtein(origPath, ufr.getXPathString());
1527 int lDT = Util.levenshtein(origText, ufr.getText());
1528 double LTPerc = (lDT / (double)origText.length()) * 100;
1529 int offDistance = Math.abs(origOffset - ufr.getOffset());
1530 int badness = 355 * lD + 5 * (int)LTPerc + offDistance;
1531 if (badness < minBadness) {
1532 minBadness = badness;
1537 fragment.updateWithUpdatableFragment(uf);
1540 fragment.setIsGood(
true);
1544 }
catch (XPathExpressionException ex) {
1546 fragment.setIsGood(
false);
1550 }
catch (Exception e) {
1551 int langNum = requestInfo.getSession().getLanguageNum();
1552 int lod = requestInfo.getSession().getProtocolLOD();
1556 String msg =
"Exception during the update of the annotation.";
1557 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg, e);
1564 if (badFragCnt == annotation.
getFragments().size() && nowOrphFragCnt > 0) {
1566 int langNum = requestInfo.getSession().getLanguageNum();
1567 int lod = requestInfo.getSession().getProtocolLOD();
1569 String info = AppBean.getBaseAnnotUri() + annotation.
getId();
1572 String info = annotation.getURIV2();
1575 }
else if (nowOrphFragCnt > 0) {
1577 int langNum = requestInfo.getSession().getLanguageNum();
1578 int lod = requestInfo.getSession().getProtocolLOD();
1580 String info = AppBean.getBaseAnnotUri() + annotation.
getId();
1583 String info = annotation.getURIV2();
1587 if (nowOrphFragCnt > 0 || updatedFragCnt > 0) {
1601 Flier flier = requestInfo.getFlier();
1604 AnnotDocument syncDoc = requestInfo.getSession().getSyncDocument();
1606 Iterator<Annotation> addedIter = flier.getAddedAnnotations().iterator();
1607 while (addedIter.hasNext()) {
1611 Boolean cmpErr =
false;
1615 int lod = requestInfo.getSession().getProtocolLOD();
1621 int langNum = requestInfo.getSession().getLanguageNum();
1635 info =
"<resynchronize resource=\"" + requestInfo.getSession().getSyncDocument().getUri()
1636 +
"\" method=\"soft\"/>";
1640 info =
"<resynchronize/>";
1642 int langNum = requestInfo.getSession().getLanguageNum();
1644 requestInfo.appendToReply(info);
1646 String msg =
"Synchronization error during the added annotation check.";
1647 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
1652 int langNum = requestInfo.getSession().getLanguageNum();
1662 Iterator<Annotation> editedIter = flier.getEditedAnnotations().iterator();
1663 while (editedIter.hasNext()) {
1667 Boolean cmpErr =
false;
1673 int langNum = requestInfo.getSession().getLanguageNum();
1674 int lod = requestInfo.getSession().getProtocolLOD();
1676 info =
"<reload uri=\"" + annot.getURI() +
"\"/>";
1679 info =
"<annotation uri=\"" + annot.getURIV2() +
"\"/>";
1683 String msg =
"Edited annotation was not saved due bad fragments.";
1684 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
1687 editedIter.remove();
1694 info =
"<resynchronize resource=\"" + requestInfo.getSession().getSyncDocument().getUri()
1695 +
"\" method=\"soft\"/>";
1699 info =
"<resynchronize/>";
1702 requestInfo.appendToReply(info);
1704 }
else if (updFr > 0) {
1706 int langNum = requestInfo.getSession().getLanguageNum();
1707 int lod = requestInfo.getSession().getProtocolLOD();
1717 info =
"<resynchronize resource=\"" + requestInfo.getSession().getSyncDocument().getUri()
1718 +
"\" method=\"soft\"/>";
1722 info =
"<resynchronize/>";
1725 requestInfo.appendToReply(info);
1727 String msg =
"Synchronization error during the edited annotation check.";
1728 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
1735 addedIter = flier.getAddedAnnotations().listIterator();
1736 while (addedIter.hasNext()) {
1743 editedIter = flier.getEditedAnnotations().iterator();
1744 while (editedIter.hasNext()) {
1747 editedIter.remove();
1765 Iterator<BaseAttribute> annotAttrIt = annot.getAttributes().iterator();
1766 ArrayList<String> names =
new ArrayList<String>();
1767 while (annotAttrIt.hasNext()) {
1770 names.add(attr.getName());
1773 StringBuilder missing =
new StringBuilder();
1774 StringBuilder missing2 =
new StringBuilder();
1775 AnnotType annotType = annot.getAnnotType();
1778 Iterator<AnnotType> modifiedIt = requestInfo.getFlier().getEditedTypes().iterator();
1779 while(modifiedIt.hasNext()){
1781 if(tmp.
getId() == annotType.getId()){
1787 Iterator<AnnotTypeAttr> attrIt = annotType.getAttributes().iterator();
1788 while (attrIt.hasNext()) {
1791 if (!names.contains(attr.
getName())) {
1792 missing.append(attr.toXMLString(
false));
1793 missing2.append(
"<attribute annotationUri=\"").append(annot.
getURIV2());
1795 missing2.append(
"\" name=\"").append(attr.
getName());
1796 missing2.append(
"\" valueType=\"").append(attr.
getValueType());
1797 missing2.append(
"\" type=\"").append(attr.
getTypeUriV2()).append(
"\"/>");
1801 int lod = requestInfo.getSession().getProtocolLOD();
1802 int langNum = requestInfo.getSession().getLanguageNum();
1806 }
else if (missing.length() > 0) {
1809 if (annot.
getId() != null) {
1810 info =
"<reload uri=\"" + annot.getId() +
"\"/>";
1812 info = info + missing.toString();
1833 Document syncDoc = requestInfo.getSession().getParsedSyncDocument();
1834 if (syncDoc == null) {
1835 int langNum = requestInfo.getSession().getLanguageNum();
1836 int lod = requestInfo.getSession().getProtocolLOD();
1841 String msg =
"Bad document for check of the annotation fragments.";
1842 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg);
1849 ListIterator<Fragment> fragIt = annotation.getFragments().listIterator();
1850 while (fragIt.hasNext()) {
1854 ArrayList<UpdatableFragment> ufl = exactMatcherProvider.matchAll(syncDoc, fragment.toUpdatableFragment());
1855 if (ufl.isEmpty() && fragment.getPath() != null && fragment.
getPath().indexOf(
"text()") == -1) {
1858 fwt.setPath(fragment.getPath() +
"/text()");
1859 ufl = exactMatcherProvider.matchAll(syncDoc, fwt.toUpdatableFragment());
1862 if (ufl.size() > 1) {
1867 ListIterator<UpdatableFragment> uflIt = ufl.listIterator();
1868 while (uflIt.hasNext()) {
1876 if (ufl.size() > 1) {
1877 uflIt = ufl.listIterator();
1878 while (uflIt.hasNext()) {
1880 ListIterator<UpdatableFragment> uflItDup = ufl.listIterator();
1881 while (uflItDup.hasNext()) {
1883 if (ufInList.
equals(inspectedUf)) {
1891 if (ufl.size() == 1) {
1895 int langNum = requestInfo.getSession().getLanguageNum();
1896 int lod = requestInfo.getSession().getProtocolLOD();
1899 info =
"<reload uri=\"" + annotation.getURI() +
"\"/>" + fragment.
toXMLString();
1900 }
else if (annotation.
getId() != null) {
1901 info =
"<annotation uri=\"" + annotation.getURIV2() +
"\"/>";
1905 String msg =
"Ambiguous fragment found.";
1906 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
1913 }
else if (!ufl.isEmpty()) {
1915 Iterator<UpdatableFragment> ufIt = ufl.iterator();
1919 ufl = nearestMatcherProvider.matchIn3ClosestNodes(syncDoc, fragment.toUpdatableFragment());
1920 if (ufl.isEmpty()) {
1922 ufl = sequenceMatcherProvider.matchAllIncrementally(syncDoc, fragment.toUpdatableFragment());
1926 if (ufl.size() == 1) {
1928 Iterator<UpdatableFragment> ufIt = ufl.iterator();
1930 }
else if (ufl.isEmpty()) {
1932 int langNum = requestInfo.getSession().getLanguageNum();
1933 int lod = requestInfo.getSession().getProtocolLOD();
1936 info =
"<reload uri=\"" + annotation.getId() +
"\"/>" + fragment.
toXMLString();
1937 }
else if (annotation.
getId() != null) {
1938 info =
"<annotation uri=\"" + annotation.getURIV2() +
"\"/>";
1942 String msg =
"Bad fragment found during the check.";
1943 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
1950 int pathLenght = fragment.getPath().length();
1951 int textLenght = fragment.getAnnotatedText().length();
1954 int minLD = Integer.MAX_VALUE;
1956 int sMinLD = Integer.MAX_VALUE;
1957 double minLDPercentage = 1;
1958 double sMinLDPercentage = 1;
1959 String origPath = fragment.getPath();
1960 String origText = fragment.getAnnotatedText();
1961 for (Iterator<UpdatableFragment> uflIt = ufl.iterator(); uflIt.hasNext();) {
1969 int lD = Util.levenshtein(origPath, ufr.getXPathString());
1973 minLDPercentage = (double) lD / pathLenght;
1975 }
else if (lD < sMinLD) {
1977 sMinLDPercentage = (double) lD / pathLenght;
1984 int langNum = requestInfo.getSession().getLanguageNum();
1985 int lod = requestInfo.getSession().getProtocolLOD();
1988 info = annotation.getURI();
1990 info = annotation.getURIV2();
1998 int langNum = requestInfo.getSession().getLanguageNum();
1999 int lod = requestInfo.getSession().getProtocolLOD();
2002 info =
"<reload uri=\"" + annotation.getURI() +
"\">" + fragment.
toXMLString() +
"</reload>";
2003 }
else if (annotation.
getId() != null) {
2004 info =
"<annotation uri=\"" + annotation.getURIV2() +
"\"/>";
2008 String msg =
"Too ambiguous fragment found.";
2009 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
2020 fragment.updateWithUpdatableFragment(uf);
2022 }
catch (XPathExpressionException ex) {
2023 int langNum = requestInfo.getSession().getLanguageNum();
2024 int lod = requestInfo.getSession().getProtocolLOD();
2027 if (annotation.
getId() != null) {
2028 info =
"<reload uri=\"" + annotation.getURI() +
"\"/>" + fragment.
toXMLString();
2032 if (annotation.
getId() != null) {
2033 info =
"<annotation uri=\"" + annotation.getURIV2() +
"\"/>" + fragment.
toXMLString();
2039 String msg =
"Bad XPath found in the fragment.";
2040 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
2043 }
catch (Exception e) {
2044 int langNum = requestInfo.getSession().getLanguageNum();
2045 int lod = requestInfo.getSession().getProtocolLOD();
2049 String msg =
"Exception dugring the checking of the annotation fragments.";
2050 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg, e);
2070 Object[] params =
new Object[2];
2071 params[0] =
"sourceDocumentId";
2072 params[1] = doc.getId();
2073 List aList = AppBean.getPersistenceManager().queryDB(
"Annotation.findBySourceDocumentID", params);
2074 if (aList != null && !aList.isEmpty()) {
2075 int annCount = aList.size();
2076 double incrValue = 100 / annCount;
2077 double affected = 0;
2078 Iterator aListIt = aList.iterator();
2079 while (aListIt.hasNext()) {
2100 Document parsedDoc = null;
2102 parsedDoc = matcherProvider.getDocumentFromString(newDoc.getContent(),
false,
true);
2105 int langNum = requestInfo.getSession().getLanguageNum();
2106 int lod = requestInfo.getSession().getProtocolLOD();
2111 String msg =
"Parsing document for the annotation affection check failed.";
2112 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg);
2117 if (parsedDoc == null) {
2118 int langNum = requestInfo.getSession().getLanguageNum();
2119 int lod = requestInfo.getSession().getProtocolLOD();
2124 String msg =
"Bad document for the annotation affection check.";
2125 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg);
2130 Iterator<Fragment> fragIt = annotation.getFragments().iterator();
2131 int fragCount = annotation.getFragments().size();
2136 double incrValue = 1 / fragCount;
2137 double affected = 0;
2138 while (fragIt.hasNext()) {
2143 uf = exactMatcherProvider.match(parsedDoc, fragment.toUpdatableFragment());
2146 ArrayList<UpdatableFragment> ufl = nearestMatcherProvider.matchIn3ClosestNodes(parsedDoc, fragment.toUpdatableFragment());
2148 ufl = sequenceMatcherProvider.matchAllIncrementally(parsedDoc, fragment.toUpdatableFragment());
2150 if(ufl.size() >= 1){
2151 if(ufl.size() == 1){
2157 int minBadness = Integer.MAX_VALUE;
2159 String origPath = fragment.getPath();
2160 String origText = fragment.getAnnotatedText();
2161 int origOffset = fragment.getOffset();
2162 for (Iterator<UpdatableFragment> uflIt = ufl.iterator(); uflIt.hasNext();) {
2164 int lD = Util.levenshtein(origPath, ufr.getXPathString());
2165 int lDT = Util.levenshtein(origText, ufr.getText());
2166 double LTPerc = (lDT / (double)origText.length()) * 100;
2167 int offDistance = Math.abs(origOffset - ufr.getOffset());
2168 int badness = 355 * lD + 5 * (int)LTPerc + offDistance;
2169 if (badness < minBadness) {
2170 minBadness = badness;
2180 affected += incrValue;
2184 }
catch (XPathExpressionException ex) {
2186 affected += incrValue;
2188 }
catch (Exception e) {
2189 int langNum = requestInfo.getSession().getLanguageNum();
2190 int lod = requestInfo.getSession().getProtocolLOD();
2194 String msg =
"Exception during the annotation affection check.";
2195 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg, e);
2197 affected += incrValue;
2210 int affectedParts = 0;
2216 int XPathLD = Util.levenshtein(origFragment.getPath(), foundFragment.
getXPathString());
2217 double XPathLDPercentage = (double) XPathLD / origFragment.
getPath().length();
2222 int TextLD = Util.levenshtein(origFragment.getAnnotatedText(), foundFragment.
getText());
2223 double TextLDPercentage = (double) TextLD / origFragment.
getAnnotatedText().length();
2227 return (
double)affectedParts / 3;
2237 requestInfo.getSession().setParsedLinDocument(null);
2238 requestInfo.getSession().setParsedSyncDocument(null);
2245 }
catch (URISyntaxException ex) {
2247 int langNum = requestInfo.getSession().getLanguageNum();
2248 int lod = requestInfo.getSession().getProtocolLOD();
2251 String msg =
"Bad URI of synchronized document: " + newDoc.getUri();
2252 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg, ex);
2260 String documentUri = newDoc.getUri();
2266 lock = AppBean.documentURILocker.get(documentUri);
2268 lock =
new ReentrantLock();
2271 AppBean.documentURILocker.put(documentUri, lock);
2277 Object[] params =
new Object[2];
2279 params[1] = newDoc.getUri();
2280 List dList = AppBean.getPersistenceManager().queryDB(
"AnnotDocument.findByUri", params);
2281 if (dList != null && !dList.isEmpty()) {
2283 if(lock.isLocked()){
2327 int langNum = session.getLanguageNum();
2328 int lod = requestInfo.getSession().getProtocolLOD();
2330 session.setLinearization(
false);
2332 Document parsedSyncDocument = null;
2334 parsedSyncDocument = this.matcherProvider.getDocumentFromString(newDoc.getContent(),
false,
true);
2335 }
catch(Exception e){
2336 langNum = requestInfo.getSession().getLanguageNum();
2337 lod = requestInfo.getSession().getProtocolLOD();
2342 String msg =
"Parsing document to get structured synchronized document failed.";
2343 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg);
2351 }
catch (InterruptedException ex) {
2353 String msg =
"Interrupted exception on trying to lock document usage counter.";
2354 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg);
2361 session.setSyncDocument(null);
2362 session.setParsedLinDocument(null);
2363 session.setParsedSyncDocument(null);
2367 requestInfo.setNewDocument(
true);
2368 requestInfo.setSyncDocument(newDoc);
2370 session.setSyncDocument(newDoc);
2371 session.setParsedLinDocument(Linearizer.linearizeDocument(parsedSyncDocument));
2372 session.setParsedSyncDocument(parsedSyncDocument);
2377 if (doc.
getContent().equals(newDoc.getContent())) {
2378 requestInfo.setSyncDocument(doc);
2380 session.setSyncDocument(doc);
2381 session.setParsedLinDocument(Linearizer.linearizeDocument(parsedSyncDocument));
2382 session.setParsedSyncDocument(parsedSyncDocument);
2387 StringBuilder docSB =
new StringBuilder();
2388 docSB.append(
"<content><![CDATA[");
2389 docSB.append(doc.getContent());
2390 docSB.append(
"]]></content>");
2393 String msg =
"Document is already opened by another client. Versions of document differs.";
2394 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
2399 requestInfo.setSyncDocument(doc);
2401 session.setSyncDocument(doc);
2402 session.setParsedLinDocument(Linearizer.linearizeDocument(parsedSyncDocument));
2403 session.setParsedSyncDocument(parsedSyncDocument);
2406 Integer lastModID = AppBean.incrementLastDocModification(doc.getId());
2407 if (lastModID == null) {
2408 String msg =
"Unable to increment text modification set ID.";
2410 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
2414 requestInfo.getFlier().setTextModificationSetID(lastModID);
2415 AppBean.addDocModificationSet(doc.getId(), lastModID, requestInfo.
getFlier().getTextModifications());
2417 doc.setModified(
new Date());
2418 doc.setContent(newDoc.getContent());
2422 requestInfo.setSyncDocument(doc);
2424 session.setSyncDocument(doc);
2425 session.setParsedLinDocument(Linearizer.linearizeDocument(parsedSyncDocument));
2426 session.setParsedSyncDocument(parsedSyncDocument);
2429 Integer lastModID = AppBean.incrementLastDocModification(doc.getId());
2430 if (lastModID == null) {
2431 String msg =
"Unable to increment text modification set ID.";
2433 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
2437 requestInfo.getFlier().setTextModificationSetID(lastModID);
2438 AppBean.addDocModificationSet(doc.getId(), lastModID, requestInfo.
getFlier().getTextModifications());
2440 doc.setModified(
new Date());
2441 doc.setContent(newDoc.getContent());
2446 StringBuilder docSB =
new StringBuilder();
2447 docSB.append(
"<content><![CDATA[");
2448 docSB.append(doc.getContent());
2449 docSB.append(
"]]></content>");
2452 String msg =
"Common synchronization error (different contents).";
2453 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
2470 requestInfo.getSession().setParsedLinDocument(null);
2471 requestInfo.getSession().setParsedSyncDocument(null);
2473 AnnotDocument doc = requestInfo.getSession().getSyncDocument();
2476 int langNum = requestInfo.getSession().getLanguageNum();
2477 int lod = requestInfo.getSession().getProtocolLOD();
2480 String msg =
"Resynchronization in state where document is not synchronized.";
2481 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg);
2487 String newContent = requestInfo.getResyncDocContent();
2490 newDoc.setId(doc.getId());
2492 if (requestInfo.
getSession().isLinearization()) {
2508 if (doc.
getContent().equals(newDoc.getContent())) {
2510 requestInfo.setSyncDocument(doc);
2515 doc.setModified(
new Date());
2516 doc.setContent(newDoc.getContent());
2517 requestInfo.setSyncDocument(doc);
2521 int langNum = requestInfo.getSession().getLanguageNum();
2522 int lod = requestInfo.getSession().getProtocolLOD();
2524 String msg =
"Common resynchronization error (different contents).";
2525 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
2529 String context =
"<content><![CDATA[" + doc.getContent() +
"]]></content>";
2547 return "Core module";
2559 return "Core module perform basic document, types and annotations manipulations.";
2568 public static String
cleanUpURI(String uri)
throws URISyntaxException {
2569 URI jUri =
new URI(uri);
2571 jUri = jUri.normalize();
2573 String cUri = jUri.toString();
2576 int fIndex = cUri.lastIndexOf(
"#");
2578 cUri = cUri.substring(0, fIndex);
2582 int pIndex = cUri.indexOf(
'?');
2588 int length = cUri.length();
2590 while (i < length && i > 0) {
2591 boolean rem =
false;
2592 int eInd = cUri.indexOf(
"&", i);
2596 Iterator<String> pIt = Constants.REM_URI_PARAMS.iterator();
2598 while (pIt.hasNext() && sInd != i) {
2599 String rParam = pIt.next();
2600 sInd = cUri.indexOf(rParam, i);
2604 cUri = cUri.substring(0, i) + cUri.substring(eInd + 1, length);
2605 length = cUri.length();
2608 i = cUri.indexOf(
"&", i) + 1;
2612 if (cUri.endsWith(
"?")) {
2613 cUri = cUri.substring(0, length - 1);
2616 if (cUri.endsWith(
"&")) {
2617 cUri = cUri.substring(0, length - 1);
2635 int langNum = requestInfo.getSession().getLanguageNum();
2636 int lod = requestInfo.getSession().getProtocolLOD();
2645 String msg =
"Attempt to synchronize linearized document (not yet implemented).";
2646 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
2654 int langNum = requestInfo.getSession().getLanguageNum();
2655 int lod = requestInfo.getSession().getProtocolLOD();
2659 String msg =
"Attempt to resynchronize linearized document (not yet implemented).";
2660 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
2674 Flier flier = requestInfo.getFlier();
2679 ArrayList<TextModification> tmsUnit;
2681 tmsUnit = TextModificationsXMLUnitProvider.getTextModifications
2684 catch(Exception ex){
2686 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, ex.getMessage());
2688 tmsUnit =
new ArrayList<TextModification>();
2691 flier.setTextModifications(tmsUnit);
2702 int protocol = actualSession.getProtocolLOD();
2704 ArrayList<EditorSession> sesList = AppBean.getSessions();
2705 if(sesList != null){
2706 Iterator<EditorSession> it = sesList.iterator();
2707 while(it.hasNext()){
2710 protocol = ses.getProtocolLOD();
2726 int langNum = requestInfo.getSession().getLanguageNum();
2727 int lod = requestInfo.getSession().getProtocolLOD();
2729 Flier flier = requestInfo.getFlier();
2735 requestInfo.setDocumentChanged(
true);
2755 lastModID = AppBean.getLastDocModification(doc.getId());
2766 AppBean.getLockMaster().getDocumentLock(doc.getId()).unlockForChange();
2767 String info =
"<modification id=\"" + requestInfo.getLastModificationNumber()
2768 +
"\" mustApply=\"" + lastModID +
"\"/>";
2772 String msg =
"An error has occured while trying to apply text modications: modification conflict";
2783 docUpdate.appendModifications(requestInfo.getTextModifications());
2785 boolean failed =
false;
2788 docUpdate.updateDocument();
2789 doc.setModified(
new Date());
2790 doc.setContent(docUpdate.getDocumentString());
2791 session.setParsedLinDocument(Linearizer.linearizeDocument(docUpdate.getDocument()));
2793 session.setParsedSyncDocument(this.matcherProvider.getDocumentFromString(doc.getContent(),
false,
true));
2794 }
catch(Exception e){
2795 langNum = requestInfo.getSession().getLanguageNum();
2796 lod = requestInfo.getSession().getProtocolLOD();
2801 String msg =
"Parsing updated document for the parsed synchronized document failed.";
2802 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg);
2806 flier.setTextModifications(requestInfo.getTextModifications());
2815 info =
"<resynchronize resource=\"" + requestInfo.getSession().getSyncDocument().getUri()
2816 +
"\" method=\"hard\"/>";
2819 info =
"<resynchronize/>";
2821 requestInfo.getSession().addMessageTS(info);
2824 ArrayList<TextModification> failedReversedMods = ex.getReverseModifications();
2837 String msg =
"Unable to generate reverse text modification.";
2838 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg, ex);
2841 requestInfo.appendToReply(
"<resynchronize/>");
2846 else if(failedReversedMods != null && !failedReversedMods.isEmpty() && session.getProtocolLOD() <
Constants.
PROTOCOL_LOD_V2){
2847 Iterator<TextModification> textModIt = failedReversedMods.iterator();
2848 while(textModIt.hasNext()){
2852 requestInfo.addError(tm.toXMLString());
2859 else if(ex.
getErrorMessage() != null && !ex.getErrorMessage().isEmpty()){
2861 String context =
"<modification id=\"" + requestInfo.getLastModificationNumber() +
"\"/>";
2865 String context =
"<module name=\"" +
getModuleName(langNum) +
"\"/>";
2869 String msg =
"An error has occured while trying to apply text modications: " + ex.getErrorMessage();
2870 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg, ex);
2875 if (doc != null && !failed) {
2876 Integer lastMod = AppBean.incrementLastDocModification(doc.getId());
2877 if (lastMod == null) {
2878 String msg =
"Unable to increment text modification set ID.";
2880 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
2884 flier.setTextModificationSetID(lastMod);
2892 synchronized (AppBean.getSessions()) {
2893 Iterator<EditorSession> sessionsIt = AppBean.getSessions().iterator();
2894 while (sessionsIt.hasNext()) {
2899 && flier.getCreatedInSessId() != actualSession.
getSessionId()) {
2904 if (doc != null && currDoc != null && currDoc.
getId() == doc.getId()
2905 && requestInfo.
getTextModifications() != null && !requestInfo.getTextModifications().isEmpty()) {
2909 actDocUpdate.appendModifications(requestInfo.getTextModifications());
2912 actDocUpdate.updateDocument();
2913 currDoc.setContent(actDocUpdate.getDocumentString());
2914 currDoc.setModified(
new Date());
2915 actualSession.setParsedLinDocument(Linearizer.linearizeDocument(actDocUpdate.getDocument()));
2917 actualSession.setParsedSyncDocument(this.matcherProvider.getDocumentFromString(doc.getContent(),
false,
true));
2918 }
catch(Exception e){
2919 langNum = actualSession.getLanguageNum();
2920 lod = actualSession.getProtocolLOD();
2924 info =
"<resynchronize resource=\"" + actualSession.getSyncDocument().getUri()
2925 +
"\" method=\"hard\"/>";
2928 info =
"<resynchronize/>";
2930 actualSession.addMessageTS(info);
2932 String msg =
"Parsing updated document for the parsed synchronized document while updating other sessions failed.";
2933 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg);
2939 langNum = actualSession.getLanguageNum();
2940 lod = actualSession.getProtocolLOD();
2944 String context =
"<module name=\"" +
getModuleName(langNum) +
"\"/>";
2949 String msg =
"Updating of document has failed.";
2950 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.ALL, msg);
2956 info =
"<resynchronize resource=\"" + requestInfo.getSession().getSyncDocument().getUri()
2957 +
"\" method=\"hard\"/>";
2961 info =
"<resynchronize/>";
2963 actualSession.addMessageTS(info);
2964 actualSession.notifyComet();
2976 retStr =
"<modificationApplied id=\"" + (lastModID + 1) +
"\"/>";
2979 AppBean.getLockMaster().getDocumentLock(doc.getId()).unlockForChange();
2993 ArrayList<String> result =
new ArrayList<String>();
2996 result.add(user.getComeFrom());
2999 List<UserGroup> groups = user.getGroups();
3000 if (groups != null) {
3001 Iterator groupsIt = groups.iterator();
3002 while (groupsIt.hasNext()) {
3003 result.add(((
UserGroup) groupsIt.next()).getUri());
3017 ArrayList<Annotation> openList =
new ArrayList<Annotation>();
3018 ArrayList<Annotation> closeList =
new ArrayList<Annotation>();
3020 if(!annotations.isEmpty())
3023 openList.addAll(annotations);
3024 while(!openList.isEmpty()){
3028 if(!closeList.contains(first)){
3031 if(!annotations.contains(first)){
3032 closeList.add(first);
3050 private ArrayList<Annotation>
getAnnotsForUpdate(ArrayList<Annotation> annotations, ArrayList<Annotation> updatedAnnots){
3051 ArrayList<Annotation> changedList =
new ArrayList<Annotation>();
3053 Iterator<Annotation> annotIt = annotations.iterator();
3054 while(annotIt.hasNext()){
3057 Object[] params = {
"linked", currentAnnot.getId()};
3058 @SuppressWarnings(
"unchecked")
3059 List<LinkedAnnotationAttribute> attrList = AppBean.getPersistenceManager().queryDB(
"Attribute.findByLinked", params);
3060 if (attrList != null) {
3061 Iterator<LinkedAnnotationAttribute> attrIt = attrList.iterator();
3064 while(attrIt.hasNext()){
3070 if(!updatedAnnots.contains(annotToAdd)){
3072 currentAttr.setValue(null);
3073 updatedAnnots.add(annotToAdd);
3077 Annotation updatedAnnot = updatedAnnots.get(updatedAnnots.indexOf(annotToAdd));
3080 Iterator<BaseAttribute> updatedAnnotAttrIt = updatedAnnot.getAttributes().iterator();
3081 while(updatedAnnotAttrIt.hasNext()){
3084 if(currAttr.
getId().equals(currentAttr.getId())){
3086 currAttr.setValue(null);
3101 ArrayList<String> result =
new ArrayList<String>();
3103 Iterator<BaseAttribute> annotAttrIt = annot.getAttributes().iterator();
3104 while(annotAttrIt.hasNext()){
3108 result.add(currentBaseAttr.getNestedAnnotation().getURIV2());
3123 ArrayList<Annotation> openList =
new ArrayList<Annotation>();
3124 ArrayList<Annotation> closeList =
new ArrayList<Annotation>();
3126 if(!approvedAnnotations.isEmpty())
3129 openList.addAll(approvedAnnotations);
3130 while(!openList.isEmpty()){
3134 if(!closeList.contains(first)){
3137 closeList.add(first);
3144 return approvedAnnotations;
3154 ArrayList<Annotation> innerAnnotationList =
new ArrayList<Annotation>();
3155 Object[] params = {
"linked", annot.getId()};
3156 @SuppressWarnings(
"unchecked")
3157 List<LinkedAnnotationAttribute> attrList = AppBean.getPersistenceManager().queryDB(
"Attribute.findByLinked", params);
3158 if (attrList != null) {
3159 Iterator<LinkedAnnotationAttribute> attrIt = attrList.iterator();
3161 while (attrIt.hasNext()) {
3164 if (dbAnnot != null) {
3165 innerAnnotationList.add(dbAnnot);
3169 return innerAnnotationList;
3179 public static ArrayList<Annotation>
getDifference(ArrayList<Annotation> annotListA, ArrayList<Annotation> annotListB) {
3180 ArrayList<Annotation> result =
new ArrayList<Annotation>();
3181 Iterator<Annotation> iteratorA = annotListA.iterator();
3182 while (iteratorA.hasNext()) {
3184 Iterator<Annotation> iteratorB = annotListB.iterator();
3185 boolean isInB =
false;
3186 while (iteratorB.hasNext()) {
3187 if (actualAnnot.
getId().equals(iteratorB.next().getId())) {
3192 result.add(actualAnnot);
3209 ArrayList<Annotation> result =
new ArrayList<Annotation>();
3210 Iterator<Annotation> unapprovedIt = unapprovedAnnot.iterator();
3213 while (unapprovedIt.hasNext()) {
3215 ArrayList<Annotation> openList =
new ArrayList<Annotation>();
3217 ArrayList<Annotation> closedList =
new ArrayList<Annotation>();
3220 openList.add(unapprovedIt.next());
3224 while (!openList.isEmpty()) {
3226 closedList.add(actualAnnot);
3239 result.add(closedList.get(0));
3250 openList.addAll(annotForAdd);
3255 if(approvedAnnot == null){
3259 approvedAnnot.addAll(result);
3260 return approvedAnnot;
3271 ArrayList<SuggestionLogEntry> suggested = requestInfo.getConfirmedSuggestions();
3273 List attr = annot.getAttributes();
3274 Iterator it = attr.iterator();
3275 while (it.hasNext()) {
3279 boolean found =
false;
3280 if (tmpId != null) {
3281 Iterator<SuggestionLogEntry> suggIt = suggested.iterator();
3282 while (suggIt.hasNext() && !found) {
3284 if (curSug.
getTmpId().equals(tmpId)) {
3285 Annotation annotHit = curSug.getConfirmedVersion();
3286 if (annotHit != null) {
3287 currAttr.setValue(annotHit);
3288 if(annotHit != null){
3289 currAttr.setAttributeType(annotHit.getAnnotType());
3295 if (found ==
false) {
3297 int langNum = requestInfo.getSession().getLanguageNum();
3298 int lod = requestInfo.getSession().getProtocolLOD();
3302 String info =
"<attribute annotationUri=\"" + annot.getURIV2()
3304 +
"\" name=\"" + currAttr.getName()
3306 +
"\" type=\"" + currAttr.getTypeUriV2() +
"\"/>";
3310 String msg =
"Annonation link wasn't found. TmpId = " + tmpId +
" .";
3311 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg);
3330 ArrayList<SuggestionLogEntry> suggested = requestInfo.getConfirmedSuggestions();
3332 List<BaseAttribute> attr = nestedAnn.getAttributes();
3333 Iterator<BaseAttribute> aIt = attr.iterator();
3334 while (aIt.hasNext()) {
3339 Iterator<SuggestionLogEntry> suggIt = suggested.iterator();
3341 boolean found =
false;
3342 while (suggIt.hasNext() && !found) {
3344 if (curSug.
getTmpId().equals(tmpId)) {
3345 Annotation annotHit = curSug.getConfirmedVersion();
3346 if (annotHit != null) {
3347 attribute.setValue(annotHit);
3348 if(annotHit != null){
3349 attribute.setAttributeType(annotHit.getAnnotType());
3355 if (found ==
false) {
3357 int langNum = requestInfo.getSession().getLanguageNum();
3358 int lod = requestInfo.getSession().getProtocolLOD();
3362 String info =
"<attribute annotationUri=\"" + nestedAnn.getURIV2()
3364 +
"\" name=\"" + attribute.getName()
3366 +
"\" type=\"" + attribute.getTypeUriV2() +
"\"/>";
3370 String msg =
"Annonation link wasn't found.";
3371 Logger.getLogger(CoreFuncModule.class.getName()).log(Level.SEVERE, msg);
3387 if (requestInfo.
getFlier() != null) {
3388 if (requestInfo.
getFlier().getTextModifications() != null && !requestInfo.
getFlier().getTextModifications().isEmpty()) {
ArrayList< String > getQueryTypes()
String makeAddedAnnotMsg(ArrayList< Annotation > addedAnnotations, EditorSession session, Flier flier, boolean proto11)
static final int ERROR_43_NOT_SYNCHRONIZED
Constants for protocol version 2.
static synchronized boolean hasModificationSetsConflicts(int documentID, int setID, ArrayList< TextModification > modifications)
static ArrayList< Annotation > getLinkedAnnotationsDB(Annotation annot)
Class representing subscription.
static boolean isGroupIncluded(String gStr)
String getModuleName(int lang)
static final int WARNING_2_ANNOT_ORPHANED
static LockMaster getLockMaster()
List< Integer > getLinkedByBeforeRemove()
String getModuleDescription(int lang)
Class representing attribute of unknown type of annotation.
static void updateTmpIdRefInNested(Annotation nestedAnn, RequestInfo requestInfo)
Annotation getRefAnnotation()
String makeDeletedAnnotMsg(ArrayList< Annotation > deletedAnnotations, ArrayList< Annotation > deletedNestedAnnotations, EditorSession session, boolean proto11)
boolean isInJustAdded(String serverUri)
AnnotDocument getSyncDocument()
void addNestedToRemoved(Annotation annot, List< Annotation > removedNested)
ArrayList< String > getSubscriptionQuery()
Annotation getNestedAnnotation()
static ArrayList< Annotation > getDifference(ArrayList< Annotation > annotListA, ArrayList< Annotation > annotListB)
static final int LOG_LEVEL_ALL_ERRORS
String getQueriedTypeLike(String qString, RequestInfo requestInfo)
static final double MIN_XPATH_LD_DIFF_TO_AUTO_MODIFY_FR
static final int ERROR_100_UNKNOWN_ERROR
ArrayList< Annotation > getAnnotsForUpdate(ArrayList< Annotation > annotations, ArrayList< Annotation > updatedAnnots)
ArrayList< String > getQueriedTypes()
static int SUBS_QUERY_URI
static boolean documentUsageLocked
Class representing attribute of type of annotation.
boolean isInSubscribeList(Subscription subscription)
ArrayList< TextModification > getTextModifications()
String processRequestBeforePersist(RequestInfo requestInfo)
void updateAnnotationLinks(Annotation annot, RequestInfo requestInfo)
static final int ERROR_105_MODIFICATION_SPECIFICATION
double isAnnotationAffected(Annotation annotation, AnnotDocument newDoc, RequestInfo requestInfo)
ArrayList< Integer > getErrorList()
double fragmentTreshold(Fragment origFragment, UpdatableFragment foundFragment)
static final int ERROR_9_SYNC_ERROR_DIFFERENT
Class representing annotated copy of document.
Document, annotations and types manipulation functionality.
MatcherProvider nearestMatcherProvider
ArrayList< Subscription > getSubscribeList()
static HashMap< String, ReentrantLock > documentURILocker
static int SUBS_QUERY_COUNT
boolean canBeDocumentModified(RequestInfo requestInfo)
static final int LOG_LEVEL_SERVER_INTERNAL_ERRORS
Singleton for storing global variables.
static final int MAX_OFFSET_DIFF_TO_AUTO_MODIFY_FR
ArrayList< String > getAllNestedIdentificators(Annotation annot)
String getQueriedSubscriptions(RequestInfo requestInfo)
Class providing access to available matchers.
String messagesFromFlier(Flier flier, EditorSession session)
static final int WARNING_6_FRAGMENTS_UPDATED
boolean typeInClientCache(AnnotType type, ArrayList< String > queries)
void reSynchronizeStructuredDocument(AnnotDocument doc, AnnotDocument newDoc, RequestInfo requestInfo)
ArrayList< SuggestionLogEntry > getAutoconfirmedSuggestions()
void generateTextModificationsToFlier(String oldVersion, String newVersion, boolean linearized, RequestInfo requestInfo)
static final int ERROR_36_BAD_DOCUMENT
ArrayList< UserGroup > getLeavedGroups()
synchronized void unlockDocumentUsage()
int checkAnnotationFragments(Annotation annotation, AnnotDocument annotDoc, RequestInfo requestInfo, Boolean cmpErr, Integer updFr)
Class representing attribute of type AnnotationLink.
static final int ERROR_39_MODIFICATION_NOT_APPLICABLE
void synchronizeDocument(RequestInfo requestInfo)
int getLastModificationNumber()
MatcherProvider sequenceMatcherProvider
String updateDocument(RequestInfo requestInfo)
String getAllInterestingAnnotations(RequestInfo requestInfo)
TextModification provider.
String getQueriedTypeExact(String qString, RequestInfo requestInfo)
boolean fragmentEqualsWUF(UpdatableFragment uf)
String getAnnotatedText()
ArrayList< Annotation > getLinkedAnnotations(ArrayList< Annotation > approvedAnnotations)
boolean isTypeInGroups(AnnotType annotType, EditorSession session)
List< Fragment > getFragments()
ArrayList< Subscription > getUnsubscribeList()
Suggested annotation with informations about suggestion.
static final int MAX_ANNOTATION_DIFFERENCE
Static class which parses and process XML with messages.
String getAttrOnto(RequestInfo requestInfo)
Class representing user group.
static int SUBS_QUERY_AUTHOR
Annotation getRefAnnotation()
void reSynchronizeLinearizedDocument(AnnotDocument doc, AnnotDocument newDoc, RequestInfo requestInfo)
boolean equals(Object obj)
String getUriInOntology()
static final int ERROR_6_ATTRIBUTE_REQUIRED
static final int ERROR_10_SYNC_ERROR_NOT_POSSIBLE
void findLinkingAnnotationsIds(Annotation remAnnot, List< Integer > closed)
static final int ERROR_25_BAD_FRAGMENT
static ArrayList< String > getUserSources(User user)
static final String DOCUMENT_XPATH
void synchronizeStructuredDocument(AnnotDocument doc, AnnotDocument newDoc, RequestInfo requestInfo)
static final int ERROR_52_AMBIGUOUS_FRAGMENT
static final int MIN_TEXT_L_TO_AUTO_MODIFY_FR
static final double MAX_XPATH_LD_TO_AUTO_MODIFY_FR
AnnotDocument getSyncDocumentData()
String getResyncDocContent()
boolean containsMoreThanTwoAsterisks(String pattern, String wildcard)
static final int MIN_XPATH_L_TO_AUTO_MODIFY_FR
ArrayList< UserGroup > getJoinedGroups()
String makeChangedAnnotMsg(ArrayList< Annotation > changedAnnotations, EditorSession session, boolean proto11)
Base class representing attribute of annotation.
static final double MAX_TEXT_LD_TO_AUTO_MODIFY_FR
Class for XML document fragment.
static final int LOG_LEVEL
ArrayList< Annotation > getRelatedAnnotations(ArrayList< Annotation > annotations)
String getQueriedTypes(RequestInfo requestInfo)
static final int WARNING_4_ANNOT_PART_ORPHANED
Class representing type of annotation.
ArrayList< Annotation > getAddedAnnotations()
Exception of DocumentUpdate class which is thrown in case of modification failure.
Class representing modification of annotated document text.
static final int ERROR_35_BAD_XPATH
String processRequestAfterPersist(RequestInfo requestInfo, boolean persistFailed)
Compare class using Levenshtein approximate string matching method.
Flier with informations for comet handlers.
EditorSession getSession()
static final int LOG_LEVEL_ALL
void updateAllExisting(RequestInfo requestInfo)
static PersistM getPersistenceManager()
static final int ERROR_59_AUTO_UPDATE_FAILED
Class consisting of traversing method and compare method.
boolean isSyncWithOverwrite()
Interface for server module.
static int getLowestProtocolFromSessionList(RequestInfo requestInfo)
Exact XPath node iterator.
String getQueryTypeAttOnto()
String getUriInOntology()
boolean isAutoconfirmRequested()
String getQueSubsLike(ArrayList< String > qString)
static final int LOG_LEVEL_SERVER_ERRORS
static final int PROTOCOL_LOD_V1_1
static final int ERROR_38_ANNOT_MALFORMED
ArrayList< Annotation > getRemovedAnnotations()
static final int PROTOCOL_LOD_V2
Node iterator which is gradually unnesting.
ArrayList< SuggestionLogEntry > getConfirmedSuggestions()
AnnotDocument getSyncDocument()
boolean isSubscribed(Annotation annot, boolean testDoc)
void reSynchronizeDocument(RequestInfo requestInfo)
Class for matcher consisting of comparator and node iterator.
Processed informations about client request.
double isAnnotationsAffected(AnnotDocument doc, AnnotDocument newDoc, RequestInfo requestInfo)
MatcherProvider matcherProvider
synchronized void lockDocumentUsage()
static int SUBS_QUERY_GROUP
Helper class with util XPath methods.
Long getCreatedInSessId()
static final int ERROR_7_ATTRIBUTE_VALUE
Class responsible for localised strings.
static ArrayList< Annotation > getRelatedAnnotations(ArrayList< Annotation > approvedAnnot, ArrayList< Annotation > unapprovedAnnot, EditorSession session)
boolean checkReqAttrsInAnnot(Annotation annot, RequestInfo requestInfo)
ArrayList< Subscription > getNewSubscriptions()
Informations about client session.
static final int ERROR_11_SYNC_ERROR_NEED_RESYNC
void synchronizeLinearizedDocument(AnnotDocument doc, AnnotDocument newDoc, RequestInfo requestInfo)
static final int ERROR_53_BAD_DOCUMENT_URI
static final int WARNING_3_ANNOT_UPDATED
boolean updateAnnotation(Annotation annotation, RequestInfo requestInfo)
static String cleanUpURI(String uri)
static synchronized boolean lastModificationSetsContains(int documentID, int setID)
Class representing annotated fragment.
static synchronized int getDocumentUsage(Integer documentId)
ArrayList< Annotation > addWithoutDuplicity(ArrayList< Annotation > listOfOld, ArrayList< Annotation > listOfNew)
List< BaseAttribute > getAttributes()
void checkAddedAndEdited(RequestInfo requestInfo)
Class representing annotation.
static final int ERROR_99_UNSUPPORTED_OPERATION
static final int ERROR_62_SYNC_ERROR_OTHER_DIFFERENT
boolean isSubscribedToLinkingAnnot(EditorSession session, Annotation remAnnot, ArrayList< Annotation > deletedAnnotations)
boolean isSyncLinearized()
ArrayList< Settings > getSettings()
static final int ERROR_33_MODULE_ERROR
MatcherProvider getMatcherProvider()
MatcherProvider exactMatcherProvider
abstract Object getValue()