Skip to content

Commit de4125a

Browse files
Merge pull request #122 from appirio-tech/dev
Fix group checks
2 parents 3a41568 + e81ac6e commit de4125a

File tree

14 files changed

+709
-222
lines changed

14 files changed

+709
-222
lines changed

.circleci/config.yml

Lines changed: 33 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,27 @@
11
version: 2
2-
jobs:
3-
"build-dev":
2+
3+
# Java image for java project
4+
java_env: &java_env
45
docker:
56
- image: circleci/openjdk:8-jdk
6-
steps:
7-
# Initialization1.
8-
- run: git clone --branch master https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
9-
- checkout
10-
- run:
11-
name: Installation of build dependencies.
12-
command: |
13-
sudo apt install jq
14-
sudo apt install awscli
15-
- run:
16-
name: Configuring maven
17-
command: |
18-
MVNSERVERSETTING='<server>\n <id>tcrepo</id> \n <username>${env.MVNUSERNAME}</username> \n <password>${env.MVNPASSWD}</password> \n </server> '
19-
C=$(echo $MVNSERVERSETTING | sed 's/\//\\\//g')
20-
sudo sed -i.bak "/<\/servers>/ s/.*/${C}\n&/" /opt/apache-maven/conf/settings.xml
21-
MVNSERVERSETTING='<server>\n <id>tcreposnap</id> \n <username>${env.MVNUSERNAME}</username> \n <password>${env.MVNPASSWD}</password> \n </server> '
22-
C=$(echo $MVNSERVERSETTING | sed 's/\//\\\//g')
23-
sudo sed -i.bak "/<\/servers>/ s/.*/${C}\n&/" /opt/apache-maven/conf/settings.xml
24-
- setup_remote_docker
25-
- restore_cache:
26-
key: ap-review-microservice-{{ checksum "~/project/service/pom.xml" }}
27-
- run: mvn -f ~/project/service/pom.xml dependency:go-offline
28-
- save_cache:
29-
paths:
30-
- ~/.m2
31-
key: ap-review-microservice-{{ checksum "~/project/service/pom.xml" }}
32-
- run: mvn -f ~/project/service/pom.xml clean site package
33-
- run:
34-
name: Save test results
7+
8+
install_deploysuite: &install_deploysuite
9+
name: Installation of install_deploysuite.
3510
command: |
36-
mkdir -p ~/junit/
37-
find . -type f -regex ".*/target/site/cobertura/coverage.xml" -exec cp {} ~/junit/ \;
38-
# find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/junit/ \;
39-
when: always
40-
- store_test_results:
41-
path: ~/junit
42-
- store_artifacts:
43-
path: ~/junit
44-
- run: docker --version
45-
- run:
46-
name: Deploy to AWS
47-
command: |
48-
chmod +x /home/circleci/project/service/build/deploy.sh
49-
/home/circleci/project/service/build/deploy.sh /home/circleci/project /home/circleci/project/service/build ap-review dev
11+
git clone --branch v1.3 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
12+
cp ./../buildscript/master_deploy.sh .
13+
cp ./../buildscript/buildenv.sh .
14+
cp ./../buildscript/awsconfiguration.sh .
5015
51-
"build-prod":
52-
docker:
53-
- image: circleci/openjdk:8-jdk
54-
steps:
16+
build_steps: &build_steps
5517
# Initialization1.
56-
- run: git clone --branch master https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
5718
- checkout
19+
- run: *install_deploysuite
5820
- run:
5921
name: Installation of build dependencies.
6022
command: |
6123
sudo apt install jq
62-
sudo apt install awscli
63-
- run:
64-
name: Configuring maven
65-
command: |
66-
MVNSERVERSETTING='<server>\n <id>tcrepo</id> \n <username>${env.MVNUSERNAME}</username> \n <password>${env.MVNPASSWD}</password> \n </server> '
67-
C=$(echo $MVNSERVERSETTING | sed 's/\//\\\//g')
68-
sudo sed -i.bak "/<\/servers>/ s/.*/${C}\n&/" /opt/apache-maven/conf/settings.xml
69-
MVNSERVERSETTING='<server>\n <id>tcreposnap</id> \n <username>${env.MVNUSERNAME}</username> \n <password>${env.MVNPASSWD}</password> \n </server> '
70-
C=$(echo $MVNSERVERSETTING | sed 's/\//\\\//g')
71-
sudo sed -i.bak "/<\/servers>/ s/.*/${C}\n&/" /opt/apache-maven/conf/settings.xml
24+
sudo apt install awscli
7225
- setup_remote_docker
7326
- restore_cache:
7427
key: ap-review-microservice-{{ checksum "~/project/service/pom.xml" }}
@@ -93,19 +46,37 @@ jobs:
9346
- run:
9447
name: Deploy to AWS
9548
command: |
49+
./awsconfiguration.sh $DEPLOY_ENV
50+
source awsenvconf
9651
chmod +x /home/circleci/project/service/build/deploy.sh
97-
/home/circleci/project/service/build/deploy.sh /home/circleci/project /home/circleci/project/service/build ap-review prod
52+
/home/circleci/project/service/build/deploy.sh /home/circleci/project /home/circleci/project/service/build ap-review $DEPLOY_APP_ENV
53+
54+
jobs:
55+
"build-dev":
56+
<<: *java_env
57+
environment:
58+
DEPLOY_APP_ENV: "dev"
59+
DEPLOY_ENV: "DEV"
60+
steps: *build_steps
61+
"build-prod":
62+
<<: *java_env
63+
environment:
64+
DEPLOY_APP_ENV: "prod"
65+
DEPLOY_ENV: "PROD"
66+
steps: *build_steps
9867

