FileDocCategorySizeDatePackage
BaseTransformationRuleCommand.javaAPI DocGlassfish v2 API11802Fri May 04 22:25:08 BST 2007com.sun.enterprise.cli.commands

BaseTransformationRuleCommand

public abstract class BaseTransformationRuleCommand extends GenericCommand
Abstract base class for the Transformation Rule commands

Fields Summary
protected static final String
WEB_SERVICE_OPTION
Constructors Summary
Methods Summary
private com.sun.appserv.management.config.J2EEApplicationConfiggetApplicationConfigMBean(javax.management.MBeanServerConnection mbsc, java.lang.String appName)

        DomainRoot domainRoot = ProxyFactory.getInstance(mbsc).getDomainRoot();
        DomainConfig domainConfig = domainRoot.getDomainConfig();
        Map appCfgMap = domainConfig.getJ2EEApplicationConfigMap();
        if ( appCfgMap != null){
            return (J2EEApplicationConfig) appCfgMap.get(appName);
        } else {
            return null;
        }
    
private com.sun.appserv.management.config.EJBModuleConfiggetEJBModuleConfigMBean(javax.management.MBeanServerConnection mbsc, java.lang.String moduleName)

        DomainRoot domainRoot = ProxyFactory.getInstance(mbsc).getDomainRoot();
        DomainConfig domainConfig = domainRoot.getDomainConfig();
        Map appCfgMap = domainConfig.getEJBModuleConfigMap();
        if ( appCfgMap != null){
            return (EJBModuleConfig) appCfgMap.get(moduleName);
        } else {
            return null;
        }
    
private java.lang.StringgetStandAloneModuleType(javax.management.MBeanServerConnection mbsc, java.lang.String fqName)

         DomainRoot domainRoot = ProxyFactory.getInstance(mbsc).getDomainRoot();
         final WebServiceEndpointInfo info =
            domainRoot.getWebServiceMgr().getWebServiceEndpointInfo(
                    fqName);
         if (info == null){
             throw new CommandException (
                        getLocalizedString("NoStandaloneModuleFoundForWS", new Object[]{fqName}));
         }
         return info.getServiceImplType();
    
private com.sun.appserv.management.config.WebModuleConfiggetWebModuleConfigMBean(javax.management.MBeanServerConnection mbsc, java.lang.String moduleName)

        DomainRoot domainRoot = ProxyFactory.getInstance(mbsc).getDomainRoot();
        DomainConfig domainConfig = domainRoot.getDomainConfig();
        Map appCfgMap = domainConfig.getWebModuleConfigMap();
        if ( appCfgMap != null){
            return (WebModuleConfig) appCfgMap.get(moduleName);
        } else {
            return null;
        }
    
protected com.sun.appserv.management.config.WebServiceEndpointConfiggetWebServiceEndpointConfig(javax.management.MBeanServerConnection mbsc, java.lang.String fqWebServiceName, boolean isCreateIfNone)
parse the operand to get the web service name return the webservice endpoint config.

