1 25 package org.ofbiz.base.location; 26 27 import java.net.MalformedURLException ; 28 import java.net.URL ; 29 30 import org.ofbiz.base.util.UtilURL; 31 32 39 40 public class OFBizHomeLocationResolver implements LocationResolver { 41 42 public static final String envName = "ofbiz.home"; 43 44 public URL resolveLocation(String location) throws MalformedURLException { 45 String propValue = System.getProperty(envName); 46 if (propValue == null) { 47 String errMsg = "The Java environment (-Dxxx=yyy) variable with name " + envName + " is not set, cannot resolve location."; 48 throw new MalformedURLException (errMsg); 49 } 50 51 StringBuffer baseLocation = new StringBuffer (FlexibleLocation.stripLocationType(location)); 52 53 if (baseLocation.charAt(0) != '/' && propValue.charAt(propValue.length() - 1) != '/') { 55 baseLocation.insert(0, '/'); 56 } 57 58 baseLocation.insert(0, propValue); 59 60 return UtilURL.fromFilename(baseLocation.toString()); 61 } 62 } 63 | Popular Tags |