9968
workflows:
10069
version: 2
10170
build:
10271
jobs:
10372
# Development builds are executed on "develop" branch only.
10473
- "build-dev":
74+
context : org-global
10575
filters:
10676
branches:
10777
only: dev
10878
- "build-prod":
79+
context : org-global
10980
filters:
11081
branches:
111-
only: master
82+
only: master

local/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ export DW_PW=1nf0rm1x
77
export DW_URL=jdbc:informix-sqli://$IP:2021/common_dw:INFORMIXSERVER=informixoltp_tcp;IFX_LOCK_MODE_WAIT=5;OPTCOMPIND=0;STMT_CACHE=1
88
export TC_JWT_KEY=secret
99
export GROUP_SERVICE_ENDPOINT="http://$IP:8080/v3/groups?memberId=%s&membershipType=User-Group"
10+
export PARENT_GROUP_SERVICE_ENDPOINT="http://$IP:8080/v3/groups/%s/getParentGroup?oneLevel=false"
1011

1112
java -jar ../service/target/review-microservice-*.jar server ../service/src/main/resources/review-service.yaml

service/build/deploy.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ AWS_S3_KEY="services/docker/$IMAGE"
2525
ENV_JAVA_PARAMS=" "
2626
ENV_CONFIG=`echo "$ENV" | tr '[:lower:]' '[:upper:]'`
2727

28-
AWS_REGION=$(eval "echo \$${ENV_CONFIG}_AWS_REGION")
29-
AWS_ACCESS_KEY_ID=$(eval "echo \$${ENV_CONFIG}_AWS_ACCESS_KEY_ID")
30-
AWS_SECRET_ACCESS_KEY=$(eval "echo \$${ENV_CONFIG}_AWS_SECRET_ACCESS_KEY")
28+
# AWS_REGION=$(eval "echo \$${ENV_CONFIG}_AWS_REGION")
29+
# AWS_ACCESS_KEY_ID=$(eval "echo \$${ENV_CONFIG}_AWS_ACCESS_KEY_ID")
30+
# AWS_SECRET_ACCESS_KEY=$(eval "echo \$${ENV_CONFIG}_AWS_SECRET_ACCESS_KEY")
3131

