Revision 1097
Added by Jing Tao over 22 years ago
src/edu/ucsb/nceas/metacat/MetacatReplication.java | ||
---|---|---|
219 | 219 |
|
220 | 220 |
} else if ( action.equals("servercontrol") ) { |
221 | 221 |
handleServerControlRequest(out, params, response); |
222 |
} else if ( action.equals("test") ) { |
|
223 |
response.setContentType("text/html"); |
|
224 |
out.println("<html><body>Test successfully</body></html>"); |
|
222 | 225 |
} |
223 | 226 |
|
224 | 227 |
out.close(); |
... | ... | |
681 | 684 |
//check if the doicd is null |
682 | 685 |
if (docId==null) |
683 | 686 |
{ |
684 |
util.debugMessage("Didn't specify docid for replication"); |
|
687 |
util.debugMessage("Didn't specify docid for replication", 20);
|
|
685 | 688 |
return; |
686 | 689 |
} |
690 |
|
|
691 |
//try to open a https stream to test if the request server's public key |
|
692 |
//in the key store, this is security issue |
|
693 |
try |
|
694 |
{ |
|
695 |
String server = ((String[])params.get("server"))[0]; |
|
696 |
URL u = new URL("https://" + server + "?server=" |
|
697 |
+util.getLocalReplicationServerName() |
|
698 |
+"&action=test"); |
|
699 |
String test = MetacatReplication.getURLContent(u); |
|
700 |
//couldn't pass the test |
|
701 |
if (test.indexOf("successfully")==-1) |
|
702 |
{ |
|
703 |
//response.setContentType("text/xml"); |
|
704 |
//outPut.println("<error>Couldn't pass the trust test</error>"); |
|
705 |
MetaCatUtil.debugMessage("Couldn't pass the trust pass", 20); |
|
706 |
return; |
|
707 |
} |
|
708 |
}//try |
|
709 |
catch (Exception ee) |
|
710 |
{ |
|
711 |
return; |
|
712 |
}//catch |
|
687 | 713 |
|
688 | 714 |
if(!filepath.endsWith("/")) |
689 | 715 |
{ |
... | ... | |
769 | 795 |
Connection conn = null; |
770 | 796 |
try |
771 | 797 |
{ |
798 |
//try to open a https stream to test if the request server's public key |
|
799 |
//in the key store, this is security issue |
|
800 |
String server = ((String[])params.get("server"))[0]; |
|
801 |
URL u = new URL("https://" + server + "?server=" |
|
802 |
+util.getLocalReplicationServerName() |
|
803 |
+"&action=test"); |
|
804 |
String test = MetacatReplication.getURLContent(u); |
|
805 |
//couldn't pass the test |
|
806 |
if (test.indexOf("successfully")==-1) |
|
807 |
{ |
|
808 |
response.setContentType("text/xml"); |
|
809 |
out.println("<error>Couldn't pass the trust test</error>"); |
|
810 |
return; |
|
811 |
} |
|
812 |
|
|
772 | 813 |
String docid = ((String[])(params.get("docid")))[0]; |
773 | 814 |
conn = MetacatReplication.getDBConnection("MetacatReplication." + |
774 | 815 |
"handleGetDocumentRequest"); |
... | ... | |
1059 | 1100 |
try |
1060 | 1101 |
{ |
1061 | 1102 |
MetaCatUtil.debugMessage("thread started for docid: " + |
1062 |
(String)fileLocks.elementAt(0)); |
|
1063 |
System.out.println("thread started for docid: " + |
|
1064 |
(String)fileLocks.elementAt(0)); |
|
1103 |
(String)fileLocks.elementAt(0), 45); |
|
1104 |
|
|
1065 | 1105 |
Thread.sleep(30000); //the lock will expire in 30 seconds |
1066 | 1106 |
MetaCatUtil.debugMessage("thread for docid: " + |
1067 | 1107 |
(String)fileLocks.elementAt(fileLocks.size() - 1) + |
1068 | 1108 |
" exiting."); |
1069 |
System.out.println("thread for docid: " + |
|
1070 |
(String)fileLocks.elementAt(fileLocks.size() - 1) + |
|
1071 |
" exiting."); |
|
1109 |
|
|
1072 | 1110 |
fileLocks.remove(fileLocks.size() - 1); |
1073 | 1111 |
//fileLocks is treated as a FIFO queue. If there are more than one lock |
1074 | 1112 |
//in the vector, the first one inserted will be removed. |
1075 | 1113 |
} |
1076 | 1114 |
catch(Exception e) |
1077 | 1115 |
{ |
1078 |
System.out.println("error in file lock thread from MetacatReplication." +
|
|
1079 |
"run: " + e.getMessage());
|
|
1116 |
MetaCatUtil.debugMessage("error in file lock thread from " +
|
|
1117 |
"MetacatReplication.run: " + e.getMessage());
|
|
1080 | 1118 |
} |
1081 | 1119 |
} |
1082 | 1120 |
|
Also available in: Unified diff
Add a test action in replication. Before handle read and read data file action. Metacat will take a test to see if the trust key in key store. If not, wouldn't replicate documents.This is security issue.