Exemplo n.º 1
0
        private async Task <Application> GetApplicationMetadataFileFromRepository()
        {
            string filePath = GetApplicationMetadataFilePath();
            string file     = await _giteaApiWrapper.GetFileAsync(_org, _app, filePath);

            Application appMetadata = JsonConvert.DeserializeObject <Application>(file);

            return(appMetadata);
        }
        private async Task <Application> GetApplicationMetadataFileFromRepository()
        {
            string           filePath = GetApplicationMetadataFilePath();
            GiteaFileContent file     = await _giteaApiWrapper.GetFileAsync(_org, _app, filePath, _shortCommitId);

            if (string.IsNullOrEmpty(file.Content))
            {
                throw new NotFoundHttpRequestException($"There is no file in {filePath}.");
            }

            byte[]      data        = Convert.FromBase64String(file.Content);
            Application appMetadata = data.Deserialize <Application>();

            return(appMetadata);
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        public async Task UpdateTextResourcesAsync(string org, string app, string shortCommitId, EnvironmentModel environmentModel)
        {
            string textResourcesPath       = GetTextResourceDirectoryPath();
            List <FileSystemObject> folder = await _giteaApiWrapper.GetDirectoryAsync(org, app, textResourcesPath, shortCommitId);

            if (folder != null)
            {
                folder.ForEach(async textResourceFromRepo =>
                {
                    if (!Regex.Match(textResourceFromRepo.Name, "^(resource\\.)..(\\.json)").Success)
                    {
                        return;
                    }

                    FileSystemObject populatedFile = await _giteaApiWrapper.GetFileAsync(org, app, textResourceFromRepo.Path, shortCommitId);
                    byte[] data = Convert.FromBase64String(populatedFile.Content);
                    PlatformStorageModels.TextResource content;

                    try
                    {
                        content = data.Deserialize <PlatformStorageModels.TextResource>();
                    }
                    catch (SerializationException e)
                    {
                        _logger.LogError($" // TextResourceService // UpdatedTextResourcesAsync // Error when trying to deserialize text resource file {org}/{app}/{textResourceFromRepo.Path} // Exception {e}");
                        return;
                    }

                    PlatformStorageModels.TextResource textResourceStorage = await GetTextResourceFromStorage(org, app, content.Language, environmentModel);
                    if (textResourceStorage == null)
                    {
                        await _storageTextResourceClient.Create(org, app, content, environmentModel);
                    }
                    else
                    {
                        await _storageTextResourceClient.Update(org, app, content, environmentModel);
                    }
                });
            }
        }
Exemplo n.º 4
0
        /// <inheritdoc/>
        public async Task UpdateTextResourcesAsync(string org, string app, string shortCommitId, EnvironmentModel environmentModel)
        {
            string textResourcesPath       = GetTextResourceDirectoryPath();
            List <GiteaFileContent> folder = await _giteaApiWrapper.GetDirectoryAsync(org, app, textResourcesPath, shortCommitId);

            if (folder != null)
            {
                folder.ForEach(async textResourceFromRepo =>
                {
                    GiteaFileContent populatedFile = await _giteaApiWrapper.GetFileAsync(org, app, textResourceFromRepo.Path, shortCommitId);
                    byte[] data                      = Convert.FromBase64String(populatedFile.Content);
                    TextResource content             = data.Deserialize <TextResource>();
                    TextResource textResourceStorage = await GetTextResourceFromStorage(org, app, content.Language, environmentModel);
                    if (textResourceStorage == null)
                    {
                        await _storageTextResourceClient.Create(org, app, content, environmentModel);
                    }
                    else
                    {
                        await _storageTextResourceClient.Update(org, app, content, environmentModel);
                    }
                });
            }
        }
        private async Task <GiteaFileContent> GetAuthorizationPolicyFileFromGitea(string org, string app, string shortCommitId)
        {
            string policyFilePath = GetAuthorizationPolicyFilePath();

            return(await _giteaApiWrapper.GetFileAsync(org, app, policyFilePath, shortCommitId));
        }
Exemplo n.º 6
0
        private async Task <string> GetAuthorizationPolicyFileFromGitea(string org, string app, string fullCommitId)
        {
            string policyFilePath = GetAuthorizationPolicyFilePath(fullCommitId);

            return(await _giteaApiWrapper.GetFileAsync(org, app, policyFilePath));
        }