Project

General

Profile

« Previous | Next » 

Revision 9953

Added by Jing Tao over 7 years ago

Add the code to throw an exception to tell users that the namespace or format id was not registered in Metacat.

View differences:

src/edu/ucsb/nceas/metacat/service/XMLSchemaService.java
48 48

  
49 49
import edu.ucsb.nceas.metacat.DocumentImpl;
50 50
import edu.ucsb.nceas.metacat.MetaCatServlet;
51
import edu.ucsb.nceas.metacat.client.MetacatException;
51 52
import edu.ucsb.nceas.metacat.database.DBConnection;
52 53
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
53 54
import edu.ucsb.nceas.metacat.properties.PropertyService;
......
526 527
	 * @param namespace  the given namespace
527 528
	 * @return the string of the namespace-schemaLocation pairs (separated by white spaces). The null will be returned, if we can't find one.
528 529
	 */
529
	public String findNamespaceAndSchemaLocalLocation(String formatId, String namespace) {
530
	public String findNamespaceAndSchemaLocalLocation(String formatId, String namespace) throws MetacatException{
530 531
	    String location = null;
531 532
	    location = getNameSpaceAndLocation(formatId);
532 533
	    logMetacat.debug("XMLSchemaService.findNamespaceAndSchemaLocation - the location based the format id "+formatId+" is "+location);
......
540 541
                logMetacat.debug("XMLSchemaService.findNamespaceAndSchemaLocation - the given namespace "+namespace+" is NOT registered in Metacat");
541 542
            }
542 543
	    }
544
	    if(location == null) {
545
	        logMetacat.error("XMLSchemaService.findNamespaceAndSchemaLocation - We can't find the schema location for the namespace "+namespace+" and format id "+formatId+". This means they are not registered in Metacat.");
546
	        throw new MetacatException("The namespace "+namespace+" and the format id "+formatId+
547
	                " are not registered in the Metacat. So the object using the namespace was rejected since Metacat can't validate the xml instance. Please contact the Metacat operator to register them.");
548
	    }
543 549
	    logMetacat.debug("XMLSchemaService.findNamespaceAndSchemaLocation - The final location string for the namespace "+namespace+" and format id "+formatId+" is "+location);
544 550
	    return location;
545 551
	}
......
553 559
	 * @param noNamespaceSchemaLocation
554 560
	 * @return
555 561
	 */
556
	public String findNoNamespaceSchemaLocalLocation(String formatId, String noNamespaceSchemaLocation) {
562
	public String findNoNamespaceSchemaLocalLocation(String formatId, String noNamespaceSchemaLocation) throws MetacatException {
557 563
	    String location = null;
558 564
        logMetacat.debug("XMLSchemaService.findNoNamespaceSchemaLocalLocation - the given format id for determining the schema local location is "+formatId);
559 565
        logMetacat.debug("XMLSchemaService.findNoNamespaceSchemaLocalLocation - the given noNamespaceSchemaLocationURI for determining the schema local location is "+noNamespaceSchemaLocation);
......
600 606
	    } else {
601 607
	        logMetacat.warn("XMLSchemaService.findNoNamespaceSchemaLocalLocation - there is no registered no-namespace schema in the Metacat");
602 608
	    }
603
	    logMetacat.warn("XMLSchemaService.findNoNamespaceSchemaLocalLocation - the schema location is "+location+" (if it is null, this means it is not registered) for the format id "+formatId+
609
	    
610
	    if(location == null) {
611
            logMetacat.error("XMLSchemaService.findNoNamespaceSchemaLocalLocation - We can't find Metacat local schema location for the noNamespaceLocation "+noNamespaceSchemaLocation+
612
                    " and format id "+formatId+". This means they are not registered in Metacat.");
613
            throw new MetacatException("The noNamespaceSchemaLocation "+noNamespaceSchemaLocation+" or the format id "+formatId+
614
                    " is not registered in the Metacat. So the object using them was rejected since Metacat can't validate the xml instance. Please contact the Metacat operator to register them.");
615
        }
616
	    logMetacat.debug("XMLSchemaService.findNoNamespaceSchemaLocalLocation - the schema location is "+location+" (if it is null, this means it is not registered) for the format id "+formatId+
604 617
	            " or noNamespaceSchemaLocation URI "+noNamespaceSchemaLocation);
605 618
	    return location;
606 619
	}

Also available in: Unified diff