Skip to content

Commit

Permalink
Merge pull request #3275 from ControlSystemStudio/CSSTUDIO-2947
Browse files Browse the repository at this point in the history
Support quoted search term in save&restore
  • Loading branch information
georgweiss authored Feb 24, 2025
2 parents c33bb87 + 1a769c4 commit 9065d8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@
import org.phoebus.security.store.SecureStore;
import org.phoebus.security.tokens.AuthenticationScope;
import org.phoebus.security.tokens.ScopedAuthenticationToken;
import org.phoebus.util.http.QueryParamsHelper;

import javax.ws.rs.core.MultivaluedMap;
import java.net.CookieHandler;
import java.net.CookieManager;
import java.net.CookiePolicy;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Base64;
import java.util.List;
Expand Down Expand Up @@ -461,7 +464,7 @@ public CompositeSnapshot updateCompositeSnapshot(CompositeSnapshot compositeSnap
public SearchResult search(MultivaluedMap<String, String> searchParams) {
try {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(Preferences.jmasarServiceUrl + "/search?" + mapToQueryParams(searchParams)))
.uri(URI.create(Preferences.jmasarServiceUrl + "/search?" + QueryParamsHelper.mapToQueryParams(searchParams)))
.header("Content-Type", CONTENT_TYPE_JSON)
.GET()
.build();
Expand Down Expand Up @@ -697,17 +700,4 @@ private HttpResponse<String> getCall(String relativeUrl) {
throw new RuntimeException(e);
}
}

private String mapToQueryParams(MultivaluedMap<String, String> map) {
StringBuilder stringBuilder = new StringBuilder();
map.keySet().forEach(k -> {
List<String> value = map.get(k);
if (value != null && !value.isEmpty()) {
stringBuilder.append(k).append("=");
stringBuilder.append(String.join(",", value));
stringBuilder.append("&");
}
});
return stringBuilder.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,6 @@ protected void updateItem(Node node, boolean empty) {
hitCountProperty, pagination.pageCountProperty()));
pagination.pageCountProperty().bind(pageCountProperty);

query.addListener((observable, oldValue, newValue) -> {
if (newValue == null || newValue.isEmpty()) {
clearSearch();
} else {
search();
}
});

resultTableView.setOnDragDetected(e -> {
List<Node> selectedNodes = resultTableView.getSelectionModel().getSelectedItems();
Expand Down Expand Up @@ -728,6 +721,12 @@ private void updateParametersAndSearch() {
return;
}
query.set(buildQueryString());
if(query.get().isEmpty()){
clearSearch();
}
else{
search();
}
}

/**
Expand Down

0 comments on commit 9065d8a

Please sign in to comment.