Stage 1 : Issue info level warning

Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/57dd0eee
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/57dd0eee
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/57dd0eee

Branch: refs/heads/master
Commit: 57dd0eee16814385dbea60ad7478e28a96c160da
Parents: 76e1039
Author: Menaka Madushanka <[email protected]>
Authored: Sat Jul 25 03:11:27 2015 +0530
Committer: Menaka Madushanka <[email protected]>
Committed: Sat Jul 25 03:11:27 2015 +0530

----------------------------------------------------------------------
 .../taverna/robundle/validator/RoValidator.java | 30 ++++++++--------
 .../robundle/validator/ValidationReport.java    | 36 ++++++++++++--------
 2 files changed, 35 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/57dd0eee/taverna-robundle/src/main/java/org/apache/taverna/robundle/validator/RoValidator.java
----------------------------------------------------------------------
diff --git 
a/taverna-robundle/src/main/java/org/apache/taverna/robundle/validator/RoValidator.java
 
b/taverna-robundle/src/main/java/org/apache/taverna/robundle/validator/RoValidator.java
index ce340cd..062134a 100644
--- 
a/taverna-robundle/src/main/java/org/apache/taverna/robundle/validator/RoValidator.java
+++ 
b/taverna-robundle/src/main/java/org/apache/taverna/robundle/validator/RoValidator.java
@@ -37,9 +37,6 @@ import org.apache.taverna.robundle.manifest.Manifest;
 import org.apache.taverna.robundle.manifest.PathAnnotation;
 import org.apache.taverna.robundle.manifest.PathMetadata;
 
-
-
-
 /*
  * Validation Process:
  * The class validates RO bundles for manifest and aggregates.
@@ -52,6 +49,7 @@ import org.apache.taverna.robundle.manifest.PathMetadata;
  * Also in annotations....
  * If the about contain a /-based resource which is not listed or not in the 
container, there will be an error.
  */
+
 public class RoValidator {
        
        private Path p;
@@ -61,6 +59,9 @@ public class RoValidator {
        //Store all the annotations
        private List<PathAnnotation> anno;
        
+       //List of resources in the bundle
+       private ArrayList<String> items = new ArrayList<String>();
+       
        
        //ArrayList for errors :- If aggregate is listed in manifest but not in 
bundle
        private ArrayList<String> errorList = new ArrayList<>();
@@ -79,14 +80,13 @@ public class RoValidator {
        
        public void validate(){
                Bundle bundle;
-               ArrayList<String> items = new ArrayList<String>();
+               
                try {
                        bundle = Bundles.openBundle(this.p);
                        Manifest manifest = bundle.getManifest();
                        this.aggr = manifest.getAggregates();
                        this.anno = manifest.getAnnotations();
                        
-                       
                        ZipFile zip = new ZipFile(new File(this.p.toString()));
                        Enumeration<? extends ZipEntry> ent = zip.entries();
                        while(ent.hasMoreElements()){
@@ -100,20 +100,17 @@ public class RoValidator {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
-               
-               check(items);
-               
-               
+                               
        }
        
-       public ValidationReport check(ArrayList<String> list){
+       public ValidationReport check(){
                
                ValidationReport report = new ValidationReport();
                
                for(PathMetadata pm : this.aggr){
-                       
+//                     System.out.println("Path metedata " + pm);
                        //If aggregates listed in manifest are not found in 
bundle...
-                       if(!list.contains(pm.toString())){
+                       if(!this.items.contains(pm.toString())){
                                
                                /*
                                 * Here it can be a external url or the file is 
missing
@@ -132,15 +129,16 @@ public class RoValidator {
                 * There are default files: mimetype and LICENSE
                 * */
                
-               for(String s : list){
+               for(String s : this.items){
                        
-                       s = s.toLowerCase();
+//                     s = s.toLowerCase();
                        PathMetadata p = new PathMetadata(s);
-                       if(s.contains("mimetype")||s.contains("license")){
+//                     System.out.println(p);
+                       
if(s.contains("mimetype")||s.toLowerCase().contains("license")){
                                //This is ok and skip
                        }else{
                                if(!this.aggr.contains(p)){
-                                       this.infoWarningList.add(s);
+                                       this.infoWarningList.add(p.toString());
                                }
                        }
                }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/57dd0eee/taverna-robundle/src/main/java/org/apache/taverna/robundle/validator/ValidationReport.java
----------------------------------------------------------------------
diff --git 
a/taverna-robundle/src/main/java/org/apache/taverna/robundle/validator/ValidationReport.java
 
b/taverna-robundle/src/main/java/org/apache/taverna/robundle/validator/ValidationReport.java
index a8b03ac..03f2b59 100644
--- 
a/taverna-robundle/src/main/java/org/apache/taverna/robundle/validator/ValidationReport.java
+++ 
b/taverna-robundle/src/main/java/org/apache/taverna/robundle/validator/ValidationReport.java
@@ -51,57 +51,63 @@ public class ValidationReport {
        public ValidationReport(){
                
        }
+       
+       public void setWarnings(ArrayList<String> warnings) {
+               this.warnings = warnings;
+       }
+       
+       public void setInfoWarnings(ArrayList<String> infoWarnings) {
+               this.infoWarnings = infoWarnings;
+       }
+       
+       public void setErrorList(ArrayList<String> errorList) {
+               this.errorList = errorList;
+       }
 
+       
        public String getErrorList() {
                String errors = "";
                if(this.errorList.size()!=0){
                        for(String e : this.errorList){
-                               errors += e + "\n";
+                               errors += "Aggregate not found error: " + e + 
"\n";
                        }
                }else{
-                       return "The ro bundle has no errors";
+                       return "The bundle has no errors";
                }
                
                return "Aggregate not found errors: " +"\n"+ errors;
        }
 
-       public void setErrorList(ArrayList<String> errorList) {
-               this.errorList = errorList;
-       }
+       
 
        public String getInfoWarnings() {
                String warning = "";
                if(this.warnings.size()!=0){
                        for(String w : this.warnings){
-                               warning += w + "\n";
+                               warning += "Warning: " +w + " is an external 
URL \n";
                        }
                }else{
                        return "The bundle has no warnings";
                }
-               return "Warnings" + "\n" + warning;
+               return warning;
        }
 
-       public void setInfoWarnings(ArrayList<String> infoWarnings) {
-               this.infoWarnings = infoWarnings;
-       }
+       
 
        public String getWarnings() {
                String infoWarning = "";
                
                if(this.infoWarnings.size()!=0){
                        for(String iw : this.infoWarnings){
-                               infoWarning += iw + "\n";
+                               infoWarning += "Warning (info) "+iw + "\n";
                        }
                }else{
                        return "The Bundle has no Info level warnings";
                }
-               return "Info-Level warnings: " +"\n"+infoWarning;
+               return infoWarning;
                
        }
 
-       public void setWarnings(ArrayList<String> warnings) {
-               this.warnings = warnings;
-       }
        
 
 }

Reply via email to