Salome HOME
Modifications to respect PMD rules.
authorrkv <rkv@opencascade.com>
Wed, 7 Nov 2012 13:51:39 +0000 (13:51 +0000)
committerrkv <rkv@opencascade.com>
Wed, 7 Nov 2012 13:51:39 +0000 (13:51 +0000)
26 files changed:
Workspace/Converter/src/Launcher.java
Workspace/Siman-Common/src/org/splat/som/DocumentRights.java
Workspace/Siman/src/org/splat/module/SaveDocumentAction.java
Workspace/Siman/src/org/splat/simer/Action.java
Workspace/Siman/src/org/splat/simer/ApplicationSettings.java
Workspace/Siman/src/org/splat/simer/ConnectionAction.java
Workspace/Siman/src/org/splat/simer/DisplayKnowledgeAction.java
Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java
Workspace/Siman/src/org/splat/simer/EditDocumentAction.java
Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java
Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java
Workspace/Siman/src/org/splat/simer/EditStudyAction.java
Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java
Workspace/Siman/src/org/splat/simer/NewScenarioAction.java
Workspace/Siman/src/org/splat/simer/NewStudyAction.java
Workspace/Siman/src/org/splat/simer/OpenStudy.java
Workspace/Siman/src/org/splat/simer/SearchBaseAction.java
Workspace/Siman/src/org/splat/simer/SearchKnowledgeAction.java
Workspace/Siman/src/org/splat/simer/SearchStudyAction.java
Workspace/Siman/src/org/splat/simer/StartAction.java
Workspace/Siman/src/org/splat/simer/UploadAction.java
Workspace/Siman/src/org/splat/simer/VersionDocumentAction.java
Workspace/Siman/src/org/splat/simer/admin/DatabaseIndexingAction.java
Workspace/Siman/src/org/splat/simer/admin/ImportUserAction.java
Workspace/Siman/src/org/splat/simer/admin/ProjectElementFacade.java
Workspace/Siman/src/org/splat/simer/admin/SimulationContextAction.java

