Project

General

Profile

« Previous | Next » 

Revision 5440

Added by berkley over 14 years ago

fixed major bug in replication where the document info was being truncated due to a poorly implemented sax parser

View differences:

src/edu/ucsb/nceas/metacat/DocInfoHandler.java
56 56
  
57 57
	private Vector<XMLAccessDAO> xmlAccessDAOList = new Vector<XMLAccessDAO>();
58 58
	private Stack<XMLAccessDAO> xmlAccessDAOStack = new Stack<XMLAccessDAO>();
59
	
60
	private String chars = "";
59 61
  
60 62
	public DocInfoHandler() {
61 63
	}
......
69 71
	 */
70 72
	public void startElement(String uri, String localName, String qName,
71 73
			Attributes attributes) throws SAXException {
74
	    chars = "";
72 75
		_currentTag = localName;
73 76
		if (_currentTag.equals("access")) {
74 77
			if (_accessPermOrder == null) {
......
97 100

  
98 101
	public void endElement(String uri, String localName, String qName)
99 102
			throws SAXException {
103
			    
104
	    _docinfo.put(_currentTag, chars);
105
    	
106
        if (_currentTag.equals(AccessControlInterface.PRINCIPAL) && _inPrincipal) {
107
            if (_currentAccessDAO != null) {
108
                _currentAccessDAO.setPrincipalName(chars);
109
            }
110
        } else if (_currentTag.equals(AccessControlInterface.PERMISSION) && _inPermission) {
111
            if (_currentAccessDAO != null) {
112
                String permString = chars;
113
                Long permLong = Long.valueOf(AccessControlList.intValue(permString));
114
                //add this permission for each DAO in the stack
115
                for (int i = 0; i < xmlAccessDAOStack.size(); i++) {
116
                    xmlAccessDAOStack.get(i).addPermission(permLong);
117
                }
118
            }
119
        }
100 120
		
101 121
		if (localName.equals(AccessControlInterface.ALLOW)) {
102 122
			_inAllow = false;
......
126 146
	 */
127 147
  public void characters(char[] ch, int start, int length) throws SAXException
128 148
  {
129
    _docinfo.put(_currentTag, new String(ch, start, length));
130
    	
131
    if (_currentTag.equals(AccessControlInterface.PRINCIPAL) && _inPrincipal) {
132
		if (_currentAccessDAO != null) {
133
			_currentAccessDAO.setPrincipalName(new String(ch, start, length));
134
		}
135
	} else if (_currentTag.equals(AccessControlInterface.PERMISSION) && _inPermission) {
136
		if (_currentAccessDAO != null) {
137
			String permString = new String(ch, start, length);
138
			Long permLong = Long.valueOf(AccessControlList.intValue(permString));
139
			//add this permission for each DAO in the stack
140
			for (int i = 0; i < xmlAccessDAOStack.size(); i++) {
141
				xmlAccessDAOStack.get(i).addPermission(permLong);
142
			}
143
		}
144
	}
149
    chars += new String(ch, start, length);
145 150
  }
146 151
  
147 152
  public Hashtable<String,String> getDocInfo()
src/edu/ucsb/nceas/metacat/replication/ReplicationHandler.java
411 411
      //process guid
412 412
      logReplication.debug("Processing guid information from docinfoHash: " + docinfoHash.toString());
413 413
      String guid = docinfoHash.get("guid");
414
      System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%guid passed from docinfo hash: " + guid);
414 415
      IdentifierManager idman = IdentifierManager.getInstance();
415 416
      if(guid != null && !idman.identifierExists(guid))
416 417
      { //if the guid was passed in, put it in the identifiers table
src/edu/ucsb/nceas/metacat/replication/ReplicationService.java
500 500
				//serverCode = MetacatReplication.getServerCode(server);
501 501
				//override = true; //we are now overriding the default action
502 502
			}
503
			logReplication.info("ReplicationService.handleForceReplicateRequest - force replication request from " + server);
504 503
			logReplication.info("ReplicationService.handleForceReplicateRequest - Force replication request from: " + server);
505 504
			logReplication.info("ReplicationService.handleForceReplicateRequest - Force replication docid: " + docid);
506 505
			logReplication.info("ReplicationService.handleForceReplicateRequest - Force replication action: " + dbaction);
......
514 513
			URL docinfourl = new URL("https://" + server + "?server="
515 514
					+ MetacatUtil.getLocalReplicationServerName()
516 515
					+ "&action=getdocumentinfo&docid=" + docid);
516
			
517 517

  
518 518
			String docInfoStr = ReplicationService.getURLContent(docinfourl);
519 519

  
......
529 529
			// Get home server of this docid
530 530
			String homeServer = (String) docinfoHash.get("home_server");
531 531
			String guid = (String) docinfoHash.get("guid");
532
			logReplication.info("XXXXXXXXXXXXXXXX GUID found in dociinfoHash: " + guid);
532 533
			
533 534
			logReplication.debug("Processing guid " + guid + 
534 535
			  " information from handleForceReplicationRequest: " + 
......
536 537
      IdentifierManager idman = IdentifierManager.getInstance();
537 538
      if(guid != null && !idman.identifierExists(guid))
538 539
      { //if the guid was passed in, put it in the identifiers table
539
        logReplication.debug("Creating guid/docid mapping for docid " + 
540
        logReplication.info("XXXXXXXXXXXXXXXXXXX Creating guid/docid mapping for docid " + 
540 541
          docinfoHash.get("docid") + " and guid: " + guid);
541 542
        idman.createMapping(guid, docinfoHash.get("docid"));
542 543
      }
......
1171 1172

  
1172 1173
			//try to open a https stream to test if the request server's public key
1173 1174
			//in the key store, this is security issue
1174
			URL u = new URL("https://" + server + "?server="
1175
					+ MetacatUtil.getLocalReplicationServerName() + "&action=test");
1175
			String testUrl = "https://" + server + "?server="
1176
					+ MetacatUtil.getLocalReplicationServerName() + "&action=test";
1177
			System.out.println("running test: " + testUrl);
1178
			logReplication.info("Running trust test: " + testUrl);
1179
			URL u = new URL(testUrl);
1176 1180
			String test = ReplicationService.getURLContent(u);
1181
			logReplication.info("trust test returned: " + test);
1182
			System.out.println("trust test returned: " + test);
1177 1183
			//couldn't pass the test
1178 1184
			if (test.indexOf("successfully") == -1) {
1179 1185
				response.setContentType("text/xml");
......
1780 1786
	public static String getURLContent(URL u) throws java.io.IOException {
1781 1787
		char istreamChar;
1782 1788
		int istreamInt;
1783
		logReplication.debug("ReplicationService.getURLContent - Before open the stream" + u.toString());
1789
		logReplication.info("ReplicationService.getURLContent - Before open the stream" + u.toString());
1784 1790
		InputStream input = u.openStream();
1785
		logReplication.debug("ReplicationService.getURLContent - After open the stream" + u.toString());
1791
		logReplication.info("ReplicationService.getURLContent - After open the stream" + u.toString());
1786 1792
		InputStreamReader istream = new InputStreamReader(input);
1787 1793
		StringBuffer serverResponse = new StringBuffer();
1788 1794
		while ((istreamInt = istream.read()) != -1) {

Also available in: Unified diff