FileDocCategorySizeDatePackage
RepositoryNameValidator.javaAPI DocGlassfish v2 API5014Fri May 04 22:24:30 BST 2007com.sun.enterprise.admin.servermgmt

RepositoryNameValidator

public class RepositoryNameValidator extends StringValidator
Validates the repository name. A repository name must be a - valid file name, - valid xml CDATA value & - valid javax.management.ObjectName property value.

Fields Summary
private static final String
VALID_CHAR
private static final String
IAS_NAME
private static final String
XML_1
private static final String
XML_2
private static final com.sun.enterprise.util.i18n.StringManager
strMgr
i18n strings manager object
Constructors Summary
public RepositoryNameValidator(String name)
Constructs new RepositoryNameValidator object.

param
name


               
      
    
        super(name);
    
Methods Summary
public voidcheckValidName(java.lang.String name)

        if (!name.matches(VALID_CHAR))
        {
            throw new InvalidConfigException(
                strMgr.getString("validator.invalid_value", getName(), name));
        }
    
public voidcheckValidObjectNameToken(java.lang.String name)

        try
        {
            new ObjectName(IAS_NAME + name);
        }
        catch (Exception e)
        {
            throw new InvalidConfigException(
                strMgr.getString("validator.invalid_value", getName(), name));
        }
    
public voidcheckValidXmlToken(java.lang.String name)
Implementation copied from com.sun.enterprise.admin.verifier.tests.StaticTest

        try
        {
            //Construct a valid xml string
            String xml = XML_1 + name + XML_2;
            ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
            InputSource is = new InputSource(bais);
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setValidating(false);
            DocumentBuilder db = dbf.newDocumentBuilder();
            db.parse(is);
        }
        catch (Exception e)
        {
            throw new InvalidConfigException(
                strMgr.getString("validator.invalid_value", getName(), name));
        }
    
public voidvalidate(java.lang.Object str)
Validates the given value for the given entry. This method first invokes its superclass's validate method and then performs additional validations.

throws
InvalidConfigException

        super.validate(str);
        checkValidName((String)str);
        checkValidXmlToken((String)str);
        checkValidObjectNameToken((String)str);