示例#1
0
        /// <exception cref="Tika.RestClient.Features.Topics.Exceptions.TopicAlreadyExistsException">Thrown when topic with given name already exists</exception>
        public async Task CreateAsync(TopicCreate topicCreate)
        {
            var payload = JsonConvert.SerializeObject(topicCreate);

            var content = new StringContent(
                payload,
                Encoding.UTF8,
                "application/json"
                );

            var res = await _httpClient.PostAsync(
                new Uri(TOPICS_ROUTE, UriKind.Relative),
                content
                );

            if (res.StatusCode == HttpStatusCode.Conflict)
            {
                var rawText = await res.Content.ReadAsStringAsync();

                var responseData = JsonConvert.DeserializeObject <TikaGenericError>(rawText);
                if (responseData.ErrName == "CcloudTopicAlreadyExists")
                {
                    throw new TopicAlreadyExistsException(responseData.ErrMessage);
                }
            }
        }
        public TopicFolderFrontEnd Create(TopicCreate data, int userId)
        {
            var user = context.Users.SingleOrDefault(x => x.Id == userId);

            if (user == null)
            {
                throw new ServiceException("User Not Found");
            }

            var topic = new Topic
            {
                Approved             = user.Role == "Admin" ? true : false,
                CriteriaForBelonging = data.CriteriaForBelonging,
                Description          = data.Description,
                Name          = data.Name,
                ParentTopicId = data.ParentTopicId,
                UserId        = user.Id,
            };

            this.context.Topics.Add(topic);
            this.context.SaveChanges();

            var result = new TopicFolderFrontEnd
            {
                Id                   = topic.Id,
                Name                 = topic.Name,
                Order                = 0,
                parentId             = topic.ParentTopicId,
                CriteriaForBelonging = topic.CriteriaForBelonging,
                Description          = topic.Description,
            };

            return(result);
        }
示例#3
0
        private async Task And_a_single_topic()
        {
            _topicName = "Integration-test-" + Guid.NewGuid();
            var topicCreate = TopicCreate.Create(
                name: _topicName,
                partitionCount: 1
                );

            await _client.Topics.CreateAsync(topicCreate);
        }
        private async Task When_a_topic_with_the_same_name_is_added()
        {
            var topicCreate = TopicCreate.Create(
                name: _topicName,
                partitionCount: 1
                );


            await _client.Topics.CreateAsync(topicCreate);
        }
示例#5
0
        private async Task And_a_single_topic()
        {
            using var client    = LocalhostRestClient.Create();
            _topicCreateCommand = TopicCreate.Create(
                name: Guid.NewGuid().ToString(),
                partitionCount: 1
                );

            await client.Topics.CreateAsync(_topicCreateCommand);
        }
        public async Task Add(Topic topic)
        {
            var topicCreate = TopicCreate.Create(topic.Name, topic.Partitions);

            foreach (var(key, value) in topic.Configurations)
            {
                var jsonElement = (JsonElement)value;
                topicCreate = topicCreate.WithConfiguration(key, JsonObjectTools.GetValueFromJsonElement(jsonElement));
            }
            await _tikaClient.Topics.CreateAsync(topicCreate);
        }
        private async Task And_a_single_topic()
        {
            using var client = LocalhostRestClient.Create();
            _topicName       = Guid.NewGuid().ToString();
            var topicCreate = TopicCreate.Create(
                name: _topicName,
                partitionCount: 1
                );

            await client.Topics.CreateAsync(topicCreate);
        }
示例#8
0
        public Task CreateAsync(TopicCreate topicCreate)
        {
            var topicDescription = new TopicDescription
            {
                name           = topicCreate.Name,
                partitionCount = topicCreate.PartitionCount,
                configurations = topicCreate.Configurations
            };

            TopicDescriptions.Add(topicDescription);

            return(Task.CompletedTask);
        }
 public IActionResult CreateTopic([FromBody] TopicCreate data)
 {
     try
     {
         var userData = jwtService.ParseData(this.User);
         var result   = this.topicService.Create(data, userData.UserId);
         return(Ok(result));
     }
     catch (ServiceException e)
     {
         return(BadRequest(e.Message));
     }
 }
示例#10
0
        private async Task Then_a_topic_is_created(Topic topic)
        {
            var topicCreate = TopicCreate.Create(topic.Name, topic.Partitions);

            if (topic.Configurations != null)
            {
                foreach (var(key, value) in topic.Configurations)
                {
                    topicCreate = topicCreate.WithConfiguration(key, value);
                }
            }

            await _tikaClient.Topics.CreateAsync(topicCreate);
        }
示例#11
0
        private async Task When_a_topic_with_the_same_name_but_different_partitions_is_added()
        {
            try
            {
                var topicCreate = TopicCreate.Create(
                    name: _topicName,
                    partitionCount: 2
                    );


                await _client.Topics.CreateAsync(topicCreate);
            }
            catch (TopicAlreadyExistsException e)
            {
                _topicAlreadyExistsException = e;
            }
        }
