4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
AppBean.java
Go to the documentation of this file.
1 /*
2  * Project: Server for annotations sharing
3  * Author: Ing. Jaroslav Dytrych idytrych@fit.vutbr.cz
4  * File: AppBean.java
5  * Description: Singleton for storing global variables and performing operations
6  * at global application level (eg. generating session id's).
7  */
8 
9 /**
10  * @file AppBean.java
11  *
12  * @brief Singleton for storing global variables
13  */
14 
15 /**
16  * @package cz.vutbr.fit.knot.annotations.app
17  *
18  * @brief Global objects and constants
19  */
20 package cz.vutbr.fit.knot.annotations.app;
21 
33 import java.util.ArrayList;
34 import java.util.HashMap;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.Map;
38 import java.util.concurrent.locks.ReentrantLock;
39 
40 /**
41  * Singleton for storing global variables and performing operations at global
42  * application level (eg. generating session id's).
43  *
44  * @brief Singleton for storing global variables
45  * @author idytrych
46  */
47 public class AppBean {
48 
49  /** Instance of AppBean */
50  private static AppBean instance = null;
51 
52  /** Persistence manager */
53  private static PersistM persistenceManager = null;
54  /** Response creator (single instance for whole application) */
55  private static ResponseCreator responseCreator = null;
56  /** Next id for session */
57  private static long idGen = 0;
58  /** Next temporary id for suggested annotation */
59  private static long tmpIdGen = 0;
60 
61  /** List of active sessions */
62  private static ArrayList<EditorSession> sessions;
63  /** Map with user authentication data for external authentication */
64  private static Map<String,Map<String,String>> extAuthData;
65  /** Instance of SessionsCleaner */
66  private static SessionCleaner sessionCleaner = null;
67  /** Counters of how many instances of document is opened. */
68  private static HashMap<Integer, Integer> documentUsageMap = new HashMap<Integer,Integer>();
69  /** HashMap for id of last used text modification on document. <documentID, lastModificationID> */
70  private static HashMap<Integer, Integer> documentLastModificationIDMap = new HashMap<Integer, Integer>();
71  /** HashMap for last 3 used text modification on document. <documentID, lastModifications> */
72  private static HashMap<Integer, LastTextModifications> documentAppliedModificationsMap = new HashMap<Integer, LastTextModifications>();
73  /** Instance of SEC API Interface */
74  private static SECAPIInterface secApiInterface = null;
75  /** Instance of LockMaster */
76  private static LockMaster lockMaster = null;
77  /* HashMap for locking document URIs while trying to search in database */
78  public static HashMap<String,ReentrantLock> documentURILocker = new HashMap<String,ReentrantLock>();
79 
80  /** Server URI */
81  private static String serverUri = Constants.SERVER_URI;
82  /** Was server URI loaded? */
83  private static boolean serverUriLoaded = false;
84  /** SEC API SERVER URI */
85  private static String secApiServerUri = null;
86  /** URI prefix for images from controlled vocabulary */
87  private static String KBImagePrefix = null;
88  /** List of requested type definitions for SEC API */
89  private static ArrayList<SecApiReqTypeDef> reqTypeDefinitions = null;
90  /** List of available type definitions for SEC API */
91  private static ArrayList<SecApiReqTypeDef> avTypeDefinitions = null;
92  /** List of desired type definitions for SEC API */
93  private static ArrayList<SecApiReqTypeDef> desTypeDefinitions = null;
94  /** List of unnecessary type definitions for SEC API */
95  private static ArrayList<SecApiReqTypeDef> unTypeDefinitions = null;
96  /** List of unnecessary attribute definitions for SEC API */
97  private static ArrayList<SecApiReqTypeDef> unAtDefinitions = null;
98  /** List of requested type definitions for SEC API entity autocomplete */
99  private static ArrayList<SecApiReqTypeDef> reqTypeDefinitionsEA = null;
100  /** List of desired type definitions for SEC API entity autocomplete */
101  private static ArrayList<SecApiReqTypeDef> desTypeDefinitionsEA = null;
102  /** List of unnecessary type definitions for SEC API entity autocomplete */
103  private static ArrayList<SecApiReqTypeDef> unTypeDefinitionsEA = null;
104  /** List of unnecessary attribute definitions for SEC API entity autocomplete */
105  private static ArrayList<SecApiReqTypeDef> unAtDefinitionsEA = null;
106  /** Should be usage of getAlternativesFor logged (for measurement purposes)? */
107  private static Boolean logGetAlternativesFor = null;
108 
109  /**
110  * Constructor - Creates a new instance of AppBean, response creator
111  * and persistence manager
112  */
113  private AppBean() {
114  if (persistenceManager == null) {
116  }
117  Object[] paramsP = {"name", Constants.SERVER_URI_SETTING_NAME};
118  @SuppressWarnings("unchecked")
119  List<ServerSetting> settingsList = persistenceManager.queryDB("ServerSetting.findByName", paramsP);
120  if (settingsList != null && !settingsList.isEmpty()) {
121  if (!settingsList.get(0).getSettingValue().isEmpty()) {
122  serverUri = settingsList.get(0).getSettingValue();
123  }
124  }
125  serverUriLoaded = true;
126  if (responseCreator == null) {
128  }
129  if (sessions == null) {
130  sessions = new ArrayList<EditorSession>();
131  }
132  if (extAuthData == null) {
133  extAuthData = new HashMap<String, Map<String,String>>();
134  }
135  if (sessionCleaner == null) {
137  }
138  if(lockMaster == null){
139  lockMaster = new LockMaster();
140  }
141  if (secApiInterface == null) {
144  SuggestionManager.initReqTypesFromRemote(sac, null);
145  } else {
147  secApiInterface.init();
148  SuggestionManager.initReqTypes();
149  }
150  }
151  }
152 
153  /**
154  * Gets instance of AppBean
155  *
156  * @return Returns instance of AppBean
157  */
158  public static AppBean getInstance() {
159  if (instance == null) {
160  instance = new AppBean();
161  }
162  return instance;
163  }
164 
165  /**
166  * Gets instance of SessionsCleaner
167  *
168  * @return Returns instance of SessionsCleaner
169  */
171  if (sessionCleaner == null) {
173  }
174 
175  return sessionCleaner;
176  }
177 
178  /**
179  * Gets instance of persistence manager
180  *
181  * @return Returns instance of persistence manager
182  */
183  public static PersistM getPersistenceManager() {
184  if (persistenceManager == null) {
186  }
187  return persistenceManager;
188  }
189 
190  /**
191  * Gets instance of response creator
192  *
193  * @return Returns instance of response creator
194  */
196  if (responseCreator == null) {
198  }
199  return responseCreator;
200  }
201 
202  /**
203  * Adds server module to list of active modules in response creator
204  *
205  * @param module Server module
206  */
207  public static void addModule(AnnotServerModule module) {
208  if (responseCreator == null) {
210  }
211  responseCreator.addModule(module);
212  }
213 
214  /**
215  * Generate session id
216  *
217  * @return New generated session id
218  */
219  public static synchronized long getNextSessId() {
220  return idGen++;
221  }
222 
223  /**
224  * Generate temporary id for suggested annotation
225  *
226  * @return New generated temporary id for suggested annotation
227  */
228  public static synchronized long getNextTmpId() {
229  return tmpIdGen++;
230  }
231 
232  /**
233  * Gets list of client sessions
234  *
235  * @return List of sessions
236  */
237  public static ArrayList<EditorSession> getSessions() {
238  if (sessions == null) {
239  sessions = new ArrayList<EditorSession>();
240  }
241  return sessions;
242  }
243 
244  /**
245  * Gets global LockMaster instance
246  *
247  * @return Global LockMaster instance
248  */
249  public static LockMaster getLockMaster(){
250  if(lockMaster == null){
251  lockMaster = new LockMaster();
252  }
253  return lockMaster;
254  }
255 
256  /**
257  * Refreshes users in client sessions
258  *
259  * @param user Optional parameter with updated user
260  */
261  public static void refreshUsersInSessions(User user) {
262  if (sessions == null) {
263  sessions = new ArrayList<EditorSession>();
264  return;
265  }
266 
267  synchronized(sessions){
268  if (user != null) { // if only given users data will be refreshed
269  for (Iterator<EditorSession> sesIt = sessions.iterator(); sesIt.hasNext();) {
270  EditorSession editorSession = sesIt.next();
271  if (editorSession.getUser() != null
272  && editorSession.getUser().getId() != null
273  && editorSession.getUser().getId() == user.getId()) {
274  editorSession.refreshUser();
275  }
276  }
277  } else { // if all users data will be refreshed
278  for (Iterator<EditorSession> sesIt = sessions.iterator(); sesIt.hasNext();) {
279  EditorSession editorSession = sesIt.next();
280  editorSession.refreshUser();
281  }
282  }
283  }
284  } // refreshUsersInSessions()
285 
286  /**
287  * Adds client session to the list of sessions
288  *
289  * @param es Session to be added
290  */
291  public static void addSession(EditorSession es) {
292  if (sessions == null) {
293  sessions = new ArrayList<EditorSession>();
294  }
295 
296  synchronized(sessions){
297  sessions.add(es);
298  }
299  }
300 
301  /**
302  * Removes client session from the list of sessions
303  *
304  * @param es Session to be removed
305  */
306  public static void removeSession(EditorSession es) {
307  if (sessions == null) {
308  sessions = new ArrayList<EditorSession>();
309  }
310 
311  synchronized(sessions){
312  sessions.remove(es);
313  }
314  }
315 
316  /**
317  * Removes client session from the list of sessions
318  *
319  * @param id Id of session to be removed
320  */
321  public static void removeSession(long id) {
322  if (sessions == null) {
323  sessions = new ArrayList<EditorSession>();
324  }
325 
326  synchronized(sessions){
327  EditorSession cmp = new EditorSession(id);
328  sessions.remove(cmp);
329  }
330  }
331 
332  /**
333  * Gets requested session
334  *
335  * @param id Id of requested session
336  * @return If session exists, returns requested session, else returns null.
337  */
338  public static EditorSession getSession(long id) {
339  if (sessions == null) {
340  sessions = new ArrayList<EditorSession>();
341  }
342 
343  synchronized(sessions){
344  EditorSession cmp = new EditorSession(id);
345  int index = sessions.indexOf(cmp);
346  if (index < 0)
347  return null;
348  return sessions.get(index);
349  }
350  }
351 
352  /**
353  * Checks whether session with given id exists
354  *
355  * @param id Id of checked session
356  * @return If session exists, returns true, false otherwise
357  */
358  public static boolean sessionExists(long id) {
359  if (sessions == null) {
360  sessions = new ArrayList<EditorSession>();
361  }
362  synchronized(sessions){
363  EditorSession cmp = new EditorSession(id);
364  return sessions.contains(cmp);
365  }
366  }
367 
368  /**
369  * Removes authentication data of given user from the global map
370  *
371  * @param system System from which user come
372  * @param login Login of the user
373  */
374  public static void removeExtAuthData(String system, String login) {
375  if (extAuthData == null) {
376  extAuthData = new HashMap<String, Map<String,String>>();
377  return;
378  }
379  Map<String,String> sysAuthData = extAuthData.get(system);
380  if (sysAuthData != null) {
381  extAuthData.remove(login);
382  }
383  }
384 
385  /**
386  * Sets authentication data of given user in the global map
387  *
388  * @param system System from which user come
389  * @param login Login of the user
390  * @param data String with authentication data for the user
391  */
392  public static void setExtAuthData(String system, String login, String data) {
393  if (extAuthData == null) {
394  extAuthData = new HashMap<String, Map<String,String>>();
395  }
396  Map<String,String> sysAuthData = extAuthData.get(system);
397  if (sysAuthData == null) {
398  sysAuthData = new HashMap<String, String>();
399  extAuthData.put(system, sysAuthData);
400  }
401  sysAuthData.put(login, data);
402  }
403 
404  /**
405  * Gets authentication data for given user
406  *
407  * @param system System from which user come
408  * @param login Login of the user
409  * @return Returns authentication data for the user or null, if no data for
410  * this user available
411  */
412  public static String getExtAuthData(String system, String login) {
413  if (extAuthData == null) {
414  extAuthData = new HashMap<String, Map<String,String>>();
415  return null;
416  }
417  Map<String,String> sysAuthData = extAuthData.get(system);
418  if (sysAuthData == null) {
419  return null;
420  }
421  return sysAuthData.get(login);
422  }
423 
424  /**
425  * Gets instance of SEC API interface
426  *
427  * @return Returns instance of SEC API interface
428  */
430  if (secApiInterface == null) {
432  secApiInterface.init();
433  SuggestionManager.initReqTypes();
434  }
435  return secApiInterface;
436  }
437 
438  /**
439  * Checks whether SEC API interface is available
440  *
441  * @return If SEC API interface is available, returns true, false otherwise
442  */
443  public static boolean isSecApiInterfaceAvailable() {
444  if (secApiInterface == null) {
445  return false;
446  }
447  return true;
448  }
449 
450  /**
451  * Sets instance of SEC API interface
452  *
453  * @param secApiInterface Instance of SEC API interface
454  */
456  AppBean.secApiInterface = secApiInterface;
457  }
458 
459  /**
460  * Gets number of opened document instances
461  *
462  * @param documentId ID of document
463  * @return Number of opened document instances
464  */
465  public static synchronized int getDocumentUsage(Integer documentId){
466  if(documentUsageMap.get(documentId) != null){
467  return documentUsageMap.get(documentId);
468  }
469  return 0;
470  }
471 
472  /**
473  * Increments number of opened document instances
474  *
475  * @param documentId ID of document
476  */
477  public static synchronized void incrementDocumentUsage(Integer documentId){
478  Integer value = documentUsageMap.get(documentId);
479  if (value != null) {
480  // Increment number of instances of existing document
481  documentUsageMap.put(documentId, value + 1);
482  } else { // Document is opened for the first time
483  documentUsageMap.put(documentId, 1);
484  }
485  }
486 
487  /**
488  * Decrement number of opened document instances
489  *
490  * @param documentId ID of document
491  */
492  public static synchronized void decrementDocumentUsage(Integer documentId){
493  Integer value = documentUsageMap.get(documentId);
494  if (value != null) {
495  if (value > 1) {
496  documentUsageMap.put(documentId, value - 1);
497  } else {
498  documentUsageMap.remove(documentId);
499  }
500  }
501  }
502 
503  /**
504  * Gets ID of the last text modification set applied on a document.
505  *
506  * @param documentId ID of the document
507  * @return modification set ID, -1 on error
508  */
509  public static synchronized int getLastDocModification(int documentId){
511  return documentLastModificationIDMap.get(documentId);
512  }
513  return -1;
514  }
515 
516  /**
517  * Increments ID of the last text modification set applied on a document.
518  *
519  * @param documentId ID of the document
520  * @return On success returns incremented ID, null otherwise
521  */
522  public static synchronized Integer incrementLastDocModification(int documentId){
524  Integer modID = documentLastModificationIDMap.get(documentId);
525  if(modID != null){
526  ++modID;
527  documentLastModificationIDMap.put(documentId, modID);
528  return modID;
529  }
530  }
531  return null;
532  }
533 
534  /**
535  * Initializes ID of the last text modification set applied on a document.
536  *
537  * @param documentId ID of the document
538  */
539  public static synchronized void initLastDocModification(int documentId){
540  if(documentLastModificationIDMap == null){
541  documentLastModificationIDMap = new HashMap<Integer, Integer>();
542  }
543  documentLastModificationIDMap.put(documentId, 0);
544  }
545 
546  /**
547  * Adds last applied set of modifications to hashmap
548  *
549  * @param documentID ID of the document
550  * @param modificationID modification set ID
551  * @param modificationSet modification set
552  */
553  public static synchronized void addDocModificationSet(int documentID, int modificationID,
554  ArrayList<TextModification> modificationSet)
555  {
557  documentAppliedModificationsMap = new HashMap<Integer, LastTextModifications>();
558  }
559  LastTextModifications lastMods = documentAppliedModificationsMap.get(documentID);
560  if(lastMods != null){
561  lastMods.addNextModificationSet(modificationID, modificationSet);
562  }
563  else{
564  LastTextModifications newLastMod = new LastTextModifications(documentID, modificationID, modificationSet);
565  documentAppliedModificationsMap.put(documentID, newLastMod);
566  }
567  }
568 
569  /**
570  * Removes all applied sets of modifications from hashmap
571  *
572  * @param documentID Document ID for modification sets removal
573  */
574  public static synchronized void removePossibleModificationSets(int documentID){
576  documentAppliedModificationsMap.remove(documentID);
577  }
578  }
579 
580  /**
581  * Checks whetever last modification sets of the document indetified by
582  * documentID contains passed modification setID.
583  *
584  * @param documentID Document ID
585  * @param setID Checked modification set ID
586  * @return true if contains otherwise false
587  */
588  public static synchronized boolean lastModificationSetsContains(int documentID, int setID){
590  LastTextModifications lastMods = documentAppliedModificationsMap.get(documentID);
591  if(lastMods != null && lastMods.containsSet(setID)){
592  return true;
593  }
594  }
595  return false;
596  }
597 
598  /**
599  * Checks whetever the modification sets applied after modification
600  * identified by the passed setID of the document indetified by
601  * documentID contains conflicts with passed modification set.
602  *
603  * @param documentID Document ID
604  * @param setID ID of the set preceding the checked sets
605  * @param modifications Checked modification set
606  * @return true if there are conflicts otherwise false
607  */
608  public static synchronized boolean hasModificationSetsConflicts(int documentID,
609  int setID, ArrayList<TextModification> modifications)
610  {
612  LastTextModifications lastMods = documentAppliedModificationsMap.get(documentID);
613  if(lastMods != null){
614  return lastMods.hasModificationSetsConflicts(setID, modifications);
615  }
616  }
617  return false;
618  }
619 
620  /**
621  * Gets server URI
622  *
623  * @return Returns server URI
624  */
625  public static String getServerUri() {
626  if (!serverUriLoaded) {
627  Object[] paramsP = {"name", Constants.SERVER_URI_SETTING_NAME};
628  @SuppressWarnings("unchecked")
629  List<ServerSetting> settingsList = getPersistenceManager().queryDB("ServerSetting.findByName", paramsP);
630  if (settingsList != null && !settingsList.isEmpty()) {
631  if (!settingsList.get(0).getSettingValue().isEmpty()) {
632  serverUri = settingsList.get(0).getSettingValue();
633  }
634  }
635  serverUriLoaded = true;
636  }
637  return serverUri;
638  }
639 
640  /**
641  * Sets server URI
642  *
643  * @param serverUri New server URI
644  */
645  public static void setServerUri(String serverUri) {
646  AppBean.serverUri = serverUri;
647  }
648 
649  /**
650  * Gets base URI
651  *
652  * @return Returns base URI
653  */
654  public static String getBaseUri() {
655  return getServerUri() + "/" + Constants.URI_C;
656  }
657 
658  /**
659  * Gets beginning of URI of annotation
660  *
661  * @return Returns beginning of URI of annotation
662  */
663  public static String getBaseAnnotUri() {
664  return getServerUri() + "/" + Constants.URI_C + Constants.ANNOT_URI_SUFFIX;
665  }
666 
667  /**
668  * Gets beginning of URI of suggestion
669  *
670  * @return Returns beginning of URI of suggestion
671  */
672  public static String getBaseSugUri() {
673  return getServerUri() + "/" + Constants.URI_C + Constants.SUG_URI_SUFFIX;
674  }
675 
676  /**
677  * Gets beginning of URI of annotation type
678  *
679  * @return Returns beginning of URI of annotation type
680  */
681  public static String getBaseTypeUri() {
682  return getServerUri() + "/" + Constants.URI_C + Constants.TYPE_URI_SUFFIX;
683  }
684 
685  /**
686  * Gets beginning of URI of annotated copy of document
687  *
688  * @return Returns beginning of URI of annotated copy of document
689  */
690  public static String getBaseDocumentUri() {
691  return getServerUri() + "/" + Constants.URI_C + Constants.DOC_URI_SUFFIX;
692  }
693 
694  /**
695  * Gets beginning of URI of stored document
696  *
697  * @return Returns beginning of URI of stored document
698  */
699  public static String getBaseStoredDocumentUri() {
700  return getServerUri() + "/" + Constants.URI_C + Constants.S_DOC_URI_SUFFIX;
701  }
702 
703  /**
704  * Gets beginning of URI of annotation author (person)
705  *
706  * @return Returns beginning of URI of annotation author (person)
707  */
708  public static String getBaseAuthorUri() {
709  return getServerUri() + "/" + Constants.URI_C + Constants.AUTHOR_URI_SUFFIX;
710  }
711 
712  /**
713  * Gets beginning of URI of user (person)
714  *
715  * @return Returns beginning of URI of user (person)
716  */
717  public static String getBaseUserUri() {
718  return getServerUri() + "/" + Constants.URI_C + Constants.USER_URI_SUFFIX;
719  }
720 
721  /**
722  * Gets beginning of URI of user (person) for protocol version 2
723  *
724  * @return Returns beginning of URI of user (person) for protocol version 2
725  */
726  public static String getBaseUserUriV2() {
727  return getServerUri() + "/" + Constants.URI_C + Constants.USER_URI_SUFFIX_V2;
728  }
729 
730  /**
731  * Gets beginning of URI of user group
732  *
733  * @return Returns beginning of URI of user group
734  */
735  public static String getBaseGroupUri() {
736  return getServerUri() + "/" + Constants.URI_C + Constants.GROUP_URI_SUFFIX;
737  }
738 
739  /**
740  * Gets base URI for ontology upload
741  *
742  * @return Returns base URI for ontology upload
743  */
744  public static String getBaseOntoUploadUri() {
745  return getServerUri() + "/" + Constants.URI_C + Constants.ONTO_UPLOAD_URI_SUFFIX;
746  }
747 
748  /**
749  * Gets address of the SEC API server for annotation suggestions
750  *
751  * @return Returns address of the SEC API server for annotation suggestions
752  */
753  public static String getSecApiServerUri() {
754  if (secApiServerUri == null) { // load on first request
755  Object[] paramsP = {"name", Constants.SEC_API_SERVER_URI_SETTING_NAME};
756  @SuppressWarnings("unchecked")
757  List<ServerSetting> settingsList = getPersistenceManager().queryDB("ServerSetting.findByName", paramsP);
758  if (settingsList != null && !settingsList.isEmpty()) {
759  if (!settingsList.get(0).getSettingValue().isEmpty()) {
760  secApiServerUri = settingsList.get(0).getSettingValue();
761  } else {
763  }
764  } else {
766  }
767  }
768  return secApiServerUri;
769  } // getSecApiServerUri()
770 
771  /**
772  * Gets beginning of URI of subscription
773  *
774  * @return Returns beginning of URI of subscription
775  */
776  public static String getBaseSubscriptionUri() {
777  return getServerUri() + "/" + Constants.URI_C + Constants.SUBSCR_URI_SUFFIX;
778  }
779 
780  /**
781  * Ensures reload of some URIs loaded from DB
782  */
783  public static void resetURIs() {
784  KBImagePrefix = null;
785  secApiServerUri = null;
786  logGetAlternativesFor = null;
787  }
788 
789  /**
790  * Sets address of the SEC API server for annotation suggestions
791  *
792  * @param secApiServerUri Address of the SEC server for annotation suggestions
793  */
794  public static void setSecApiServerUri(String secApiServerUri) {
795  AppBean.secApiServerUri = secApiServerUri;
796  }
797 
798  /**
799  * Gets URI prefix for images from controlled vocabulary
800  *
801  * @return Returns URI prefix for images from controlled vocabulary
802  */
803  public static String getKBImagePrefix() {
804  if (KBImagePrefix == null) { // load on first request
805  Object[] paramsP = {"name", Constants.KB_IMG_PREFIX_SETTING_NAME};
806  @SuppressWarnings("unchecked")
807  List<ServerSetting> settingsList = getPersistenceManager().queryDB("ServerSetting.findByName", paramsP);
808  if (settingsList != null && !settingsList.isEmpty()) {
809  if (!settingsList.get(0).getSettingValue().isEmpty()) {
810  KBImagePrefix = settingsList.get(0).getSettingValue();
811  } else {
813  }
814  } else {
816  }
817  }
818  return KBImagePrefix;
819  }
820 
821  /**
822  * Gets whethershould be usage of getAlternativesFor logged
823  *
824  * @return Returns whether should be usage of getAlternativesFor logged
825  */
826  public static Boolean getLogGetAlternativesFor() {
827  if (logGetAlternativesFor == null) { // load on first request
828  Object[] paramsP = {"name", Constants.LOG_GET_ALTERNATIVES_SETTINGS};
829  @SuppressWarnings("unchecked")
830  List<ServerSetting> settingsList = getPersistenceManager().queryDB("ServerSetting.findByName", paramsP);
831  if (settingsList != null && !settingsList.isEmpty()) {
832  if (!settingsList.get(0).getSettingValue().isEmpty()) {
833  String settingsStr = settingsList.get(0).getSettingValue();
834  if (Boolean.parseBoolean(settingsStr) || "1".equals(settingsStr)) {
835  logGetAlternativesFor = true;
836  } else {
837  logGetAlternativesFor = false;
838  }
839  } else {
840  logGetAlternativesFor = false;
841  }
842  } else {
843  logGetAlternativesFor = false;
844  }
845  }
846  return logGetAlternativesFor;
847  }
848 
849  /**
850  * Sets URI prefix for images from controlled vocabulary
851  *
852  * @param KBImagePrefix URI prefix for images from controlled vocabulary
853  */
854  public static void setKBImagePrefix(String KBImagePrefix) {
855  AppBean.KBImagePrefix = KBImagePrefix;
856  }
857 
858  /**
859  * Gets list of requested type definitions for SEC API
860  *
861  * @return Returns list of requested type definitions for SEC API
862  */
863  public static ArrayList<SecApiReqTypeDef> getReqTypeDefinitions() {
864  return reqTypeDefinitions;
865  }
866 
867  /**
868  * Sets list of requested type definitions for SEC API
869  *
870  * @param reqTypeDefinitions List of requested type definitions for SEC API
871  */
872  public static void setReqTypeDefinitions(ArrayList<SecApiReqTypeDef> reqTypeDefinitions) {
873  AppBean.reqTypeDefinitions = reqTypeDefinitions;
874  }
875 
876  /**
877  * Gets list of desired type definitions for SEC API
878  *
879  * @return Returns list of desired type definitions for SEC API
880  */
881  public static ArrayList<SecApiReqTypeDef> getDesTypeDefinitions() {
882  return desTypeDefinitions;
883  }
884 
885  /**
886  * Sets list of desired type definitions for SEC API
887  *
888  * @param desTypeDefinitions List of desired type definitions for SEC API
889  */
890  public static void setDesTypeDefinitions(ArrayList<SecApiReqTypeDef> desTypeDefinitions) {
891  AppBean.desTypeDefinitions = desTypeDefinitions;
892  }
893 
894  /**
895  * Gets list of unnecessary type definitions for SEC API
896  *
897  * @return Returns list of unnecessary type definitions for SEC API
898  */
899  public static ArrayList<SecApiReqTypeDef> getUnTypeDefinitions() {
900  return unTypeDefinitions;
901  }
902 
903  /**
904  * Sets list of unnecessary type definitions for SEC API
905  *
906  * @param unTypeDefinitions List of unnecessary type definitions for SEC API
907  */
908  public static void setUnTypeDefinitions(ArrayList<SecApiReqTypeDef> unTypeDefinitions) {
909  AppBean.unTypeDefinitions = unTypeDefinitions;
910  }
911 
912  /**
913  * Gets list of available type definitions for SEC API
914  *
915  * @return Returns list of available type definitions for SEC API
916  */
917  public static ArrayList<SecApiReqTypeDef> getAvTypeDefinitions() {
918  return avTypeDefinitions;
919  }
920 
921  /**
922  * Sets list of available type definitions for SEC API
923  *
924  * @param avTypeDefinitions List of available type definitions for SEC API
925  */
926  public static void setAvTypeDefinitions(ArrayList<SecApiReqTypeDef> avTypeDefinitions) {
927  AppBean.avTypeDefinitions = avTypeDefinitions;
928  }
929 
930  /**
931  * Gets list of unnecessary attribute definitions for SEC API
932  *
933  * @return Returns list of unnecessary attribute definitions for SEC API
934  */
935  public static ArrayList<SecApiReqTypeDef> getUnAtDefinitions() {
936  return unAtDefinitions;
937  }
938 
939  /**
940  * Sets list of unnecessary attribute definitions for SEC API
941  *
942  * @param unAtDefinitions List of unnecessary attribute definitions for SEC API
943  */
944  public static void setUnAtDefinitions(ArrayList<SecApiReqTypeDef> unAtDefinitions) {
945  AppBean.unAtDefinitions = unAtDefinitions;
946  }
947 
948 
949  /**
950  * Gets list of desired type definitions for SEC API entity autocomplete
951  *
952  * @return Returns list of desired type definitions for SEC API entity autocomplete
953  */
954  public static ArrayList<SecApiReqTypeDef> getDesTypeDefinitionsEA() {
955  return desTypeDefinitionsEA;
956  }
957 
958  /**
959  * Sets list of desired type definitions for SEC API entity autocomplete
960  *
961  * @param desTypeDefinitionsEA List of desired type definitions for SEC API entity autocomplete
962  */
963  public static void setDesTypeDefinitionsEA(ArrayList<SecApiReqTypeDef> desTypeDefinitionsEA) {
964  AppBean.desTypeDefinitionsEA = desTypeDefinitionsEA;
965  }
966 
967  /**
968  * Gets list of requested type definitions for SEC API entity autocomplete
969  *
970  * @return Returns list of requested type definitions for SEC API entity autocomplete
971  */
972  public static ArrayList<SecApiReqTypeDef> getReqTypeDefinitionsEA() {
973  return reqTypeDefinitionsEA;
974  }
975 
976  /**
977  * Sets list of requested type definitions for SEC API entity autocomplete
978  *
979  * @param reqTypeDefinitionsEA List of requested type definitions for SEC API entity autocomplete
980  */
981  public static void setReqTypeDefinitionsEA(ArrayList<SecApiReqTypeDef> reqTypeDefinitionsEA) {
982  AppBean.reqTypeDefinitionsEA = reqTypeDefinitionsEA;
983  }
984 
985  /**
986  * Gets list of unnecessary attribute definitions for SEC API entity autocomplete
987  *
988  * @return Returns list of unnecessary attribute definitions for SEC API entity autocomplete
989  */
990  public static ArrayList<SecApiReqTypeDef> getUnAtDefinitionsEA() {
991  return unAtDefinitionsEA;
992  }
993 
994  /**
995  * Sets list of unnecessary attribute definitions for SEC API entity autocomplete
996  *
997  * @param unAtDefinitionsEA List of unnecessary attribute definitions for SEC API entity autocomplete
998  */
999  public static void setUnAtDefinitionsEA(ArrayList<SecApiReqTypeDef> unAtDefinitionsEA) {
1000  AppBean.unAtDefinitionsEA = unAtDefinitionsEA;
1001  }
1002 
1003  /**
1004  * Gets list of unnecessary type definitions for SEC API entity autocomplete
1005  *
1006  * @return Returns list of unnecessary type definitions for SEC API
1007  */
1008  public static ArrayList<SecApiReqTypeDef> getUnTypeDefinitionsEA() {
1009  return unTypeDefinitionsEA;
1010  }
1011 
1012  /**
1013  * Sets list of unnecessary type definitions for SEC API entity autocomplete
1014  *
1015  * @param unTypeDefinitionsEA List of unnecessary type definitions for SEC API
1016  */
1017  public static void setUnTypeDefinitionsEA(ArrayList<SecApiReqTypeDef> unTypeDefinitionsEA) {
1018  AppBean.unTypeDefinitionsEA = unTypeDefinitionsEA;
1019  }
1020 
1021 } // class AppBean
static synchronized void initLastDocModification(int documentId)
Definition: AppBean.java:539
static ArrayList< SecApiReqTypeDef > unAtDefinitionsEA
Definition: AppBean.java:105
static void setServerUri(String serverUri)
Definition: AppBean.java:645
static synchronized boolean hasModificationSetsConflicts(int documentID, int setID, ArrayList< TextModification > modifications)
Definition: AppBean.java:608
static synchronized long getNextSessId()
Definition: AppBean.java:219
static boolean sessionExists(long id)
Definition: AppBean.java:358
static ArrayList< SecApiReqTypeDef > reqTypeDefinitions
Definition: AppBean.java:89
static void setReqTypeDefinitions(ArrayList< SecApiReqTypeDef > reqTypeDefinitions)
Definition: AppBean.java:872
static void removeExtAuthData(String system, String login)
Definition: AppBean.java:374
static void addModule(AnnotServerModule module)
Definition: AppBean.java:207
static void setUnAtDefinitions(ArrayList< SecApiReqTypeDef > unAtDefinitions)
Definition: AppBean.java:944
Persistence manager (database manipulator)
Definition: PersistM.java:35
Class representing parameter of server settings.
static ArrayList< SecApiReqTypeDef > unTypeDefinitionsEA
Definition: AppBean.java:103
static ArrayList< SecApiReqTypeDef > getUnAtDefinitions()
Definition: AppBean.java:935
static ArrayList< SecApiReqTypeDef > getDesTypeDefinitions()
Definition: AppBean.java:881
static ArrayList< SecApiReqTypeDef > avTypeDefinitions
Definition: AppBean.java:91
static HashMap< String, ReentrantLock > documentURILocker
Definition: AppBean.java:78
static void setReqTypeDefinitionsEA(ArrayList< SecApiReqTypeDef > reqTypeDefinitionsEA)
Definition: AppBean.java:981
static void setUnTypeDefinitions(ArrayList< SecApiReqTypeDef > unTypeDefinitions)
Definition: AppBean.java:908
Singleton for storing global variables.
Definition: AppBean.java:47
static ArrayList< SecApiReqTypeDef > reqTypeDefinitionsEA
Definition: AppBean.java:99
static void setSecApiServerUri(String secApiServerUri)
Definition: AppBean.java:794
static synchronized void addDocModificationSet(int documentID, int modificationID, ArrayList< TextModification > modificationSet)
Definition: AppBean.java:553
static void setExtAuthData(String system, String login, String data)
Definition: AppBean.java:392
static SessionCleaner getSessionsCleaner()
Definition: AppBean.java:170
static Map< String, Map< String, String > > extAuthData
Definition: AppBean.java:64
static ArrayList< SecApiReqTypeDef > getUnAtDefinitionsEA()
Definition: AppBean.java:990
Interface for call of SEC API as external program (deamon)
static ArrayList< SecApiReqTypeDef > desTypeDefinitionsEA
Definition: AppBean.java:101
static void setUnTypeDefinitionsEA(ArrayList< SecApiReqTypeDef > unTypeDefinitionsEA)
Definition: AppBean.java:1017
static ArrayList< SecApiReqTypeDef > getAvTypeDefinitions()
Definition: AppBean.java:917
static ArrayList< EditorSession > sessions
Definition: AppBean.java:62
static ResponseCreator responseCreator
Definition: AppBean.java:55
static ArrayList< SecApiReqTypeDef > getDesTypeDefinitionsEA()
Definition: AppBean.java:954
Class provides offerining of suggestions with usage of local knowledge repository.
static void setAvTypeDefinitions(ArrayList< SecApiReqTypeDef > avTypeDefinitions)
Definition: AppBean.java:926
static synchronized void decrementDocumentUsage(Integer documentId)
Definition: AppBean.java:492
Class that provides cleaning of unactive sessions (basic version, not final)
Class for creating of requested type definition for SEC API.
static void setKBImagePrefix(String KBImagePrefix)
Definition: AppBean.java:854
static SECAPIInterface secApiInterface
Definition: AppBean.java:74
static ArrayList< SecApiReqTypeDef > getReqTypeDefinitions()
Definition: AppBean.java:863
static String getExtAuthData(String system, String login)
Definition: AppBean.java:412
static void setSecApiInterface(SECAPIInterface secApiInterface)
Definition: AppBean.java:455
Class representing user.
Definition: User.java:51
static ArrayList< EditorSession > getSessions()
Definition: AppBean.java:237
static HashMap< Integer, Integer > documentLastModificationIDMap
Definition: AppBean.java:70
synchronized boolean containsSet(int modificationID)
static void removeSession(EditorSession es)
Definition: AppBean.java:306
static HashMap< Integer, Integer > documentUsageMap
Definition: AppBean.java:68
static ArrayList< SecApiReqTypeDef > unTypeDefinitions
Definition: AppBean.java:95
static synchronized void incrementDocumentUsage(Integer documentId)
Definition: AppBean.java:477
static void addSession(EditorSession es)
Definition: AppBean.java:291
static synchronized long getNextTmpId()
Definition: AppBean.java:228
Class that creates responses and persists data.
static ArrayList< SecApiReqTypeDef > getUnTypeDefinitionsEA()
Definition: AppBean.java:1008
static ResponseCreator getResponseCreator()
Definition: AppBean.java:195
Class representing last applied modifications on a document.
static HashMap< Integer, LastTextModifications > documentAppliedModificationsMap
Definition: AppBean.java:72
Class implementing functions for communication with remote SEC API.
Definition: SECAPIConn.java:37
static ArrayList< SecApiReqTypeDef > getReqTypeDefinitionsEA()
Definition: AppBean.java:972
static EditorSession getSession(long id)
Definition: AppBean.java:338
static ArrayList< SecApiReqTypeDef > getUnTypeDefinitions()
Definition: AppBean.java:899
static void refreshUsersInSessions(User user)
Definition: AppBean.java:261
static synchronized void removePossibleModificationSets(int documentID)
Definition: AppBean.java:574
static ArrayList< SecApiReqTypeDef > desTypeDefinitions
Definition: AppBean.java:93
Informations about client session.
static ArrayList< SecApiReqTypeDef > unAtDefinitions
Definition: AppBean.java:97
static void setUnAtDefinitionsEA(ArrayList< SecApiReqTypeDef > unAtDefinitionsEA)
Definition: AppBean.java:999
static synchronized boolean lastModificationSetsContains(int documentID, int setID)
Definition: AppBean.java:588
static synchronized int getDocumentUsage(Integer documentId)
Definition: AppBean.java:465
static void setDesTypeDefinitionsEA(ArrayList< SecApiReqTypeDef > desTypeDefinitionsEA)
Definition: AppBean.java:963
static synchronized int getLastDocModification(int documentId)
Definition: AppBean.java:509
static synchronized Integer incrementLastDocModification(int documentId)
Definition: AppBean.java:522
static SessionCleaner sessionCleaner
Definition: AppBean.java:66
static SECAPIInterface getSecApiInterface()
Definition: AppBean.java:429
static void setDesTypeDefinitions(ArrayList< SecApiReqTypeDef > desTypeDefinitions)
Definition: AppBean.java:890