Changeset 18206
- Timestamp:
- 2008-12-16T14:18:45+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/trunk/greenstone3-extension/mat/src/org/greenstone/gsdl3_extension/mat/servlet/MatServlet.java
r18167 r18206 15 15 import org.greenstone.gsdl3.util.GlobalProperties; 16 16 import org.greenstone.gsdl3.util.GSPath; 17 import java.net.Authenticator; 18 import java.net.PasswordAuthentication; 17 19 18 20 public class MatServlet extends HttpServlet { … … 38 40 private String proxyPortContent = ""; 39 41 private String collection_creator = ""; 40 42 private String proxyUserName= ""; 43 private String proxyUserPassword = ""; 41 44 42 45 public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException { … … 114 117 else if (req.getParameter("collName") != null){ 115 118 out.println(headerString); 116 //out.write("<script type=\"text/javascript\" src=\"http://"+hostName+":"+port_number+"/greenstone3/mat/script/getInfomation.js\"></script>\r\n");117 //out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/yahoo/yahoo-min.js\"></script>\r\n");118 //out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/event/event-min.js\"></script>\r\n");119 //out.write("<script type=\"text/javascript\" src=\"http://yui.yahooapis.com/2.4.1/build/connection/connection-min.js\"></script>\r\n");120 119 out.println("<body>"); 121 120 out.println(h1String); … … 192 191 // trim the URL back and then add on verb=Identify 193 192 194 195 //System.setProperty("http.proxyHost", "wwwcache.cs.waikato.ac.nz"); 196 //System.setProperty("http.proxyPort","80"); 197 //System.setProperty("http.nonProxyHosts", "localhost|*.waikato.ac.nz"); 198 193 199 194 Properties systemSettings = System.getProperties(); 200 195 … … 215 210 216 211 URL identifyURL = new URL (url.toString() + identifyVerb); 212 213 if( proxyUserName.equals("") || proxyUserPassword.equals("")){} 214 else{ 215 Authenticator.setDefault( new ProxyAuthenticator(proxyUserName, proxyUserPassword) ); 216 } 217 217 218 HttpURLConnection connection = (HttpURLConnection)identifyURL.openConnection(); 218 //URLConnection connection = identifyURL.openConnection();219 219 connection.connect(); 220 221 //BufferedReader inIdentify = new BufferedReader(new InputStreamReader( 222 //connection.getInputStream())); 220 223 221 224 222 Document identifyDocument; … … 396 394 // maybe check the baseURL against the query we issued? 397 395 398 399 // if we get here we have a valid non-waikato non-local OAI server400 // /* process stuff here */401 // test with University home page - as it doesn't require402 // dealing with the proxy server403 // URL url = new URL("http://waikato.ac.nz");404 // URL url = new URL(oaiURL);405 // need to go through the proxy here406 // http://dn.codegear.com/article/29783407 // http://java.ittoolbox.com/groups/technical-functional/java-l/response-to-proxy-authentication-exception-71438408 // http://www.jguru.com/faq/view.jsp?EID=13186409 // http://www.developer.com/java/other/article.php/1551421410 // System.setProperty("http.proxyHost","http://proxy.scms.waikato.ac.nz");411 // System.setProperty("http.proxyPort","80");412 // System.setProperty("http.nonProxyHosts", "localhost|*.waikato.ac.nz");413 // build a GS 3 collection from the OAI URL414 // http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html415 // http://codon.kribb.re.kr/wiki/display/Java/Using+Runtime.exec+to+invoke+child+process416 417 396 out.print("</body></html>"); 418 397 out.close(); … … 541 520 String cacheDir = gsdl3Root +fileSeparator+"ext"+fileSeparator+"mat"+fileSeparator+"tmp"+fileSeparator + collName; 542 521 543 // downloading 544 //String gs3Root = "/research/cc108/greenstone3Project"; 522 545 523 String gs3Root = gsdl3Root; 546 524 String collectDir = gsdl3Home + fileSeparator +"sites"+fileSeparator+"localsite"+ fileSeparator +"collect"; 547 525 String logFile = gsdl3Root +fileSeparator+"ext"+fileSeparator+"mat"+fileSeparator+"tmp"+fileSeparator + "log.txt"; 548 //source /research/cc108/greenstone3Project/gs2build/bin/script/mat-colbuild-download.bash 549 //source /research/cc108/greenstone3Project/ext/mat/bin/script/mat-colbuild-download.bash 550 526 String proxy_settings = ""; 551 527 String matShell = ""; 552 528 529 530 if(!proxyHostContent.equals("") && !proxyPortContent.equals("")){ 531 proxy_settings = "-proxy_on -proxy_host "+proxyHostContent+" -proxy_port "+proxyPortContent; 532 } 533 534 if(!proxyUserName.equals("") && !proxyUserPassword.equals("")){ 535 proxy_settings = proxy_settings + " -user_name " +proxyUserName+" -user_password "+proxyUserPassword; 536 } 537 538 553 539 if(System.getProperty("os.name").toLowerCase().indexOf("windows")!=-1){ 554 540 … … 568 554 alist.add(logFile); 569 555 alist.add(collection_creator); 570 556 alist.add(proxy_settings); 571 557 String[] arrays = new String[alist.size()]; 572 558 for(int i = 0; i< arrays.length; i++){ … … 600 586 + logFile 601 587 + " " 602 + collection_creator; 588 + collection_creator 589 + " " 590 + proxy_settings; 603 591 604 592 out.println("<p><pre>" + matShell + "</pre></p>"); … … 613 601 } 614 602 out.flush(); 615 //p = null;616 603 p.destroy(); 617 604 … … 880 867 proxyPortContent = prop.getProperty("Servlet.proxyPort"); 881 868 869 proxyUserName = prop.getProperty("Servlet.proxyUserName"); 870 proxyUserPassword = prop.getProperty("Servlet.proxyUserPassword"); 871 882 872 collection_creator = prop.getProperty("Servlet.Collection.Creator"); 883 873 … … 896 886 } 897 887 } 888 889 class ProxyAuthenticator extends Authenticator 890 { 891 892 private String username; 893 private char[] password; 894 895 896 public ProxyAuthenticator (String username, String password){ 897 this.username = username; 898 this.password = password.toCharArray(); 899 } 900 901 902 protected PasswordAuthentication getPasswordAuthentication(){ 903 return new PasswordAuthentication (username, password ); 904 } 905 }
Note:
See TracChangeset
for help on using the changeset viewer.