throws
CommandException

    
                            
      
                               
                              
                              
    
        // this webserviceName is fully qualified name
        //String fqWebServiceName = getOption(WEB_SERVICE_OPTION);
        // extract the partially qualified web service endpoing config name
        int firstHashIdx = fqWebServiceName.indexOf("#");
        String wsName= null;
        if ( firstHashIdx != -1 ) {
            if ( firstHashIdx+1 == fqWebServiceName.length()) {
                throw new CommandException(getLocalizedString("InvalidFormatForWebservice"));
            }
            wsName =  fqWebServiceName.substring(firstHashIdx +1);
        }
        else
        {
            throw new CommandException(getLocalizedString("InvalidFormatForWebservice"));
        }
        String regName = fqWebServiceName.substring(0,firstHashIdx);
        StringTokenizer sTok = new StringTokenizer(fqWebServiceName,"#");
        int numTokens = sTok.countTokens();
        if ( numTokens == 3 ) {
            // this is an application
            J2EEApplicationConfig appConfig = getApplicationConfigMBean(mbsc, regName);
             if ( appConfig == null){
                 throw new CommandException (
                            getLocalizedString("NoAppFoundForWS", 
                                                new Object[] {regName}));             
             }
            DomainRoot domainRoot = ProxyFactory.getInstance(mbsc).getDomainRoot();
            final WebServiceEndpointInfo info =
                domainRoot.getWebServiceMgr().getWebServiceEndpointInfo(fqWebServiceName);
            if (info == null)
            {
                String moduleName = fqWebServiceName.substring(firstHashIdx + 1, 
                                            fqWebServiceName.lastIndexOf("#"));
                throw new CommandException(getLocalizedString("NoModuleOrEndpointFoundForWS", 
                                                new Object[]{fqWebServiceName}));
            }
             Map epMap = appConfig.getWebServiceEndpointConfigMap();
                if (epMap == null) {
                    if (isCreateIfNone)
                    {
                        return appConfig.createWebServiceEndpointConfig(wsName,null);
                    }
                } else {
                    WebServiceEndpointConfig wsEpConfig = (WebServiceEndpointConfig) epMap.get(wsName);
                    if ((wsEpConfig == null) && (isCreateIfNone)) {
                         return appConfig.createWebServiceEndpointConfig(wsName,null);
                    } else {
                        return wsEpConfig;
                    }
                }
        } else if ( numTokens == 2 ) {
            // this is a stand alone module
            // we need to figure out a type
            String modType = getStandAloneModuleType(mbsc, fqWebServiceName);
            if ( modType.equals(WebServiceEndpointInfo.EJB_IMPL)) {
                EJBModuleConfig ejbModuleConfig = getEJBModuleConfigMBean(mbsc, regName);
                 if ( ejbModuleConfig == null){
                     throw new CommandException (
                                getLocalizedString("NoEJBModuleFoundForWS", 
                                                    new Object[] {regName}));             
                }
                Map epMap = ejbModuleConfig.getWebServiceEndpointConfigMap();
                if ( epMap == null) {
                    if (isCreateIfNone)
                       return ejbModuleConfig.createWebServiceEndpointConfig(wsName,null);
                } else {
                    WebServiceEndpointConfig wsEpConfig = (WebServiceEndpointConfig) epMap.get(wsName);
                    if ((wsEpConfig == null) && (isCreateIfNone)) {
                         return ejbModuleConfig.createWebServiceEndpointConfig(wsName,null);
                    } else {
                        return wsEpConfig;
                    }
                }
            } else if (modType.equals(WebServiceEndpointInfo.SERVLET_IMPL) ) {
                WebModuleConfig webModuleConfig = getWebModuleConfigMBean(mbsc, regName);
                if ( webModuleConfig == null){
                     throw new CommandException (
                                getLocalizedString("NoWebModuleFoundForWS",
                                                     new Object[] {regName}));
                }
                Map epMap = webModuleConfig.getWebServiceEndpointConfigMap();
                if ( epMap == null) {
                    if (isCreateIfNone)
                       return webModuleConfig.createWebServiceEndpointConfig(wsName, null);
                } else {
                    WebServiceEndpointConfig wsEpConfig = (WebServiceEndpointConfig) epMap.get(wsName);
                     if ((wsEpConfig == null) && (isCreateIfNone)){
                         return webModuleConfig.createWebServiceEndpointConfig(wsName,null);
                    } else {
                        return wsEpConfig;
                    }
                }
                
            } else {
                // user entered non servlet/ejb module
                 throw new CommandException (
                            getLocalizedString("InvalidModuleTypeForWS"));
            }
        } else {
            // format of FQN is wrong
            throw new CommandValidationException(getLocalizedString("InvalidFormatForWebservice"));
        }
        // this wsc does not exist
        
        return null;
    
protected voidvalidateWebServiceName(java.lang.String fqWebServiceName, boolean validateIfNull)
validate the webservice name format.

throws
CommandException

         // this webserviceName is fully qualified name
        //String fqWebServiceName = getOption(WEB_SERVICE_OPTION); 
        if ((fqWebServiceName == null) && (!validateIfNull))
        {
            return;
        }
        else
        {
            //This will not happen as the webservicename is required option
            // for create & delete commands
        }
        int hashIdx = fqWebServiceName.lastIndexOf("#");
        if ( hashIdx != -1 ) {
            if ( hashIdx+1 == fqWebServiceName.length()) {
                throw new CommandValidationException(getLocalizedString("InvalidFormatForWebservice"));
            }
        }
        else
        {
            throw new CommandValidationException(getLocalizedString("InvalidFormatForWebservice"));
        }