Ejemplo n.º 1
0
        public async Task <ActionResult <ExtensionResource> > Get(string id)
        {
            var metadata = await _metadataRepository.GetExtensionMetadata(id);

            if (metadata == null)
            {
                Log.Information($"Couldn't find ExtensionMetadata '{id}'.");
                return(new NotFoundResult());
            }
            if (metadata.Type != ExtensionType.Default)
            {
                Log.Information($"ExtensionMetadata '{id}' doesn't contain themes (ExtensionType: {metadata.Type})");
                return(new NotFoundResult());
            }

            var storedTheme = await _themeRepository.GetTheme(id);

            if (storedTheme == null)
            {
                Log.Error($"Stored theme for '{id}' extension is empty.");
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            var extension = _mapper.Map <ExtensionMetadata, ExtensionResource>(metadata);

            extension.Themes = ConvertThemes(storedTheme.Themes);

            return(new OkObjectResult(extension));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <ExtensionResource> > Get(string id)
        {
            var metadata = await _metadataRepository.GetExtensionMetadata(id);

            if (metadata == null)
            {
                Log.Information($"Couldn't find ExtensionMetadata '{id}'.");
                return(NotFound(id));
            }
            if (metadata.Type != ExtensionType.Default)
            {
                Log.Information($"ExtensionMetadata '{id}' doesn't contain themes (ExtensionType: {metadata.Type})");
                return(NotFound(id));
            }

            var theme = await _themeRepository.GetTheme(id);

            if (theme == null)
            {
                Log.Error($"Stored theme for '{id}' extension is empty.");
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            return(CreateExtensionResource(metadata, theme.Themes));
        }
        private async Task RefreshExtensionMetadata(ExtensionMetadata freshMetadata)
        {
            try
            {
                var extensionMetadata = await _metadataRepository
                                        .GetExtensionMetadata(freshMetadata.Id);

                if (extensionMetadata == null)
                {
                    await CreateExtensionMetadata(freshMetadata);
                }
                else if (extensionMetadata.LastUpdated != freshMetadata.LastUpdated)
                {
                    await UpdateExtensionMetadata(freshMetadata);
                }
                else
                {
                    await UpdateGalleryStatistics(freshMetadata.Id, freshMetadata.Statistics);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"Error while refreshing extension metadata: '{freshMetadata.Id}'.");
            }
        }
Ejemplo n.º 4
0
        public async Task <ActionResult <ExtensionMetadataResource> > Get(string id)
        {
            var metadata = await _metadataRepository.GetExtensionMetadata(id);

            if (metadata == null)
            {
                Log.Information($"Couldn't find ExtensionMetadata '{id}'.");
                return(NotFound(id));
            }
            if (metadata.Type != ExtensionType.Default)
            {
                Log.Information($"ExtensionMetadata '{id}' doesn't contain themes (ExtensionType: {metadata.Type})");
                return(NotFound(id));
            }

            return(_mapper.Map <ExtensionMetadata, ExtensionMetadataResource>(metadata));
        }
Ejemplo n.º 5
0
        public async Task <ExtensionType> GetSavedExtensionType(string extensionId)
        {
            var savedThemeMetadata = await _metadataRepository.GetExtensionMetadata(extensionId);

            return(savedThemeMetadata.Type);
        }