Project

General

Profile

« Previous | Next » 

Revision 5298

Added by Matt Jones about 14 years ago

Modified readFromMetacat() to pass most exceptions up the call stack, which
allows creation of new entry points for calling reads. Still need to
continue factoring out the HTTPServletResponse that is passed in in order to
make entrypoints that are not servlet based possible. Problem now is in
setting the content type properly on the servlet response before writing to
the output stream.

Added new dataone interface implementation for the CRUD service, but it is incomplete -- most interfaces thrown NotImplemented for now . The get() method should work but is not tested.

View differences:

DocumentImpl.java
1357 1357
        
1358 1358
		String xmlFileContents = "";
1359 1359
		
1360
		try {			
1361
			xmlFileContents = FileUtil.readFileToString(documentPath);
1360
		try {
1361
            xmlFileContents = FileUtil.readFileToString(documentPath);
1362
       
1362 1363
            
1363 1364
			// get a list of inline data sections that are not readable
1364 1365
			// by this user
......
1395 1396
			pw.write(xmlFileContents);
1396 1397
			pw.close();	
1397 1398
			
1398
            
1399
        } catch (Exception e) {
1400
            throw new McdbException("Error reading document " + documentPath 
1401
            		+ " from disk: " + e.getMessage());
1399
	     } catch (UtilException e) {
1400
             throw new McdbException(e.getMessage());
1401
         } catch (IOException e) {
1402
             throw new McdbException(e.getMessage());
1402 1403
        }
1403
        
1404 1404
    }
1405 1405
    
1406 1406
    /**
......
1465 1465
	 *            the unique key for this inline element
1466 1466
	 */
1467 1467
    private String stripInline20XData(String xmlFileContents, String inLineId)
1468
			throws Exception {
1468
			throws McdbException {
1469 1469
		String changedString = xmlFileContents;
1470 1470
		
1471 1471
    	Pattern distStartPattern = Pattern.compile("<distribution", Pattern.CASE_INSENSITIVE); 
......
1483 1483
    		// find the index of the corresponding end element
1484 1484
    		int distStart = distStartMatcher.end();
1485 1485
        	if (!distEndMatcher.find(distStart)) {
1486
        		throw new Exception("Could not find end tag for distribution");
1486
        		throw new McdbException("Could not find end tag for distribution");
1487 1487
        	}
1488 1488
        	int distEnd = distEndMatcher.start();
1489 1489
        	
......
1516 1516
	 * @param inLineKey
1517 1517
	 *            the unique key for this inline element
1518 1518
	 */
1519
    private String stripInline21XData(String xmlFileContents, String inLineId) throws Exception {
1519
    private String stripInline21XData(String xmlFileContents, String inLineId) throws McdbException {
1520 1520
    	int distributionIndex = Integer.valueOf(inLineId);
1521 1521
    	String changedString = xmlFileContents;
1522 1522
    	Pattern distStartPattern = Pattern.compile("<distribution", Pattern.CASE_INSENSITIVE); 
......
1529 1529
    	// to set the start range we will search for the inline element.
1530 1530
    	for (int i = 0; i < distributionIndex; i++) {
1531 1531
    		if (!matcher.find()) {
1532
    			throw new Exception("Could not find distribution number " + (i + 1));
1532
    			throw new McdbException("Could not find distribution number " + (i + 1));
1533 1533
    		}
1534 1534
    	}	
1535 1535
    	int distStart = matcher.end();
......
1538 1538
    	// the end range we will search for the inline element
1539 1539
    	matcher.usePattern(distEndPattern);
1540 1540
    	if (!matcher.find(distStart)) {
1541
    		throw new Exception("Could not find end tag for distribution");
1541
    		throw new McdbException("Could not find end tag for distribution");
1542 1542
    	}
1543 1543
    	int distEnd = matcher.start();
1544 1544
    	

Also available in: Unified diff