1 23 24 package com.sun.enterprise.config.serverbeans.validation.tests; 25 import java.util.logging.Level ; 26 27 import com.sun.enterprise.config.ConfigContextEvent; 28 import com.sun.enterprise.config.ConfigException; 29 import com.sun.enterprise.config.serverbeans.MessageSecurityConfig; 30 import com.sun.enterprise.config.serverbeans.ProviderConfig; 31 import com.sun.enterprise.config.serverbeans.ServerTags; 32 import com.sun.enterprise.config.serverbeans.validation.GenericValidator; 33 import com.sun.enterprise.config.serverbeans.validation.Result; 34 import com.sun.enterprise.config.serverbeans.validation.ValidationDescriptor; 35 36 public class ProviderConfigTest extends GenericValidator { 37 38 private static final char [] illegalChars = {'*', ',', ':'}; 39 40 public ProviderConfigTest (ValidationDescriptor desc) { 41 super(desc); 42 } 43 44 public Result validate(ConfigContextEvent cce) { 45 46 Result result = super.validate(cce); 47 try { 48 if (cce.getChoice().equals(StaticTest.DELETE)){ 49 if (isReferencedByParent(cce)){ 50 result.failed( 51 smh.getLocalString( 52 getClass().getName() + ".cannotDeleteReferencedProviderConfig", 53 "provider config (provider-id={0}) can not be removed. It is referenced by its parent message-security-config", 54 new Object []{getProviderConfig(cce).getProviderId()})); 55 } 56 } 57 } 58 catch (Exception e){ 59 _logger.log(Level.FINE, "domainxmlverifier.exception", e); 60 } 61 62 return result; 63 } 64 65 private final boolean isReferencedByParent(final ConfigContextEvent cce) throws ConfigException { 66 final ProviderConfig pc = getProviderConfig(cce); 67 final MessageSecurityConfig msc = (MessageSecurityConfig) pc.parent().parent(); 68 return msc.getDefaultProvider() != null && msc.getDefaultProvider().equals(pc.getProviderId()); 69 } 70 71 private ProviderConfig getProviderConfig(final ConfigContextEvent cce) throws ConfigException { 72 return (ProviderConfig) cce.getValidationTarget(); 73 } 74 75 } 76 | Popular Tags |