-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #520 from bcgov/grad-release
Grad release 1.18.0
- Loading branch information
Showing
18 changed files
with
394 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/DistrictTrax.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package ca.bc.gov.educ.api.graduation.model.dto; | ||
|
||
import lombok.Data; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Data | ||
@Component | ||
public class DistrictTrax { | ||
|
||
private String districtNumber; | ||
private String districtName; | ||
private String districtSeq; | ||
private String schoolETPSystem; | ||
private String superIntendent; | ||
private String djdeFlash; | ||
private String activeFlag; | ||
private String address1; | ||
private String address2; | ||
private String city; | ||
private String provCode; | ||
private String countryCode; | ||
private String postal; | ||
|
||
public String getDistrictName() { | ||
return districtName != null ? districtName.trim(): null; | ||
} | ||
|
||
public String getDistrictSeq() { return districtSeq != null ? districtSeq.trim(): null; } | ||
|
||
public String getSchoolETPSystem() { return schoolETPSystem != null ? schoolETPSystem.trim(): null; } | ||
|
||
public String getSuperIntendent() {return superIntendent != null ? superIntendent.trim(): null;} | ||
|
||
public String getDjdeFlash() { return djdeFlash != null ? djdeFlash.trim(): null; } | ||
|
||
public String getActiveFlag() { return activeFlag != null ? activeFlag.trim(): null; } | ||
|
||
public String getAddress1() { return address1 != null ? address1.trim(): null; } | ||
|
||
public String getAddress2() { return address2 != null ? address2.trim(): null; } | ||
|
||
public String getCity() { return postal != null ? city.trim(): null; } | ||
|
||
public String getPostal() { return postal != null ? postal.trim(): null; } | ||
|
||
@Override | ||
public String toString() { | ||
return "District [districtNumber=" + districtNumber + ", districtName=" + districtName + ", districtSeq=" | ||
+ districtSeq + ", schoolETPSystem=" + schoolETPSystem + ", superIntendent=" + superIntendent | ||
+ ", djdeFlash=" + djdeFlash + ", activeFlag=" + activeFlag + ", address1=" + address1 + ", address2=" | ||
+ address2 + ", city=" + city + ", provCode=" + provCode + ", countryCode=" + countryCode + ", postal=" | ||
+ postal + "]"; | ||
} | ||
|
||
|
||
} | ||
|
42 changes: 42 additions & 0 deletions
42
api/src/main/java/ca/bc/gov/educ/api/graduation/model/dto/ResponseObjCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ca.bc.gov.educ.api.graduation.model.dto; | ||
|
||
import org.json.JSONObject; | ||
|
||
import java.util.Base64; | ||
|
||
public class ResponseObjCache { | ||
|
||
private long tokenExpiry = 0; | ||
private ResponseObj responseObj; | ||
|
||
// tokenExpiry-[seconds] provides a slight offset, if token WILL expire in | ||
// [seconds], obtain a new one | ||
private int offset; | ||
|
||
public ResponseObjCache(int offset) { | ||
this.offset = offset; | ||
} | ||
|
||
public ResponseObj getResponseObj() { | ||
return responseObj; | ||
} | ||
|
||
public void setResponseObj(ResponseObj responseObj) { | ||
this.setTokenExpiry(responseObj); | ||
this.responseObj = responseObj; | ||
} | ||
|
||
public boolean isExpired(){ | ||
// tokenExpiry-[seconds] provides a slight offset, if token WILL expire in | ||
// 10 seconds, obtain a new one | ||
return (responseObj == null) || (tokenExpiry-offset) < (System.currentTimeMillis() / 1000); | ||
} | ||
|
||
private void setTokenExpiry(ResponseObj responseObj){ | ||
String[] parts = responseObj.getAccess_token().split("\\."); | ||
JSONObject payload = new JSONObject(new String(Base64.getUrlDecoder().decode(parts[1]))); | ||
this.tokenExpiry = payload.getLong("exp"); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 21 additions & 2 deletions
23
api/src/main/java/ca/bc/gov/educ/api/graduation/service/SchoolService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,44 @@ | ||
package ca.bc.gov.educ.api.graduation.service; | ||
|
||
import ca.bc.gov.educ.api.graduation.model.dto.DistrictTrax; | ||
import ca.bc.gov.educ.api.graduation.model.dto.ExceptionMessage; | ||
import ca.bc.gov.educ.api.graduation.model.dto.SchoolTrax; | ||
import ca.bc.gov.educ.api.graduation.util.EducGraduationApiConstants; | ||
import ca.bc.gov.educ.api.graduation.util.TokenUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class SchoolService { | ||
EducGraduationApiConstants educGraduationApiConstants; | ||
RESTService restService; | ||
TokenUtils tokenUtils; | ||
|
||
@Autowired | ||
public SchoolService(EducGraduationApiConstants educGraduationApiConstants, RESTService restService) { | ||
public SchoolService(EducGraduationApiConstants educGraduationApiConstants, RESTService restService, TokenUtils tokenUtils) { | ||
this.educGraduationApiConstants = educGraduationApiConstants; | ||
this.restService = restService; | ||
this.tokenUtils = tokenUtils; | ||
} | ||
|
||
public SchoolTrax getSchoolDetails(String mincode, String accessToken, ExceptionMessage message) { | ||
public SchoolTrax getTraxSchoolDetails(String mincode, String accessToken, ExceptionMessage message) { | ||
return this.restService.get(String.format(educGraduationApiConstants.getSchoolDetails(),mincode, accessToken), | ||
SchoolTrax.class, | ||
accessToken); | ||
} | ||
|
||
public SchoolTrax getTraxSchoolDetails(String mincode) { | ||
String accessToken = tokenUtils.getAccessToken(); | ||
return this.restService.get(String.format(educGraduationApiConstants.getSchoolDetails(),mincode, accessToken), | ||
SchoolTrax.class, | ||
accessToken); | ||
} | ||
|
||
public DistrictTrax getTraxDistrictDetails(String districtCode) { | ||
String accessToken = tokenUtils.getAccessToken(); | ||
return this.restService.get(String.format(educGraduationApiConstants.getDistrictDetails(), districtCode, accessToken), | ||
DistrictTrax.class, | ||
accessToken); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.