* This is the *only* place replacement and encoding of the network
* place URI elements should occur as it is the only time when we
* have all the supporting objects (Session, Policy, Resource).
*/
VariableReplacement r = new VariableReplacement();
r.setLaunchSession(getLaunchSession());
// User info. Encoded
String userinfo = null;
if(!Util.isNullOrTrimmedBlank(getNetworkPlace().getUsername())) {
String username = r.replace(getNetworkPlace().getUsername());
String password = null;
if(!Util.isNullOrTrimmedBlank(getNetworkPlace().getPassword())) {
password = r.replace(getNetworkPlace().getPassword());
}
userinfo = DAVUtilities.encodeURIUserInfo(username + (password == null ? "" : ":" + password));
}
// Host. TODO check host only contains SPACE,a-z,A-Z and - and doesn't begin with -
String host = null;
//if(getStore().getProvider().getHostRequirement() == VFSProvider.ELEMENT_REQUIRED) {
if(!Util.isNullOrTrimmedBlank(getNetworkPlace().getHost())) {
host = r.replace(getNetworkPlace().getHost());
}
// Port. Integer. A port of -1 signifies default (0 means default in network place)
int port = -1;
// This test seems wrong because as all provider don't have port required.
// It means that the port saved in the database won't never be used.
//if(getStore().getProvider().getPortRequirement() == VFSProvider.ELEMENT_REQUIRED && getNetworkPlace().getPort() > 0) {
// replace by this one which test if port > 0 (different to the default port).
if(getNetworkPlace().getPort() > 0) {
port = getNetworkPlace().getPort();
}
// Path. Always required. Replaced and encoded.
String path = DAVUtilities.encodePath(r.replace(getNetworkPlace().getPath().replace('\\', '/')), charset);
if(!Util.isNullOrTrimmedBlank(path) && !path.startsWith("/") && !path.startsWith("./")) {
path = "/" + path;
}
// Query String. TODO we need to support