Skip to content

Commit

Permalink
Merge branch 'main' of github.com:mycloudnexus/kraken into fix/user-m…
Browse files Browse the repository at this point in the history
…gmt-list-filter
  • Loading branch information
xuelianhan007 committed Dec 2, 2024
2 parents 8e7a181 + 8df9da8 commit 69996a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public enum ClientEventTypeEnum {
CLIENT_TEMPLATE_UPGRADE_RESULT,
CLIENT_SYSTEM_INFO,
CLIENT_MAPPER_VERSION,
CLIENT_APP_VERSION_UPGRADE_RESULT
CLIENT_APP_VERSION_UPGRADE_RESULT,
CLIENT_PUSH_API_ACTIVITY_LOG
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.consoleconnect.kraken.operator.sync.service.push;

import static com.consoleconnect.kraken.operator.core.client.ClientEventTypeEnum.CLIENT_PUSH_API_ACTIVITY_LOG;
import static com.consoleconnect.kraken.operator.core.toolkit.JsonToolkit.fromJson;
import static com.consoleconnect.kraken.operator.core.toolkit.PagingHelper.toPageNoSubList;
import static java.util.Collections.emptyList;

import com.consoleconnect.kraken.operator.core.client.ClientEvent;
import com.consoleconnect.kraken.operator.core.dto.ApiActivityLog;
import com.consoleconnect.kraken.operator.core.dto.ComposedHttpRequest;
import com.consoleconnect.kraken.operator.core.entity.AbstractHttpEntity;
Expand All @@ -16,6 +18,7 @@
import com.consoleconnect.kraken.operator.core.model.HttpResponse;
import com.consoleconnect.kraken.operator.core.repo.ApiActivityLogRepository;
import com.consoleconnect.kraken.operator.core.repo.MgmtEventRepository;
import com.consoleconnect.kraken.operator.core.toolkit.AssetsConstants;
import com.consoleconnect.kraken.operator.sync.model.SyncProperty;
import com.consoleconnect.kraken.operator.sync.service.KrakenServerConnector;
import jakarta.persistence.criteria.CriteriaBuilder;
Expand All @@ -36,6 +39,7 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpMethod;
import org.springframework.scheduling.annotation.Scheduled;
Expand Down Expand Up @@ -111,7 +115,9 @@ private List<PushExternalSystemPayload> pushLogsInBatches(
while (true) {
var pageable =
PageRequest.of(
page, getAppProperty().getControlPlane().getPushActivityLogExternal().getBatchSize());
page,
getAppProperty().getControlPlane().getPushActivityLogExternal().getBatchSize(),
Sort.by(Sort.Direction.DESC, AssetsConstants.FIELD_CREATE_AT));
var entities = getApiActivityLogRequestIds(logInfo, pageable);
var composedLogs = getComposedHttpRequests(entities.get());
if (composedLogs.isEmpty()) {
Expand All @@ -129,7 +135,9 @@ private List<PushExternalSystemPayload> pushLogsInBatches(
entities.getNumber(),
entities.getSize(),
entities.getTotalElements()));
var res = sendLogsToExternalSystem(payload);
var res =
sendLogsToExternalSystem(
ClientEvent.of(CLIENT_ID, CLIENT_PUSH_API_ACTIVITY_LOG, payload));
if (res.getCode() != 200) {
throw new KrakenException(
400, "Pushing logs to external system filed with status: " + res.getCode());
Expand All @@ -140,7 +148,7 @@ private List<PushExternalSystemPayload> pushLogsInBatches(
return sent;
}

private HttpResponse<String> sendLogsToExternalSystem(PushExternalSystemPayload payload) {
private HttpResponse<String> sendLogsToExternalSystem(ClientEvent payload) {
return blockCurl(
HttpMethod.POST, UriBuilder::build, payload, new ParameterizedTypeReference<>() {});
}
Expand Down

0 comments on commit 69996a5

Please sign in to comment.