forked from Sunbird-Lern/certificate-registry
-
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.
Issue# SB-18727 feat:merging release-1.2.0 to master (Sunbird-Lern#36)
- Loading branch information
AMIT KUMAR
authored
Apr 6, 2020
1 parent
fd04b1b
commit 3c8a777
Showing
78 changed files
with
5,461 additions
and
557 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
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
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 was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
all-actors/src/main/java/org/sunbird/actor/CertBackgroundActor.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,67 @@ | ||
package org.sunbird.actor; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.sunbird.BaseActor; | ||
import org.sunbird.BaseException; | ||
import org.sunbird.JsonKeys; | ||
import org.sunbird.actor.core.ActorConfig; | ||
import org.sunbird.cassandra.CassandraOperation; | ||
import org.sunbird.common.ElasticSearchHelper; | ||
import org.sunbird.common.factory.EsClientFactory; | ||
import org.sunbird.common.inf.ElasticSearchService; | ||
import org.sunbird.helper.ServiceFactory; | ||
import org.sunbird.request.Request; | ||
|
||
import java.util.Map; | ||
|
||
@ActorConfig( | ||
tasks = {"add_cert_es","delete_cert_cassandra"}, | ||
dispatcher = "", | ||
asyncTasks = {} | ||
) | ||
public class CertBackgroundActor extends BaseActor { | ||
static Logger logger = Logger.getLogger(CertBackgroundActor.class); | ||
private ElasticSearchService elasticSearchService = getESService(); | ||
private CassandraOperation cassandraOperation = getCassandraOperation(); | ||
private static CassandraOperation getCassandraOperation(){ | ||
return ServiceFactory.getInstance(); | ||
} | ||
|
||
private static ElasticSearchService getESService(){ | ||
return EsClientFactory.getInstance(); | ||
} | ||
@Override | ||
public void onReceive(Request request) throws Throwable { | ||
logger.info("CertificationActor:onReceive:request arrived with operation" + request.getOperation()); | ||
String operation = request.getOperation(); | ||
switch (operation) { | ||
case "add_cert_es": | ||
add(request); | ||
break; | ||
|
||
case "delete_cert_cassandra": | ||
delete(request); | ||
break; | ||
|
||
default: | ||
onReceiveUnsupportedMessage("CertificationActor"); | ||
} | ||
} | ||
|
||
private void delete(Request request) throws BaseException { | ||
String id = (String) request.getRequest().get(JsonKeys.ID); | ||
try { | ||
cassandraOperation.deleteRecord(JsonKeys.SUNBIRD, JsonKeys.CERT_REGISTRY, id); | ||
logger.info("Data deleted from cassandra for id " + id); | ||
}catch (Exception ex){ | ||
logger.error("Exception occurred while deleting data from cert_registry for id : "+id,ex); | ||
} | ||
} | ||
|
||
|
||
private void add(Request request) { | ||
Map<String,Object> certAddReqMap = (Map<String, Object>) request.getRequest().get(JsonKeys.REQUEST); | ||
String id = (String)ElasticSearchHelper.getResponseFromFuture(elasticSearchService.save(JsonKeys.CERT_ALIAS,(String)certAddReqMap.get(JsonKeys.ID),certAddReqMap)); | ||
logger.info("ES save response for id "+id); | ||
} | ||
} |
Oops, something went wrong.