public static ICloudSdkConfiguration SetDefaults(ICloudSdkConfiguration configuration)
 {
     configuration.SDKEngineVersion = Constants.Header.SDK_ENGINE_VERSION_VALUE;
     configuration.SDKApiVersion    = Constants.Header.SDK_API_VERSION_VALUE;
     configuration.EnableCache      = false;
     return(configuration);
 }
Beispiel #2
0
        public static IServiceCollection ConfigureServices(this IServiceCollection serviceCollection, IConfiguration configuration)
        {
            IQueueConfiguration queueConfig = RabbitMqDefaultConfigLoader.SetDefaults(new RabbitMqQueueConfiguration());

            configuration.Bind(queueConfig);
            serviceCollection.AddTransient <IQueueConfiguration>(x => queueConfig);

            IStoreConfiguration storeConfig = AdaptationStoreConfigLoader.SetDefaults(new AdaptationStoreConfiguration());

            configuration.Bind(storeConfig);
            serviceCollection.AddTransient <IStoreConfiguration>(x => storeConfig);

            IProcessingConfiguration processingConfig = IcapProcessingConfigLoader.SetDefaults(new IcapProcessingConfiguration());

            configuration.Bind(processingConfig);
            serviceCollection.AddTransient <IProcessingConfiguration>(x => processingConfig);

            ICloudSdkConfiguration versionConfiguration = CloudSdkConfigLoader.SetDefaults(new CloudSdkConfiguration());

            configuration.Bind(versionConfiguration);
            serviceCollection.AddTransient <ICloudSdkConfiguration>(x => versionConfiguration);

            serviceCollection.AddTransient(typeof(IAdaptationServiceClient <>), typeof(RabbitMqClient <>));
            serviceCollection.AddTransient <IResponseProcessor, AdaptationOutcomeProcessor>();
            serviceCollection.AddTransient <IHttpService, HttpService.HttpService>();
            serviceCollection.AddSingleton <IRabbitMqConnectionFactory, RabbitMqConnectionFactory>();

            return(serviceCollection);
        }
Beispiel #3
0
 public CloudProxyController(ILogger <TController> logger, IAdaptationServiceClient <AdaptationOutcomeProcessor> adaptationServiceClient, IFileUtility fileUtility,
                             ICloudSdkConfiguration cloudSdkConfiguration, IProcessingConfiguration processingConfiguration, IStoreConfiguration storeConfiguration, IZipUtility zipUtility,
                             IHttpService httpService)
 {
     _logger                  = logger ?? throw new ArgumentNullException(nameof(logger));
     _fileUtility             = fileUtility ?? throw new ArgumentNullException(nameof(fileUtility));
     _cloudSdkConfiguration   = cloudSdkConfiguration ?? throw new ArgumentNullException(nameof(cloudSdkConfiguration));
     _processingConfiguration = processingConfiguration ?? throw new ArgumentNullException(nameof(processingConfiguration));
     _storeConfiguration      = storeConfiguration ?? throw new ArgumentNullException(nameof(storeConfiguration));
     _adaptationServiceClient = adaptationServiceClient ?? throw new ArgumentNullException(nameof(adaptationServiceClient));
     _zipUtility              = zipUtility ?? throw new ArgumentNullException(nameof(zipUtility));
     _httpService             = httpService ?? throw new ArgumentNullException(nameof(httpService));
 }
Beispiel #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseCors(Constants.CORS_POLICY);
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, Constants.STATIC_FILES_FOLDER_Name)),
            });
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/openapi.json", "Cloud SDK Api");
                c.InjectJavascript("/Swg/func.js");
                c.InjectJavascript("/Swg/toast/toastify.js");
                c.InjectStylesheet("/Swg/toast/toastify.css");
            });
            app.UseRouting();
            app.UseAuthorization();
            app.Use((context, next) =>
            {
                ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
                {
                    builder.AddConsole();
                });
                ILogger logger = loggerFactory.CreateLogger <Startup>();
                UserAgentInfo userAgentInfo = new UserAgentInfo(context.Request.Headers[Constants.UserAgent.USER_AGENT]);
                logger.LogInformation($"UserAgent:: [{userAgentInfo?.ClientInfo?.String}]");
                ICloudSdkConfiguration versionConfig = app.ApplicationServices.GetService <ICloudSdkConfiguration>();
                context.Response.Headers[Constants.Header.ACCESS_CONTROL_EXPOSE_HEADERS] = Constants.STAR;
                context.Response.Headers[Constants.Header.ACCESS_CONTROL_ALLOW_HEADERS]  = Constants.STAR;
                context.Response.Headers[Constants.Header.ACCESS_CONTROL_ALLOW_ORIGIN]   = Constants.STAR;
                context.Response.Headers[Constants.Header.VIA] = Environment.MachineName;
                context.Response.Headers[Constants.Header.SDK_ENGINE_VERSION] = versionConfig.SDKEngineVersion;
                context.Response.Headers[Constants.Header.SDK_API_VERSION]    = versionConfig.SDKApiVersion;
                return(next.Invoke());
            });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
 public RebuildController(IAdaptationServiceClient <AdaptationOutcomeProcessor> adaptationServiceClient, IStoreConfiguration storeConfiguration,
                          IProcessingConfiguration processingConfiguration, ILogger <RebuildController> logger, IFileUtility fileUtility,
                          IZipUtility zipUtility, ICloudSdkConfiguration cloudSdkConfiguration, IHttpService httpService) : base(logger, adaptationServiceClient, fileUtility, cloudSdkConfiguration,
                                                                                                                                 processingConfiguration, storeConfiguration, zipUtility, httpService)
 {
 }