3232
configure_aws_cli() {
3333
aws --version
@@ -38,7 +38,7 @@ configure_aws_cli() {
3838
echo "Configured AWS CLI."
3939
}
4040

41-
configure_aws_cli
41+
# configure_aws_cli
4242

4343
# Elastic Beanstalk Application name
4444
# dev
@@ -110,4 +110,4 @@ aws elasticbeanstalk create-application-version --application-name $APPNAME --ve
110110

111111
echo "Updating EBS with the version $IMAGE \n"
112112
# assumes beanstalk app for this service has already been created and configured
113-
aws elasticbeanstalk update-environment --environment-name $SERVICE-$ENV --version-label $IMAGE
113+
aws elasticbeanstalk update-environment --environment-name $SERVICE-$ENV --version-label $IMAGE

service/pom.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<dropwizard.version>1.0.0</dropwizard.version>
1111
<powermock.version>1.5.4</powermock.version>
1212
<jackson-version>2.7.3</jackson-version>
13-
<core.api.version>4.2.0</core.api.version>
13+
<core.api.version>4.3.1</core.api.version>
1414
<supply-library.version>1.0.20-SNAPSHOT</supply-library.version>
1515
</properties>
1616

@@ -60,6 +60,9 @@
6060
<plugin>
6161
<artifactId>maven-surefire-plugin</artifactId>
6262
<version>2.18.1</version>
63+
<configuration>
64+
<forkCount>0</forkCount>
65+
</configuration>
6366
</plugin>
6467
<plugin>
6568
<groupId>org.apache.maven.plugins</groupId>
@@ -288,7 +291,7 @@
288291
<plugin>
289292
<groupId>org.codehaus.mojo</groupId>
290293
<artifactId>findbugs-maven-plugin</artifactId>
291-
<version>3.0.0</version>
294+
<version>3.0.4</version>
292295
<configuration>
293296
<onlyAnalyze>com.appirio.service.-</onlyAnalyze>
294297
<effort>Max</effort>
@@ -301,7 +304,7 @@
301304
<repositories>
302305
<repository>
303306
<id>tcrepo</id>
304-
<url>s3://tc-mvn-repo/release</url>
307+
<url>http://tc-mvn-repo.s3-website-us-east-1.amazonaws.com/release</url>
305308
<snapshots>
306309
<enabled>false</enabled>
307310
<updatePolicy>always</updatePolicy>
@@ -313,7 +316,7 @@
313316
</repository>
314317
<repository>
315318
<id>tcreposnap</id>
316-
<url>s3://tc-mvn-repo/snapshot</url>
319+
<url>http://tc-mvn-repo.s3-website-us-east-1.amazonaws.com/snapshot</url>
317320
<snapshots>
318321
<enabled>true</enabled>
319322
<updatePolicy>always</updatePolicy>

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
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;
89
import com.appirio.service.supply.resources.ResourceFactory;
910
import com.appirio.supply.DAOFactory;
1011
import com.appirio.supply.SupplyException;
11-
import com.appirio.supply.dataaccess.db.IdGenerator;
1212

1313
/**
1414
* ReviewOpportunitiesFactory is used to create the ReviewOpportunitiesResource
@@ -42,9 +42,15 @@
4242
* </ul>
4343
* </p>
4444
*
45+
* <p>
46+
* Version 1.5 (Topcoder Review Service - Fix Group Checks v1.0)
47+
* <ul>
48+
* <li>Create ReviewOpportunitiesManager with the GroupServiceClient and ParentGroupServiceClient</li>
49+
* </ul>
50+
* </p>
4551
*
4652
* @author TCCoder
47-
* @version 1.4
53+
* @version 1.5
4854
*
4955
*/
5056
public class ReviewOpportunitiesFactory implements ResourceFactory<ReviewOpportunitiesResource> {
@@ -54,13 +60,20 @@ public class ReviewOpportunitiesFactory implements ResourceFactory<ReviewOpportu
5460
*/
5561
private final GroupServiceClient groupServiceClient;
5662

63+
/**
64+
* The parent group service client
65+
*/
66+
private final ParentGroupServiceClient parentGroupServiceClient;
67+
5768
/**
5869
* Simple constructor to initialize ReviewOpportunitiesFactory
5970
*
6071
* @param groupServiceClient the groupServiceClient to use
72+
* @param parentGroupServiceClient the parent groupServiceClient to use
6173
*/
62-
public ReviewOpportunitiesFactory(GroupServiceClient groupServiceClient) {
74+
public ReviewOpportunitiesFactory(GroupServiceClient groupServiceClient, ParentGroupServiceClient parentGroupServiceClient) {
6375
this.groupServiceClient = groupServiceClient;
76+
this.parentGroupServiceClient = parentGroupServiceClient;
6477
}
6578

6679
/**
@@ -73,7 +86,7 @@ public ReviewOpportunitiesResource getResourceInstance() throws SupplyException
7386
final ReviewOpportunitiesDAO dao = DAOFactory.getInstance().createDAO(ReviewOpportunitiesDAO.class);
7487
final ChallengeDAO challengeDao = DAOFactory.getInstance().createDAO(ChallengeDAO.class);
7588
final ReviewOpportunitiesManager reviewOpportunitiesManager =
76-
new ReviewOpportunitiesManager(dao, challengeDao, this.groupServiceClient);
89+
new ReviewOpportunitiesManager(dao, challengeDao, this.groupServiceClient, this.parentGroupServiceClient);
7790
return new ReviewOpportunitiesResource(reviewOpportunitiesManager);
7891
}
7992
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.appirio.service.review;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
import javax.validation.constraints.NotNull;
7+
8+
/**
9+
* The M2mAuthConfiguration is for configuration.
10+
*
11+
* Version 1.0 (Topcoder Review Service - Fix Group Checks v1.0)
12+
*
13+
* @author TCCoder
14+
* @version 1.0
15+
*/
16+
public class M2mAuthConfiguration {
17+
/**
18+
* The client id.
19+
*/
20+
@JsonProperty
21+
@NotNull
22+
@Getter
23+
@Setter
24+
private String clientId;
25+
26+
/**
27+
* The client secret.
28+
*/
29+
@JsonProperty
30+
@NotNull
31+
@Getter
32+
@Setter
33+
private String clientSecret;
34+
35+
/**
36+
* The audience.
37+
*/
38+
@JsonProperty
39+
@NotNull
40+
@Getter
41+
@Setter
42+
private String audience;
43+
44+
/**
45+
* The auth domain.
46+
*/
47+
@JsonProperty
48+
@NotNull
49+
@Getter
50+
@Setter
51+
private String m2mAuthDomain;
52+
53+
/**
54+
* The token expire time in minutes.
55+
*/
56+
@JsonProperty
57+
@NotNull
58+
@Getter
59+
@Setter
60+
private Integer tokenExpireTimeInMinutes;
61+
62+
/**
63+
* The user id.
64+
*/
65+
@JsonProperty
66+
@NotNull
67+
@Getter
68+
@Setter
69+
private Long userId;
70+
}

0 commit comments

Comments
 (0)