Project

General

Profile

Revision 5941

Added by Jing Tao about 10 years ago

Add a static method to get base url base on a schema url.

View differences:

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

  
582 582
		return filename;
583 583
	}
584
    
585
    /**
586
     * Get a base url from the schema url. If url=http://www.example.com/example.xsd,
587
     * http://www.example.com/ will be returned.
588
     * 
589
     * @param uri
590
     *            the uri from which to extract the base url
591
     * @return a string holding the base url. null will be return if it is not url.
592
     */
593
      public static String getBaseUrlFromSchemaURL(String url) 
594
      {
595
        String baseURL = null;        
596
        if (url != null && (url.indexOf("http://") != -1 || url.indexOf("https://") !=-1)) 
597
        {
598
          int slash = url.lastIndexOf('/');
599
          if (slash > -1) 
600
          {
601
            baseURL = url.substring(0,slash+1);
602
          }
603
        } 
604
        return baseURL;
605
      }
584 606
}

Also available in: Unified diff