示例#12
0
        private async Task When_creating_a_topic_with_configuration()
        {
            _topicName = "Integration-test-" + Guid.NewGuid();
            var random = new Random();

            _messageRetentionPeriod = TimeSpan.FromDays(random.Next(1, 7));
            _maxDiskUsageInBytes    = random.Next(1, 2001) * 1000000;

            var topicCreate = TopicCreate
                              .Create(
                name: _topicName,
                partitionCount: 1)
                              .WithConfiguration("retention.ms", _messageRetentionPeriod.TotalMilliseconds)
                              .WithConfiguration("retention.bytes", _maxDiskUsageInBytes);

            await _client.Topics.CreateAsync(topicCreate);
        }
示例#13
0
        public ActionResult UploadTopic(IPPTopic ippTopic, HttpPostedFileBase image)
        {
            var tmp = ippTopic.Approver.Replace(';', ';').Trim();

            if (tmp[tmp.Length - 1] != ';')
            {
                ippTopic.Approver += ";";
            }

            var topicCreate = new TopicCreate
            {
                ID                = ippTopic.ID,
                DescriptionCn     = ippTopic.DescriptionCn,
                DescriptionEn     = ippTopic.DescriptionEn,
                IsApprove         = ippTopic.IsApprove,
                IsInternalApprove = ippTopic.IsInternalApprove,
                IsDirectDelete    = ippTopic.IsDirectDelete,
                Approver          = ippTopic.Approver,
                RMLink            = ippTopic.RMLink,
                Tag               = ippTopic.Tag,
                NameCn            = ippTopic.NameCn,
                NameEn            = ippTopic.NameEn,
                ModuleID          = Convert.ToInt32(ippTopic.ModuleID),
                Creater           = UserSettingHelper.GetEikonUserID(Request),
                ImageName         = ippTopic.ImageName
            };

            if (image != null && image.ContentLength > 0)
            {
                topicCreate.Thumbnail = new byte[image.ContentLength];
                image.InputStream.Read(topicCreate.Thumbnail, 0, image.ContentLength);
            }

            IPPRepository.UploadTopic(topicCreate);
            return(Redirect("~/ipp/MyDocument/topicManagement"));
        }
示例#14
0
 private async Task When_a_topic_creation_is_requested()
 {
     var topicCreate = TopicCreate.Create("devex-integrationtest", 3);
     await _tikaRestClient.Topics.CreateAsync(topicCreate);
 }
示例#15
0
        public void UploadTopic(TopicCreate topicCreate)
        {
            var paramArray = new[]
            {
                new OracleParameter("V_ID", OracleDbType.Int32)
                {
                    Value = topicCreate.ID
                },
                new OracleParameter("V_NameCn", OracleDbType.NVarchar2)
                {
                    Value = topicCreate.NameCn
                },
                new OracleParameter("V_NameEn", OracleDbType.NVarchar2)
                {
                    Value = topicCreate.NameEn
                },
                new OracleParameter("V_ModuleID", OracleDbType.Int32)
                {
                    Value = topicCreate.ModuleID
                },
                new OracleParameter("V_Creater", OracleDbType.NVarchar2)
                {
                    Value = topicCreate.Creater
                },
                //new OracleParameter("V_Image", OracleDbType.VarBinary) { Value = topicCreate.Thumbnail },
                new OracleParameter("V_DescriptionCn", OracleDbType.NVarchar2)
                {
                    Value = topicCreate.DescriptionCn
                },
                new OracleParameter("V_DescriptionEn", OracleDbType.NVarchar2)
                {
                    Value = topicCreate.DescriptionEn
                },
                new OracleParameter("V_IsApprove", OracleDbType.Int16)
                {
                    Value = topicCreate.IsApprove?1:0
                },
                new OracleParameter("V_IsInternalApprove", OracleDbType.Int16)
                {
                    Value = topicCreate.IsInternalApprove?1:0
                },
                new OracleParameter("V_IsDirectDelete", OracleDbType.Int16)
                {
                    Value = topicCreate.IsDirectDelete?1:0
                },
                new OracleParameter("V_Tag", OracleDbType.NVarchar2)
                {
                    Value = topicCreate.Tag
                },
                new OracleParameter("V_RMLink", OracleDbType.NVarchar2)
                {
                    Value = topicCreate.RMLink
                },
                new OracleParameter("V_Approver", OracleDbType.NVarchar2)
                {
                    Value = topicCreate.Approver
                },
                new OracleParameter("V_ImageName", OracleDbType.NVarchar2)
                {
                    Value = topicCreate.ImageName
                }
            };

            ExecNonQuerySp("UploadTopic", paramArray);
        }