//print.ln("hasAccess:"+hasAccess);
//print.ln("hasInsertAccess:"+hasInsertAccess);
//boolean hasAccess=ConfigWebUtil.hasAccess(config,SecurityManager.TYPE_DATASOURCE);
if(!hasAccess)
throw new SecurityException("no access to update datsource connections");
// check parameters
if(name==null || name.length()==0)
throw new ExpressionException("name can't be a empty value");
try {
ClassUtil.loadInstance(clazzName);
}
catch (ClassException e) {
throw new ExpressionException(e.getMessage());
}
Element datasources=_getRootElement("data-sources");
// Update
Element[] children = ConfigWebFactory.getChildren(datasources,"data-source");
for(int i=0;i<children.length;i++) {
String n=children[i].getAttribute("name");
if(n.equalsIgnoreCase(name)) {
Element el=children[i];
if(password.equalsIgnoreCase("****************"))
password=el.getAttribute("password");
if(!StringUtil.isEmpty(newName) && !newName.equals(name))
el.setAttribute("name",newName);
el.setAttribute("class",clazzName);
el.setAttribute("dsn",dsn);
el.setAttribute("username",username);
el.setAttribute("password",ConfigWebFactory.encrypt(password));
el.setAttribute("host",host);
if(!StringUtil.isEmpty(timezone))el.setAttribute("timezone",timezone);
else if(el.hasAttribute("timezone")) el.removeAttribute("timezone");
el.setAttribute("database",database);
el.setAttribute("port",Caster.toString(port));
el.setAttribute("connectionLimit",Caster.toString(connectionLimit));
el.setAttribute("connectionTimeout",Caster.toString(connectionTimeout));
el.setAttribute("metaCacheTimeout",Caster.toString(metaCacheTimeout));
el.setAttribute("blob",Caster.toString(blob));
el.setAttribute("clob",Caster.toString(clob));
el.setAttribute("allow",Caster.toString(allow));
el.setAttribute("validate",Caster.toString(validate));
el.setAttribute("storage",Caster.toString(storage));
el.setAttribute("custom",toStringURLStyle(custom));
if (!StringUtil.isEmpty( dbdriver ))
el.setAttribute("dbdriver", Caster.toString(dbdriver));
return;
}
}
if(!hasInsertAccess)
throw new SecurityException("no access to add datasource connections, the maximum count of ["+maxLength+"] datasources is reached");
// Insert
Element el=doc.createElement("data-source");
datasources.appendChild(el);
if(!StringUtil.isEmpty(newName))