Revision 1059
Added by Jing Tao over 22 years ago
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
86 | 86 |
private String userupdated = null; |
87 | 87 |
private int rev; |
88 | 88 |
private int serverlocation; |
89 |
private String docHomeServer; |
|
89 | 90 |
private String publicaccess; |
90 | 91 |
private long rootnodeid; |
91 | 92 |
private ElementNode rootNode = null; |
... | ... | |
675 | 676 |
return serverlocation; |
676 | 677 |
} |
677 | 678 |
|
678 |
public String getHomeServer(String docId) |
|
679 |
{ |
|
680 |
String homeServer=null; |
|
681 |
Connection conn = null; |
|
682 |
MetaCatUtil ut=new MetaCatUtil(); |
|
683 |
docId=ut.getDocIdFromString(docId); |
|
684 |
ut.debugMessage("docId: "+docId, 50); |
|
685 |
PreparedStatement pstmt=null; |
|
686 |
//PreparedStatement getServerStatement=null; |
|
687 |
int serverLocation; |
|
688 |
try |
|
689 |
{ |
|
690 |
conn=ut.getConnection(); |
|
691 |
//get a server location from xml_document table |
|
692 |
pstmt = conn.prepareStatement("select server_location from " |
|
693 |
+"xml_documents where docid = ?"); |
|
694 |
pstmt.setString(1, docId); |
|
695 |
pstmt.execute(); |
|
696 |
ResultSet serverName = pstmt.getResultSet(); |
|
697 |
//get a server location |
|
698 |
if(serverName.next()) |
|
699 |
{ |
|
700 |
serverLocation=serverName.getInt(1); |
|
701 |
ut.debugMessage("serverLocation: "+serverLocation, 50); |
|
702 |
pstmt.close(); |
|
703 |
} |
|
704 |
else |
|
705 |
{ |
|
706 |
pstmt.close(); |
|
707 |
ut.returnConnection(conn); |
|
708 |
return homeServer; |
|
709 |
} |
|
710 |
pstmt = conn.prepareStatement("select server " + |
|
711 |
"from xml_replication where serverid = ?"); |
|
712 |
|
|
713 |
|
|
714 |
pstmt.setInt(1, serverLocation); |
|
715 |
pstmt.execute(); |
|
716 |
ResultSet rs = pstmt.getResultSet(); |
|
717 |
boolean tableHasRows = rs.next(); |
|
718 |
if (tableHasRows) |
|
719 |
{ |
|
720 |
|
|
721 |
String server = rs.getString(1); |
|
722 |
//get homeserver name |
|
723 |
if(!server.equals("localhost")) |
|
724 |
{ |
|
725 |
homeServer=server; |
|
726 |
} |
|
727 |
else |
|
728 |
{ |
|
729 |
homeServer=ut.getLocalReplicationServerName(); |
|
730 |
} |
|
731 |
ut.debugMessage("server: "+homeServer, 50); |
|
732 |
|
|
733 |
} |
|
734 |
else |
|
735 |
{ |
|
736 |
pstmt.close(); |
|
737 |
ut.returnConnection(conn); |
|
738 |
return homeServer; |
|
739 |
} |
|
740 |
pstmt.close(); |
|
741 |
} |
|
742 |
catch(Exception e) |
|
743 |
{ |
|
744 |
System.out.println("error in DocumentIpml.getHomerserver(): " + |
|
745 |
e.getMessage()); |
|
746 |
} |
|
747 |
finally |
|
748 |
{ |
|
749 |
try |
|
750 |
{ |
|
751 |
pstmt.close(); |
|
752 |
ut.returnConnection(conn); |
|
753 |
} |
|
754 |
catch (Exception ee) |
|
755 |
{ |
|
756 |
} |
|
757 |
|
|
758 |
} |
|
759 |
|
|
760 |
return homeServer; |
|
679 |
public String getDocHomeServer() { |
|
680 |
return docHomeServer; |
|
761 | 681 |
} |
682 |
|
|
762 | 683 |
|
684 |
|
|
763 | 685 |
public String getPublicaccess() { |
764 | 686 |
return publicaccess; |
765 | 687 |
} |
... | ... | |
1039 | 961 |
{ |
1040 | 962 |
PreparedStatement pstmt; |
1041 | 963 |
String table = "xml_documents"; |
1042 |
|
|
964 |
|
|
1043 | 965 |
try |
1044 | 966 |
{ |
1045 | 967 |
if(isRevisionOnly(docid)) |
... | ... | |
1095 | 1017 |
this.rev = rs.getInt(10); |
1096 | 1018 |
} |
1097 | 1019 |
pstmt.close(); |
1020 |
|
|
1021 |
//get doc home server name |
|
1022 |
|
|
1023 |
pstmt = conn.prepareStatement("select server " + |
|
1024 |
"from xml_replication where serverid = ?"); |
|
1025 |
|
|
1026 |
|
|
1027 |
pstmt.setInt(1, serverlocation); |
|
1028 |
pstmt.execute(); |
|
1029 |
rs = pstmt.getResultSet(); |
|
1030 |
tableHasRows = rs.next(); |
|
1031 |
if (tableHasRows) |
|
1032 |
{ |
|
1033 |
|
|
1034 |
String server = rs.getString(1); |
|
1035 |
//get homeserver name |
|
1036 |
if(!server.equals("localhost")) |
|
1037 |
{ |
|
1038 |
this.docHomeServer=server; |
|
1039 |
} |
|
1040 |
else |
|
1041 |
{ |
|
1042 |
this.docHomeServer=MetaCatUtil.getLocalReplicationServerName(); |
|
1043 |
} |
|
1044 |
MetaCatUtil.debugMessage("server: "+docHomeServer, 50); |
|
1045 |
|
|
1046 |
} |
|
1047 |
pstmt.close(); |
|
1098 | 1048 |
if (this.doctype != null) { |
1099 | 1049 |
pstmt = |
1100 | 1050 |
conn.prepareStatement("SELECT system_id " + |
Also available in: Unified diff
Add the feature to get doc home server into method getDocumentInfo.
Add a method to return docHomeServer.