index 9bb42a2b64a3282b2397c35c60563c614a229cce..bc611d70fcace08eae75ff15593a5a624e181898 100644 (file)
@@ -1,44 +1,47 @@
-import java.io.*;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.Writer;
 import java.util.Properties;
 
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 
+public class Launcher { //RKV: NOPMD: TODO: Move this class into a package
 
-public class Launcher {
-
-    private String  executable;
-    private String  source;
-    private File    log;
+    private transient String  _executable;
+    private transient String  _source;
+    private transient File    _log;
 
 //  ==============================================================================================================================
 //  Main
 //  ==============================================================================================================================
 
-       public static void main(String[] args) {
+       public static void main(final String[] args) {
 //  --------------------------------------
-         if (args.length < 2) return;
+         if (args.length < 2) {
+               return;
+       }
 
       Launcher session     = new Launcher();
-      session.executable  = args[0];
-      session.source      = args[1];
+      session._executable  = args[0];
+      session._source      = args[1];
 
-      String[]      parse = session.source.split("\\x2E");
+      String[]      parse = session._source.split("\\x2E");
       StringBuffer  path  = new StringBuffer(parse[0]);
-      for (int i=1; i<parse.length-1; i++) path.append(".").append(parse[i]);
+      for (int i=1; i<parse.length-1; i++) {
+               path.append(".").append(parse[i]);
+       }
       try {
-        session.log = new File(path.append(".").append("log").toString());
-        session.log.createNewFile();
+        session._log = new File(path.append(".").append("log").toString());
+        session._log.createNewFile();
         session.doConvert();
       }
       catch (Exception error) {
-       System.out.print(error.getMessage());
+       System.out.print(error.getMessage()); //RKV: NOPMD: TODO: use logger?
       }
        }
 
@@ -48,9 +51,9 @@ public class Launcher {
 
     private void doConvert () throws IOException {
 //  -------------------------
-      Writer  output = new BufferedWriter( new FileWriter(log) );
+      Writer  output = new BufferedWriter( new FileWriter(_log) );
 
-      output.write("Conversion of " + source + "\r\n");
+      output.write("Conversion of " + _source + "\r\n");
       try {
         String            jndir     = System.getProperty("resource.dir") + "jndi.conf";
         File              propfile  = new File(jndir);
@@ -66,7 +69,7 @@ public class Launcher {
 //        MessageProducer   myself    = session.createProducer(queue);
 //        TextMessage       message   = session.createTextMessage();
 
-        output.write("Launching converter " + executable + "\r\n");
+        output.write("Launching converter " + _executable + "\r\n");
         output.write("Context : " + context.toString() + "\r\n");
 
 //      Process           converter = Runtime.getRuntime().exec("\"" + executable + "\" " + source);
@@ -78,7 +81,7 @@ public class Launcher {
       }
       catch (Exception error) {
        output.write("ERROR Converter Launcher, reason:\r\n");
-       error.printStackTrace( new PrintStream(log) );
+       error.printStackTrace( new PrintStream(_log) );
       }
       output.close();
     }
index 599a32c48a55283ec7c148b2e89b476101d63ca0..dfe1cf4e004d1c613df3db044f4d72173bf9eb6e 100644 (file)
@@ -29,30 +29,29 @@ import org.splat.service.ServiceLocatorImpl;
 
 public class DocumentRights {
 
-    private User             user;
-    private Publication      operand;
-    private ValidationCycle  cycle;
-    private boolean          isauthor;     // True if the user is author of the document
+    private transient final User            _user;
+    private transient Publication           _operand;
+    private transient final ValidationCycle _cycle;
+    private transient boolean               _isauthor;     // True if the user is author of the document
 
 //  ==============================================================================================================================
 //  Constructors
 //  ==============================================================================================================================
 
-    public DocumentRights (User user, Publication tag) {
-//  --------------------------------------------------
-      this.user     = user;
-      this.operand  = tag;
+    public DocumentRights (final User user, final Publication tag) {
+      this._user     = user;
+      this._operand  = tag;
 //RKV      this.cycle    = operand.getOwnerStudy().getValidationCycleOf(operand.value().getType());
-      this.cycle    = ServiceLocatorImpl.getInstance().getStudyService().getValidationCycleOf(operand.getOwnerStudy(), operand.value().getType());
-      this.isauthor = operand.value().getAuthor().equals(user);
+      this._cycle    = ServiceLocatorImpl.getInstance().getStudyService().getValidationCycleOf(_operand.getOwnerStudy(), _operand.value().getType());
+      this._isauthor = _operand.value().getAuthor().equals(user);
 //TODO: all contributors of the given document (when supported) must also behave as author
     }
-    protected DocumentRights (Publication tag) {
-//  ------------------------------------------
-      this.user     = operand.value().getAuthor();
-      this.operand  = tag;
-      this.cycle    = ServiceLocatorImpl.getInstance().getStudyService().getValidationCycleOf(operand.getOwnerStudy(), operand.value().getType());
-      this.isauthor = true;           // In order to ignore the author state in the context of any user
+    protected DocumentRights (final Publication tag) {
+      this._operand  = tag;
+      this._user     = _operand.value().getAuthor();
+      this._operand  = tag;
+      this._cycle    = ServiceLocatorImpl.getInstance().getStudyService().getValidationCycleOf(_operand.getOwnerStudy(), _operand.value().getType());
+      this._isauthor = true;           // In order to ignore the author state in the context of any user
 //TODO: all contributors of the given document (when supported) must also behave as author
     }
 
@@ -68,90 +67,101 @@ public class DocumentRights {
  * @return true if the user has right to accept the modifications of dependencies of the document.
  * @see    Publication#accept()
  */
-    public boolean canAccept () {
-//  ---------------------------
-      if (!isauthor) return false;
-      return operand.isOutdated();
-    }
+    public boolean canAccept() {
+               return _isauthor && _operand.isOutdated();
+       }
 
 /**
- * Checks if the user has right to approve the selected document.
- * Only the approver of the type of selected document has such right, providing that the document is candidate for approval and
- * all document dependencies have already been approved.
+ * Checks if the user has right to approve the selected document. Only the approver of the type of selected document has such right,
+ * providing that the document is candidate for approval and all document dependencies have already been approved.
  * 
  * @return true if the user has right to approve the document.
- * @see    Publication#approve()
- * @see    ValidationCycle
+ * @see Publication#approve()
+ * @see ValidationCycle
  */
-    public boolean canApprove () {
-//  ----------------------------
-      User  approver = cycle.getActor(ValidationStep.APPROVAL);             // May be null if not approvable
-
-      if (!user.equals(approver)) return false;
-      if (operand.getProgressState() != ProgressState.inCHECK) return false;
-      
-      List<Relation>            use = operand.value().getRelations(UsesRelation.class);
-      for (Iterator<Relation> i=use.iterator(); i.hasNext();) {
-       Document      depend = (Document)i.next().getTo();
-       ProgressState state  = depend.getProgressState();
-       if (state == ProgressState.EXTERN)   continue;                      // External documents do not follow this progress state
-       if (state != ProgressState.APPROVED) return false;
-      }
-      return true;
-    }
+    public boolean canApprove() {
+               User approver = _cycle.getActor(ValidationStep.APPROVAL); // May be null if not approvable
+               boolean res = (_user.equals(approver))
+                               && (_operand.getProgressState() == ProgressState.inCHECK);
+               if (res) {
+                       List<Relation> use = _operand.value().getRelations(
+                                       UsesRelation.class);
+                       for (Iterator<Relation> i = use.iterator(); i.hasNext();) {
+                               Document depend = (Document) i.next().getTo();
+                               ProgressState state = depend.getProgressState();
+                               if (state == ProgressState.EXTERN) {
+                                       continue; // External documents do not follow this progress state
+                               }
+                               if (state != ProgressState.APPROVED) {
+                                       res = false;
+                                       break;
+                               }
+                       }
+               }
+               return res;
+       }
 
 /**
- * Checks if the user has right to attach a file to the selected document.
- * Both, the author, during the elaboration of the document, and the reviewer of the document, during the review process,
- * have such right.
+ * Checks if the user has right to attach a file to the selected document. Both, the author, during the elaboration of the document, and the
+ * reviewer of the document, during the review process, have such right.
  * 
  * @return true if the user has right to attach a file to the document.
- * @see    Publication#attach(String)
- * @see    Publication#attach(String, String)
+ * @see Publication#attach(String)
+ * @see Publication#attach(String, String)
  */
-    public boolean canAttach () {
-//  ---------------------------
-      User           manager  = operand.getOwnerStudy().getAuthor();
-      User           reviewer = cycle.getActor(ValidationStep.REVIEW);      // May be null if not reviewable
-      ProgressState  state    = operand.value().getProgressState();
-
-      if (state == ProgressState.inWORK) return (isauthor);
-      else                               return (isauthor || user.equals(manager) || user.equals(reviewer));
-    }
+    public boolean canAttach() {
+               User manager = _operand.getOwnerStudy().getAuthor();
+               User reviewer = _cycle.getActor(ValidationStep.REVIEW); // May be null if not reviewable
+               ProgressState state = _operand.value().getProgressState();
+
+               return _isauthor
+                               || ((state != ProgressState.inWORK) && (_user.equals(manager) || _user
+                                               .equals(reviewer)));
+       }
 
 /**
- * Checks if the user has right to demote the selected document.
- * A document can be demoted providing that it is In-Draft or In-Check and all documents using it have previously been demoted.
- * In-Draft documents can be demoted by default by both, the author of the document and the responsible of study, while
- * documents in approval process can be demoted by their approver only.
+ * Checks if the user has right to demote the selected document. A document can be demoted providing that it is In-Draft or In-Check and all
+ * documents using it have previously been demoted. In-Draft documents can be demoted by default by both, the author of the document and the
+ * responsible of study, while documents in approval process can be demoted by their approver only.
  * 
  * @return true if the user has right to demote the document.
- * @see    #canInvalidate()
- * @see    #canPromote()
- * @see    Publication#demote()
- * @see    ValidationCycle
+ * @see #canInvalidate()
+ * @see #canPromote()
+ * @see Publication#demote()
+ * @see ValidationCycle
  */
     public boolean canDemote () {
-//  ---------------------------
-      User           manager   = operand.getOwnerStudy().getAuthor();
-      User           publisher = cycle.getActor(ValidationStep.PROMOTION);  // Null if the default users are involved
-      User           approver  = cycle.getActor(ValidationStep.APPROVAL);   // May be null if not approvable
-      ProgressState  mystate   = operand.value().getProgressState();
+      User           manager   = _operand.getOwnerStudy().getAuthor();
+      User           publisher = _cycle.getActor(ValidationStep.PROMOTION);  // Null if the default users are involved
+      User           approver  = _cycle.getActor(ValidationStep.APPROVAL);   // May be null if not approvable
+      ProgressState  mystate   = _operand.value().getProgressState();
 
       if (mystate == ProgressState.inDRAFT) {
-        if (publisher == null) { if (!isauthor && !user.equals(manager)) return false;
-        } else                   if (!user.equals(publisher))            return false;
+        if (publisher == null) { if (!_isauthor && !_user.equals(manager)) {
+                       return false;
+               }
+        } else                   if (!_user.equals(publisher)) {
+                       return false;
+               }
       } else
       if (mystate == ProgressState.inCHECK) {
-       if (!user.equals(approver))                                      return false;
-      } else                                                             return false;
+       if (!_user.equals(approver)) {
+                       return false;
+               }
+      } else {
+               return false;
+       }
       
-      List<Relation>            use = operand.value().getRelations(UsedByRelation.class);
+      List<Relation>            use = _operand.value().getRelations(UsedByRelation.class);
       for (Iterator<Relation> i=use.iterator(); i.hasNext();) {
        Document      depend = (Document)i.next().getTo();
        ProgressState state  = depend.getProgressState();
-       if (mystate == ProgressState.inDRAFT &&  state != ProgressState.inWORK)  return false;
-       if (mystate == ProgressState.inCHECK && (state != ProgressState.inDRAFT && state != ProgressState.inWORK)) return false;
+       if (mystate == ProgressState.inDRAFT &&  state != ProgressState.inWORK) {
+                       return false;
+               }
+       if (mystate == ProgressState.inCHECK && (state != ProgressState.inDRAFT && state != ProgressState.inWORK)) {
+                       return false;
+               }
       }
       return true;
     }
@@ -164,17 +174,20 @@ public class DocumentRights {
  * @return true if the user has right to edit the document.
  */
     public boolean canEdit () {
-//  -------------------------
-      User           manager  = operand.getOwnerStudy().getAuthor();
-      User           reviewer = cycle.getActor(ValidationStep.REVIEW);      // May be null if not reviewable
-      ProgressState  state    = operand.value().getProgressState();
+      User           manager  = _operand.getOwnerStudy().getAuthor();
+      User           reviewer = _cycle.getActor(ValidationStep.REVIEW);      // May be null if not reviewable
+      ProgressState  state    = _operand.value().getProgressState();
 
 //TODO: Should be restricted by the application if no editor available
       if (state == ProgressState.inWORK) {
-        if (isauthor || user.equals(manager)) return true;
+        if (_isauthor || _user.equals(manager)) {
+                       return true;
+               }
       } else
       if (state == ProgressState.inDRAFT) {
-        if (user.equals(reviewer))            return true;
+        if (_user.equals(reviewer)) {
+                       return true;
+               }
       }
       return false;
     }
@@ -191,20 +204,29 @@ public class DocumentRights {
  * @see    ValidationCycle
  */
     public boolean canPromote () {
-//  ----------------------------
-      User manager   = operand.getOwnerStudy().getAuthor();
-      User publisher = cycle.getActor(ValidationStep.PROMOTION);            // Null if the default users are involved
-
-      if (operand.getProgressState() != ProgressState.inWORK)          return false;
-      if (publisher == null) { if (!isauthor && !user.equals(manager)) return false;
-      } else {                 if (!user.equals(publisher))            return false;
+      User manager   = _operand.getOwnerStudy().getAuthor();
+      User publisher = _cycle.getActor(ValidationStep.PROMOTION);            // Null if the default users are involved
+
+      if (_operand.getProgressState() != ProgressState.inWORK) {
+               return false;
+       }
+      if (publisher == null) { if (!_isauthor && !_user.equals(manager)) {
+               return false;
+       }
+      } else {                 if (!_user.equals(publisher)) {
+               return false;
+       }
       }
-      List<Relation>            use = operand.value().getRelations(UsesRelation.class);
+      List<Relation>            use = _operand.value().getRelations(UsesRelation.class);
       for (Iterator<Relation> i=use.iterator(); i.hasNext();) {
        Document      depend = (Document)i.next().getTo();
        ProgressState state  = depend.getProgressState();
-       if (state == ProgressState.EXTERN) continue;                        // External documents do not follow this progress state
-       if (state == ProgressState.inWORK) return false;
+       if (state == ProgressState.EXTERN) {
+                       continue;                        // External documents do not follow this progress state
+               }
+       if (state == ProgressState.inWORK) {
+                       return false;
+               }
       }
       return true;
     }
@@ -216,13 +238,18 @@ public class DocumentRights {
  * @return true if the user has right to purge the document.
  */
     public boolean canPurge () {
-//  --------------------------
-      User      manager = operand.getOwnerStudy().getAuthor();
-      Document  doc     = operand.value();
+      User      manager = _operand.getOwnerStudy().getAuthor();
+      Document  doc     = _operand.value();
       
-      if (!user.equals(manager))                                return false;
-      if (doc.isShared())                                       return false;
-      if (doc.getFirstRelation(VersionsRelation.class) == null) return false;
+      if (!_user.equals(manager)) {
+               return false;
+       }
+      if (doc.isShared()) {
+               return false;
+       }
+      if (doc.getFirstRelation(VersionsRelation.class) == null) {
+               return false;
+       }
       return true;
     }
 
@@ -236,15 +263,18 @@ public class DocumentRights {
  * @see    Step#removeDocument(Publication)
  */
     public boolean canRemove () {
-//  ---------------------------
-      User          manager = operand.getOwnerStudy().getAuthor();
-      ProgressState state   = operand.getProgressState();
-
-      if (!isauthor && !user.equals(manager))                             return false;
-      if (state != ProgressState.inWORK && state != ProgressState.EXTERN) return false;
-
-      List<Publication> using = operand.getRelations(UsedByRelation.class);
-      return (using.size() == 0);
+      User          manager = _operand.getOwnerStudy().getAuthor();
+      ProgressState state   = _operand.getProgressState();
+
+      if (!_isauthor && !_user.equals(manager)) {
+               return false;
+       }
+      if (state != ProgressState.inWORK && state != ProgressState.EXTERN) {
+               return false;
+       }
+
+      List<Publication> using = _operand.getRelations(UsedByRelation.class);
+      return using.isEmpty();
     }
 
 /**
@@ -255,12 +285,15 @@ public class DocumentRights {
  * @see    Publication#rename(String)
  */
     public boolean canRename () {
-//  ---------------------------
-      ProgressState state = operand.getProgressState();
-
-      if (!isauthor) return false;     // In case of external document, the author is the one who has imported the document.
-      if (state != ProgressState.inWORK && state != ProgressState.EXTERN) return false;
-      return (!operand.value().isShared());
+      ProgressState state = _operand.getProgressState();
+
+      if (!_isauthor) {
+               return false;     // In case of external document, the author is the one who has imported the document.
+       }
+      if (state != ProgressState.inWORK && state != ProgressState.EXTERN) {
+               return false;
+       }
+      return (!_operand.value().isShared());
     }
 
 /**
@@ -271,13 +304,16 @@ public class DocumentRights {
  * @return true if the user has right to replace the document.
  */
     public boolean canReplace () {
-//  ----------------------------
-      User          manager = operand.getOwnerStudy().getAuthor();
-      ProgressState state   = operand.getProgressState();
-
-      if (!isauthor && !user.equals(manager)) return false;                 // Supposed to work also in case of external document.
-      if (state != ProgressState.inWORK && state != ProgressState.EXTERN) return false;
-      return !operand.value().isShared();
+      User          manager = _operand.getOwnerStudy().getAuthor();
+      ProgressState state   = _operand.getProgressState();
+
+      if (!_isauthor && !_user.equals(manager)) {
+               return false;                 // Supposed to work also in case of external document.
+       }
+      if (state != ProgressState.inWORK && state != ProgressState.EXTERN) {
+               return false;
+       }
+      return !_operand.value().isShared();
     }
 
 /**
@@ -291,18 +327,25 @@ public class DocumentRights {
  * @see    ValidationCycle
  */
     public boolean canReview () {
-//  ---------------------------
-      User  reviewer = cycle.getActor(ValidationStep.REVIEW);               // May be null if not reviewable
-
-      if (!user.equals(reviewer))                              return false;
-      if (operand.getProgressState() != ProgressState.inDRAFT) return false;
+      User  reviewer = _cycle.getActor(ValidationStep.REVIEW);               // May be null if not reviewable
+
+      if (!_user.equals(reviewer)) {
+               return false;
+       }
+      if (_operand.getProgressState() != ProgressState.inDRAFT) {
+               return false;
+       }
       
-      List<Relation>            use = operand.value().getRelations(UsesRelation.class);
+      List<Relation>            use = _operand.value().getRelations(UsesRelation.class);
       for (Iterator<Relation> i=use.iterator(); i.hasNext();) {
        Document      depend = (Document)i.next().getTo();
        ProgressState state  = depend.getProgressState();
-       if (state == ProgressState.EXTERN) continue;                        // External documents do not follow this progress state
-       if (state == ProgressState.inWORK || state == ProgressState.inDRAFT) return false;
+       if (state == ProgressState.EXTERN) {
+                       continue;                        // External documents do not follow this progress state
+               }
+       if (state == ProgressState.inWORK || state == ProgressState.inDRAFT) {
+                       return false;
+               }
       }
       return true;
     }
@@ -318,19 +361,26 @@ public class DocumentRights {
  * @see    ValidationCycle
  */
     public boolean canInvalidate () {
-//  -------------------------------
-      User           reviewer = cycle.getActor(ValidationStep.REVIEW);      // May be null if not reviewable
-      ProgressState  mystate  = operand.value().getProgressState();
-
-      if (mystate != ProgressState.inCHECK)    return false;
-      if (!isauthor && !user.equals(reviewer)) return false;
+      User           reviewer = _cycle.getActor(ValidationStep.REVIEW);      // May be null if not reviewable
+      ProgressState  mystate  = _operand.value().getProgressState();
+
+      if (mystate != ProgressState.inCHECK) {
+               return false;
+       }
+      if (!_isauthor && !_user.equals(reviewer)) {
+               return false;
+       }
         
-      List<Relation>            use = operand.value().getRelations(UsedByRelation.class);
+      List<Relation>            use = _operand.value().getRelations(UsedByRelation.class);
       for (Iterator<Relation> i=use.iterator(); i.hasNext();) {
         Document      depend = (Document)i.next().getTo();
         ProgressState state  = depend.getProgressState();
-        if (mystate == ProgressState.inDRAFT &&  state != ProgressState.inWORK)  return false;
-        if (mystate == ProgressState.inCHECK && (state != ProgressState.inDRAFT && state != ProgressState.inWORK)) return false;
+        if (mystate == ProgressState.inDRAFT &&  state != ProgressState.inWORK) {
+                       return false;
+               }
+        if (mystate == ProgressState.inCHECK && (state != ProgressState.inDRAFT && state != ProgressState.inWORK)) {
+                       return false;
+               }
       }
       return true;
     }
@@ -347,19 +397,24 @@ public class DocumentRights {
  * @see    Step#versionDocument(Publication, String)
  */
     public boolean canVersion () {
-//  ----------------------------
-      User           manager  = operand.getOwnerStudy().getAuthor();
-      User           reviewer = cycle.getActor(ValidationStep.REVIEW);      // May be null if not reviewable
-      ProgressState  state    = operand.value().getProgressState();
+      User           manager  = _operand.getOwnerStudy().getAuthor();
+      User           reviewer = _cycle.getActor(ValidationStep.REVIEW);      // May be null if not reviewable
+      ProgressState  state    = _operand.value().getProgressState();
 
       if (state == ProgressState.inWORK) {
-        if (isauthor || user.equals(manager)) return true;
+        if (_isauthor || _user.equals(manager)) {
+                       return true;
+               }
       } else
       if (state == ProgressState.inDRAFT) {
-        if (user.equals(reviewer))            return true;
+        if (_user.equals(reviewer)) {
+                       return true;
+               }
       } else
       if (state == ProgressState.APPROVED) {
-       if (isauthor)                         return true;
+       if (_isauthor) {
+                       return true;
+               }
       }
       return false;
  }
@@ -374,7 +429,6 @@ public class DocumentRights {
  * @return the document subject of checks.
  */
     public Document getOperand () {
-//  -----------------------------
-      return operand.value();
+      return _operand.value();
     }
 }
\ No newline at end of file
index 332d9209aa0838d5f5f772b0b2eb1f5ffdd92a68..1ab81b7058326859d6aee64d4d13c4df8ee361f4 100644 (file)
@@ -1,10 +1,10 @@
 package org.splat.module;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
-import java.util.Vector;
 
 import org.hibernate.HibernateException;
 import org.hibernate.Session;
@@ -40,13 +40,13 @@ public class SaveDocumentAction extends Action {
        /**
         * Current open study.
         */
-       private OpenStudy mystudy = null;
-       private int doctype = 0;
-       private String filename = null;
-       private String docname = null;
-       private ProgressState state = null;
-       private List<Document> defuses = null;
-       private String summary = null; // Summary of changes in the new version
+       private transient OpenStudy _mystudy = null;
+       private transient int _doctype = 0;
+       private transient String _filename = null;
+       private transient String _docname = null;
+       private transient ProgressState _state = null;
+       private transient List<Document> _defuses = null;
+       private String _description = null; // Summary of changes in the new version
        /**
         * Injected scenario service.
         */
@@ -82,16 +82,16 @@ public class SaveDocumentAction extends Action {
                Transaction transax = connex.beginTransaction();
                try {
                        // Getting user inputs
-                       mystudy = getOpenStudy();
+                       _mystudy = getOpenStudy();
                        User user = getConnectedUser();
-                       Step step = mystudy.getSelectedStep();
-                       DocumentType type = getDocumentTypeService().selectType(doctype);
+                       Step step = _mystudy.getSelectedStep();
+                       DocumentType type = getDocumentTypeService().selectType(_doctype);
                        // File updir = Database.getDownloadDirectory(user);
                        // File upfile = new File(updir.getPath() + "/" + filename);
                        String upath = getRepositoryService().getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file
                        // between users
-                       File upfile = new File(upath + filename);
-                       String[] table = filename.split("\\x2E");
+                       File upfile = new File(upath + _filename);
+                       String[] table = _filename.split("\\x2E");
                        String format = table[table.length - 1];
 
                        // Creation of the document
@@ -101,7 +101,7 @@ public class SaveDocumentAction extends Action {
                        Document.Properties dprop = new Document.Properties();
                        Publication credoc = getStepService().createDocument(
                                        step,
-                                       dprop.setName(docname).setType(type).setFormat(format)
+                                       dprop.setName(_docname).setType(type).setFormat(format)
                                                        .setAuthor(user));
                        // Writing the uploaded file into the created document
                        File target = credoc.getSourceFile().asFile();
@@ -112,12 +112,12 @@ public class SaveDocumentAction extends Action {
                        // upfile.renameTo(target);
 
                        // Saving the document in given state
-                       getPublicationService().saveAs(credoc, state);
+                       getPublicationService().saveAs(credoc, _state);
 
                        // Creation of default uses relations
-                       defuses = new Vector<Document>();
+                       _defuses = new ArrayList<Document>();
                        setupDefaultUses(type); // Recursive function
-                       for (Iterator<Document> i = defuses.iterator(); i.hasNext();) {
+                       for (Iterator<Document> i = _defuses.iterator(); i.hasNext();) {
                                credoc.addDependency(i.next());
                        }
 
@@ -125,7 +125,7 @@ public class SaveDocumentAction extends Action {
 
                        // 1. Conversion of the document to internal format, if required
                        // TODO: The following code is temporary, waiting for the support of converters
-                       if (format.equals("part")) {
+                       if ("part".equals(format)) {
                                ConvertsRelation export = getPublicationService().attach(
                                                credoc, "brep");
 
@@ -136,7 +136,7 @@ public class SaveDocumentAction extends Action {
                                Do.copy(upfile, target); // Instead of rename for keeping the "uploaded" file for further use
                        }
                        // 2. Addition of simulation contexts
-                       if (type.equals("model")) { // Set the characteristics of the mesh
+                       if ("model".equals(type)) { // Set the characteristics of the mesh
                                SimulationContext.Properties cprop = new SimulationContext.Properties();
                                SimulationContextType ctype = getSimulationContextService()
                                                .selectType("model");
@@ -169,18 +169,18 @@ public class SaveDocumentAction extends Action {
                        }
                        // Update of the open study
                        // mystudy.add(credoc); // Useless while the SIMER page need to be refreshed manually
-                       getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of first added document
+                       getMenu("study").selects(_mystudy.getSelection()); // Updates the menu icon, in case of first added document
 
                        transax.commit();
                        return SUCCESS;
                } catch (Exception saverror) {
-                       logger.error("Reason:", saverror);
+                       LOG.error("Reason:", saverror);
                        if (transax != null && transax.isActive()) {
                                // Second try-catch as the rollback could fail as well
                                try {
                                        transax.rollback();
                                } catch (HibernateException backerror) {
-                                       logger.debug("Error rolling back transaction", backerror);
+                                       LOG.debug("Error rolling back transaction", backerror);
                                }
                        }
                        return ERROR;
@@ -255,23 +255,23 @@ public class SaveDocumentAction extends Action {
                Transaction transax = connex.beginTransaction();
                try {
                        // Getting user inputs
-                       mystudy = getOpenStudy();
+                       _mystudy = getOpenStudy();
                        User user = getConnectedUser();
-                       Step step = mystudy.getSelectedStep();
+                       Step step = _mystudy.getSelectedStep();
                        // File updir = Database.getDownloadDirectory(user);
                        // File upfile = new File(updir.getPath() + "/" + filename);
                        String upath = getRepositoryService().getTemplatePath(); // Instead of DownloadDirectory for sharing the "uploaded" file
                        // between users
-                       File upfile = new File(upath + filename);
-                       String[] table = filename.split("\\x2E");
+                       File upfile = new File(upath + _filename);
+                       String[] table = _filename.split("\\x2E");
                        String format = table[table.length - 1];
 
                        // Versioning of the document
-                       Publication current = mystudy.getSelectedDocument();
+                       Publication current = _mystudy.getSelectedDocument();
                        Document.Properties dprop = new Document.Properties();
                        dprop.setAuthor(user);
-                       if (summary.length() > 0) {
-                               dprop.setDescription(summary);
+                       if (_description.length() > 0) {
+                               dprop.setDescription(_description);
                        }
 
                        Publication next = getStepService().versionDocument(step, current,
@@ -286,12 +286,12 @@ public class SaveDocumentAction extends Action {
                        // upfile.renameTo(target);
 
                        // Saving the document in given state
-                       getPublicationService().saveAs(next, state);
+                       getPublicationService().saveAs(next, _state);
 
                        // Creation of default uses relations
-                       defuses = new Vector<Document>();
+                       _defuses = new ArrayList<Document>();
                        setupDefaultUses(next.value().getType()); // Recursive function
-                       for (Iterator<Document> i = defuses.iterator(); i.hasNext();) {
+                       for (Iterator<Document> i = _defuses.iterator(); i.hasNext();) {
                                next.addDependency(i.next());
                        }
                        // TODO: Outdating impacted document
@@ -300,7 +300,7 @@ public class SaveDocumentAction extends Action {
 
                        // 1. Conversion of the document to internal format, if required
                        // TODO: The following code is temporary, waiting for the support of converters
-                       if (format.equals("part")) {
+                       if ("part".equals(format)) {
                                ConvertsRelation export = getPublicationService().attach(next,
                                                "brep");
                                String fname = table[0];
@@ -318,13 +318,13 @@ public class SaveDocumentAction extends Action {
                        transax.commit();
                        return SUCCESS;
                } catch (Exception saverror) {
-                       logger.error("Reason:", saverror);
+                       LOG.error("Reason:", saverror);
                        if (transax != null && transax.isActive()) {
                                // Second try-catch as the rollback could fail as well
                                try {
                                        transax.rollback();
                                } catch (HibernateException backerror) {
-                                       logger.debug("Error rolling back transaction", backerror);
+                                       LOG.debug("Error rolling back transaction", backerror);
                                }
                        }
                        return ERROR;
@@ -337,32 +337,32 @@ public class SaveDocumentAction extends Action {
 
        public String getDescription() {
                // -------------------------------
-               return summary;
+               return _description;
        }
 
        public void setDescription(final String summary) {
                // -------------------------------------------
-               this.summary = summary;
+               this._description = summary;
        }
 
        public void setDocumentName(final String name) {
                // -----------------------------------------
-               this.docname = name;
+               this._docname = name;
        }
 
        public void setDocumentState(final String state) {
                // -------------------------------------------
-               this.state = ProgressState.valueOf(state);
+               this._state = ProgressState.valueOf(state);
        }
 
        public void setDocumentType(final String value) {
                // ------------------------------------------
-               this.doctype = Integer.valueOf(value);
+               this._doctype = Integer.valueOf(value);
        }
 
        public void setFileName(final String name) {
                // -------------------------------------
-               this.filename = name;
+               this._filename = name;
        }
 
        // ==============================================================================================================================
@@ -374,11 +374,11 @@ public class SaveDocumentAction extends Action {
 
                for (Iterator<DocumentType> i = uses.iterator(); i.hasNext();) {
                        DocumentType usetype = i.next();
-                       List<Document> usedoc = mystudy.collectInvolvedDocuments(usetype);
+                       List<Document> usedoc = _mystudy.collectInvolvedDocuments(usetype);
                        if (usedoc.isEmpty()) {
                                setupDefaultUses(usetype);
                        } else {
-                               defuses.addAll(usedoc);
+                               _defuses.addAll(usedoc);
                        }
                }
        }
index 71e8bb1822d4226f687c00d9105ed562e626a5a0..47e928dba330fd80edd8b424f1b4949accd9266e 100644 (file)
@@ -1,55 +1,74 @@
 package org.splat.simer;
 
-import java.util.Map;
 import java.util.Comparator;
+import java.util.Map;
 import java.util.ResourceBundle;
 
 import javax.security.auth.login.LoginContext;
 import javax.servlet.http.HttpServletRequest;
 
-import com.opensymphony.xwork2.ActionSupport;
-
+import org.apache.log4j.Logger;
 import org.apache.struts2.interceptor.ServletRequestAware;
 import org.apache.struts2.interceptor.SessionAware;
-import org.apache.log4j.Logger;
 import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.DocumentType;
+import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.dal.bo.som.Study;
 import org.splat.service.dto.KnowledgeElementDTO;
 import org.splat.som.ApplicationRights;
 import org.splat.som.StudyRights;
-import org.splat.dal.bo.som.KnowledgeElement;
-import org.splat.dal.bo.som.SimulationContextType;
-import org.splat.dal.bo.som.Study;
-import org.splat.dal.bo.som.DocumentType;
 import org.splat.wapp.Menu;
 import org.splat.wapp.PopupMenu;
 
+import com.opensymphony.xwork2.ActionSupport;
 
 /**
  * Base Siman action.
  */
-public class Action extends ActionSupport implements ServletRequestAware, SessionAware {
+public class Action extends ActionSupport implements ServletRequestAware,
+               SessionAware {
 
        /**
         * Serial version ID.
         */
-       private   static final long    serialVersionUID = -895295026709526501L;
+       private static final long serialVersionUID = -895295026709526501L;
        /**
         * Action logger.
         */
-    protected static final Logger  logger           = Logger.getLogger(Action.class);
+       protected static final Logger LOG = Logger.getLogger(Action.class);
+
+       /**
+        * Open knowledge key in session.
+        */
+       public static final String KNOWLEDGE_OPEN = "knowledge.open";
+
+       /**
+        * Open study key in session.
+        */
+       public static final String STUDY_OPEN = "study.open";
+
+       /**
+        * User rights key in session.
+        */
+       public static final String USER_RIGHTS = "user.rights";
+
+       /**
+        * Login context key in session.
+        */
+       public static final String LOGIN_CONTEXT = "login.context";
 
        /**
         * Http servlet request.
         */
-       private HttpServletRequest  request;
+       private HttpServletRequest _servletRequest;
        /**
         * Http session container.
         */
-       private   Map<String, Object>  session;
+       private Map<String, Object> _session;
        /**
         * Error code.
         */
-       private   String               mercode;
+       private String _errorCode;
        /**
         * Current open study facade object.
         */
@@ -58,13 +77,12 @@ public class Action extends ActionSupport implements ServletRequestAware, Sessio
         * Current open knowledge facade object.
         */
        private OpenKnowledge _openKnowledge;
-       
-       
+
        /**
         * MenuBarSettings bean.
         */
        private MenuBarSettings _menuBarSettings;
-       
+
        /**
         * TitleBarSettings bean.
         */
@@ -73,325 +91,490 @@ public class Action extends ActionSupport implements ServletRequestAware, Sessio
         * ToolBarSettings bean.
         */
        private ToolBarSettings _toolBarSettings;
-       
+
        /**
         * LeftMenuSettings bean.
         */
        private LeftMenuSettings _leftMenuSettings;
-       
+
        /**
         * Injected application settings bean.
         */
        private ApplicationSettings _applicationSettings;
-       
-       /**
-        * Will be removed!!!
-        * It's temporary solution for menuitem.jsp
-        */
-       private static Menu staticMenu; 
-
-    public class DocumentTypeComparator implements Comparator<DocumentType> {
-      public int compare(DocumentType t1, DocumentType t2)
-      {
-        ResourceBundle       locale = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
-        String               name1  = t1.getName();
-        if (t1.isApproved()) name1  = locale.getString("type.document." + name1);
-        String               name2  = t2.getName();
-        if (t2.isApproved()) name2  = locale.getString("type.document." + name2);
-
-        return name1.compareToIgnoreCase(name2);
-      }
-    }
-    public class ContextTypeComparator  implements Comparator<SimulationContextType> {
-      public int compare(SimulationContextType t1, SimulationContextType t2)
-      {
-        ResourceBundle       locale = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
-        String               name1  = t1.getName();
-        if (t1.isApproved()) name1  = locale.getString("type.context." + name1);
-        String               name2  = t2.getName();
-        if (t2.isApproved()) name2  = locale.getString("type.context." + name2);
-
-        return name1.compareToIgnoreCase(name2);
-      }
-    }
-
-//  ==============================================================================================================================
-//  Session services
-//  ==============================================================================================================================
-
-    protected void closeKnowledge () {
-      OpenObject open = (OpenObject)session.remove("knowledge.open");
-      if (open != null) {
-        if (session.get("study.open") == null) open.clearFacades();      // For eventually reopening the knowledge from a fresh context
-      }
-    }
-    protected void closeStudy () {
-      OpenObject open = (OpenObject)session.remove("study.open");
-      if (open != null) {
-        if (session.get("knowledge.open") == null) open.clearFacades();  // For eventually reopening the study from a fresh context
-      }
-    }
-    protected void connect (LoginContext context, User user) {
-      OpenStudy  open = getOpenStudy();
-      if (open != null) {
-          open.changeUser(user);
-      }
-      session.put("user.rights", new ApplicationRights(user) );
-      session.put("login.context", context);                             // For executing the deconnection, when requested
-    }
-    protected void disconnect () {
-      OpenStudy  open = getOpenStudy();
-      if (open != null) {
-          open.changeUser(null);
-      }
-      session.put("user.rights", new ApplicationRights(null) );          // Disables user rights
-      session.remove("login.context");
-    }
-    public User getConnectedUser () {
-      ApplicationRights  rights = (ApplicationRights)session.get("user.rights");
-      User connected = null;
-      if (rights != null) {
-         connected = rights.getUser();
-      }
-      return connected;                                           // May be null
-    }
-    protected Menu getMenu (String name) {
-      return (Menu)session.get("menu." + name);
-    }
-    public void setOpenKnowledge (OpenKnowledge kelm) {
-        _openKnowledge = kelm;
-      }
-    protected OpenKnowledge getOpenKnowledge () {
-//     _openKnowledge = (OpenKnowledge)session.get("knowledge.open");               // May be null
-       return _openKnowledge;
-    }
-    public void setOpenStudy (OpenStudy aStudy) {
-      _openStudy = aStudy;
-    }
-    public OpenStudy getOpenStudy () {
-//     _openStudy = (OpenStudy)session.get("study.open");
-          return _openStudy;                       // May be null
-        }
-    protected OpenKnowledge open (KnowledgeElementDTO kelm) {
-      OpenKnowledge open = _openKnowledge.open(kelm);
-
-      closeKnowledge();   // Just in case
-         session.put("knowledge.open", open);
-         return open;
-    }
-    protected OpenStudy open (Study study) {
-         OpenStudy open = _openStudy.open(getConnectedUser(), study);         // The connected user may be null
-
-      closeStudy();       // Just in case
-         session.put("study.open", open);
-         return open;
-    }
-    
-    /**
-     * Initialization the Context for menubar and toolbar.
-     */
-    public void initializationContext() {
-       getMenuBarSettings().initializeInitialMenuProperties();
-       
-       if (session.get("study.open") == null) {
-               getMenuBarSettings().setIsStudyNull(true);
-       } else {
-               getMenuBarSettings().setIsStudyNull(false);
-               
-               //for initialization ToolBarSettings.canUserEdit property
-               // and ToolBarSettings.isEnabledScript property.
-               
-               OpenStudy currentStudy = (OpenStudy)session.get("study.open");
-               PopupMenu    popup = currentStudy.getPopup();
-           StudyRights  user  = currentStudy.getStudyRights();
-           
-           if(user.canEditProperties()) {
-               getToolBarSettings().setCanUserEdit(true);
-           } else {
-               getToolBarSettings().setCanUserEdit(false);
-           }
-           
-           if (popup == null) {
-               getToolBarSettings().setIsEnabledScript(false);
-           } else if (popup.isEnabled("script")) {
-               getToolBarSettings().setIsEnabledScript(true);
-           } else {
-               getToolBarSettings().setIsEnabledScript(false);
-           }
-       }
-       
-       if (session.get("knowledge.open") == null) {
-               getMenuBarSettings().setIsKnowledgeNull(true);
-       } else {
-               getMenuBarSettings().setIsKnowledgeNull(false);
-       }
-       
-       ApplicationRights userRights  = (ApplicationRights)session.get("user.rights");
-       
-       if ((userRights != null) && userRights.canCreateStudy()) {
-               getMenuBarSettings().setCanUserCreateStudy(true);
-       } else {
-               getMenuBarSettings().setCanUserCreateStudy(false);
-       }
-       
-       if ((userRights != null) && userRights.canManageDatabase()) {
-               getMenuBarSettings().setCanUserManageDatabase(true);
-       } else {
-               getMenuBarSettings().setCanUserManageDatabase(false);
-       } 
-       
-    }
-    
-    /**
-     * Initialization the Context for left menu.
-     * @param leftMenuProperty - the property of the left menu.
-     */
-    public void initializationContextLeftMenus(final String leftMenuProperty) {
-                 
-        Menu    menu   = (Menu)session.get("menu." + leftMenuProperty);
-        
-        getLeftMenuSettings().setMenu(menu);
-        setStaticMenu(menu);
-        getLeftMenuSettings().setMenuName(menu.getName());
-        getLeftMenuSettings().setMenuNamespace(menu.getNamespace());
-    }
-    
-    /**
-     * Initialization the Context for Menu Bar and Tool Bar.
-     * 
-     * @param titleProperty - The title of the open study/knowledge.
-     * @param editDisabledProperty - Property that indicates whether the current open study is editable or not.
-     */
-    public void initializationContext(final String titleProperty, final String editDisabledProperty) {
-       
-       initializationContext();
-       
-       OpenObject entity = (OpenObject)session.get(titleProperty + ".open");
-       
-       getTitleBarSettings().setProgressState(entity.getProgressState().toString());
-       getTitleBarSettings().setSelectionState(entity.getSelection());
-       getTitleBarSettings().setEntryType(entity.getType().toLowerCase());
-       getTitleBarSettings().setEntryTypeTitle(entity.getType());
-       getTitleBarSettings().setEntryTitle(entity.getTitle());
-       getTitleBarSettings().setEditDisabledProperty(editDisabledProperty);
-    }
-    
-    /**
+
+       /**
+        * Will be removed!!! It's temporary solution for menuitem.jsp
+        */
+       private static Menu staticMenu;
+
+       /**
+        * Comparator for sorting document types with localized names.
+        */
+       public class DocumentTypeComparator implements Comparator<DocumentType> {
+               /**
+                * {@inheritDoc}
+                * 
+                * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+                */
+               public int compare(final DocumentType t1, final DocumentType t2) {
+                       ResourceBundle locale = ResourceBundle.getBundle("som",
+                                       ApplicationSettings.getCurrentLocale());
+                       String name1 = t1.getName();
+                       if (t1.isApproved()) {
+                               name1 = locale.getString("type.document." + name1);
+                       }
+                       String name2 = t2.getName();
+                       if (t2.isApproved()) {
+                               name2 = locale.getString("type.document." + name2);
+                       }
+
+                       return name1.compareToIgnoreCase(name2);
+               }
+       }
+
+       /**
+        * Comparator for sorting simulation context types with localized names.
+        */
+       public class ContextTypeComparator implements
+                       Comparator<SimulationContextType> {
+               /**
+                * {@inheritDoc}
+                * 
+                * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+                */
+               public int compare(final SimulationContextType t1,
+                               final SimulationContextType t2) {
+                       ResourceBundle locale = ResourceBundle.getBundle("som",
+                                       ApplicationSettings.getCurrentLocale());
+                       String name1 = t1.getName();
+                       if (t1.isApproved()) {
+                               name1 = locale.getString("type.context." + name1);
+                       }
+                       String name2 = t2.getName();
+                       if (t2.isApproved()) {
+                               name2 = locale.getString("type.context." + name2);
+                       }
+
+                       return name1.compareToIgnoreCase(name2);
+               }
+       }
+
+       // ==============================================================================================================================
+       // Session services
+       // ==============================================================================================================================
+
+       /**
+        * Remove the currently open knowledge from the session.
+        */
+       protected void closeKnowledge() {
+               OpenObject open = (OpenObject) _session.remove(KNOWLEDGE_OPEN);
+               if ((open != null) && (_session.get(STUDY_OPEN) == null)) {
+                       open.clearFacades(); // For eventually reopening the knowledge from a fresh context
+               }
+       }
+
+       /**
+        * Remove the currently open study from the session.
+        */
+       protected void closeStudy() {
+               OpenObject open = (OpenObject) _session.remove(STUDY_OPEN);
+               if ((open != null) && (_session.get(KNOWLEDGE_OPEN) == null)) {
+                       open.clearFacades(); // For eventually reopening the study from a fresh context
+               }
+       }
+
+       /**
+        * Connect the given user to SIMAN. Store his rights and login context in HTTP session.
+        * 
+        * @param context
+        *            login context
+        * @param user
+        *            the user to connect
+        */
+       protected void connect(final LoginContext context, final User user) {
+               OpenStudy open = getOpenStudy();
+               if (open != null) {
+                       open.changeUser(user);
+               }
+               _session.put(USER_RIGHTS, new ApplicationRights(user));
+               _session.put(LOGIN_CONTEXT, context); // For executing the deconnection, when requested
+       }
+
+       /**
+        * Disconnect the currently connected user from SIMAN. Remove his rihgts and login context from the session.
+        */
+       protected void disconnect() {
+               OpenStudy open = getOpenStudy();
+               if (open != null) {
+                       open.changeUser(null);
+               }
+               _session.put(USER_RIGHTS, new ApplicationRights(null)); // Disables user rights
+               _session.remove(LOGIN_CONTEXT);
+       }
+
+       /**
+        * Get the currently connected user from HTTP session.
+        * 
+        * @return the user
+        */
+       public User getConnectedUser() {
+               ApplicationRights rights = (ApplicationRights) _session
+                               .get(USER_RIGHTS);
+               User connected = null;
+               if (rights != null) {
+                       connected = rights.getUser();
+               }
+               return connected; // May be null
+       }
+
+       /**
+        * Get a menu named as "menu." with the given suffix from HTTP session.
+        * 
+        * @param name
+        *            the menu name suffix
+        * @return the menu
+        */
+       protected Menu getMenu(final String name) {
+               return (Menu) _session.get("menu." + name);
+       }
+
+       /**
+        * Open knowledge setter.
+        * 
+        * @param kelm
+        *            the OpenKnowledge to set
+        */
+       public void setOpenKnowledge(final OpenKnowledge kelm) {
+               _openKnowledge = kelm;
+       }
+
+       /**
+        * Open knowledge getter.
+        * 
+        * @return the currently open knowledge wrapper. May be null
+        */
+       protected OpenKnowledge getOpenKnowledge() {
+               // _openKnowledge = (OpenKnowledge)session.get(KNOWLEDGE_OPEN); // May be null
+               return _openKnowledge;
+       }
+
+       /**
+        * Open study setter.
+        * 
+        * @param aStudy
+        *            the OpenStudy to set
+        */
+       public void setOpenStudy(final OpenStudy aStudy) {
+               _openStudy = aStudy;
+       }
+
+       /**
+        * Open study getter.
+        * 
+        * @return the currently open stydy wrapper. May be null.
+        */
+       public OpenStudy getOpenStudy() {
+               // _openStudy = (OpenStudy)session.get(STUDY_OPEN);
+               return _openStudy; // May be null
+       }
+
+       /**
+        * Open the given knowledge in the current HTTP session. Replace the previose one in the session if any.
+        * 
+        * @param kelm
+        *            the knowledge element to open
+        * @return OpenKnowledge wrapper object
+        */
+       protected OpenKnowledge open(final KnowledgeElementDTO kelm) {
+               OpenKnowledge open = _openKnowledge.open(kelm);
+
+               closeKnowledge(); // Just in case
+               _session.put(KNOWLEDGE_OPEN, open);
+               return open;
+       }
+
+       /**
+        * Open the given study in the current HTTP session. Replace the previose one in the session if any.
+        * 
+        * @param study
+        *            the study to open
+        * @return OpenStudy wrapper object
+        */
+       protected OpenStudy open(final Study study) {
+               OpenStudy open = _openStudy.open(getConnectedUser(), study); // The connected user may be null
+
+               closeStudy(); // Just in case
+               _session.put(STUDY_OPEN, open);
+               return open;
+       }
+
+       /**
+        * Initialization the Context for menubar and toolbar.
+        */
+       public void initializationContext() {
+               getMenuBarSettings().initializeInitialMenuProperties();
+
+               if (_session.get(STUDY_OPEN) == null) {
+                       getMenuBarSettings().setIsStudyNull(true);
+               } else {
+                       getMenuBarSettings().setIsStudyNull(false);
+
+                       // for initialization ToolBarSettings.canUserEdit property
+                       // and ToolBarSettings.isEnabledScript property.
+
+                       OpenStudy currentStudy = (OpenStudy) _session.get(STUDY_OPEN);
+                       PopupMenu popup = currentStudy.getPopup();
+                       StudyRights user = currentStudy.getStudyRights();
+
+                       if (user.canEditProperties()) {
+                               getToolBarSettings().setCanUserEdit(true);
+                       } else {
+                               getToolBarSettings().setCanUserEdit(false);
+                       }
+
+                       if (popup == null) {
+                               getToolBarSettings().setIsEnabledScript(false);
+                       } else if (popup.isEnabled("script")) {
+                               getToolBarSettings().setIsEnabledScript(true);
+                       } else {
+                               getToolBarSettings().setIsEnabledScript(false);
+                       }
+               }
+
+               if (_session.get(KNOWLEDGE_OPEN) == null) {
+                       getMenuBarSettings().setIsKnowledgeNull(true);
+               } else {
+                       getMenuBarSettings().setIsKnowledgeNull(false);
+               }
+
+               ApplicationRights userRights = (ApplicationRights) _session
+                               .get(USER_RIGHTS);
+
+               if ((userRights != null) && userRights.canCreateStudy()) {
+                       getMenuBarSettings().setCanUserCreateStudy(true);
+               } else {
+                       getMenuBarSettings().setCanUserCreateStudy(false);
+               }
+
+               if ((userRights != null) && userRights.canManageDatabase()) {
+                       getMenuBarSettings().setCanUserManageDatabase(true);
+               } else {
+                       getMenuBarSettings().setCanUserManageDatabase(false);
+               }
+
+       }
+
+       /**
+        * Initialization the Context for left menu.
+        * 
+        * @param leftMenuProperty -
+        *            the property of the left menu.
+        */
+       public void initializationContextLeftMenus(final String leftMenuProperty) {
+
+               Menu menu = (Menu) _session.get("menu." + leftMenuProperty);
+
+               getLeftMenuSettings().setMenu(menu);
+               setStaticMenu(menu);
+               getLeftMenuSettings().setMenuName(menu.getName());
+               getLeftMenuSettings().setMenuNamespace(menu.getNamespace());
+       }
+
+       /**
+        * Initialization the Context for Menu Bar and Tool Bar.
+        * 
+        * @param titleProperty -
+        *            The title of the open study/knowledge.
+        * @param editDisabledProperty -
+        *            Property that indicates whether the current open study is editable or not.
+        */
+       public void initializationContext(final String titleProperty,
+                       final String editDisabledProperty) {
+
+               initializationContext();
+
+               OpenObject entity = (OpenObject) _session.get(titleProperty + ".open");
+
+               getTitleBarSettings().setProgressState(
+                               entity.getProgressState().toString());
+               getTitleBarSettings().setSelectionState(entity.getSelection());
+               getTitleBarSettings().setEntryType(entity.getType().toLowerCase());
+               getTitleBarSettings().setEntryTypeTitle(entity.getType());
+               getTitleBarSettings().setEntryTitle(entity.getTitle());
+               getTitleBarSettings().setEditDisabledProperty(editDisabledProperty);
+       }
+
+       /**
         * Initialization of the screen context for menu bar.
         * 
-        * @param menuProperty - the property of the menu bar.
+        * @param menuProperty -
+        *            the property of the menu bar.
         */
        public void initializationScreenContext(final String menuProperty) {
-               
+
                initializationContext();
                getMenuBarSettings().intializeMenuBar(menuProperty);
        }
-       
+
        /**
         * Initialization of the screen context for menu bar and title bar.
         * 
-        * @param menuProperty - the property of the menu bar.
-        * @param titleProperty - The title of the open study/knowledge.
-     * @param editDisabledProperty - Property that indicates whether the current open study is editable or not.
+        * @param menuProperty -
+        *            the property of the menu bar.
+        * @param titleProperty -
+        *            The title of the open study/knowledge.
+        * @param editDisabledProperty -
+        *            Property that indicates whether the current open study is editable or not.
         */
-       public void initializationScreenContext(final String menuProperty, 
+       public void initializationScreenContext(final String menuProperty,
                        final String titleProperty, final String editDisabledProperty) {
-               
+
                initializationContext(titleProperty, editDisabledProperty);
                getMenuBarSettings().intializeMenuBar(menuProperty);
        }
-       
+
        /**
         * Initialization of the screen context for menu bar, title bar and tool bar.
         * 
-        * @param menuProperty - the property of the menu bar.
-        * @param titleProperty - The title of the open study/knowledge.
-     * @param editDisabledProperty - Property that indicates whether the current open study is editable or not.
-     * @param toolProperty - the property of the tool bar.
+        * @param menuProperty -
+        *            the property of the menu bar.
+        * @param titleProperty -
+        *            The title of the open study/knowledge.
+        * @param editDisabledProperty -
+        *            Property that indicates whether the current open study is editable or not.
+        * @param toolProperty -
+        *            the property of the tool bar.
         */
-       public void initializationScreenContext(final String menuProperty, 
+       public void initializationScreenContext(final String menuProperty,
                        final String titleProperty, final String editDisabledProperty,
                        final String toolProperty) {
-               
-               initializationScreenContext(menuProperty, titleProperty, editDisabledProperty);
+
+               initializationScreenContext(menuProperty, titleProperty,
+                               editDisabledProperty);
                getToolBarSettings().intializeMenuBar(toolProperty);
        }
-       
+
        /**
         * Initialization of the screen context for menu bar and tool bar.
         * 
-        * @param menuProperty - the property of the menu bar.
-     * @param toolProperty - the property of the tool bar.
+        * @param menuProperty -
+        *            the property of the menu bar.
+        * @param toolProperty -
+        *            the property of the tool bar.
         */
-       public void initializationScreenContext(final String menuProperty, 
+       public void initializationScreenContext(final String menuProperty,
                        final String toolProperty) {
-               
+
                initializationContext();
                getMenuBarSettings().intializeMenuBar(menuProperty);
                getToolBarSettings().intializeMenuBar(toolProperty);
        }
-       
+
        /**
         * Initialization of the screen context for menu bar, title bar and tool bar.
         * 
-        * @param menuProperty - the property of the menu bar.
-        * @param titleProperty - The title of the open study/knowledge.
-     * @param editDisabledProperty - Property that indicates whether the current open study is editable or not.
-     * @param toolProperty - the property of the tool bar.
-     * @param leftMenuProperty - the property of the left menu.
+        * @param menuProperty -
+        *            the property of the menu bar.
+        * @param titleProperty -
+        *            The title of the open study/knowledge.
+        * @param editDisabledProperty -
+        *            Property that indicates whether the current open study is editable or not.
+        * @param toolProperty -
+        *            the property of the tool bar.
+        * @param leftMenuProperty -
+        *            the property of the left menu.
         */
-       public void initializationFullScreenContext(final String menuProperty, 
+       public void initializationFullScreenContext(final String menuProperty,
                        final String titleProperty, final String editDisabledProperty,
                        final String toolProperty, final String leftMenuProperty) {
-               
-               initializationScreenContext(menuProperty, titleProperty, editDisabledProperty);
+
+               initializationScreenContext(menuProperty, titleProperty,
+                               editDisabledProperty);
                initializationContextLeftMenus(leftMenuProperty);
                getToolBarSettings().intializeMenuBar(toolProperty);
        }
-       
+
        /**
         * Initialization of the screen context for menu bar and tool bar.
         * 
-        * @param menuProperty - the property of the menu bar.
-     * @param toolProperty - the property of the tool bar.
-     * @param leftMenuProperty - the property of the left menu.
+        * @param menuProperty -
+        *            the property of the menu bar.
+        * @param toolProperty -
+        *            the property of the tool bar.
+        * @param leftMenuProperty -
+        *            the property of the left menu.
         */
-       public void initializationFullScreenContext(final String menuProperty, 
+       public void initializationFullScreenContext(final String menuProperty,
                        final String toolProperty, final String leftMenuProperty) {
-               
+
                initializationContext();
                initializationContextLeftMenus(leftMenuProperty);
                getMenuBarSettings().intializeMenuBar(menuProperty);
                getToolBarSettings().intializeMenuBar(toolProperty);
        }
-//  ==============================================================================================================================
-//  Getters and setters
-//  ==============================================================================================================================
-    
-       public void setServletRequest (HttpServletRequest request) {
-               this.request = request;
+
+       // ==============================================================================================================================
+       // Getters and setters
+       // ==============================================================================================================================
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.apache.struts2.interceptor.ServletRequestAware#setServletRequest(javax.servlet.http.HttpServletRequest)
+        */
+       public void setServletRequest(final HttpServletRequest request) {
+               this._servletRequest = request;
        }
-       
+
+       /**
+        * Get current HTTP request.
+        * 
+        * @return HTTP request
+        */
        public HttpServletRequest getServletRequest() {
-               return request;
+               return _servletRequest;
+       }
+
+       /**
+        * Get current error code.
+        * 
+        * @return error code
+        */
+       public String getErrorCode() {
+               return _errorCode;
        }
 
-    public String getErrorCode () {
-      return mercode;
-    }
-    public Map<String, Object> getSession () {
-      return session;
-    }
+       /**
+        * Get session map.
+        * 
+        * @return session map
+        */
+       public Map<String, Object> getSession() {
+               return _session;
+       }
+
+       /**
+        * Set error code.
+        * 
+        * @param code
+        *            the error code to set
+        */
+       public void setErrorCode(final String code) {
+               this._errorCode = code;
+       }
 
-    public void setErrorCode (String code) {
-      this.mercode = code;
-    }
-       public void setSession (Map<String, Object> session) {
-         this.session = session;
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.apache.struts2.interceptor.SessionAware#setSession(java.util.Map)
+        */
+       public void setSession(final Map<String, Object> session) {
+               this._session = session;
        }
-       
+
        /**
         * Get the menuBarSettings.
+        * 
         * @return the menuBarSettings
         */
        public MenuBarSettings getMenuBarSettings() {
@@ -400,84 +583,108 @@ public class Action extends ActionSupport implements ServletRequestAware, Sessio
 
        /**
         * Set the menuBarSettings.
-        * @param menuBarSettings the menuBarSettings to set
+        * 
+        * @param menuBarSettings
+        *            the menuBarSettings to set
         */
        public void setMenuBarSettings(final MenuBarSettings menuBarSettings) {
                _menuBarSettings = menuBarSettings;
        }
-       
+
        /**
         * Get the _titleBarSettings.
+        * 
         * @return the _titleBarSettings
         */
        public TitleBarSettings getTitleBarSettings() {
                return _titleBarSettings;
        }
+
        /**
         * Set the titleBarSettings.
-        * @param titleBarSettings the titleBarSettings to set
+        * 
+        * @param titleBarSettings
+        *            the titleBarSettings to set
         */
-       public void setTitleBarSettings(TitleBarSettings titleBarSettings) {
+       public void setTitleBarSettings(final TitleBarSettings titleBarSettings) {
                _titleBarSettings = titleBarSettings;
        }
+
        /**
         * Get the toolBarSettings.
+        * 
         * @return the toolBarSettings
         */
        public final ToolBarSettings getToolBarSettings() {
                return _toolBarSettings;
        }
+
        /**
         * Set the toolBarSettings.
-        * @param toolBarSettings the toolBarSettings to set
+        * 
+        * @param toolBarSettings
+        *            the toolBarSettings to set
         */
-       public final void setToolBarSettings(ToolBarSettings toolBarSettings) {
+       public final void setToolBarSettings(final ToolBarSettings toolBarSettings) {
                _toolBarSettings = toolBarSettings;
        }
-       
+
        /**
         * Get the applicationSettings.
+        * 
         * @return the applicationSettings
         */
        public ApplicationSettings getApplicationSettings() {
                return _applicationSettings;
        }
+
        /**
         * Set the applicationSettings.
-        * @param applicationSettings the applicationSettings to set
+        * 
+        * @param applicationSettings
+        *            the applicationSettings to set
         */
-       public void setApplicationSettings(ApplicationSettings applicationSettings) {
+       public void setApplicationSettings(
+                       final ApplicationSettings applicationSettings) {
                _applicationSettings = applicationSettings;
        }
+
        /**
         * Get the leftMenuSettings.
+        * 
         * @return the leftMenuSettings
         */
        public LeftMenuSettings getLeftMenuSettings() {
                return _leftMenuSettings;
        }
-               
+
        /**
         * Get the staticMenu.
+        * 
         * @return the staticMenu
         */
        public static Menu getStaticMenu() {
                return staticMenu;
        }
+
        /**
         * Set the staticMenu.
-        * @param staticMenu the staticMenu to set
+        * 
+        * @param staticMenu
+        *            the staticMenu to set
         */
-       public static void setStaticMenu(Menu staticMenu) {
+       public static void setStaticMenu(final Menu staticMenu) {
                Action.staticMenu = staticMenu;
        }
+
        /**
         * Set the leftMenuSettings.
-        * @param leftMenuSettings the leftMenuSettings to set
+        * 
+        * @param leftMenuSettings
+        *            the leftMenuSettings to set
         */
-       public void setLeftMenuSettings(LeftMenuSettings leftMenuSettings) {
+       public void setLeftMenuSettings(final LeftMenuSettings leftMenuSettings) {
                _leftMenuSettings = leftMenuSettings;
        }
-       
-       
+
 }
\ No newline at end of file
index 427925a50e3d65705ea8590ca64432f67e49d6d6..a95b58b4b36ecd93244e3ecfa5d3d6afceba529d 100644 (file)
@@ -40,6 +40,9 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+/**
+ * SIMAN project settings service. Provides settings according to XML customization.
+ */
 public class ApplicationSettings implements ServletContextAware {
 
        /**
@@ -48,30 +51,187 @@ public class ApplicationSettings implements ServletContextAware {
        protected final static Logger LOG = Logger
                        .getLogger(ApplicationSettings.class);
 
+       /**
+        * Singleton instance of application settings service.
+        */
+       private static final ApplicationSettings MY_APP = new ApplicationSettings();
+
+       /**
+        * All value.
+        */
+       private static final String ALL = "all";
+
+       /**
+        * Hold icon file name.
+        */
+       private static final String IMG_HOLD = "image.hold.gif";
+       /**
+        * Attach icon file name.
+        */
+       private static final String IMG_ATTACH = "image.attach.png";
+       /**
+        * Version icon file name.
+        */
+       private static final String IMG_VERSION = "image.version.png";
+       /**
+        * Delete icon file name.
+        */
+       private static final String IMG_DELETE = "icon.delete.png";
+       /**
+        * Attach menu item name.
+        */
+       private static final String MNU_ATTACH = "attach";
+       /**
+        * Demote menu item name.
+        */
+       private static final String MNU_DEMOTE = "demote";
+       /**
+        * Promote menu item name.
+        */
+       private static final String MNU_PROMOTE = "promote";
+       /**
+        * Publish menu item name.
+        */
+       private static final String MNU_PUBLISH = "publish";
+       /**
+        * Edit menu item name.
+        */
+       private static final String MNU_EDIT = "edit";
+       /**
+        * Script menu item name.
+        */
+       private static final String MNU_SCRIPT = "script";
+       /**
+        * Version menu item name.
+        */
+       private static final String MNU_VERSION = "version";
+       /**
+        * Purge menu item name.
+        */
+       private static final String MNU_PURGE = "purge";
+       /**
+        * Remove menu item name.
+        */
+       private static final String MNU_REMOVE = "remove";
+       /**
+        * Rename menu item name.
+        */
+       private static final String MNU_RENAME = "rename";
+
+       /**
+        * Attach menu item name.
+        */
+       private static final String MNU_NAME_ATTACH = "menu.attach";
+       /**
+        * Demote menu item name.
+        */
+       private static final String MNU_NAME_DEMOTE = "menu.demote";
+       /**
+        * Promote menu item name.
+        */
+       private static final String MNU_NAME_PROMOTE = "menu.promote";
+       /**
+        * Publish menu item name.
+        */
+       private static final String MNU_NAME_PUBLISH = "menu.publish";
+       /**
+        * Edit menu item name.
+        */
+       private static final String MNU_NAME_EDIT = "menu.edit";
+       /**
+        * Script menu item name.
+        */
+       private static final String MNU_NAME_SCRIPT = "menu.newscenario";
+       /**
+        * Version menu item name.
+        */
+       private static final String MNU_NAME_VERSION = "menu.version";
+       /**
+        * Purge menu item name.
+        */
+       private static final String MNU_NAME_PURGE = "menu.purge";
+       /**
+        * Remove menu item name.
+        */
+       private static final String MNU_NAME_REMOVE = "menu.remove.version";
+       /**
+        * Rename menu item name.
+        */
+       private static final String MNU_NAME_RENAME = "menu.rename";
+       /**
+        * Not yet implemented action name.
+        */
+       private static final String ACT_NOT_YET_IMPLEMENTED = "notyetimplemented";
+       /**
+        * Attach action name.
+        */
+       private static final String ACT_ATTACH = "select-file?nextAction=attach";
+       /**
+        * Version action name.
+        */
+       private static final String ACT_VERSION = "select-file?nextAction=version";
+
        /**
         * Injected servlet context to get path to resources.
         */
-       private ServletContext _servletContext; 
-       
-       private String wappserver;
-       private String wappname;
-       private final Properties wapprops = new Properties(); // General properties from the application properties files
-       private Locale locale; // Current user locale
-       private final Map<String, SimpleMenu> menus = new HashMap<String, SimpleMenu>(); // Application menus
-       private Map<Integer, ToolBar> bars = null; // Study module-bars structured by steps
-       private Map<String, PopupMenu> popups = null;
-       private Map<String, Map<String, Object>> filter = null; // Named search filters
-       private Map<String, DocumentType> defdoctype = null; // Default document types structured by step.formats
-       private Map<String, String> tempfile = null; // Available template files
-       private String[] viewermap = null; // List of file extensions mapped to a viewer
-       private Map<String, Converter> convertmap = null; // Available document format converters
-       private final Properties jndprops = new Properties(); // JNDI context for launching converters
-
-       private static ApplicationSettings my = new ApplicationSettings(); // Singleton instance
+       private transient ServletContext _servletContext;
+
+       /**
+        * Siman application server name.
+        */
+       private transient String _wappserver;
+       /**
+        * Siman web application name.
+        */
+       private transient String _wappname;
+       /**
+        * General properties from the application properties files.
+        */
+       private transient final Properties _wapprops = new Properties();
+       /**
+        * Current user locale.
+        */
+       private transient Locale _locale;
+       /**
+        * Application menus.
+        */
+       private transient final Map<String, SimpleMenu> _menus = new HashMap<String, SimpleMenu>();
+       /**
+        * Study module-bars structured by steps.
+        */
+       private transient Map<Integer, ToolBar> _bars = null;
+       /**
+        * Popup menus.
+        */
+       private transient Map<String, PopupMenu> _popups = null;
+       /**
+        * Named search filters.
+        */
+       private transient Map<String, Map<String, Object>> _filter = null;
+       /**
+        * Default document types structured by step.formats.
+        */
+       private transient Map<String, DocumentType> _defdoctype = null;
+       /**
+        * Available template files.
+        */
+       private transient Map<String, String> _tempfile = null;
+       /**
+        * List of file extensions mapped to a viewer.
+        */
+       private transient String[] _viewermap = null;
+       /**
+        * Available document format converters.
+        */
+       private transient Map<String, Converter> _convertmap = null;
+       /**
+        * JNDI context for launching converters.
+        */
+       private transient final Properties _jndprops = new Properties();
        /**
         * Injected project settings service.
         */
-       private ProjectSettingsService _projectSettingsService;
+       private ProjectSettingsService _projectSettings;
        /**
         * Injected document type service.
         */
@@ -83,7 +243,7 @@ public class ApplicationSettings implements ServletContextAware {
         * @return the projectSettingsService
         */
        public ProjectSettingsService getProjectSettings() {
-               return _projectSettingsService;
+               return _projectSettings;
        }
 
        /**
@@ -92,12 +252,12 @@ public class ApplicationSettings implements ServletContextAware {
         * @param projectSettingsService
         *            the projectSettingsService to set
         */
-       public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
-               _projectSettingsService = projectSettingsService;
+       public void setProjectSettings(
+                       final ProjectSettingsService projectSettingsService) {
+               _projectSettings = projectSettingsService;
        }
 
        private static class NewMenu extends SimpleMenu {
-               // -----------------------------------------------------------------
                private NewMenu() {
                        super("create");
                        addItem("new-empty", "menu.new.empty", "image.empty.png",
@@ -105,7 +265,7 @@ public class ApplicationSettings implements ServletContextAware {
                        addItem("new-copy", new MenuItem("menu.new.copy")
                                        .icon("image.copy.png"));
                        addItem("new-instance", new MenuItem("menu.new.instance")
-                                       .icon("image.hold.gif"));
+                                       .icon(IMG_HOLD));
                        addItem("new-import", new MenuItem("menu.new.import")
                                        .icon("icon.upload.png"));
                        this.selects("new-empty");
@@ -113,7 +273,6 @@ public class ApplicationSettings implements ServletContextAware {
        }
 
        private static class SearchMenu extends SimpleMenu {
-               // -----------------------------------------------------------------
                private SearchMenu() {
                        super("search");
                        addItem("search-study", "menu.search.study", "image.study.png",
@@ -127,28 +286,25 @@ public class ApplicationSettings implements ServletContextAware {
        }
 
        private static class PropertiesMenu extends SimpleMenu {
-               // -----------------------------------------------------------------
                private PropertiesMenu() {
                        super("configuration");
-                       addItem("prop-general", "menu.prop.general", "image.hold.gif",
+                       addItem("prop-general", "menu.prop.general", IMG_HOLD,
                                        "select?menu=properties&item=prop-general");
-                       addItem("prop-scenario", "menu.prop.scenario", "image.hold.gif",
+                       addItem("prop-scenario", "menu.prop.scenario", IMG_HOLD,
                                        "select?menu=properties&item=prop-scenario");
-                       //These menu items will not be implemented in the current version.
-                       /*addItem("prop-timestamp", new MenuItem("menu.prop.timestamp")
-                                       .icon("image.stamp.png"));
-                       addItem("prop-comlog", new MenuItem("menu.prop.comlog")
-                                       .icon("image.hold.gif"));
-                       addItem("prop-version", new MenuItem("menu.prop.version")
-                                       .icon("image.dirclosed.png"));*/
+                       // These menu items will not be implemented in the current version.
+                       /*
+                        * addItem("prop-timestamp", new MenuItem("menu.prop.timestamp") .icon("image.stamp.png")); addItem("prop-comlog", new
+                        * MenuItem("menu.prop.comlog") .icon(IMG_HOLD)); addItem("prop-version", new MenuItem("menu.prop.version")
+                        * .icon("image.dirclosed.png"));
+                        */
                }
        }
 
        private static class DatadminMenu extends SimpleMenu {
-               // -----------------------------------------------------------------
                private DatadminMenu() {
                        super("datadmin");
-                       addItem("admin-scontext", "menu.admin.context", "image.hold.gif",
+                       addItem("admin-scontext", "menu.admin.context", IMG_HOLD,
                                        "select?menu=datadmin&item=admin-scontext");
                        addItem("admin-knowelm", "menu.admin.knowledge", "image.idea.png",
                                        "select?menu=datadmin&item=admin-knowelm");
@@ -158,7 +314,6 @@ public class ApplicationSettings implements ServletContextAware {
        }
 
        private static class SysadminMenu extends SimpleMenu {
-               // -----------------------------------------------------------------
                private SysadminMenu() {
                        super("sysadmin");
                        addItem("admin-indexing", "menu.admin.indexing", "image.index.png",
@@ -175,67 +330,71 @@ public class ApplicationSettings implements ServletContextAware {
 
        // Resources relative to studies
        private static class EditableStudyPopup extends PopupMenu {
-               // ----------------------------------------------------------------
-               private StudyRights user = null;
+               private transient StudyRights _user = null;
 
                private EditableStudyPopup() {
-                       addItem("publish", new PopupItem("menu.publish").icon(
+                       super();
+                       addItem(MNU_PUBLISH, new PopupItem(MNU_NAME_PUBLISH).icon(
                                        "image.publish.png").action("edit-study?action=publish")
                                        .confirmation("message.publish.study"));
-                       addItem("promote", new PopupItem("menu.archive"));
+                       addItem(MNU_PROMOTE, new PopupItem("menu.archive"));
                        addSeparator();
-                       addItem("edit", new PopupItem("menu.properties")
-                                       .icon("icon.ed.png").action("../select?menu=properties"));
+                       addItem(MNU_EDIT, new PopupItem("menu.properties").icon(
+                                       "icon.ed.png").action("../select?menu=properties"));
                        addSeparator();
-                       addItem("script", new PopupItem("menu.newscenario")
+                       addItem(MNU_SCRIPT, new PopupItem(MNU_NAME_SCRIPT)
                                        .action("add-scenario"));
-                       addItem("version", new PopupItem("menu.version").icon(
-                                       "image.version.png").action("notyetimplemented"));
+                       addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
+                                       IMG_VERSION).action(ACT_NOT_YET_IMPLEMENTED));
                        addSeparator();
-                       addItem("purge", new PopupItem("menu.purge")
+                       addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE)
                                        .confirmation("message.purge.study"));
                        addItem("export", new PopupItem("menu.export")
                                        .icon("image.export.png")); // For future needs
-                       addItem("remove", new PopupItem("menu.remove.version").icon(
-                                       "icon.delete.png").action("notyetimplemented")
-                                       .confirmation("message.delete.study"));
+                       addItem(MNU_REMOVE, new PopupItem(MNU_NAME_REMOVE).icon(IMG_DELETE)
+                                       .action(ACT_NOT_YET_IMPLEMENTED).confirmation(
+                                                       "message.delete.study"));
                }
 
                @Override
                public boolean isEnabled(final String name) {
-                       if (user == null) {
-                               return false; // Should not happen
-                       }
-                       Item item = Item.valueOf(name);
-                       if (item == Item.publish) {
-                               return user.canPublish();
-                       }
-                       if (item == Item.edit) {
-                               return user.canEditProperties();
-                       }
-                       if (item == Item.script) {
-                               return user.canAddScenario();
-                       }
-                       if (item == Item.version) {
-                               return user.canVersion();
-                       }
-                       if (item == Item.remove) {
-                               return user.canRemove();
-                       }
-                       if (item == Item.purge) {
-                               return user.canPurge();
+                       boolean res = (_user != null);
+                       if (res) {
+                               Item item = Item.valueOf(name);
+                               switch (item) {
+                                       case publish:
+                                               res = _user.canPublish();
+                                               break;
+                                       case edit:
+                                               res = _user.canEditProperties();
+                                               break;
+                                       case script:
+                                               res = _user.canAddScenario();
+                                               break;
+                                       case version:
+                                               res = _user.canVersion();
+                                               break;
+                                       case remove:
+                                               res = _user.canRemove();
+                                               break;
+                                       case purge:
+                                               res = _user.canPurge();
+                                               break;
+                                       default:
+                                               res = false;
+                               }
                        }
-                       return false;
+                       return res;
                }
 
                @Override
                public void setContext(final String name, final Object context) {
                        if (context instanceof StudyRights) {
-                               user = (StudyRights) context; // Just for optimizing
-                               boolean history = user.getOperand().isVersioned();
-                               PopupItem item = this.item("remove");
+                               _user = (StudyRights) context; // Just for optimizing
+                               boolean history = _user.getOperand().isVersioned();
+                               PopupItem item = this.item(MNU_REMOVE);
                                if (history) {
-                                       item.rename("menu.remove.version");
+                                       item.rename(MNU_NAME_REMOVE);
                                } else {
                                        item.rename("menu.remove.study");
                                }
@@ -244,78 +403,85 @@ public class ApplicationSettings implements ServletContextAware {
        }
 
        // Resources relative to documents
-       private static class EditableDocumentPopup extends PopupMenu { // Popup of In-Work documents
-       // ----------------------------------------------------------------
-               private DocumentRights user = null;
+       /**
+        * Popup of In-Work documents.
+        */
+       private static class EditableDocumentPopup extends PopupMenu {
+               private transient DocumentRights _user = null;
 
                private EditableDocumentPopup() {
+                       super();
                        addItem("accept", new PopupItem("menu.accept").icon(
                                        "image.accept.png").action("setDocument?action=accept")
                                        .confirmation("message.accept.document"));
-                       addItem("promote", new PopupItem("menu.promote").icon(
+                       addItem(MNU_PROMOTE, new PopupItem(MNU_NAME_PROMOTE).icon(
                                        "image.publish.png").action("setDocument?action=promote")
                                        .confirmation("message.promote.document"));
                        addSeparator();
-                       addItem("rename", new PopupItem("menu.rename")
+                       addItem(MNU_RENAME, new PopupItem(MNU_NAME_RENAME)
                                        .action("edit-document?action=renameDocument"));
-                       addItem("attach", new PopupItem("menu.attach").icon(
-                                       "image.attach.png").action("select-file?nextAction=attach"));
+                       addItem(MNU_ATTACH, new PopupItem(MNU_NAME_ATTACH).icon(IMG_ATTACH)
+                                       .action(ACT_ATTACH));
                        addSeparator();
-                       addItem("version", new PopupItem("menu.version").icon(
-                                       "image.version.png").action(
-                                       "select-file?nextAction=version"));
+                       addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
+                                       IMG_VERSION).action(ACT_VERSION));
                        addItem("replace", new PopupItem("menu.replace").icon(
                                        "image.replace.png").action(
                                        "select-file?nextAction=replace"));
                        addSeparator();
-                       addItem("purge", new PopupItem("menu.purge").action(
-                                       "notyetimplemented").confirmation("message.purge.document"));
-                       addItem("remove", new PopupItem("menu.remove.version").icon(
-                                       "icon.delete.png").action("remove-document").confirmation(
-                                       "message.delete.document"));
+                       addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE).action(
+                                       ACT_NOT_YET_IMPLEMENTED).confirmation(
+                                       "message.purge.document"));
+                       addItem(MNU_REMOVE, new PopupItem(MNU_NAME_REMOVE).icon(IMG_DELETE)
+                                       .action("remove-document").confirmation(
+                                                       "message.delete.document"));
                }
 
                @Override
                public boolean isEnabled(final String name) {
-                       if (user == null) {
-                               return false; // Should not happen
-                       }
-                       Item item = Item.valueOf(name);
-                       if (item == Item.accept) {
-                               return user.canAccept();
-                       }
-                       if (item == Item.promote) {
-                               return user.canPromote();
-                       }
-                       if (item == Item.rename) {
-                               return user.canRename();
-                       }
-                       if (item == Item.attach) {
-                               return user.canAttach();
-                       }
-                       if (item == Item.version) {
-                               return user.canVersion();
-                       }
-                       if (item == Item.replace) {
-                               return user.canReplace();
-                       }
-                       if (item == Item.purge) {
-                               return user.canPurge();
-                       }
-                       if (item == Item.remove) {
-                               return user.canRemove();
+                       boolean res = (_user != null);
+                       if (res) {
+                               Item item = Item.valueOf(name);
+                               switch (item) {
+                                       case accept:
+                                               res = _user.canAccept();
+                                               break;
+                                       case promote:
+                                               res = _user.canPromote();
+                                               break;
+                                       case rename:
+                                               res = _user.canRename();
+                                               break;
+                                       case attach:
+                                               res = _user.canAttach();
+                                               break;
+                                       case version:
+                                               res = _user.canVersion();
+                                               break;
+                                       case replace:
+                                               res = _user.canReplace();
+                                               break;
+                                       case purge:
+                                               res = _user.canPurge();
+                                               break;
+                                       case remove:
+                                               res = _user.canRemove();
+                                               break;
+                                       default:
+                                               res = false;
+                               }
                        }
-                       return false;
+                       return res;
                }
 
                @Override
                public void setContext(final String name, final Object context) {
                        if (context instanceof DocumentRights) {
-                               user = (DocumentRights) context; // Just for optimizing
-                               Document downer = user.getOperand();
-                               PopupItem item = this.item("remove");
+                               _user = (DocumentRights) context; // Just for optimizing
+                               Document downer = _user.getOperand();
+                               PopupItem item = this.item(MNU_REMOVE);
                                if (downer.isVersioned()) {
-                                       item.rename("menu.remove.version");
+                                       item.rename(MNU_NAME_REMOVE);
                                } else {
                                        item.rename("menu.remove.document");
                                }
@@ -323,95 +489,105 @@ public class ApplicationSettings implements ServletContextAware {
                }
        }
 
-       private static class ReviewableDocumentPopup extends PopupMenu { // Popup of In-Draft documents
-       // ----------------------------------------------------------------
-               private DocumentRights user = null;
+       /**
+        * Popup of In-Draft documents.
+        */
+       private static class ReviewableDocumentPopup extends PopupMenu {
+               private transient DocumentRights _user = null;
 
                private ReviewableDocumentPopup() {
-                       addItem("demote", new PopupItem("menu.demote").icon(
+                       super();
+                       addItem(MNU_DEMOTE, new PopupItem(MNU_NAME_DEMOTE).icon(
                                        "image.demote.png").action("setDocument?action=demote")
                                        .confirmation("message.demote.document"));
-                       addItem("promote", new PopupItem("menu.review").icon(
+                       addItem(MNU_PROMOTE, new PopupItem("menu.review").icon(
                                        "image.review.png").action("setDocument?action=review")
                                        .confirmation("message.review.document"));
                        addSeparator();
-                       addItem("attach", new PopupItem("menu.attach").icon(
-                                       "image.attach.png").action("select-file?nextAction=attach"));
+                       addItem(MNU_ATTACH, new PopupItem(MNU_NAME_ATTACH).icon(IMG_ATTACH)
+                                       .action(ACT_ATTACH));
                        addSeparator();
-                       addItem("version", new PopupItem("menu.version").icon(
-                                       "image.version.png").action(
-                                       "select-file?nextAction=version"));
+                       addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
+                                       IMG_VERSION).action(ACT_VERSION));
                        addSeparator();
-                       addItem("purge", new PopupItem("menu.purge").action(
-                                       "notyetimplemented").confirmation("message.purge.document"));
+                       addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE).action(
+                                       ACT_NOT_YET_IMPLEMENTED).confirmation(
+                                       "message.purge.document"));
                }
 
                @Override
                public boolean isEnabled(final String name) {
-                       if (user == null) {
-                               return false; // Should not happen
-                       }
-                       Item item = Item.valueOf(name);
-                       if (item == Item.demote) {
-                               return user.canDemote();
-                       }
-                       if (item == Item.promote) {
-                               return user.canReview();
-                       }
-                       if (item == Item.attach) {
-                               return user.canAttach();
-                       }
-                       if (item == Item.version) {
-                               return user.canVersion();
-                       }
-                       if (item == Item.purge) {
-                               return user.canPurge();
+                       boolean res = (_user != null);
+                       if (res) {
+                               Item item = Item.valueOf(name);
+                               switch (item) {
+                                       case demote:
+                                               res = _user.canDemote();
+                                               break;
+                                       case promote:
+                                               res = _user.canReview();
+                                               break;
+                                       case attach:
+                                               res = _user.canAttach();
+                                               break;
+                                       case version:
+                                               res = _user.canVersion();
+                                               break;
+                                       case purge:
+                                               res = _user.canPurge();
+                                               break;
+                                       default:
+                                               res = false;
+                               }
                        }
-                       return false;
+                       return res;
                }
 
                @Override
                public void setContext(final String name, final Object context) {
                        if (context instanceof DocumentRights) {
-                               user = (DocumentRights) context; // Just for optimizing
+                               _user = (DocumentRights) context; // Just for optimizing
                        }
                }
        }
 
        private static class NotResultDocumentPopup extends PopupMenu {
-               // ----------------------------------------------------------------
-               private final DocumentRights user = null;
+               // private final DocumentRights _user = null;
 
                private NotResultDocumentPopup() {
-                       addItem("demote", new PopupItem("menu.demote").icon(
+                       super();
+                       addItem(MNU_DEMOTE, new PopupItem(MNU_NAME_DEMOTE).icon(
                                        "image.demote.png").action("setDocument?action=demote")
                                        .confirmation("message.demote.document"));
                        addSeparator();
-                       addItem("attach", new PopupItem("menu.attach").icon(
-                                       "image.attach.png").action("select-file?nextAction=attach"));
+                       addItem(MNU_ATTACH, new PopupItem(MNU_NAME_ATTACH).icon(IMG_ATTACH)
+                                       .action(ACT_ATTACH));
                        addSeparator();
-                       addItem("version", new PopupItem("menu.version").icon(
-                                       "image.version.png").action(
-                                       "select-file?nextAction=version"));
+                       addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
+                                       IMG_VERSION).action(ACT_VERSION));
                        addSeparator();
-                       addItem("purge", new PopupItem("menu.purge").action(
-                                       "notyetimplemented").confirmation("message.purge.document"));
-                       addItem("remove", new PopupItem("menu.remove.version").icon(
-                                       "icon.delete.png").action("remove-document").confirmation(
-                                       "message.delete.document"));
+                       addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE).action(
+                                       ACT_NOT_YET_IMPLEMENTED).confirmation(
+                                       "message.purge.document"));
+                       addItem(MNU_REMOVE, new PopupItem(MNU_NAME_REMOVE).icon(IMG_DELETE)
+                                       .action("remove-document").confirmation(
+                                                       "message.delete.document"));
                }
        }
 
-       private static class ApprovableDocumentPopup extends PopupMenu { // Popup of In-Check documents
-       // ----------------------------------------------------------------
-               private DocumentRights user = null;
+       /**
+        * Popup of In-Check documents.
+        */
+       private static class ApprovableDocumentPopup extends PopupMenu {
+               private transient DocumentRights _user = null;
 
                private ApprovableDocumentPopup() {
-                       addItem("undo", new PopupItem("menu.demote").icon(
+                       super();
+                       addItem("undo", new PopupItem(MNU_NAME_DEMOTE).icon(
                                        "image.invalidate.png").action(
                                        "setDocument?action=invalidate").confirmation(
                                        "message.demote.document"));
-                       addItem("demote", new PopupItem("menu.disapprove").icon(
+                       addItem(MNU_DEMOTE, new PopupItem("menu.disapprove").icon(
                                        "image.demote.png").action("setDocument?action=disapprove")
                                        .confirmation("message.disapprove.document"));
                        addItem("approve", new PopupItem("menu.approve").icon(
@@ -421,117 +597,131 @@ public class ApplicationSettings implements ServletContextAware {
 
                @Override
                public boolean isEnabled(final String name) {
-                       if (user == null) {
-                               return false; // Should not happen
-                       }
-                       Item item = Item.valueOf(name);
-                       if (item == Item.undo) {
-                               return user.canInvalidate();
-                       }
-                       if (item == Item.demote) {
-                               return user.canDemote();
-                       }
-                       if (item == Item.approve) {
-                               return user.canApprove();
+                       boolean res = (_user != null);
+                       if (res) {
+                               Item item = Item.valueOf(name);
+                               switch (item) {
+                                       case undo:
+                                               res = _user.canInvalidate();
+                                               break;
+                                       case demote:
+                                               res = _user.canDemote();
+                                               break;
+                                       case approve:
+                                               res = _user.canApprove();
+                                               break;
+                                       default:
+                                               res = false;
+                               }
                        }
-                       return false;
+                       return res;
                }
 
                @Override
                public void setContext(final String name, final Object context) {
                        if (context instanceof DocumentRights) {
-                               user = (DocumentRights) context; // Just for optimizing
+                               _user = (DocumentRights) context; // Just for optimizing
                        }
                }
        }
 
-       private static class ApprovedPopup extends PopupMenu { // Popup of Approved documents
-       // ----------------------------------------------------------------
+       /**
+        * Popup of Approved documents.
+        */
+       private static class ApprovedPopup extends PopupMenu {
                private ApprovedPopup() {
-                       addItem("attach", new PopupItem("menu.attach").icon(
-                                       "image.attach.png").action("select-file?nextAction=attach"));
+                       super();
+                       addItem(MNU_ATTACH, new PopupItem(MNU_NAME_ATTACH).icon(IMG_ATTACH)
+                                       .action(ACT_ATTACH));
                        addSeparator();
-                       addItem("version", new PopupItem("menu.version").icon(
-                                       "image.version.png").action(
-                                       "select-file?nextAction=version"));
+                       addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
+                                       IMG_VERSION).action(ACT_VERSION));
                }
        }
 
-       private static class ExternPopup extends PopupMenu { // Popup of Extern documents
-       // ----------------------------------------------------------------
-               private DocumentRights user = null;
+       /**
+        * Popup of Extern documents.
+        */
+       private static class ExternPopup extends PopupMenu {
+               private transient DocumentRights _user = null;
 
                private ExternPopup() {
-                       addItem("rename", new PopupItem("menu.rename")
+                       super();
+                       addItem(MNU_RENAME, new PopupItem(MNU_NAME_RENAME)
                                        .action("edit-document?action=renameDocument"));
                        addItem("replace", new PopupItem("menu.replace").icon(
                                        "image.replace.png").action(
                                        "select-file?nextAction=replace"));
                        addSeparator();
-                       addItem("remove", new PopupItem("menu.remove.document").icon(
-                                       "icon.delete.png").action("remove-document").confirmation(
+                       addItem(MNU_REMOVE, new PopupItem("menu.remove.document").icon(
+                                       IMG_DELETE).action("remove-document").confirmation(
                                        "message.delete.document"));
                }
 
                @Override
                public boolean isEnabled(final String name) {
-                       if (user == null) {
-                               return false; // Should not happen
-                       }
-                       Item item = Item.valueOf(name);
-                       if (item == Item.rename) {
-                               return user.canRename();
-                       }
-                       if (item == Item.replace) {
-                               return user.canReplace();
-                       }
-                       if (item == Item.remove) {
-                               return user.canRemove();
+                       boolean res = (_user != null);
+                       if (res) {
+                               Item item = Item.valueOf(name);
+                               switch (item) {
+                                       case rename:
+                                               res = _user.canRename();
+                                               break;
+                                       case replace:
+                                               res = _user.canReplace();
+                                               break;
+                                       case remove:
+                                               res = _user.canRemove();
+                                               break;
+                                       default:
+                                               res = false;
+                               }
                        }
-                       return false;
+                       return res;
                }
 
                @Override
                public void setContext(final String name, final Object context) {
                        if (context instanceof DocumentRights) {
-                               user = (DocumentRights) context; // Just for optimizing
+                               _user = (DocumentRights) context; // Just for optimizing
                        }
                }
        }
 
        // Resources relative to simulation contexts
        private static class ScontextPopup extends PopupMenu {
-               // --------------------------------------------------------
-               private SimulationContextFacade owner = null;
+               private SimulationContextFacade _owner = null; // RKV: NOPMD: TODO: Refine the usage of this field or remove it.
 
                private ScontextPopup() {
-                       addItem("rename", new PopupItem("menu.rename")
+                       super();
+                       addItem(MNU_RENAME, new PopupItem(MNU_NAME_RENAME)
                                        .action("edit-context?action=renameContext"));
-                       addItem("edit", new PopupItem("menu.edit")
+                       addItem(MNU_EDIT, new PopupItem(MNU_NAME_EDIT)
                                        .action("edit-context?action=editContext"));
                        addSeparator();
-                       addItem("remove", new PopupItem("menu.remove").icon(
-                                       "icon.delete.png").action("remove-context").confirmation(
-                                       "message.delete.context"));
+                       addItem(MNU_REMOVE, new PopupItem("menu.remove").icon(IMG_DELETE)
+                                       .action("remove-context").confirmation(
+                                                       "message.delete.context"));
                }
 
                @Override
                public boolean isEnabled(final String name) {
                        Item item = Item.valueOf(name);
+                       boolean res = true;
 
                        if (item == Item.rename) {
-                               return false;
+                               res = false;
                        } else if (item == Item.edit) {
                                // if (!owner.isEditable())
-                               return false;
+                               res = false;
                        }
-                       return true;
+                       return res;
                }
 
                @Override
                public void setContext(final String name, final Object context) {
                        if (context instanceof SimulationContextFacade) {
-                               owner = (SimulationContextFacade) context; // Just for optimizing
+                               _owner = (SimulationContextFacade) context; // Just for optimizing
                        } else {
                                super.setContext(name, context);
                        }
@@ -540,47 +730,47 @@ public class ApplicationSettings implements ServletContextAware {
 
        // Resources relative to knowledge
        private static class FeedbexPopup extends PopupMenu {
-               // --------------------------------------------------------
-               private KnowledgeElement owner = null;
+               private transient KnowledgeElement _owner = null;
 
                private FeedbexPopup() {
-                       addItem("promote", new PopupItem("menu.promote").icon(
+                       super();
+                       addItem(MNU_PROMOTE, new PopupItem(MNU_NAME_PROMOTE).icon(
                                        "image.review.png").action("promote-knowledge")
                                        .confirmation("message.promote.knowledge"));
-                       addItem("demote", new PopupItem("menu.demote").icon(
+                       addItem(MNU_DEMOTE, new PopupItem(MNU_NAME_DEMOTE).icon(
                                        "image.invalidate.png").action("demote-knowledge")
                                        .confirmation("message.demote.knowledge"));
                        addSeparator();
-                       addItem("rename", new PopupItem("menu.rename")
+                       addItem(MNU_RENAME, new PopupItem(MNU_NAME_RENAME)
                                        .action("edit-knowledge?action=renameKnowledge"));
-                       addItem("edit", new PopupItem("menu.edit")
+                       addItem(MNU_EDIT, new PopupItem(MNU_NAME_EDIT)
                                        .action("edit-knowledge?action=editKnowledge"));
                        addSeparator();
-                       addItem("remove", new PopupItem("menu.remove").icon(
-                                       "icon.delete.png").action("remove-knowledge").confirmation(
-                                       "message.delete.knowledge"));
+                       addItem(MNU_REMOVE, new PopupItem("menu.remove").icon(IMG_DELETE)
+                                       .action("remove-knowledge").confirmation(
+                                                       "message.delete.knowledge"));
                }
 
                @Override
                public boolean isEnabled(final String name) {
                        Item item = Item.valueOf(name);
+                       boolean res = true;
 
                        if (item == Item.promote) {
-                               if (owner.getProgressState() != ProgressState.inDRAFT) {
-                                       return false;
-                               }
-                       } else if (item == Item.demote) {
-                               if (owner.getProgressState() != ProgressState.inCHECK) {
-                                       return false;
+                               if (_owner.getProgressState() != ProgressState.inDRAFT) {
+                                       res = false;
                                }
+                       } else if ((item == Item.demote)
+                                       && (_owner.getProgressState() != ProgressState.inCHECK)) {
+                               res = false;
                        }
-                       return true;
+                       return res;
                }
 
                @Override
                public void setContext(final String name, final Object context) {
                        if (context instanceof KnowledgeElement) {
-                               owner = (KnowledgeElement) context; // Just for optimizing
+                               _owner = (KnowledgeElement) context; // Just for optimizing
                        } else {
                                super.setContext(name, context);
                        }
@@ -592,7 +782,7 @@ public class ApplicationSettings implements ServletContextAware {
        // ==============================================================================================================================
 
        public static ApplicationSettings getMe() {
-               return my; // The application is supposed being previously created below
+               return MY_APP; // The application is supposed being previously created below
        }
 
        /**
@@ -602,25 +792,24 @@ public class ApplicationSettings implements ServletContextAware {
         */
        public ApplicationSettings init(final String wappurl, final Locale lang)
                        throws IOException {
-               ClassLoader cloader = getClass().getClassLoader();
+               ClassLoader cloader = Thread.currentThread().getContextClassLoader();
                String[] wurl = wappurl.split("/"); // [0]="http:", [1]="", [2]="{server}:{port}", [3]="name"
 
-               locale = lang;
-               wappserver = wurl[2];
-               wappname = wurl[3];
-               wapprops.clear();
-               jndprops.clear();
-               wapprops.load(cloader.getResourceAsStream(wappname + ".properties"));
-               jndprops.load(cloader.getResourceAsStream("jndi.properties"));
+               synchronized (MY_APP) {
+                       MY_APP._locale = lang;
+                       MY_APP._wappserver = wurl[2];
+                       MY_APP._wappname = wurl[3];
+                       MY_APP._wapprops.clear();
+                       MY_APP._jndprops.clear();
+                       MY_APP._wapprops.load(cloader.getResourceAsStream(_wappname
+                                       + ".properties"));
+                       MY_APP._jndprops.load(cloader
+                                       .getResourceAsStream("jndi.properties"));
+               }
 
                LOG.info("Application root set to "
-                               + wapprops.getProperty("wapp.root"));
-               if (my == null) {
-                       my = this;
-               }
-//RKV          my = this;
-//RKV          return this;
-               return my;
+                               + _wapprops.getProperty("wapp.root"));
+               return MY_APP;
        }
 
        // ==============================================================================================================================
@@ -628,36 +817,35 @@ public class ApplicationSettings implements ServletContextAware {
        // ==============================================================================================================================
 
        public void configure(final String filename) {
-               // ---------------------------------------
                // Non customizable settings
-               menus.clear();
+               _menus.clear();
                SimpleMenu menu = new NewMenu();
-               menus.put(menu.getName(), menu);
+               _menus.put(menu.getName(), menu);
                menu = new SearchMenu();
-               menus.put(menu.getName(), menu);
+               _menus.put(menu.getName(), menu);
                menu = new DatadminMenu();
-               menus.put(menu.getName(), menu);
+               _menus.put(menu.getName(), menu);
                menu = new SysadminMenu();
-               menus.put(menu.getName(), menu);
+               _menus.put(menu.getName(), menu);
                menu = new PropertiesMenu();
-               menus.put(menu.getName(), menu);
-
-               popups = new HashMap<String, PopupMenu>();
-               popups.put("steditable", new EditableStudyPopup());
-               popups.put("editable", new EditableDocumentPopup());
-               popups.put("notresult", new NotResultDocumentPopup());
-               popups.put("reviewable", new ReviewableDocumentPopup());
-               popups.put("approvable", new ApprovableDocumentPopup());
-               popups.put("approved", new ApprovedPopup());
-               popups.put("extern", new ExternPopup());
-               popups.put("scontext", new ScontextPopup());
-               popups.put("feedbex", new FeedbexPopup());
+               _menus.put(menu.getName(), menu);
+
+               _popups = new HashMap<String, PopupMenu>();
+               _popups.put("steditable", new EditableStudyPopup());
+               _popups.put("editable", new EditableDocumentPopup());
+               _popups.put("notresult", new NotResultDocumentPopup());
+               _popups.put("reviewable", new ReviewableDocumentPopup());
+               _popups.put("approvable", new ApprovableDocumentPopup());
+               _popups.put("approved", new ApprovedPopup());
+               _popups.put("extern", new ExternPopup());
+               _popups.put("scontext", new ScontextPopup());
+               _popups.put("feedbex", new FeedbexPopup());
 
                // Default customizable mandatory settings
                Map<String, Object> fprop = new HashMap<String, Object>();
                fprop.put("visibility", "PRIVATE");
-               fprop.put("matchamong", "all");
-               fprop.put("matcontext", "all");
+               fprop.put("matchamong", ALL);
+               fprop.put("matcontext", ALL);
                fprop.put("state", "APPROVED");
                fprop.put("author", "0");
                fprop.put("reference", "");
@@ -666,21 +854,21 @@ public class ApplicationSettings implements ServletContextAware {
 
                Map<String, Object> gprop = new HashMap<String, Object>();
                gprop.put("visibility", "PUBLIC");
-               gprop.put("matchamong", "all");
-               gprop.put("matcontext", "all");
+               gprop.put("matchamong", ALL);
+               gprop.put("matcontext", ALL);
                gprop.put("type", "2"); // TODO: Get the index from the type name
                gprop.put("author", "0");
                gprop.put("reference", "");
                gprop.put("title", "");
                gprop.put("context", new ArrayList<SimulationContext>());
 
-               defdoctype = new LinkedHashMap<String, DocumentType>();
-               tempfile = new HashMap<String, String>();
-               viewermap = new String[0];
-               convertmap = new HashMap<String, Converter>();
-               filter = new HashMap<String, Map<String, Object>>();
-               filter.put("study", fprop);
-               filter.put("knowledge", gprop);
+               _defdoctype = new LinkedHashMap<String, DocumentType>();
+               _tempfile = new HashMap<String, String>();
+               _viewermap = new String[0];
+               _convertmap = new HashMap<String, Converter>();
+               _filter = new HashMap<String, Map<String, Object>>();
+               _filter.put("study", fprop);
+               _filter.put("knowledge", gprop);
 
                // Customization (must be done after above default settings)
                File config = new File(filename);
@@ -691,20 +879,27 @@ public class ApplicationSettings implements ServletContextAware {
                                        + config.getAbsolutePath() + "\", using default settings");
                }
                // Settings based on the customization
-               bars = new HashMap<Integer, ToolBar>(); // May be empty if no module installed
+               _bars = new HashMap<Integer, ToolBar>(); // May be empty if no module installed
+
+               configureToolbars();
+       }
 
+       /**
+        * Configure toolbars for steps.
+        */
+       private void configureToolbars() {
                List<ProjectSettingsService.Step> steps = getProjectSettings()
                                .getAllSteps();
                for (Iterator<ProjectSettingsService.Step> i = steps.iterator(); i
                                .hasNext();) {
                        ProjectSettingsService.Step step = i.next();
                        List<String> formats = getDefaultFormats(step);
-                       if (formats.size() == 0) {
+                       if (formats.isEmpty()) {
                                continue;
                        }
 
                        ToolBar bar = new ToolBar(24); // Height of the module-bar
-                       HashSet<String> module = new HashSet<String>(); // For not duplicating modules
+                       Set<String> module = new HashSet<String>(); // For not duplicating modules
                        for (Iterator<String> j = formats.iterator(); j.hasNext();) {
                                String format = j.next();
                                String command = getApplicationProperty("executable." + format);
@@ -717,16 +912,16 @@ public class ApplicationSettings implements ServletContextAware {
                                module.add(command);
                                String[] parsed = command.split("/");
                                String[] name = parsed[parsed.length - 1].split("\\x2E");
-                               DocumentType dtype = my.defdoctype.get(
-                                               step.getNumber() + "." + format);
+                               DocumentType dtype = MY_APP._defdoctype.get(step.getNumber()
+                                               + "." + format);
                                String docname = "";
                                if (dtype != null) {
                                        docname = dtype.getName();
                                }
-                               if (tempfile.get(docname) == null) { // No available template
+                               if (_tempfile.get(docname) == null) { // No available template
                                        String tool = parsed[parsed.length - 1];
                                        String icon = name[0];
-                                       if (icon.equals("index")) {
+                                       if ("index".equals(icon)) {
                                                tool = parsed[parsed.length - 2];
                                                icon = "tool." + tool.toLowerCase() + ".png";
                                        } else {
@@ -752,40 +947,36 @@ public class ApplicationSettings implements ServletContextAware {
                                }
                        }
                        if (!bar.isEmpty()) {
-                               bars.put(step.getNumber(), bar);
+                               _bars.put(step.getNumber(), bar);
                        }
                }
        }
 
        public String getApplicationProperty(final String name) {
-               return wapprops.getProperty(name); // May be null
+               return _wapprops.getProperty(name); // May be null
        }
 
        public String getApplicationRootPath() {
-               //RKV: return getApplicationProperty("wapp.root"); // The property is supposed including the Web application name
+               // RKV: return getApplicationProperty("wapp.root"); // The property is supposed including the Web application name
                return _servletContext.getRealPath("/");
        }
 
        public String getApplicationURL() {
-               // ----------------------------------
-               StringBuffer url = new StringBuffer("http://").append(my.wappserver)
-                               .append("/").append(wappname);
+               StringBuffer url = new StringBuffer("http://").append(
+                               MY_APP._wappserver).append("/").append(_wappname);
                return url.toString();
        }
 
        public Map<String, Object> getFilter(final String name) {
-               // --------------------------------------------------
-               return filter.get(name);
+               return _filter.get(name);
        }
 
        public ToolBar getModuleBar(final Step step) {
-               // -----------------------------------------
-               return bars.get(step.getNumber());
+               return _bars.get(step.getNumber());
        }
 
        public Properties getNamingProperties() {
-               // ----------------------------------------
-               return jndprops;
+               return _jndprops;
        }
 
        // ==============================================================================================================================
@@ -793,64 +984,57 @@ public class ApplicationSettings implements ServletContextAware {
        // ==============================================================================================================================
 
        public static String getApplicationPluginPath() {
-               // ------------------------------------------------
-               return my.getApplicationRootPath() + "plugin/";
+               return MY_APP.getApplicationRootPath() + "plugin/";
        }
 
        public static String getApplicationResourcePath() {
-               // --------------------------------------------------
-               return my.getApplicationRootPath() + "WEB-INF/classes/";
+               return MY_APP.getApplicationRootPath() + "WEB-INF/classes/";
        }
 
        public static String getApplicationSkinPath() {
-               // ----------------------------------------------
-               return my.getApplicationRootPath() + "skin/";
+               return MY_APP.getApplicationRootPath() + "skin/";
        }
 
-       public static Converter getConverter(final DocumentType type, final String format) {
-               // -----------------------------------------------------------------------
-               return my.convertmap.get(format + type.getName()); // May be null;
+       public static Converter getConverter(final DocumentType type,
+                       final String format) {
+               return MY_APP._convertmap.get(format + type.getName()); // May be null;
        }
 
-       public static DocumentType getDefaultDocumentType(final Step step, final String format) {
-               // ----------------------------------------------------------------------------
+       public static DocumentType getDefaultDocumentType(final Step step,
+                       final String format) {
                String[] table = format.split("\\x2E");
-               return my.defdoctype.get(step.getNumber() + "."
+               return MY_APP._defdoctype.get(step.getNumber() + "."
                                + table[table.length - 1]); // May be null
        }
 
        public static String getDownloadURL(final User user) {
-               // --------------------------------------------------
-               StringBuffer url = new StringBuffer("http://").append(my.wappserver)
-                               .append("/download/").append(user.getUsername()).append("/");
+               StringBuffer url = new StringBuffer("http://").append(
+                               MY_APP._wappserver).append("/download/").append(
+                               user.getUsername()).append("/");
                return url.toString(); // The download Tomcat context is supposed being defined
        }
 
        public static Locale getCurrentLocale() {
-               // ----------------------------------------
-               return my.locale;
+               return MY_APP._locale;
        }
 
        public static SimpleMenu getMenu(final String name) {
-               // ----------------------------------------------
-               return my.menus.get(name);
+               return MY_APP._menus.get(name);
        }
 
        public static PopupMenu getPopupMenu(final String name) {
-               // --------------------------------------------------
-               return my.popups.get(name);
+               return MY_APP._popups.get(name);
        }
 
        public static String getRepositoryURL() {
-               // ----------------------------------------
-               StringBuffer url = new StringBuffer("http://").append(my.wappserver)
-                               .append("/repository/");
+               StringBuffer url = new StringBuffer("http://").append(
+                               MY_APP._wappserver).append("/repository/");
                return url.toString(); // The repository Tomcat context is supposed being defined
        }
 
        public static Locale[] getSupportedLocales() {
-               // ---------------------------------------------
-               String[] code = my.wapprops.getProperty("locale.supported").split(",");
+               String[] code = MY_APP._wapprops.getProperty("locale.supported").split(
+                               ",");
                Locale[] result = new Locale[code.length];
                for (int i = 0; i < code.length; i++) {
                        result[i] = new Locale(code[i]);
@@ -859,27 +1043,24 @@ public class ApplicationSettings implements ServletContextAware {
        }
 
        public static String[] getViewersMapping() {
-               // -------------------------------------------
-               return my.viewermap;
+               return MY_APP._viewermap;
        }
 
        public static String getWebSiteURL() {
-               // -------------------------------------
-               return my.getApplicationProperty("wapp.website");
+               return MY_APP.getApplicationProperty("wapp.website");
        }
 
        public static String getHelpURL() {
-               // ----------------------------------
-               return my.getApplicationProperty("wapp.onlinehelp");
+               return MY_APP.getApplicationProperty("wapp.onlinehelp");
        }
 
        // ==============================================================================================================================
        // Private services
        // ==============================================================================================================================
 
-       private List<String> getDefaultFormats(final ProjectSettingsService.Step step) {
-               // ------------------------------------------------------------------
-               Set<String> keys = defdoctype.keySet();
+       private List<String> getDefaultFormats(
+                       final ProjectSettingsService.Step step) {
+               Set<String> keys = _defdoctype.keySet();
                int number = step.getNumber();
                List<String> result = new ArrayList<String>();
 
@@ -896,8 +1077,11 @@ public class ApplicationSettings implements ServletContextAware {
                return result;
        }
 
+       /**
+        * Load customization of workflow from the given XML file.
+        * @param config the XML configuration file
+        */
        private void loadCustomization(final File config) {
-               // --------------------------------------------
                try {
                        DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory
                                        .newInstance();
@@ -907,89 +1091,128 @@ public class ApplicationSettings implements ServletContextAware {
                        HashMap<String, Node> children = XDOM.getNamedChildNodes(conf
                                        .getDocumentElement());
 
-                       // Default document types tag
-                       Node child = children.get("default-doctypes");
-                       NodeList nlist = child.getChildNodes();
+                       // Load default document types.
+                       loadDocTypes(children);
 
-                       List<DocumentType> listype = getDocumentTypeService()
-                                       .selectAllTypes();
-                       HashMap<String, DocumentType> maptype = new HashMap<String, DocumentType>();
-                       for (Iterator<DocumentType> i = listype.iterator(); i.hasNext();) {
-                               DocumentType type = i.next();
-                               maptype.put(type.getName(), type);
-                       }
-                       for (int i = 0; i < nlist.getLength(); i++) {
-                               child = nlist.item(i);
-                               if (!child.getNodeName().equals("step")) {
-                                       continue;
-                               }
+                       // Modules tag
+                       loadModules(children);
 
-                               String nstep = child.getAttributes().getNamedItem("number")
-                                               .getNodeValue();
-                               NodeList map = child.getChildNodes();
-                               for (int j = 0; j < map.getLength(); j++) {
-                                       child = map.item(j);
-                                       if (!child.getNodeName().equals("mapping")) {
-                                               continue;
-                                       }
-                                       NamedNodeMap natr = child.getAttributes();
-                                       String dext = natr.getNamedItem("extension").getNodeValue();
-                                       String type = natr.getNamedItem("type").getNodeValue();
-                                       defdoctype.put(nstep + "." + dext, maptype.get(type));
-                               }
+                       // Converters tag
+                       loadConverters(children);
+
+                       // Templates tag
+                       loadTemplates(children);
+               } catch (Exception error) {
+                       LOG.info("Error in customization", error);
+               }
+       }
+
+       /**
+        * Load modules from XML configuration.
+        * 
+        * @param children
+        *            XML nodes
+        */
+       private void loadModules(final Map<String, Node> children) {
+               Node child = children.get("modules");
+               NodeList nlist = child.getChildNodes();
+               for (int i = 0; i < nlist.getLength(); i++) {
+                       child = nlist.item(i);
+                       if (!child.getNodeName().equals("mapping")) {
+                               continue;
                        }
-                       // Modules tag
-                       child = children.get("modules");
-                       nlist = child.getChildNodes();
-                       for (int i = 0; i < nlist.getLength(); i++) {
-                               child = nlist.item(i);
-                               if (!child.getNodeName().equals("mapping")) {
-                                       continue;
-                               }
 
+                       NamedNodeMap natr = child.getAttributes();
+                       String dext = natr.getNamedItem("extension").getNodeValue();
+                       String exec = natr.getNamedItem("executable").getNodeValue();
+                       _wapprops.put("executable." + dext, exec);
+               }
+               // Viewer mappings tag
+               child = children.get("viewers");
+               _viewermap = child.getAttributes().getNamedItem("extension")
+                               .getNodeValue().split(",");
+       }
+
+       /**
+        * Load converters from XML configuration.
+        * 
+        * @param children
+        *            XML nodes
+        */
+       private void loadConverters(final Map<String, Node> children) {
+               Node child = children.get("converters");
+               NodeList nlist = child.getChildNodes();
+               for (int i = 0; i < nlist.getLength(); i++) {
+                       child = nlist.item(i);
+
+                       if (child.getNodeName().equals("geometry")) {
                                NamedNodeMap natr = child.getAttributes();
-                               String dext = natr.getNamedItem("extension").getNodeValue();
+                               String from = natr.getNamedItem("from").getNodeValue();
+                               String to = natr.getNamedItem("to").getNodeValue();
                                String exec = natr.getNamedItem("executable").getNodeValue();
-                               wapprops.put("executable." + dext, exec);
+                               _convertmap.put(from + "geometry", new Converter("geometry",
+                                               from, to, exec));
                        }
-                       // Viewer mappings tag
-                       child = children.get("viewers");
-                       viewermap = child.getAttributes().getNamedItem("extension")
-                                       .getNodeValue().split(",");
+               }
+       }
 
-                       // Converters tag
-                       child = children.get("converters");
-                       nlist = child.getChildNodes();
-                       for (int i = 0; i < nlist.getLength(); i++) {
-                               child = nlist.item(i);
-
-                               if (child.getNodeName().equals("geometry")) {
-                                       NamedNodeMap natr = child.getAttributes();
-                                       String from = natr.getNamedItem("from").getNodeValue();
-                                       String to = natr.getNamedItem("to").getNodeValue();
-                                       String exec = natr.getNamedItem("executable")
-                                                       .getNodeValue();
-                                       convertmap.put(from + "geometry", new Converter("geometry",
-                                                       from, to, exec));
-                               }
+       /**
+        * Load templates from XML configuration.
+        * 
+        * @param children
+        *            XML nodes
+        */
+       private void loadTemplates(final Map<String, Node> children) {
+               Node child = children.get("templates");
+               NodeList nlist = child.getChildNodes();
+               for (int i = 0; i < nlist.getLength(); i++) {
+                       child = nlist.item(i);
+                       if (!child.getNodeName().equals("document")) {
+                               continue;
                        }
 
-                       // Templates tag
-                       child = children.get("templates");
-                       nlist = child.getChildNodes();
-                       for (int i = 0; i < nlist.getLength(); i++) {
-                               child = nlist.item(i);
-                               if (!child.getNodeName().equals("document")) {
+                       NamedNodeMap natr = child.getAttributes();
+                       String type = natr.getNamedItem("type").getNodeValue();
+                       String file = natr.getNamedItem("file").getNodeValue();
+                       _tempfile.put(type, file);
+               }
+       }
+
+       /**
+        * Load default document types from XML configuration.
+        * 
+        * @param children
+        *            XML nodes
+        */
+       private void loadDocTypes(final Map<String, Node> children) {
+               Node child = children.get("default-doctypes");
+               NodeList nlist = child.getChildNodes();
+
+               List<DocumentType> listype = getDocumentTypeService().selectAllTypes();
+               Map<String, DocumentType> maptype = new HashMap<String, DocumentType>();
+               for (Iterator<DocumentType> i = listype.iterator(); i.hasNext();) {
+                       DocumentType type = i.next();
+                       maptype.put(type.getName(), type);
+               }
+               for (int i = 0; i < nlist.getLength(); i++) {
+                       child = nlist.item(i);
+                       if (!child.getNodeName().equals("step")) {
+                               continue;
+                       }
+
+                       String nstep = child.getAttributes().getNamedItem("number")
+                                       .getNodeValue();
+                       NodeList map = child.getChildNodes();
+                       for (int j = 0; j < map.getLength(); j++) {
+                               child = map.item(j);
+                               if (!child.getNodeName().equals("mapping")) {
                                        continue;
                                }
-
                                NamedNodeMap natr = child.getAttributes();
+                               String dext = natr.getNamedItem("extension").getNodeValue();
                                String type = natr.getNamedItem("type").getNodeValue();
-                               String file = natr.getNamedItem("file").getNodeValue();
-                               tempfile.put(type, file);
+                               _defdoctype.put(nstep + "." + dext, maptype.get(type));
                        }
-               } catch (Exception error) {
-                       LOG.info("Error in customization", error);
                }
        }
 
@@ -1008,12 +1231,14 @@ public class ApplicationSettings implements ServletContextAware {
         * @param documentTypeService
         *            the documentTypeService to set
         */
-       public void setDocumentTypeService(final DocumentTypeService documentTypeService) {
+       public void setDocumentTypeService(
+                       final DocumentTypeService documentTypeService) {
                _documentTypeService = documentTypeService;
        }
 
-       /** 
+       /**
         * {@inheritDoc}
+        * 
         * @see org.apache.struts2.util.ServletContextAware#setServletContext(javax.servlet.ServletContext)
         */
        @Override
index 7e655654aed6dcaa2205784e6f5e7ee146fc8736..6f7eab962e6ce2eed6499ec17fd0c02a3cbcabaf 100644 (file)
@@ -97,7 +97,7 @@ public class ConnectionAction extends Action {
                        setErrorCode("message.error.login." + error.getMessage());
                        return INPUT;
                } catch (Exception error) {
-                       logger.error("Reason:", error);
+                       LOG.error("Reason:", error);
                        return ERROR;
                }
        }
@@ -118,7 +118,7 @@ public class ConnectionAction extends Action {
                                connectedUsr = getConnectedUser().toString();
                        }
                        
-                       logger.info("Deconnection of " + connectedUsr
+                       LOG.info("Deconnection of " + connectedUsr
                                        + ".");
                        
                        if (context != null) {
@@ -138,7 +138,7 @@ public class ConnectionAction extends Action {
                        
                        return backmenu;
                } catch (Exception error) {
-                       logger.error("Reason:", error);
+                       LOG.error("Reason:", error);
                        return ERROR;
                }
        }
index 339742c4407a163c58434736d060dece32624574..4fbcd3eed2c85c3246ce06442a24516c3afc0ffc 100644 (file)
@@ -73,7 +73,7 @@ public class DisplayKnowledgeAction extends DisplayBaseAction {
                                        selection = myknelm.getSelection(); // Default selection
                                }
                        } catch (Exception error) {
-                               logger.error("Reason:", error);
+                               LOG.error("Reason:", error);
                                return ERROR;
                        }
                } else if (selection != null) { // Re-opening (refreshing) the currently open knowledge
index db5487e3e85d6cbee70d56569bbe2aa2abfad36c..6a9536c254525278f14789636383ad96980a3e6e 100644 (file)
@@ -88,7 +88,7 @@ public class DisplayStudyStepAction extends DisplayBaseAction {
                                        selection = mystudy.getSelection(); // Default selection
                                }
                        } catch (Exception error) {
-                               logger.error("Reason:", error);
+                               LOG.error("Reason:", error);
                                return ERROR;
                        }
                else if (selection == null) { // Opening a study just newed
index 9c24fc99f1db24f60b080822c34af3adf14b019e..955e65b9734cd3e88ea9779ab20f3b08c06c2535 100644 (file)
@@ -148,7 +148,7 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                        }
                        return SUCCESS;
                } catch (RuntimeException saverror) {
-                       logger.error("Reason:", saverror);
+                       LOG.error("Reason:", saverror);
                        return ERROR;
                } catch (InvalidPropertyException error) {
                        return INPUT;
@@ -179,15 +179,15 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                        Publication edited = step.getDocument(Integer.valueOf(index));
                        ConvertsRelation export = getPublicationService().attach(edited, parse[parse.length - 1]);
 
-                       if (logger.isInfoEnabled())
-                               logger.info("Moving \"" + upfile.getName() + "\" to \""
+                       if (LOG.isInfoEnabled())
+                               LOG.info("Moving \"" + upfile.getName() + "\" to \""
                                                + updir.getPath() + "\".");
                        upfile.renameTo(export.getTo().asFile());
 
                        mystudy.update(edited);
                        return SUCCESS;
                } catch (Exception error) {
-                       logger.error("Reason:", error);
+                       LOG.error("Reason:", error);
                        return ERROR;
                }
        }
@@ -215,7 +215,7 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                        mystudy.remove(doctag); // Updates the presentation
                        return SUCCESS;
                } catch (RuntimeException saverror) {
-                       logger.error("Reason:", saverror);
+                       LOG.error("Reason:", saverror);
                        return ERROR;
                }
        }
index 0346c9850cbe7184711eaa2efc503ba15105296f..7f9afa14976ea718473f00a21f15b2b50ff56a6a 100644 (file)
@@ -145,10 +145,10 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
                        }
                        return SUCCESS;
                } catch (RuntimeException saverror) {
-                       logger.error("Reason:", saverror);
+                       LOG.error("Reason:", saverror);
                        return ERROR;
                } catch (Exception error) {
-                       logger.error("Exception while saving a knowledge: ", error);
+                       LOG.error("Exception while saving a knowledge: ", error);
                        return INPUT;
                }
        }
index ff83ddfc03ec0d6879ee0041230494cae4728db1..31ec5a3ffff3a2764411cec9bf9fcb7e71c05d05 100644 (file)
@@ -159,7 +159,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                        mystudy.add(contex);
                        return SUCCESS;
                } catch (RuntimeException saverror) {
-                       logger.error("Reason:", saverror);
+                       LOG.error("Reason:", saverror);
                        return ERROR;
                } catch (Exception error) {
                        return INPUT;
@@ -194,7 +194,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                        mystudy.remove(context);
                        return SUCCESS;
                } catch (RuntimeException saverror) {
-                       logger.error("Reason:", saverror);
+                       LOG.error("Reason:", saverror);
                        return ERROR;
                }
        }
@@ -251,7 +251,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
 //                     transax.commit();
                        return SUCCESS;
                } catch (RuntimeException saverror) {
-                       logger.error("Reason:", saverror);
+                       LOG.error("Reason:", saverror);
                        return ERROR;
                } catch (Exception error) {
                        value = input[0];
index faaa14a4979f0064e29e575e10efa6736f7ec4d4..2cef5d01db2c01fdfff7790cd70b7efe0c26fb0e 100644 (file)
@@ -74,7 +74,7 @@ public class EditStudyAction extends DisplayStudyStepAction {
         return SUCCESS;
          }
       catch (RuntimeException saverror) {
-        logger.error("Reason:", saverror);
+        LOG.error("Reason:", saverror);
         return ERROR;
       }
     }
index 02d29ca827b39028e318388846e79abdb26b954a..32ffa8c25c8f465fdbf5f8b991a856a2655bf373 100644 (file)
@@ -266,15 +266,15 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                                                .setType(type).setFormat(table[table.length - 1])
                                                .setAuthor(user));
                                updir = addoc.getSourceFile().asFile();
-                               if (logger.isInfoEnabled())
-                                       logger.info("Moving \"" + upfile.getName() + "\" to \""
+                               if (LOG.isInfoEnabled())
+                                       LOG.info("Moving \"" + upfile.getName() + "\" to \""
                                                        + updir.getPath() + "\".");
                                upfile.renameTo(updir);
                                try {
                                        getPublicationService().saveAs(addoc, state); // May throw FileNotFound if rename was not done
                                } catch (FileNotFoundException saverror) {
                                        Thread.sleep(1000);
-                                       logger.info("Waiting for the file.");
+                                       LOG.info("Waiting for the file.");
                                        upfile.renameTo(updir);
                                        getPublicationService().saveAs(addoc, state); // Forget it if throw again FileNotFound
                                }
@@ -289,8 +289,8 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                                addoc = getStepService().assignDocument(step, dprop.setReference(docref).setName(
                                                docname));
                                updir = addoc.getSourceFile().asFile();
-                               if (logger.isInfoEnabled())
-                                       logger.info("Moving \"" + upfile.getName() + "\" to \""
+                               if (LOG.isInfoEnabled())
+                                       LOG.info("Moving \"" + upfile.getName() + "\" to \""
                                                        + updir.getPath() + "\".");
                                upfile.renameTo(updir);
                                try {
@@ -301,7 +301,7 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                                                getPublicationService().saveAs(addoc, state);
                                } catch (FileNotFoundException saverror) {
                                        Thread.sleep(1000);
-                                       logger.info("Waiting for the file.");
+                                       LOG.info("Waiting for the file.");
                                        upfile.renameTo(updir);
                                        if (docver.length() > 0)
                                                getPublicationService().saveAs(addoc,
@@ -329,10 +329,10 @@ public class ImportDocumentAction extends UploadBaseNextAction {
                        mystudy.add(addoc); // Updates the presentation
                        return SUCCESS;
                } catch (FileNotFoundException error) {
-                       logger.error("Reason:", error);
+                       LOG.error("Reason:", error);
                        setErrorCode("import.file");
                } catch (Exception error) {
-                       logger.error("Reason:", error);
+                       LOG.error("Reason:", error);
                        setErrorCode("internal");
                }
                
index e9da800fb15b35ea8c6f90ea764cfa776bb68b0b..c20b83dedc358441784a5995da0332999e86570d 100644 (file)
@@ -171,7 +171,7 @@ public class NewScenarioAction extends Action {
            return SUCCESS;
          }
       catch (RuntimeException saverror) {
-        logger.error("Reason:", saverror);
+        LOG.error("Reason:", saverror);
         
         setMenuProperty("study");
         setTitleProperty("study");
index 9c48097575583488c912ae3d4390d359e848fd7a..94b40177ff329d6b4072841705b0b00ef0367943 100644 (file)
@@ -153,7 +153,7 @@ public class NewStudyAction extends Action {
 
                        return SUCCESS;
                } catch (Exception error) {
-                       logger.error("Unable to save the study, reason:", error);
+                       LOG.error("Unable to save the study, reason:", error);
                        setMenuProperty("none");
                        initializationScreenContext(_menuProperty);
                        return ERROR;
index f1a6b5e16f151669613e0cea97ea3a94473238ac..0769013e3bbae45424fd58d3ac7e04e2e8de4fd9 100644 (file)
@@ -45,7 +45,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        /**
         * Serial version ID.
         */
-       protected final static Logger LOGGER = org.splat.simer.Action.logger;
+       protected final static Logger LOGGER = org.splat.simer.Action.LOG;
 
        private transient Study _mystudy;
        private transient StudyRights _urightstudy; // User rights on the open study
index 07c03ef6c05045dcccf0688145cb698837e2cc02..7db86ad4db77c978e390a0ce60d0bdf7f8452264 100644 (file)
@@ -86,7 +86,7 @@ public abstract class SearchBaseAction extends Action {
                        return done;
                } catch (Exception error) {
                        // No need to roll back the transaction as it is read only
-                       logger.error("Reason: ", error);
+                       LOG.error("Reason: ", error);
                        return ERROR;
                }
        }
index 92a200873c21c75bb92ce56df273177b1dd468fa..0720eae6b0dc76286fc8bb67d50175ee02c16c56 100644 (file)
@@ -95,7 +95,7 @@ public class SearchKnowledgeAction extends SearchBaseAction {
                        return SUCCESS;
                } catch (Exception error) {
                        // No need to roll back the transaction as it is read only
-                       logger.error("Reason: ", error);
+                       LOG.error("Reason: ", error);
                        return ERROR;
                }
        }
index 18ed3fdb61e277a26dae391a04a788a9ad92da19..f752eb3a70a837dbdedaf514e05eff79a6dc9a11 100644 (file)
@@ -97,7 +97,7 @@ public class SearchStudyAction extends SearchBaseAction {
                        return SUCCESS;
                } catch (Exception error) {
                        // No need to roll back the transaction as it is read only
-                       logger.error("Reason: ", error);
+                       LOG.error("Reason: ", error);
                        
                        setMenuProperty("none");
                        initializationScreenContext(_menuProperty);
index e84c0841c385bc605fac281b8898c67a16521601..8eaab0a79053091aaf651cf7b5acb146e044a527 100644 (file)
@@ -69,12 +69,12 @@ public class StartAction extends Action implements ServletRequestAware {
 //      Transaction  transax = connex.beginTransaction();                
          StringBuffer wappurl = request.getRequestURL();     // "http://{server}:{port}/{webapp}/", including the leading '/'
 
-      logger.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
+      LOG.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
          try {
                ProjectSettingsService project = getProjectSettings();
         ApplicationSettings wapp    = getApplicationSettings().init(wappurl.toString(), this.getLocale());
         String              root    = wapp.getApplicationRootPath();
-        logger.debug("Application root: " + root);
+        LOG.debug("Application root: " + root);
 
 //      Database configuration
                project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
@@ -98,7 +98,7 @@ public class StartAction extends Action implements ServletRequestAware {
            return SUCCESS;
       }
       catch (Exception error) {
-        logger.fatal("Reason:", error);
+        LOG.fatal("Reason:", error);
         
         setMenuProperty("study");
         setTitleProperty("study");
index 16328ec4d81184bf1dd12e12691fbc9cc29f6b2f..49651266f32ceab6c92c2f00d6d4ab40bbd459e1 100644 (file)
@@ -86,7 +86,7 @@ public class UploadAction extends Action {
        if (!udir.exists()) udir.mkdir();
        if (file.exists())  file.delete();
        Do.copy(upload, file);
-        logger.info("Uploading \"" + uploadFileName + "\" " + uploadMimeType + " file.");
+        LOG.info("Uploading \"" + uploadFileName + "\" " + uploadMimeType + " file.");
         /*if (next == null || next.isEmpty()) {
                next = "import";
         }*/
@@ -105,7 +105,7 @@ public class UploadAction extends Action {
        return "outofmemory";
       }
       catch (Exception error) {
-       logger.error("Reason: ", error);
+       LOG.error("Reason: ", error);
         return ERROR;
       }
     }
index 5c0830bd8548c30e2b8e6377acff1ff1634ff0d6..d171ce1b65da1bba2cde1156795beaf2d35cfcd1 100644 (file)
@@ -272,10 +272,10 @@ public class VersionDocumentAction extends UploadBaseNextAction {
 
                        return SUCCESS;
                } catch (FileNotFoundException error) {
-                       logger.error("Reason:", error);
+                       LOG.error("Reason:", error);
                        setErrorCode("import.file");
                } catch (Exception error) {
-                       logger.error("Reason:", error);
+                       LOG.error("Reason:", error);
                        setErrorCode("internal");
                }
                
index 4287a4b11a356962a5eca4701fd44c8e7b594ac0..1dd125b4b084de54aa1e6e316f799b66ea7146c9 100644 (file)
@@ -22,11 +22,11 @@ public class DatabaseIndexingAction extends Action {
        /**
         * New studies which are not yet indexed by lucene.
         */
-       private List<ImportedStudyDTO> newstudies;
+       private transient List<ImportedStudyDTO> _newstudies;
        /**
         * Id's of studies to reindex.
         */
-       private String indices;
+       private String _indices;
        /**
         * Injected search service.
         */
@@ -59,8 +59,8 @@ public class DatabaseIndexingAction extends Action {
         * @return SUCCESS
         */
        public String doInitialize() {
-               newstudies = getSearchService().selectStudies();
-               indices = "";
+               _newstudies = getSearchService().selectStudies();
+               _indices = "";
                
                setMenuProperty("sysadmin");
                setToolProperty("none");
@@ -75,7 +75,7 @@ public class DatabaseIndexingAction extends Action {
         * @return SUCCESS
         */
        public String doIndexing() {
-               String[] ridlist = indices.split(",");
+               String[] ridlist = _indices.split(",");
                @SuppressWarnings("unchecked")
                Map<String, Object> filter = (Map<String, Object>) getSession().get(
                                "study.filter");
@@ -95,7 +95,7 @@ public class DatabaseIndexingAction extends Action {
         * @return the new studies
         */
        public List<ImportedStudyDTO> getNewStudies() {
-               return newstudies;
+               return _newstudies;
        }
 
        /**
@@ -103,15 +103,15 @@ public class DatabaseIndexingAction extends Action {
         * @return the indices
         */
        public String getIndices() {
-               return indices;
+               return _indices;
        }
 
        /**
         * Set the indices.
         * @param indices the indices to set
         */
-       public void setIndices(String indices) {
-               this.indices = indices;
+       public void setIndices(final String indices) {
+               this._indices = indices;
        }
 
        /**
@@ -129,7 +129,7 @@ public class DatabaseIndexingAction extends Action {
         * @param searchService
         *            the searchService to set
         */
-       public void setSearchService(SearchService searchService) {
+       public void setSearchService(final SearchService searchService) {
                _searchService = searchService;
        }
        
@@ -145,7 +145,7 @@ public class DatabaseIndexingAction extends Action {
         * Set the menuProperty.
         * @param menuProperty the menuProperty to set
         */
-       public void setMenuProperty(String menuProperty) {
+       public void setMenuProperty(final String menuProperty) {
                this._menuProperty = menuProperty;
        }
        
index 91586d7ae56736f91c7e2e845250a764778747c6..955ce2ee6e17ab6cc5d83b21794f3f6adbeb5dff 100644 (file)
@@ -5,13 +5,10 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
-import org.hibernate.Session;
-import org.hibernate.Transaction;
 import org.splat.dal.bo.kernel.User;
 import org.splat.service.UserService;
 import org.splat.service.technical.RepositoryService;
 import org.splat.simer.UploadBaseNextAction;
-import org.splat.dal.dao.som.Database;
 
 
 public class ImportUserAction extends UploadBaseNextAction {
@@ -21,8 +18,8 @@ public class ImportUserAction extends UploadBaseNextAction {
         */
     private static final long serialVersionUID = 1516715800624817965L;
 
-    private List<User> users;
-    private Set<User>  newsers;
+    private transient List<User> _users;
+    private transient Set<User>  _newsers;
        /**
         * Injected repository service.
         */
@@ -56,16 +53,19 @@ public class ImportUserAction extends UploadBaseNextAction {
 //  ==============================================================================================================================
 
     public String doImport () {
+      String res = SUCCESS;
       try {
         User       user    = getConnectedUser();     // The database administrator
        File       updir   = getRepositoryService().getDownloadDirectory(user);
        File       upfile  = new File(updir.getPath() + "/" + filename);
 
-        newsers = getUserService().importUsers(upfile);
-        users   = getUserService().selectAllUsers();
-        for (Iterator<User> i=users.iterator(); i.hasNext(); ) {
+        _newsers = getUserService().importUsers(upfile);
+        _users   = getUserService().selectAllUsers();
+        for (Iterator<User> i=_users.iterator(); i.hasNext(); ) {
           User next = i.next();
-          if (!next.equals(user)) continue;
+          if (!next.equals(user)) {
+                       continue;
+               }
           i.remove();                                // Just for not showing the corresponding reserved username
           break;
         }
@@ -74,12 +74,11 @@ public class ImportUserAction extends UploadBaseNextAction {
         setToolProperty("none");
         setLeftMenuProperty("open");
         initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty);
-        
-        return SUCCESS;
       }
       catch (Exception error) {
-        return ERROR;          
+        res = ERROR;           
       }
+      return res;
     }
     
 //  ==============================================================================================================================
@@ -88,12 +87,12 @@ public class ImportUserAction extends UploadBaseNextAction {
 
     public List<User> getUsers () {
 //  -----------------------------
-      return  users;
+      return  _users;
     }
 
-    public boolean isNew (User user) {
+    public boolean isNew (final User user) {
 //  --------------------------------
-      return newsers.contains(user);
+      return _newsers.contains(user);
     }
 
        /**
@@ -108,7 +107,7 @@ public class ImportUserAction extends UploadBaseNextAction {
         * Set the repositoryService.
         * @param repositoryService the repositoryService to set
         */
-       public void setRepositoryService(RepositoryService repositoryService) {
+       public void setRepositoryService(final RepositoryService repositoryService) {
                _repositoryService = repositoryService;
        }
 
@@ -124,7 +123,7 @@ public class ImportUserAction extends UploadBaseNextAction {
         * Set the userService.
         * @param userService the userService to set
         */
-       public void setUserService(UserService userService) {
+       public void setUserService(final UserService userService) {
                _userService = userService;
        }
        
@@ -140,7 +139,7 @@ public class ImportUserAction extends UploadBaseNextAction {
         * Set the menuProperty.
         * @param menuProperty the menuProperty to set
         */
-       public void setMenuProperty(String menuProperty) {
+       public void setMenuProperty(final String menuProperty) {
                this._menuProperty = menuProperty;
        }
        
index c75000a3648d81b900d10f6d087d55e98fd9fa06..e03b78b006a1752fef441aedc651bbd7f417a2dd 100644 (file)
@@ -1,48 +1,50 @@
 package org.splat.simer.admin;
 
 import org.splat.dal.bo.som.ProgressState;
-import org.splat.service.technical.ProjectSettingsService;
 import org.splat.dal.bo.som.Scenario;
 import org.splat.dal.bo.som.Study;
+import org.splat.service.technical.ProjectSettingsService;
 
 
 public class ProjectElementFacade {
 
-    private long     index;        // For checking the equality between ProjectElementFacade objects
-    private Study   my;
-    private String  subtitle;
-    private String  step;
+    private transient final long    _index;        // For checking the equality between ProjectElementFacade objects
+    private transient final Study   _my;
+    private transient final String  _subtitle;
+    private transient final String  _step;
 
 //  ==============================================================================================================================
 //  Constructor
 //  ==============================================================================================================================
 
-    public ProjectElementFacade (Study represented, ProjectSettingsService.Step at) {
+    public ProjectElementFacade (final Study represented, final ProjectSettingsService.Step at) {
 //  ------------------------------------------------------------------------
-      index    = represented.getIndex();         // The index of scenarios AND studies are unique
-      my       = represented;
-      subtitle = "";
-      step     = "0." + at.getNumber();
+      _index    = represented.getIndex();         // The index of scenarios AND studies are unique
+      _my       = represented;
+      _subtitle = "";
+      _step     = "0." + at.getNumber();
     }
-    public ProjectElementFacade (Scenario represented, ProjectSettingsService.Step at) {
+    public ProjectElementFacade (final Scenario represented, final ProjectSettingsService.Step at) {
 //  ---------------------------------------------------------------------------
-      index    = represented.getIndex();         // The index of scenarios AND studies are unique
-      my       = represented.getOwnerStudy();
-      subtitle = ", " + represented.getTitle();
-      step     = String.valueOf(index) + "." + at.getNumber();
+      _index    = represented.getIndex();         // The index of scenarios AND studies are unique
+      _my       = represented.getOwnerStudy();
+      _subtitle = ", " + represented.getTitle();
+      _step     = String.valueOf(_index) + "." + at.getNumber();
     }
 
 //  ==============================================================================================================================
 //  Services for not duplicating Study facades into a Set
 //  ==============================================================================================================================
 
-    public boolean equals (Object other) {
+    @Override
+       public boolean equals (final Object other) {
 //  ------------------------------------
       return (this.hashCode() == other.hashCode());
     }
-    public int hashCode () {
+    @Override
+       public int hashCode () {
 //  ----------------------
-      return  (int) index;
+      return  (int) _index;
     }
 
 //  ==============================================================================================================================
@@ -51,26 +53,26 @@ public class ProjectElementFacade {
 
     public String getAuthorName () {
 //  ------------------------------
-      return  my.getAuthor().getDisplayName();
+      return  _my.getAuthor().getDisplayName();
     }
     public ProgressState getProgressState () {
 //  ----------------------------------------
-      return  my.getProgressState();
+      return  _my.getProgressState();
     }
     public String getReference () {
 //  -----------------------------
-      return  my.getReference();
+      return  _my.getReference();
     }
     public String getSelection () {
 //  -----------------------------
-      return step;
+      return _step;
     }
     public String getStudyIndex () {
 //  ------------------------------
-      return  String.valueOf(my.getIndex());
+      return  String.valueOf(_my.getIndex());
     }
     public String getTitle () {
 //  -------------------------
-      return  my.getTitle() + subtitle;
+      return  _my.getTitle() + _subtitle;
     }
 }
\ No newline at end of file
index 47a5c37fe19c262f8f6ab56c2973a83eca582584..fb7914715cd8404361de8b708df24ace6b62bedc 100644 (file)
@@ -156,7 +156,7 @@ public class SimulationContextAction extends Action {
 
                        return SUCCESS;
                } catch (Exception error) {
-                       logger.error("Reason:", error);
+                       LOG.error("Reason:", error);
                        return ERROR; // No need to roll-back the transaction as it is read-only
                }
        }
@@ -235,7 +235,7 @@ public class SimulationContextAction extends Action {
                        transax.commit();
                        return SUCCESS;
                } catch (Exception error) {
-                       logger.error("Reason:", error);
+                       LOG.error("Reason:", error);
                        return ERROR; // No need to roll-back the transaction as it is read-only
                }
        }