Changeset 3735 in main
- Timestamp:
- 04/21/12 00:31:47 (10 years ago)
- Location:
- trunk/src/main
- Files:
-
- 3 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/main/java/org/ibisph/systemid/ClassPathSystemID.java
r3710 r3735 14 14 * @throws java.io.FileNotFoundException 15 15 */ 16 public ClassPathSystemID(String urlOrPathAndFilename) throws java.net.MalformedURLException, java.io.IOException {16 public ClassPathSystemID(String urlOrPathAndFilename) { 17 17 java.net.URL url = Thread.currentThread().getContextClassLoader().getResource(urlOrPathAndFilename); 18 18 if(null != url) this.systemID = url.toExternalForm(); -
trunk/src/main/java/org/ibisph/systemid/ResourceSystemID.java
r3710 r3735 19 19 * @throws java.io.FileNotFoundException 20 20 */ 21 public ResourceSystemID(String pathAndFilename) throws Exception{21 public ResourceSystemID(String pathAndFilename) { 22 22 23 23 // another way is to use the servlet context like: … … 28 28 } //----------------------- End of Constructor ---------------------------- 29 29 30 public ResourceSystemID(String contextPath, String subPathAndFilename) throws Exception{30 public ResourceSystemID(String contextPath, String subPathAndFilename) { 31 31 this(org.ibisph.util.IOPath.concat(contextPath, subPathAndFilename)); 32 32 } //----------------------- End of Constructor ---------------------------- -
trunk/src/main/java/org/ibisph/systemid/modelmap/SystemIDFromHTTPRequestParameter.java
r3710 r3735 8 8 import org.ibisph.systemid.VerifiedURLSystemID; 9 9 import org.ibisph.util.IOPath; 10 import org.ibisph.util.StrLib; 10 11 11 12 /** … … 34 35 SystemID xmlSystemID = null; 35 36 String xmlName = request.getParameter("xmlURL"); 36 if( xmlName != null) {37 if(StrLib.isSomething(xmlName)) { 37 38 xmlSystemID = new VerifiedURLSystemID(xmlName); 38 39 } … … 40 41 else { 41 42 xmlName = request.getParameter("xmlFile"); 42 if( xmlName == null) xmlName = request.getParameter("xml");43 if(!StrLib.isSomething(xmlName)) xmlName = request.getParameter("xml"); 43 44 try { 44 45 xmlSystemID = new VerifiedFileSystemID(xmlName); -
trunk/src/main/java/org/ibisph/xml/service/FileStoredDocument.java
r3734 r3735 13 13 import org.ibisph.util.FileLib; 14 14 import org.ibisph.util.IOPath; 15 import org.ibisph.util.StrLib; 15 16 16 17 /** … … 48 49 } //-------------------------- End of Method ------------------------------ 49 50 public org.dom4j.Document get(String xmlPathAndFilename) throws DocumentException { 50 return( get(new File(xmlPathAndFilename)) ); 51 String s = getVerifiedPathAndFilename(xmlPathAndFilename); 52 File file = new File(s); 53 return(get(file)); 51 54 } //-------------------------- End of Method ------------------------------ 52 55 … … 64 67 public boolean load(File xmlFile, org.dom4j.Document document) throws DocumentException { 65 68 SAXReader xmlReader = new SAXReader(); 66 if(( xmlFile != null) && xmlFile.exists()) {69 if((null != xmlFile) && xmlFile.exists()) { 67 70 document.setDocument( xmlReader.read(xmlFile) ); 68 71 return(true); … … 122 125 String xmlPathAndFilename 123 126 ) throws IOException, UnsupportedEncodingException { 124 save(document, xmlPathAndFilename, outputFormat); 127 save( 128 document, 129 getVerifiedPathAndFilename(xmlPathAndFilename), 130 this.outputFormat 131 ); 125 132 } //-------------------------- End of Method ------------------------------ 126 133 … … 143 150 144 151 145 public boolean delete(String documentPathAndName) {146 return(FileLib.delete( documentPathAndName));152 public boolean delete(String xmlPathAndFilename) { 153 return(FileLib.delete(xmlPathAndFilename)); 147 154 } //-------------------------- End of Method ------------------------------ 148 155 149 156 150 public boolean exists(String documentPathAndName) { 151 File file = new File(documentPathAndName); 152 boolean exists = file.exists(); 153 return(exists); 157 public boolean exists(String xmlPathAndFilename) { 158 return(StrLib.isSomething(getVerifiedPathAndFilename(xmlPathAndFilename))); 154 159 } //-------------------------- End of Method ------------------------------ 155 160 161 162 /** 163 * Helper that localizes getting/searching the path and resource path for 164 * the given file. First checks path passed in. If file exists then that 165 * is verified so return. Else check the classloader's path. Else check 166 * the thread's class path. In the case of the two latter checks a URL/ 167 * system id type string is returned 168 * @param pathAndFilename path and filename to be verified. 169 * @return verified path and filename. If supplied value does not exist 170 * then the classpath is checked. 171 * @throws Exception 172 */ 173 protected String getVerifiedPathAndFilename(String pathAndFilename) { 174 File file = new File(pathAndFilename); 175 if(file.exists()) return(pathAndFilename); 176 177 java.net.URL url = Thread.currentThread().getContextClassLoader().getResource(pathAndFilename); 178 if(null != url) return(url.toExternalForm()); 179 180 url = this.getClass().getClassLoader().getResource(pathAndFilename); 181 if(null != url) return(url.toExternalForm()); 182 183 return(null); 184 } //-------------------------- End of Method ------------------------------ 185 156 186 } //============================ END OF CLASS ================================= 157 187
Note: See TracChangeset
for help on using the changeset viewer.