Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification setting #247

Open
wants to merge 54 commits into
base: main
Choose a base branch
from
Open
Changes from 7 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
d58d604
RC-Synch
kumarpawantarento Aug 8, 2023
07a50f0
Update SunbirdRCApplication.java
kumarpawantarento Aug 8, 2023
a80f8c6
Update SunbirdRCApplication.java
kumarpawantarento Aug 8, 2023
2f6db6a
schema updates
kumarpawantarento Aug 9, 2023
5131363
cors issue
kumarpawantarento Aug 9, 2023
5c3a6a8
feeRecipt
kumarpawantarento Aug 9, 2023
a173d8e
cors filter removal
kumarpawantarento Aug 9, 2023
817f318
cors config
kumarpawantarento Aug 9, 2023
d62bf3a
multifiles upload and single files upload
kumarpawantarento Aug 10, 2023
c245ca6
schema updates
kumarpawantarento Aug 10, 2023
795aa89
XXX
kumarpawantarento Aug 10, 2023
7fe9e28
json updates
kumarpawantarento Aug 10, 2023
454a1ef
json change
kumarpawantarento Aug 10, 2023
60a6018
cors issue
kumarpawantarento Aug 10, 2023
7809c2e
claim-ms
kumarpawantarento Aug 14, 2023
fd31bc3
json correction
kumarpawantarento Aug 15, 2023
0252ce4
json fix
kumarpawantarento Aug 16, 2023
1e56ca8
mail integration upto pending item
rahu-tarento Aug 16, 2023
21e8169
Mail integration up-to pending Item
rahu-tarento Aug 16, 2023
12ca11d
Merge and resolve conflict
rahu-tarento Aug 16, 2023
3f24085
Added new feature to persist user credential through API
rahu-tarento Aug 16, 2023
2be20ed
Merge pull request #1 from kumarpawantarento/rahu_um_new
kumarpawantarento Aug 18, 2023
18fb1e7
digilocker implementation
kumarpawantarento Aug 18, 2023
f01aaac
credType updates
kumarpawantarento Aug 21, 2023
bb3acf3
course api
kumarpawantarento Aug 22, 2023
2a54322
Sending pending item mail to foreign council Regulator through cron job
rahu-tarento Aug 22, 2023
d87612f
Merge and conflict resolved. Removed unused snippet from claim
rahu-tarento Aug 22, 2023
037b69a
student verification
kumarpawantarento Aug 22, 2023
d36344d
Cred Type addition in pending action item.
rahu-tarento Aug 22, 2023
9f2d016
review changes
kumarpawantarento Aug 22, 2023
abc8a4c
Support direct call for send OTP and User creation mail.
rahu-tarento Aug 22, 2023
dceba4c
Merge pull request #2 from kumarpawantarento/rahu_um_new
kumarpawantarento Aug 22, 2023
54b2a9c
diploma change
kumarpawantarento Aug 22, 2023
0bb5e79
Merge branch 'main' into rahu_mail_integration
rahu-tarento Aug 22, 2023
3724775
Send manual pending action item for foreign student
rahu-tarento Aug 23, 2023
78027dd
Merge pull request #3 from kumarpawantarento/rahu_mail_integration
kumarpawantarento Aug 23, 2023
3b0e50e
claim get course
kumarpawantarento Aug 23, 2023
5d3871f
outside up
kumarpawantarento Aug 23, 2023
209b370
certificate number
kumarpawantarento Aug 24, 2023
ac1bf0c
Verify link with candidate details and approval. Manual mail send to …
rahu-tarento Aug 24, 2023
9e615f7
Merge branch 'main' into rahu_verify_mail
rahu-tarento Aug 24, 2023
dac0e30
Merge pull request #4 from kumarpawantarento/rahu_verify_mail
kumarpawantarento Aug 24, 2023
304b97d
api request
kumarpawantarento Aug 24, 2023
59e8dad
Merge branch 'main' of https://github.com/kumarpawantarento/sunbird-r…
kumarpawantarento Aug 24, 2023
9ab9959
api request
kumarpawantarento Aug 24, 2023
818b699
updates
kumarpawantarento Aug 25, 2023
14927e9
adding user represtation and role representation details to auth tok…
mahesh-maney Aug 27, 2023
ff682aa
outside up fix
kumarpawantarento Aug 29, 2023
84f75d7
Auto mail for foreign, outside, from up and good standing candidate. …
rahu-tarento Aug 29, 2023
e1e78e2
Merge branch 'main' into rahu_auto_manual_mail
rahu-tarento Aug 29, 2023
0052168
Merge pull request #5 from kumarpawantarento/rahu_auto_manual_mail
kumarpawantarento Aug 29, 2023
cf7d3a4
notifications setting
kumarpawantarento Aug 29, 2023
487997a
notification change
kumarpawantarento Aug 29, 2023
ce6e36a
Send mail notification with default password while calling candidate …
rahu-tarento Aug 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ public class AttributeNames {
public static final String ENTITY = "ENTITY";
public static final String LOWERCASE_ENTITY = "entity";;
public static final String ATTESTOR_INFO = "attestorInfo";

public static final String REQUESTOR_INFO = "reguestorInfo";
public static final String CONTENT = "content";
public static final String TOTAL_PAGES = "totalPages";
public static final String TOTAL_ELEMENTS = "totalElements";
Original file line number Diff line number Diff line change
@@ -17,11 +17,11 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.Optional;

import static dev.sunbirdrc.claim.contants.AttributeNames.ATTESTOR_INFO;
import static dev.sunbirdrc.claim.contants.AttributeNames.LOWERCASE_ENTITY;
import static dev.sunbirdrc.claim.contants.AttributeNames.*;

@Controller
public class ClaimsController {
@@ -45,6 +45,15 @@ public ResponseEntity<Map<String, Object>> getClaims(@RequestHeader HttpHeaders
return new ResponseEntity<>(claims, HttpStatus.OK);
}


@RequestMapping(value = "/api/v2/getClaims", method = RequestMethod.POST)
public ResponseEntity<List<Claim>> getStudentClaims(@RequestHeader HttpHeaders headers,
@RequestBody JsonNode requestBody, Pageable pageable) {
String entity = requestBody.get(LOWERCASE_ENTITY).asText();
JsonNode attestorNode = requestBody.get(ATTESTOR_INFO);
List<Claim> claims = claimService.findByRequestorName(attestorNode.asText(), pageable);
return new ResponseEntity<>(claims, HttpStatus.OK);
}
@RequestMapping(value = "/api/v1/getClaims/{claimId}", method = RequestMethod.POST)
public ResponseEntity<ClaimWithNotesDTO> getClaimById(@RequestHeader HttpHeaders headers, @PathVariable String claimId,
@RequestBody JsonNode requestBody) {
Original file line number Diff line number Diff line change
@@ -11,4 +11,6 @@ public interface ClaimRepository extends JpaRepository<Claim, String> {
List<Claim> findByConditionsIn(List<String> conditions);
List<Claim> findByAttestorEntityIn(List<String> entities);
List<Claim> findByAttestorEntity(String entity);

List<Claim> findByRequestorName(String requestorName);
}
Original file line number Diff line number Diff line change
@@ -63,6 +63,14 @@ public Map<String, Object> findClaimsForAttestor(String entity, JsonNode attesto
return toMap(claimsToAttestor, pageable);
}

public List<Claim> findByRequestorName(String entity, Pageable pageable) {
List<Claim> claims = claimRepository.findByRequestorName(entity);
logger.info("Found {} claims to process", claims.size());
List<Claim> claimsRequestor = claims.stream()
.collect(Collectors.toList());
return claimsRequestor;
}

private Map<String, Object> toMap(List<Claim> claims, Pageable pageable) {
Map<String, Object> response = new HashMap<>();
response.put(TOTAL_PAGES, (int)(Math.ceil(claims.size() * 1.0/pageable.getPageSize())));
12 changes: 6 additions & 6 deletions java/claim/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
server.port=8082

spring.datasource.url=${connectionInfo_uri:jdbc:postgresql://localhost:5432/registry5}
spring.datasource.url=${connectionInfo_uri:jdbc:postgresql://localhost:5432/registry}
spring.datasource.username=${connectionInfo_username:postgres}
spring.datasource.password=${connectionInfo_password:postgres}

@@ -9,11 +9,11 @@ spring.jpa.hibernate.ddl-auto=update

spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
sunbirdrc.url=${sunbirdrc_url:http://localhost:8081}
spring.mail.host=smtp.gmail.com
spring.mail.port=465
spring.mail.username=upsmf.otp@upsmfac.org
spring.mail.password=OTP22023##
spring.mail.properties.mail.smtp.ssl.enable = true
spring.mail.host=smtp.sendgrid.net
spring.mail.port=587
spring.mail.username=apikey

spring.mail.password=


# Other properties
Original file line number Diff line number Diff line change
@@ -51,8 +51,8 @@ public static ApplicationContext getAppContext() {
return context;
}

// @Value("${cors.allowedOrigin}")
// public String corsAllowedOrigin;
@Value("${cors.allowedOrigin}")
public String corsAllowedOrigin;

@Bean
public FilterRegistrationBean corsFilter() {
@@ -61,17 +61,17 @@ public FilterRegistrationBean corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
//config.setAllowCredentials(true);
// config.addAllowedOrigin(corsAllowedOrigin);
config.addAllowedOrigin(corsAllowedOrigin);
config.addAllowedOrigin("*");
// config.setAllowedOrigins(list);
// config.addAllowedHeader("*");
// config.addAllowedMethod("POST");
// config.addAllowedMethod("DELETE");
// config.addAllowedMethod("GET");
// config.addAllowedMethod("OPTIONS");
// config.addAllowedMethod("PUT");
// source.registerCorsConfiguration("/**", config);
FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
config.setAllowedOrigins(list);
config.addAllowedHeader("*");
config.addAllowedMethod("POST");
config.addAllowedMethod("DELETE");
config.addAllowedMethod("GET");
config.addAllowedMethod("OPTIONS");
config.addAllowedMethod("PUT");
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
bean.setOrder(0);
return bean;
}
Original file line number Diff line number Diff line change
@@ -57,6 +57,22 @@ public ResponseEntity<Object> getAllClaims(@PathVariable String entityName, Page
}
}


@RequestMapping(value = "/api/v2/{entityName}/claims", method = RequestMethod.GET)
public ResponseEntity<Object> getStudentsClaims(@PathVariable String entityName, Pageable pageable,
HttpServletRequest request) {
try {
JsonNode result = registryHelper.getRequestedUserDetails(request, entityName);
JsonNode claims = claimRequestClient.getStudentsClaims(result.get(entityName).get(0).get("email"), pageable, entityName);
logger.info("Received {} claims", claims.size());
return new ResponseEntity<>(claims, HttpStatus.OK);
} catch (Exception e) {
logger.error("Fetching claims failed {}", e.getMessage());
e.printStackTrace();
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}

@RequestMapping(value = "/api/v1/{entityName}/claims/{claimId}", method = RequestMethod.GET)
public ResponseEntity<Object> getClaim(@PathVariable String entityName, @PathVariable String claimId,
HttpServletRequest request) {
Original file line number Diff line number Diff line change
@@ -448,7 +448,8 @@ private JsonNode getAttestationNode(String attestationId, JsonNode node) {
JsonNode attestationNode = null;
while (iterator.hasNext()) {
attestationNode = iterator.next();
if (attestationNode.get(uuidPropertyName).toString().equals(attestationId)) {
JsonNode jsonNode = attestationNode.get(uuidPropertyName);
if (jsonNode!=null && jsonNode.toString().equals(attestationId)) {
break;
}
}
@@ -494,7 +495,7 @@ public ResponseEntity<Object> getUserDetails(
try {
checkEntityNameInDefinitionManager(entityName);
ArrayList<String> fields = getConsentFields(request);
JsonNode userInfoFromRegistry = registryHelper.getRequestedUserDetailsSearch(request, entityName);
JsonNode userInfoFromRegistry = registryHelper.getRequestedUserDetails(request, entityName);
JsonNode jsonNode = userInfoFromRegistry.get(entityName);
if (jsonNode instanceof ArrayNode) {
ArrayNode values = (ArrayNode) jsonNode;
@@ -572,11 +573,11 @@ public ResponseEntity<Object> getEntityType(@PathVariable String entityName,
JsonNode node = registryHelper.readEntity(readerUserId, entityName, entityId, false,
viewTemplateManager.getViewTemplateById(viewTemplateId), false)
.get(entityName);
JsonNode signedNode = objectMapper.readTree(node.get(OSSystemFields._osSignedData.name()).asText());
// JsonNode signedNode = objectMapper.readTree(node.get(OSSystemFields._osSignedData.name()).asText());

String templateUrlFromRequest = getTemplateUrlFromRequest(request, entityName);

return new ResponseEntity<>(certificateService.getCertificate(signedNode,
return new ResponseEntity<>(certificateService.getCertificate(node,
entityName,
entityId,
request.getHeader(HttpHeaders.ACCEPT),
@@ -727,6 +728,13 @@ public ResponseEntity<Object> getEntityByToken(@PathVariable String entityName,
@RequestHeader(required = false) String viewTemplateId) throws RecordNotFoundException {
ResponseParams responseParams = new ResponseParams();
Response response = new Response(Response.API_ID.GET, "OK", responseParams);
ResponseEntity<Object> objectResponseEntity = getObjectResponseEntity(entityName, request, viewTemplateId, responseParams, response);
return objectResponseEntity;
}


@NotNull
private ResponseEntity<Object> getObjectResponseEntity(String entityName, HttpServletRequest request, String viewTemplateId, ResponseParams responseParams, Response response) {
try {
checkEntityNameInDefinitionManager(entityName);
String userId = registryHelper.getUserId(request, entityName);
@@ -746,7 +754,7 @@ public ResponseEntity<Object> getEntityByToken(@PathVariable String entityName,
return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
}
} catch (RecordNotFoundException e) {
createSchemaNotFoundResponse(e.getMessage(),responseParams);
createSchemaNotFoundResponse(e.getMessage(), responseParams);
response = new Response(Response.API_ID.GET, "ERROR", responseParams);
return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
} catch (Exception e) {
@@ -981,7 +989,18 @@ public ResponseEntity<Object> revokeACredential (
return new ResponseEntity<>(response,HttpStatus.INTERNAL_SERVER_ERROR);
}
}

@Nullable
private JsonNode getAttestationNode1(String attestationId, JsonNode node) {
Iterator<JsonNode> iterator = node.iterator();
JsonNode attestationNode = null;
while (iterator.hasNext()) {
attestationNode = iterator.next();
if (attestationNode.get(uuidPropertyName).toString().equals(attestationId)) {
break;
}
}
return attestationNode;
}
/**
* PULL-URI-Request API for DigiLocker
* @param request
@@ -1016,20 +1035,33 @@ public ResponseEntity<Object> issueCertificateToDigiLocker(HttpServletRequest re
Response response = new Response(Response.API_ID.SEARCH, "OK", responseParams);
String osid = null;
JsonNode result = null;
try {
result = registryHelper.getRequestedUserDetailsCustom(request, entityName, xmlString);
if (result != null && result.get(entityName) != null && result.get(entityName).size() > 0) {
ArrayNode responseFromDb = registryHelper.fetchFromDBUsingEsResponse(entityName, (ArrayNode) result.get(entityName));
if(responseFromDb!=null && responseFromDb.size() > 0){
osid = responseFromDb.get(0).get("osid").asText();
}
}
try{
String userId = registryHelper.getUserId(request, entityName);
JsonNode responseFromDb = registryHelper.searchEntitiesByUserId(entityName, userId, null);
JsonNode entities = responseFromDb.get(entityName);
} catch (Exception e) {
statusCode = "0";
e.printStackTrace();
return new ResponseEntity<>(statusCode, HttpStatus.INTERNAL_SERVER_ERROR);
}


// ResponseEntity<Object> objectResponseEntity = getObjectResponseEntity(entityName, request, null, responseParams, response);

// try {
// result = registryHelper.getRequestedUserDetailsCustom(request, entityName, xmlString);
// if (result != null && result.get(entityName) != null && result.get(entityName).size() > 0) {
// ArrayNode responseFromDb = registryHelper.fetchFromDBUsingEsResponse(entityName, (ArrayNode) result.get(entityName));
// if(responseFromDb!=null && responseFromDb.size() > 0){
// osid = responseFromDb.get(0).get("osid").asText();
// }
// }
// } catch (Exception e) {
// statusCode = "0";
// e.printStackTrace();
// return new ResponseEntity<>(statusCode, HttpStatus.INTERNAL_SERVER_ERROR);
// }

if(osid!=null) {
try {
String readerUserId = getUserId(entityName, request);
Loading