Das client files
[jalview.git] / src / org / biojava / dasobert / dasregistry / DasSourceValidator.java
1 /*
2  *                  BioJava development code
3  *
4  * This code may be freely distributed and modified under the
5  * terms of the GNU Lesser General Public Licence.  This should
6  * be distributed with the code.  If you do not have a copy,
7  * see:
8  *
9  *      http://www.gnu.org/copyleft/lesser.html
10  *
11  * Copyright for this code is held jointly by the individual
12  * authors.  These should be listed in @author doc comments.
13  *
14  * For more information on the BioJava project and its aims,
15  * or to join the biojava-l mailing list, visit the home page
16  * at:
17  *
18  *      http://www.biojava.org/
19  *
20  * Created on Mar 20, 2006
21  *
22  */
23 package org.biojava.dasobert.dasregistry;
24
25 import org.biojava.dasobert.das2.Das2Source;
26
27 public class DasSourceValidator {
28
29     public DasSourceValidator() {
30         super();
31
32     }
33
34     public void validateDasSource(DasSource ds) throws Exception {
35
36         if ( ds instanceof Das2Source ){
37
38             Das2Source d2s = (Das2Source)ds;
39
40             Das2Validator validator = new Das2Validator();
41             boolean ok = validator.validate(d2s);
42             if ( ! ok)
43                 throw new Exception("coul not validate DasSource");
44
45         } else {
46
47             // a DAS 1 source ...
48
49             String url =ds.getUrl();
50             String[] caps = ds.getCapabilities();
51             //String testCode = ds.getTestCode();
52
53             Das1Validator validator = new Das1Validator();
54
55             String[] okcaps = validator.validate(url,ds.getCoordinateSystem(),caps);
56             String validationMessage = validator.getValidationMessage();
57             if ( okcaps.length != caps.length){
58                 throw new Exception("could not validate DasSource " + validationMessage);
59             }
60
61
62         }
63
64     }
65
66 }