Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit e9c4827

Browse files
authored
Merge pull request #305 from deedee/use_challenge_service_v3
use challenge service v3
2 parents c9769ba + 2156633 commit e9c4827

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed

conf/ApplicationServer.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ SSO_HASH_SECRET = @ApplicationServer.SSO_HASH_SECRET@
4646
SSO_DOMAIN = @ApplicationServer.SSO_DOMAIN@
4747

4848
JWT_COOKIE_KEY = @ApplicationServer.JWT_COOKIE_KEY@
49+
JWT_V3_COOKIE_KEY = @ApplicationServer.JWT_V3_COOKIE_KEY@
4950

5051
DIRECT_API_SERVICE_ENDPOINT = @ApplicationServer.DIRECT_API_SERVICE_ENDPOINT@

conf/web/WEB-INF/applicationContext.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,13 +1554,13 @@
15541554

15551555
<bean id="myCreatedChallengesAction"
15561556
class="com.topcoder.direct.services.view.action.my.MyCreatedChallengesAction" scope="prototype">
1557-
<property name="serviceURL" value="/challenges"/>
1557+
<property name="serviceURL" value="@directChallengeServicesApiUrl@"/>
15581558
<property name="userService" ref="userService"/>
15591559
</bean>
15601560

15611561
<bean id="myChallengesAction"
15621562
class="com.topcoder.direct.services.view.action.my.MyChallengesAction" scope="prototype">
1563-
<property name="serviceURL" value="/challenges"/>
1563+
<property name="serviceURL" value="@directChallengeServicesApiUrl@"/>
15641564
</bean>
15651565

15661566
<bean id="xmlPhaseTemplatePersistence"

src/java/main/com/topcoder/direct/services/configs/ServerConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ public class ServerConfiguration extends ApplicationServer {
5555
*
5656
* @since 1.1
5757
*/
58-
public static String JWT_COOOKIE_KEY = bundle.getProperty("JWT_COOOKIE_KEY", "tcjwt");
58+
public static String JWT_COOOKIE_KEY = bundle.getProperty("JWT_COOKIE_KEY", "tcjwt");
5959

6060
/**
6161
* The end point URL of the direct API. The default value is set to empty
6262
*
6363
* @since 1.1
6464
*/
6565
public static String DIRECT_API_SERVICE_ENDPOINT = bundle.getProperty("DIRECT_API_SERVICE_ENDPOINT", "");
66+
67+
public static String JWT_V3_COOKIE_KEY = bundle.getProperty("JWT_V3_COOKIE_KEY", "v3jwt");
6668
}

src/java/main/com/topcoder/direct/services/view/action/ServiceBackendDataTablesAction.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
import org.codehaus.jackson.map.ObjectMapper;
2424

2525
import javax.servlet.http.Cookie;
26+
import java.io.UnsupportedEncodingException;
2627
import java.net.URI;
2728
import java.net.URISyntaxException;
29+
import java.net.URLEncoder;
2830
import java.text.SimpleDateFormat;
2931
import java.util.ArrayList;
3032
import java.util.LinkedHashMap;
@@ -265,23 +267,29 @@ protected void setupFilterPanel() throws Exception {
265267
* @return the built URI.
266268
* @throws URISyntaxException if the syntax is error.
267269
*/
268-
protected URI buildServiceEndPoint(Map<String, String> parameters) throws URISyntaxException {
270+
protected URI buildServiceEndPoint(Map<String, String> parameters) throws URISyntaxException, UnsupportedEncodingException {
269271

270272
int pageSize = getiDisplayLength() == -1 ? MAX_PAGINATION_SIZE : getiDisplayLength();
271273

272274

273-
URIBuilder builder = new URIBuilder();
274-
builder.setScheme("http").setHost(ServerConfiguration.DIRECT_API_SERVICE_ENDPOINT).setPath(getServiceURL())
275-
.setParameter("offset", String.valueOf(getiDisplayStart()))
275+
URIBuilder builder = new URIBuilder(getServiceURL());
276+
277+
builder.setParameter("offset", String.valueOf(getiDisplayStart()))
276278
.setParameter("limit", String.valueOf(pageSize));
277279

280+
String filters = "";
278281
if (parameters != null) {
279282
for (String key : parameters.keySet()) {
280-
builder.setParameter(key, parameters.get(key));
283+
if ("filter".equals(key)) {
284+
filters = URLEncoder.encode(parameters.get(key), "UTF-8");
285+
} else {
286+
builder.setParameter(key, parameters.get(key));
287+
}
281288
}
282289
}
283290

284-
return builder.build();
291+
return new URI(new StringBuilder(builder.build().toString()).append("&filter=").append(filters).toString());
292+
285293
}
286294

287295
/**
@@ -314,7 +322,7 @@ protected JsonNode getJsonResultFromAPI(URI apiEndPoint) throws Exception {
314322
HttpGet getRequest = new HttpGet(apiEndPoint);
315323

316324
Cookie jwtCookie = DirectUtils.getCookieFromRequest(ServletActionContext.getRequest(),
317-
ServerConfiguration.JWT_COOOKIE_KEY);
325+
ServerConfiguration.JWT_V3_COOKIE_KEY);
318326

319327
if (jwtCookie == null) {
320328
throw new Exception("The jwt cookie for the authorized user could not be loaded");

src/java/main/com/topcoder/direct/services/view/action/my/MyCreatedChallengesAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.codehaus.jackson.JsonNode;
1414

1515
import javax.servlet.http.Cookie;
16+
import java.net.URLEncoder;
1617
import java.text.DateFormat;
1718
import java.text.NumberFormat;
1819
import java.text.SimpleDateFormat;
@@ -120,7 +121,6 @@ public String getMyCreatedChallenges() {
120121
} else {
121122
filtersQuery = "creator=" + getUserService().getUserHandle(DirectUtils.getTCSubjectFromSession().getUserId());
122123
}
123-
124124
params.put("filter", filtersQuery);
125125

126126
JsonNode jsonNode = getJsonResultFromAPI(buildServiceEndPoint(params));

token.properties.docker

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@
356356
# Direct API #
357357
#####################################
358358
@ApplicationServer.JWT_COOKIE_KEY@=tcjwt_vm
359+
@ApplicationServer.JWT_V3_COOKIE_KEY@=v3jwt
359360
@ApplicationServer.DIRECT_API_SERVICE_ENDPOINT@= direct.dev.topcoder.com/direct/api/v2/
360361

361362
@memberSearchApiUrl@=https://tc-api.cloud.topcoder.com:8443/v3/members/_suggest/
363+
@directChallengeServicesApiUrl@=http://api.topcoder-dev.com/v3/direct/challenges
364+

token.properties.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@
321321
@ApplicationServer.SSO_DOMAIN@=topcoder.com
322322

323323
@ApplicationServer.JWT_COOKIE_KEY@=tcjwt
324+
@ApplicationServer.JWT_V3_COOKIE_KEY@=v3jwt
324325

325326
@ApplicationServer.DIRECT_API_SERVICE_ENDPOINT@= direct.dev.topcoder.com/direct/api/v2/
326327

@@ -416,3 +417,5 @@
416417
@member.profile.url.base@=http://tc.cloud.topcoder.com
417418

418419
@memberSearchApiUrl@=https://tc-api.cloud.topcoder.com:8443/v3/members/_suggest/
420+
@directChallengeServicesApiUrl@=http://api.topcoder-dev.com/v3/direct/challenges
421+

0 commit comments

Comments
 (0)