Skip to content

Commit

Permalink
Merge branch 'beta-dev' of https://github.com/ekstep/sunbird-mw into …
Browse files Browse the repository at this point in the history
…beta
  • Loading branch information
manzarul.haque committed Jul 10, 2017
2 parents c44bb3a + 927f919 commit 3b4b4f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ private void getPageData(Request actorMessage) {
String orgCode = (String) req.get(JsonKey.ORG_CODE);
List<Map<String, Object>> result = null;
try{
if(!ProjectUtil.isStringNullOREmpty(orgCode)){
response = cassandraOperation.getRecordsByProperty(orgDbInfo.getKeySpace(), orgDbInfo.getTableName(), JsonKey.ORG_CODE, orgCode);
result = (List<Map<String, Object>>) response.getResult().get(JsonKey.RESPONSE);
}
}catch(Exception e){
logger.error(e.getMessage(), e);
}
Expand Down
30 changes: 17 additions & 13 deletions src/main/java/org/sunbird/learner/actors/UserManagementActor.java
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ private void processEducationInfo(Map<String, Object> reqMap, Map<String, Object

@SuppressWarnings("unchecked")
private void checkForEmailAndUserNameUniqueness(Map<String, Object> userMap, DbInfo usrDbInfo) {
String email = (String)userMap.get(JsonKey.EMAIL);
/*String email = (String)userMap.get(JsonKey.EMAIL);
Response resultFrEmail = cassandraOperation.getRecordsByProperty(usrDbInfo.getKeySpace(),usrDbInfo.getTableName(),JsonKey.EMAIL,email);
if(((List<Map<String,Object>>)resultFrEmail.get(JsonKey.RESPONSE)).size() != 0){
Map<String,Object> dbusrMap = ((List<Map<String,Object>>)resultFrEmail.get(JsonKey.RESPONSE)).get(0);
Expand All @@ -487,7 +487,7 @@ private void checkForEmailAndUserNameUniqueness(Map<String, Object> userMap, DbI
sender().tell(exception, self());
return;
}
}
}*/
if(null != userMap.get(JsonKey.USERNAME)){
String userName = (String)userMap.get(JsonKey.USERNAME);
Response resultFruserName = cassandraOperation.getRecordsByProperty(usrDbInfo.getKeySpace(),usrDbInfo.getTableName(),JsonKey.USERNAME,userName);
Expand Down Expand Up @@ -538,20 +538,26 @@ private void createUser(Request actorMessage){
Map<String , Object> userMap=(Map<String, Object>) req.get(JsonKey.USER);

boolean isSSOEnabled = Boolean.valueOf(PropertiesCache.getInstance().getProperty(JsonKey.IS_SSO_ENABLED));
if(null != userMap.get(JsonKey.EMAIL)){

if(!ProjectUtil.isStringNullOREmpty((String)userMap.get(JsonKey.PROVIDER))){
userMap.put(JsonKey.LOGIN_ID, ((String)userMap.get(JsonKey.USERNAME)+"@"+(String)userMap.get(JsonKey.PROVIDER)));
}else{
userMap.put(JsonKey.LOGIN_ID,userMap.get(JsonKey.USERNAME));
}
/*if(null != userMap.get(JsonKey.EMAIL)){
String email = (String)userMap.get(JsonKey.EMAIL);
Response resultFrEmail = cassandraOperation.getRecordsByProperty(usrDbInfo.getKeySpace(),usrDbInfo.getTableName(),JsonKey.EMAIL,email);
if(((List<Map<String,Object>>)resultFrEmail.get(JsonKey.RESPONSE)).size() != 0){
ProjectCommonException exception = new ProjectCommonException(ResponseCode.emailAlreadyExistError.getErrorCode(), ResponseCode.emailAlreadyExistError.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
sender().tell(exception, self());
return;
}
}
if(null != userMap.get(JsonKey.USERNAME)){
String userName = (String)userMap.get(JsonKey.USERNAME);
Response resultFrUserName = cassandraOperation.getRecordsByProperty(usrDbInfo.getKeySpace(),usrDbInfo.getTableName(),JsonKey.USERNAME,userName);
}*/
if(null != userMap.get(JsonKey.LOGIN_ID)){
String loginId = (String)userMap.get(JsonKey.LOGIN_ID);
Response resultFrUserName = cassandraOperation.getRecordsByProperty(usrDbInfo.getKeySpace(),usrDbInfo.getTableName(),JsonKey.LOGIN_ID,loginId);
if(((List<Map<String,Object>>)resultFrUserName.get(JsonKey.RESPONSE)).size() != 0){
ProjectCommonException exception = new ProjectCommonException(ResponseCode.userNameAlreadyExistError.getErrorCode(), ResponseCode.userNameAlreadyExistError.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
ProjectCommonException exception = new ProjectCommonException(ResponseCode.userAlreadyExist.getErrorCode(), ResponseCode.userAlreadyExist.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
sender().tell(exception, self());
return;
}
Expand All @@ -578,11 +584,7 @@ private void createUser(Request actorMessage){
userMap.put(JsonKey.USER_ID,OneWayHashing.encryptVal((String)userMap.get(JsonKey.USERNAME)));
userMap.put(JsonKey.ID,OneWayHashing.encryptVal((String)userMap.get(JsonKey.USERNAME)));
}
if(!ProjectUtil.isStringNullOREmpty((String)userMap.get(JsonKey.PROVIDER))){
userMap.put(JsonKey.LOGIN_ID, ((String)userMap.get(JsonKey.USERNAME)+"@"+(String)userMap.get(JsonKey.PROVIDER)));
}else{
userMap.put(JsonKey.LOGIN_ID,userMap.get(JsonKey.USERNAME));
}

userMap.put(JsonKey.CREATED_DATE, ProjectUtil.getFormattedDate());
userMap.put(JsonKey.STATUS, ProjectUtil.Status.ACTIVE.getValue());
if(!ProjectUtil.isStringNullOREmpty((String)userMap.get(JsonKey.PASSWORD))){
Expand Down Expand Up @@ -833,6 +835,8 @@ private void removeUnwanted(Map<String, Object> reqMap) {
reqMap.remove(JsonKey.EDUCATION);
reqMap.remove(JsonKey.JOB_PROFILE);
reqMap.remove(JsonKey.ORGANISATION);
reqMap.remove(JsonKey.EMAIL_VERIFIED);
reqMap.remove(JsonKey.PHONE_NUMBER_VERIFIED);
}

/**
Expand Down

0 comments on commit 3b4b4f6

Please sign in to comment.