NameListMgrpublic class NameListMgr extends Object This class provides access to NameLists defined for validations
Its constructor parses nameLists.xml file to read lists descriptors.
$Id: NameListMgr.java,v 1.5 2007/05/05 05:24:36 tcfujii Exp $ |
Fields Summary |
---|
static Logger | _logger | com.sun.enterprise.util.LocalStringManagerImpl | _localStrings | Hashtable | _lists | boolean | _precreateAndKeepLists | com.sun.enterprise.config.ConfigContext | _ctx |
Constructors Summary |
---|
public NameListMgr(com.sun.enterprise.config.ConfigContext ctx, boolean precreateAndKeepLists)
_lists = new Hashtable();
_precreateAndKeepLists = precreateAndKeepLists;
_ctx = ctx;
loadDescriptors();
//System.out.println(this.toString());
|
Methods Summary |
---|
public java.lang.String | getDescriptionForNameDomain(java.lang.String nameDomainName)
//returns true only if value is in correspondent name domain
NameList list = getNameList(nameDomainName);
if(list!=null && list._fullName!=null)
{
return list._fullName;
}
return nameDomainName;
| private java.lang.String | getDescriptorsFilePath()
URL propertiesFile = NameListMgr.class.getClassLoader().getResource(
"com/sun/enterprise/config/serverbeans/validation/config/name-domains.xml");
//TODO: for test only
// URL propertiesFile = (new File("/ias/admin/validator/NameLists.xml")).toURL();
return propertiesFile.toString();
| public java.lang.String | getDomainValueReferenceeXPath(java.lang.String nameDomainName, java.lang.Object value, java.lang.String xpath)
//returns true even if value not in doamin at all
NameList list = getNameList(nameDomainName);
if(list!=null)
{
return list.getDomainValueSourceXPath(value, xpath, true);
}
return null;
| public java.lang.String | getDomainValueSourceXPath(java.lang.String nameDomainName, java.lang.Object value, java.lang.String xpath)
//returns true even if value not in doamin at all
NameList list = getNameList(nameDomainName);
if(list!=null)
{
return list.getDomainValueSourceXPath(value, xpath, false);
}
return null;
| private org.w3c.dom.NameList | getNameList(java.lang.String nameDomainName)
NameList list = null;
if(_lists!=null)
list=(NameList)_lists.get(nameDomainName);
if(list!=null)
{
//FIXME: 1. should no recreate all sublists
//FIXME: 2. should recreate only if ADD/DELETE happened
if(!_precreateAndKeepLists)
{
//XPathHelper.getXPathPrefix(xpath
list.buildLists(null);
}
}
return list;
| public boolean | isUniqueValueInNameDomain(java.lang.String nameDomainName, java.lang.Object value, java.lang.String xpath)
//returns true even if value not in doamin at all
NameList list = getNameList(nameDomainName);
if(list!=null && list.isValueInNameDomain(value, xpath, false))
{
String sourceXPath = list.getDomainValueSourceXPath(value, xpath, false);
return (xpath.equals(sourceXPath));
}
return true;
| public boolean | isValueInNameDomain(java.lang.String nameDomainName, java.lang.Object value, java.lang.String xpath)
//returns true only if value is in correspondent name domain
NameList list = getNameList(nameDomainName);
if(list!=null)
{
return list.isValueInNameDomain(value, xpath, false);
}
return false;
| public boolean | isValueInNameDomainReferenced(java.lang.String nameDomainName, java.lang.Object value, java.lang.String xpath)
//returns true only if value is in correspondent name domain
NameList list = getNameList(nameDomainName);
if(list!=null)
{
return list.isValueInNameDomain(value, xpath, true);
}
return false;
| public boolean | loadDescriptors()
boolean allIsWell = true;
try {
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource is = new InputSource(getDescriptorsFilePath());
Document doc = db.parse(is);
NodeList list = doc.getElementsByTagName("name-list");
for(int i=0; i<list.getLength(); i++)
{
Element e = (Element) list.item(i);
String name = e.getAttribute("name");
String fullName = e.getAttribute("full-name");
String scope = e.getAttribute("scope");
//sources list
NodeList nl = e.getElementsByTagName("forms-from");
ArrayList xpath_arr = new ArrayList();
for(int j=0; j<nl.getLength(); j++)
{
String xpath = ((Element)nl.item(j)).getAttribute("xpath");
if(xpath!=null && xpath.length()>0)
xpath_arr.add(xpath);
}
//referencees list
nl = e.getElementsByTagName("referenced-by");
ArrayList ref_xpath_arr = new ArrayList();
for(int j=0; j<nl.getLength(); j++)
{
String xpath = ((Element)nl.item(j)).getAttribute("xpath");
if(xpath!=null && xpath.length()>0)
ref_xpath_arr.add(xpath);
}
/*
System.out.println("name="+name);
System.out.println(" fullname="+fullName);
System.out.println(" scope="+scope);
for(int j=0; j<xpath_arr.size(); j++)
System.out.println(" xpath="+xpath_arr.get(j));
*/
_lists.put(name, new NameList(name, fullName, scope, xpath_arr, ref_xpath_arr, _ctx, _precreateAndKeepLists));
}
} catch (ParserConfigurationException e) {
_logger.log(Level.WARNING, "parser_error", e);
allIsWell = false;
} catch (SAXException e) {
_logger.log(Level.WARNING, "sax_error", e);
allIsWell = false;
} catch (IOException e) {
_logger.log(Level.WARNING, "error_loading_xmlfile", e);
allIsWell = false;
} catch(Exception e) {
_logger.log(Level.WARNING, "error", e);
allIsWell = false;
}
return allIsWell;
| public java.lang.String | toString()
String str = "";
if(_lists!=null)
{
Enumeration keys = _lists.keys();
while(keys.hasMoreElements())
{
String key = (String)keys.nextElement();
str = str + "\n" + ((NameList)_lists.get(key)).toString();
}
}
return str;
|
|