Project

General

Profile

« Previous | Next » 

Revision 4451

Added by daigle over 15 years ago

Get the file name from the system_id, handling cases where the id starts with http

View differences:

src/edu/ucsb/nceas/metacat/service/XMLSchema.java
76 76
	 *            the file name to set
77 77
	 */
78 78
	public void setFileName(String fileName) {
79
		// there are a few different cases for the file name:
80
		// -- it starts with /schema/.  if so, use everything after /schema/ as 
81
		//    the file name.
82
		// -- it starts with http and has /schema/ in the path.  again, use 
83
		//    everything after /schema/
84
		// -- it starts with http but doesnt have /schema/ in the path.  use 
85
		//    everything after the last / as the file name
86
		// -- otherwise leave the file name as is.
79 87
		if (fileName.startsWith(XMLSchemaService.SCHEMA_DIR)) {
80 88
			fileName = fileName.substring(XMLSchemaService.SCHEMA_DIR.length());
89
		} else if (fileName.startsWith("http") && fileName.contains(XMLSchemaService.SCHEMA_DIR)) {
90
			int index = fileName.lastIndexOf(XMLSchemaService.SCHEMA_DIR) + XMLSchemaService.SCHEMA_DIR.length();
91
			fileName = fileName.substring(index);
92
		} else if (fileName.startsWith("http")) {
93
			fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
81 94
		}
95
			
82 96
		this.fileName = fileName;
83 97
		try {
84 98
			this.localFileUri = SystemUtil.getContextURL() + XMLSchemaService.SCHEMA_DIR

Also available in: Unified diff