Skip to content

Commit

Permalink
fix headers and body of site-session request
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorin Bogdan committed Aug 4, 2023
1 parent c792df1 commit de19ac3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/main/java/com/adm/utils/uft/sdk/RunManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
import com.adm.utils.uft.sdk.handler.PollHandlerFactory;
import com.adm.utils.uft.sdk.handler.RunHandler;
import com.adm.utils.uft.sdk.handler.RunHandlerFactory;
import com.microfocus.adm.performancecenter.plugins.common.rest.RESTConstants;

import java.util.HashMap;
import java.util.Map;

public class RunManager {
private RunHandler _runHandler;
Expand Down Expand Up @@ -78,19 +82,27 @@ private void initialize(Args args, RestClient client) {
}

private void appendQCSessionCookies(RestClient client) {
Map<String, String> headers = new HashMap<String, String>();
headers.put(RESTConstants.CONTENT_TYPE, RESTConstants.APP_XML);
headers.put(RESTConstants.ACCEPT, RESTConstants.APP_XML);

// issue a post request so that cookies relevant to the QC Session will be added to the RestClient
Response response =
client.httpPost(
client.build("rest/site-session"),
null,
null,
generateClientTypeData(),
headers,
ResourceAccessLevel.PUBLIC);
if (!response.isOk()) {
throw new SSEException("Cannot appned QCSession cookies", response.getFailure());
throw new SSEException("Cannot append QCSession cookies", response.getFailure());
}
}

private byte[] generateClientTypeData() {
String data = String.format("<session-parameters><client-type>%s</client-type></session-parameters>", CLIENT_TYPE);
return data.getBytes();
}

private boolean poll() throws InterruptedException {

return _pollHandler.poll(_logger);
Expand Down

0 comments on commit de19ac3

Please sign in to comment.