Skip to content

Commit 6c9baa7

Browse files
Merge pull request #146 from appirio-tech/migrate-groups-api
Migrate V5 groups api
2 parents 8dba16d + 2fb053c commit 6c9baa7

File tree

12 files changed

+486
-621
lines changed

12 files changed

+486
-621
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ workflows:
9494
branches:
9595
only:
9696
- dev
97-
- feature/jira-plat-130
98-
- dev-ecs
97+
9998
- "build-prod":
10099
context : org-global
101100
filters:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.classpath
2-
.project
32
service/dependency-reduced-pom.xml
43
service/run-config/*/target
54
service/target
@@ -10,3 +9,4 @@ service/log
109
*.iml
1110
/target/
1211
.settings
12+
.project

.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,15 @@
2020
<nature>org.eclipse.jdt.core.javanature</nature>
2121
<nature>org.eclipse.m2e.core.maven2Nature</nature>
2222
</natures>
23+
<filteredResources>
24+
<filter>
25+
<id>1650210132504</id>
26+
<name></name>
27+
<type>30</type>
28+
<matcher>
29+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
30+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31+
</matcher>
32+
</filter>
33+
</filteredResources>
2334
</projectDescription>

service/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target/
2+
.idea

service/src/main/java/com/appirio/service/resourcefactory/ReviewOpportunitiesFactory.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.appirio.service.review.manager.ReviewOpportunitiesManager;
66
import com.appirio.service.review.resources.ReviewOpportunitiesResource;
77
import com.appirio.service.review.util.GroupServiceClient;
8-
import com.appirio.service.review.util.ParentGroupServiceClient;
98
import com.appirio.service.supply.resources.ResourceFactory;
109
import com.appirio.supply.DAOFactory;
1110
import com.appirio.supply.SupplyException;
@@ -49,8 +48,12 @@
4948
* </ul>
5049
* </p>
5150
*
51+
* <p>
52+
* Version 1.6 (Topcoder Review Service - Migrate Groups API to V5)
53+
* </p>
54+
*
5255
* @author TCCoder
53-
* @version 1.5
56+
* @version 1.6
5457
*
5558
*/
5659
public class ReviewOpportunitiesFactory implements ResourceFactory<ReviewOpportunitiesResource> {
@@ -60,20 +63,13 @@ public class ReviewOpportunitiesFactory implements ResourceFactory<ReviewOpportu
6063
*/
6164
private final GroupServiceClient groupServiceClient;
6265

63-
/**
64-
* The parent group service client
65-
*/
66-
private final ParentGroupServiceClient parentGroupServiceClient;
67-
6866
/**
6967
* Simple constructor to initialize ReviewOpportunitiesFactory
7068
*
7169
* @param groupServiceClient the groupServiceClient to use
72-
* @param parentGroupServiceClient the parent groupServiceClient to use
7370
*/
74-
public ReviewOpportunitiesFactory(GroupServiceClient groupServiceClient, ParentGroupServiceClient parentGroupServiceClient) {
71+
public ReviewOpportunitiesFactory(GroupServiceClient groupServiceClient) {
7572
this.groupServiceClient = groupServiceClient;
76-
this.parentGroupServiceClient = parentGroupServiceClient;
7773
}
7874

7975
/**
@@ -86,7 +82,7 @@ public ReviewOpportunitiesResource getResourceInstance() throws SupplyException
8682
final ReviewOpportunitiesDAO dao = DAOFactory.getInstance().createDAO(ReviewOpportunitiesDAO.class);
8783
final ChallengeDAO challengeDao = DAOFactory.getInstance().createDAO(ChallengeDAO.class);
8884
final ReviewOpportunitiesManager reviewOpportunitiesManager =
89-
new ReviewOpportunitiesManager(dao, challengeDao, this.groupServiceClient, this.parentGroupServiceClient);
85+
new ReviewOpportunitiesManager(dao, challengeDao, this.groupServiceClient);
9086
return new ReviewOpportunitiesResource(reviewOpportunitiesManager);
9187
}
9288
}

service/src/main/java/com/appirio/service/review/ReviewServiceApplication.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.appirio.service.resourcefactory.ScorecardFactory;
1818
import com.appirio.service.resourcefactory.ScorecardQuestionFactory;
1919
import com.appirio.service.review.util.GroupServiceClient;
20-
import com.appirio.service.review.util.ParentGroupServiceClient;
2120
import com.appirio.service.supply.resources.SupplyDatasourceFactory;
2221

2322
import com.appirio.tech.core.api.v3.dropwizard.APIApplication;
@@ -52,9 +51,13 @@
5251
* </ul>
5352
* </p>
5453
*
54+
* <p>
55+
* Version 1.4 (Topcoder Review Service - Migrate Groups API to V5)
56+
* </p>
57+
*
5558
*
5659
* @author TCDEVELOPER, TCSCODER
57-
* @version 1.3
60+
* @version 1.4
5861
*/
5962
public class ReviewServiceApplication extends BaseApplication<ReviewServiceConfiguration> {
6063
/**
@@ -138,7 +141,6 @@ public String getName() {
138141
protected void prepare(ReviewServiceConfiguration config, Environment env) throws Exception {
139142
configDatabases(config, config.getDatabases(), env);
140143
config.getGroupServiceClientConfig().setEndpoint(getConfigValueFromEnv(ENV_VAR_PATTERN, config.getGroupServiceClientConfig().getEndpoint()));
141-
config.getParentGroupServiceClientConfig().setEndpoint(getConfigValueFromEnv(ENV_VAR_PATTERN, config.getParentGroupServiceClientConfig().getEndpoint()));
142144
}
143145

144146
/**
@@ -156,8 +158,6 @@ protected void logServiceSpecificConfigs(ReviewServiceConfiguration config) {
156158
}
157159
logger.info("\tGroup Service Client Configuration ");
158160
logger.info("\t\tGroup Service Client Endpoint : " + config.getGroupServiceClientConfig().getEndpoint());
159-
logger.info("\tParent Group Service Client Configuration ");
160-
logger.info("\t\tParent Group Service Client Endpoint : " + config.getParentGroupServiceClientConfig().getEndpoint());
161161
logger.info("\r\n");
162162
}
163163

@@ -179,8 +179,7 @@ protected void registerResources(ReviewServiceConfiguration config, Environment
179179
env.jersey().register(new ScorecardQuestionFactory(config, env).getResourceInstance());
180180

181181
GroupServiceClient groupServiceClient = new GroupServiceClient(ClientBuilder.newClient(), config.getGroupServiceClientConfig(), config.getM2mAuthConfiguration());
182-
ParentGroupServiceClient parentGroupServiceClient = new ParentGroupServiceClient(ClientBuilder.newClient(), config.getParentGroupServiceClientConfig(), config.getM2mAuthConfiguration());
183-
env.jersey().register(new ReviewOpportunitiesFactory(groupServiceClient, parentGroupServiceClient).getResourceInstance());
182+
env.jersey().register(new ReviewOpportunitiesFactory(groupServiceClient).getResourceInstance());
184183
}
185184

186185
/**

service/src/main/java/com/appirio/service/review/ReviewServiceConfiguration.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@
2828
* </ul>
2929
* </p>
3030
*
31+
* <p>
32+
* Version 1.3 (Topcoder Review Service - Migrate Groups API to V5)
33+
* </p>
34+
*
3135
* @author TCDEVELOPER, TCSCODER
32-
* @version 1.2
36+
* @version 1.3
3337
*
3438
*/
3539
public class ReviewServiceConfiguration extends BaseAppConfiguration {
@@ -58,14 +62,6 @@ public class ReviewServiceConfiguration extends BaseAppConfiguration {
5862
@JsonProperty("groupServiceClient")
5963
private final BaseClientConfiguration groupServiceClientConfig = new BaseClientConfiguration();
6064

61-
/**
62-
* The parent group service client configuration
63-
*/
64-
@Valid
65-
@NotNull
66-
@JsonProperty("parentGroupServiceClient")
67-
private final BaseClientConfiguration parentGroupServiceClientConfig = new BaseClientConfiguration();
68-
6965
/**
7066
* Get the data source factory
7167
*
@@ -85,15 +81,6 @@ public BaseClientConfiguration getGroupServiceClientConfig() {
8581
return this.groupServiceClientConfig;
8682
}
8783

88-
/**
89-
* Return the sub group service client configuration
90-
*
91-
* @return the sub group service client configuration
92-
*/
93-
public BaseClientConfiguration getParentGroupServiceClientConfig() {
94-
return parentGroupServiceClientConfig;
95-
}
96-
9784
/**
9885
* Get m2m auth configuration
9986
*

service/src/main/java/com/appirio/service/review/manager/ReviewOpportunitiesManager.java

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.appirio.service.review.dao.ChallengeDAO;
1010
import com.appirio.service.review.dao.ReviewOpportunitiesDAO;
1111
import com.appirio.service.review.util.GroupServiceClient;
12-
import com.appirio.service.review.util.ParentGroupServiceClient;
1312
import com.appirio.supply.SupplyException;
1413
import com.appirio.tech.core.api.v3.TCID;
1514
import com.appirio.tech.core.api.v3.request.FieldSelector;
@@ -98,8 +97,12 @@
9897
* - add the support for the design spec review
9998
* </p>
10099
*
100+
* <p>
101+
* Version 1.8 (Topcoder Review Service - Migrate Groups API to V5)
102+
* </p>
103+
*
101104
* @author TCCoder
102-
* @version 1.7
105+
* @version 1.8
103106
*/
104107
public class ReviewOpportunitiesManager {
105108
/**
@@ -242,11 +245,6 @@ public class ReviewOpportunitiesManager {
242245
*/
243246
private final GroupServiceClient groupServiceClient;
244247

245-
/**
246-
* The parent group service client
247-
*/
248-
private final ParentGroupServiceClient parentGroupServiceClient;
249-
250248
private final ChallengeDAO challengeDao;
251249

252250
/**
@@ -255,15 +253,13 @@ public class ReviewOpportunitiesManager {
255253
* @param reviewOpportunitiesDAO the reviewOpportunitiesDAO to use
256254
* @param challengeDao the challengeDao to use
257255
* @param groupServiceClient the groupServiceClient to use
258-
* @param parentGroupServiceClient the parent groupServiceClient to use
259256
* @throws SupplyException if any error occurs
260257
*/
261258
public ReviewOpportunitiesManager(ReviewOpportunitiesDAO reviewOpportunitiesDAO, ChallengeDAO challengeDao,
262-
GroupServiceClient groupServiceClient, ParentGroupServiceClient parentGroupServiceClient) throws SupplyException {
259+
GroupServiceClient groupServiceClient) throws SupplyException {
263260
this.reviewOpportunitiesDAO = reviewOpportunitiesDAO;
264261
this.challengeDao = challengeDao;
265262
this.groupServiceClient = groupServiceClient;
266-
this.parentGroupServiceClient = parentGroupServiceClient;
267263
}
268264

269265
/**
@@ -846,15 +842,7 @@ private Map<Long, Set<Long>> checkUserChallengeEligibility(AuthUser authUser, Li
846842
private Set<Long> getAllGroupIds(long userId) throws SupplyException {
847843
try {
848844
Set<Long> groupIds = groupServiceClient.getGroups(userId);
849-
850-
// get parent groups
851-
Set<Long> allGroupIds = new HashSet<>(groupIds);
852-
for (Long groupId : groupIds) {
853-
Set<Long> parentGroupIds = parentGroupServiceClient.getGroups(groupId);
854-
allGroupIds.addAll(parentGroupIds);
855-
}
856-
857-
return allGroupIds;
845+
return groupIds;
858846
} catch (Exception e) {
859847
throw new SupplyException(e);
860848
}

service/src/main/java/com/appirio/service/review/util/GroupServiceClient.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,10 @@ public Set<Long> getGroups(long userId) throws Exception {
7676
throw new SupplyException("Unable to get groups from the API, the returned status code is: " + response.getStatusInfo().getStatusCode());
7777
}
7878

79-
JsonNode apiResponse = response.readEntity(JsonNode.class);
80-
JsonNode result = apiResponse.path("result");
81-
if (result.path("status").asInt() != HttpStatus.OK_200) {
82-
LOGGER.error("Unable to get groups: {}", apiResponse);
83-
84-
throw new SupplyException("Unable to get groups from the API, the error is: " + result.path("content").asText());
85-
}
86-
87-
JsonNode groups = result.path("content");
79+
JsonNode result = response.readEntity(JsonNode.class);
8880
Set<Long> groupIds = new HashSet<Long>();
89-
for (JsonNode group : groups) {
90-
groupIds.add(group.path("id").asLong());
81+
for (JsonNode group : result) {
82+
groupIds.add(group.asLong());
9183
}
9284

9385
return groupIds;

service/src/main/java/com/appirio/service/review/util/ParentGroupServiceClient.java

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)