Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/localhost #339

Merged
merged 2 commits into from
Dec 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@
import com.arextest.web.model.mapper.WorkspaceMapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.SetUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.MutablePair;
import org.bson.internal.Base64;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -98,17 +110,6 @@
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.SetUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.MutablePair;
import org.bson.internal.Base64;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Slf4j
@Component
Expand All @@ -125,6 +126,10 @@ public class FileSystemService {
private static final String AREX_RECORD_ID = "arex-record-id";
private static final String AREX_REPLAY_PREPARE_DEPENDENCY = "arex_replay_prepare_dependency";
private static final String PINNED_PRE_FIX = "pinned_";
private static final String LOCAL_HOST = "http://127.0.0.1";
private static final String DEFAULT_PORT = "8080";
private static final String HOST_KEY = "host";
private static final String COLON = ":";

@Value("${arex.api.case.inherited}")
private String arexCaseInherited;
Expand Down Expand Up @@ -700,9 +705,6 @@ public ValidInvitationResponseType validInvitation(ValidInvitationRequestType re
}

public FSQueryCaseResponseType queryDebuggingCase(String planId, String recordId) {
if (StringUtils.isBlank(planId)) {
return new FSQueryCaseResponseType();
}
if (StringUtils.isBlank(recordId)) {
return new FSQueryCaseResponseType();
}
Expand All @@ -719,7 +721,17 @@ public FSQueryCaseResponseType queryDebuggingCase(String planId, String recordId
header.setActive(true);
caseDto.getHeaders().add(0, header);

setAddressEndpoint(planId, caseDto.getAddress());
if (StringUtils.isNotEmpty(planId)) {
setAddressEndpoint(planId, caseDto.getAddress());
} else {
String oldHost = caseDto.getHeaders().stream()
.filter(h -> h.getKey().equalsIgnoreCase(HOST_KEY))
.findFirst()
.map(KeyValuePairDto::getValue)
.orElse(null);
String port = oldHost == null ? DEFAULT_PORT : oldHost.split(COLON)[1];
caseDto.getAddress().setEndpoint(contactUrl(LOCAL_HOST + COLON + port, caseDto.getAddress().getEndpoint()));
}

return FSCaseMapper.INSTANCE.contractFromDto(caseDto);
}
Expand Down