mil.dod.th.ose.remote/src/mil/dod/th/ose/remote/osgi/ConfigAdminMessageService.java
private Message createFactoryConfig(final TerraHarvestMessage request, final ConfigAdminNamespace message, 
        final RemoteChannel channel) throws IOException
    {
        //parse request
        final CreateFactoryConfigurationRequestData propMessage = CreateFactoryConfigurationRequestData.parseFrom(
            message.getData());
        final String factoryPid = propMessage.getFactoryPid();
        final List<SimpleTypesMapEntry> listProps = propMessage.getFactoryPropertyList();    

        if (listProps.isEmpty())
        {
            final String errorDescription = 
                    String.format("Missing properties, unable to create a factory configuration");
            
            final ConfigAdminNamespaceErrorData error = ConfigAdminNamespaceErrorData.newBuilder().
                    setError(ConfigAdminErrorCode.MissingPropertyError).
                    setErrorDescription(errorDescription).build();

            //send message
            m_MessageFactory.createConfigAdminResponseMessage(request, 
                    ConfigAdminMessageType.ConfigAdminNamespaceError, error).queue(channel);
            
            return propMessage;         
        }
        final Dictionary<String, Object> props = SharedMessageUtils.convertMaptoDictionary(listProps);

        //response builder
        final CreateFactoryConfigurationResponseData.Builder responseBuilder = 
            CreateFactoryConfigurationResponseData.newBuilder();
        
        //create the configuration
        try
        {
            final Configuration config = m_ConfigAdmin.createFactoryConfiguration(factoryPid, null);
            config.update(props);
            responseBuilder.setPid(config.getPid());
        }
        catch (final IOException exception)
        {
            final String errorDescription = String.format("Unable to create a configuration from Factory PID %s", 
                factoryPid);

            m_Logging.error(exception, errorDescription);
            final ConfigAdminNamespaceErrorData error = ConfigAdminNamespaceErrorData.newBuilder().
                setError(ConfigAdminErrorCode.ConfigurationPersistentStorageError).
                setErrorDescription(errorDescription + exception.getMessage()).build();

            //send message
            m_MessageFactory.createConfigAdminResponseMessage(request, 
                ConfigAdminMessageType.ConfigAdminNamespaceError, error).queue(channel);
            return propMessage;
        }

        //send response
        m_MessageFactory.createConfigAdminResponseMessage(request, 
            ConfigAdminMessageType.CreateFactoryConfigurationResponse, responseBuilder.build()).queue(channel);
        return propMessage;
    }
/**
     * Handle the request to create a factory configuration.
     * @param request
     *      entire remote message for the request
     * @param message
     *      the config admin message that contains the request to create a factory configuration
     * @param channel
     *      channel to use for sending a response
     * @throws IOException
     *      thrown if the message cannot be parsed correctly 
     * @return
     *     the data message associated with the request
     */
Handle the request to create a factory configuration.
Handle the request to create a factory configuration .
private Message createFactoryConfig(final TerraHarvestMessage request, final ConfigAdminNamespace message, 
        final RemoteChannel channel) throws IOException
    {
        final CreateFactoryConfigurationRequestData propMessage = CreateFactoryConfigurationRequestData.parseFrom(
            message.getData());
        final String factoryPid = propMessage.getFactoryPid();
        final List<SimpleTypesMapEntry> listProps = propMessage.getFactoryPropertyList();    
        if (listProps.isEmpty())
        {
            final String errorDescription = 
                    String.format("Missing properties, unable to create a factory configuration");
            final ConfigAdminNamespaceErrorData error = ConfigAdminNamespaceErrorData.newBuilder().
                    setError(ConfigAdminErrorCode.MissingPropertyError).
                    setErrorDescription(errorDescription).build();
            m_MessageFactory.createConfigAdminResponseMessage(request, 
                    ConfigAdminMessageType.ConfigAdminNamespaceError, error).queue(channel);
            return propMessage;         
        }
        final Dictionary<String, Object> props = SharedMessageUtils.convertMaptoDictionary(listProps);
        final CreateFactoryConfigurationResponseData.Builder responseBuilder = 
            CreateFactoryConfigurationResponseData.newBuilder();
        try
        {
            final Configuration config = m_ConfigAdmin.createFactoryConfiguration(factoryPid, null);
            config.update(props);
            responseBuilder.setPid(config.getPid());
        }
        catch (final IOException exception)
        {
            final String errorDescription = String.format("Unable to create a configuration from Factory PID %s", 
                factoryPid);
            m_Logging.error(exception, errorDescription);
            final ConfigAdminNamespaceErrorData error = ConfigAdminNamespaceErrorData.newBuilder().
                setError(ConfigAdminErrorCode.ConfigurationPersistentStorageError).
                setErrorDescription(errorDescription + exception.getMessage()).build();
            m_MessageFactory.createConfigAdminResponseMessage(request, 
                ConfigAdminMessageType.ConfigAdminNamespaceError, error).queue(channel);
            return propMessage;
        }
        m_MessageFactory.createConfigAdminResponseMessage(request, 
            ConfigAdminMessageType.CreateFactoryConfigurationResponse, responseBuilder.build()).queue(channel);
        return propMessage;
    }
private Message createFactoryConfig ( final TerraHarvestMessage request , final ConfigAdminNamespace message , final RemoteChannel channel ) throws IOException { final CreateFactoryConfigurationRequestData propMessage = CreateFactoryConfigurationRequestData . parseFrom ( message . getData ( ) ) ; final String factoryPid = propMessage . getFactoryPid ( ) ; final List < SimpleTypesMapEntry > listProps = propMessage . getFactoryPropertyList ( ) ; if ( listProps . isEmpty ( ) ) { final String errorDescription = String . format ( "Missing properties, unable to create a factory configuration" ) ; final ConfigAdminNamespaceErrorData error = ConfigAdminNamespaceErrorData . newBuilder ( ) . setError ( ConfigAdminErrorCode . MissingPropertyError ) . setErrorDescription ( errorDescription ) . build ( ) ; m_MessageFactory . createConfigAdminResponseMessage ( request , ConfigAdminMessageType . ConfigAdminNamespaceError , error ) . queue ( channel ) ; return propMessage ; } final Dictionary < String , Object > props = SharedMessageUtils . convertMaptoDictionary ( listProps ) ; final CreateFactoryConfigurationResponseData . Builder responseBuilder = CreateFactoryConfigurationResponseData . newBuilder ( ) ; try { final Configuration config = m_ConfigAdmin . createFactoryConfiguration ( factoryPid , null ) ; config . update ( props ) ; responseBuilder . setPid ( config . getPid ( ) ) ; } catch ( final IOException exception ) { final String errorDescription = String . format ( "Unable to create a configuration from Factory PID %s" , factoryPid ) ; m_Logging . error ( exception , errorDescription ) ; final ConfigAdminNamespaceErrorData error = ConfigAdminNamespaceErrorData . newBuilder ( ) . setError ( ConfigAdminErrorCode . ConfigurationPersistentStorageError ) . setErrorDescription ( errorDescription + exception . getMessage ( ) ) . build ( ) ; m_MessageFactory . createConfigAdminResponseMessage ( request , ConfigAdminMessageType . ConfigAdminNamespaceError , error ) . queue ( channel ) ; return propMessage ; } m_MessageFactory . createConfigAdminResponseMessage ( request , ConfigAdminMessageType . CreateFactoryConfigurationResponse , responseBuilder . build ( ) ) . queue ( channel ) ; return propMessage ; }
Handle the request to create a factory configuration.
Handle the request to create a factory configuration .
//parse request //send message //response builder //create the configuration //send message //send response