当前位置: 首页>>代码示例>>Java>>正文


Java ElasticSearchUtil.getDataByIdentifier方法代码示例

本文整理汇总了Java中org.sunbird.common.ElasticSearchUtil.getDataByIdentifier方法的典型用法代码示例。如果您正苦于以下问题:Java ElasticSearchUtil.getDataByIdentifier方法的具体用法?Java ElasticSearchUtil.getDataByIdentifier怎么用?Java ElasticSearchUtil.getDataByIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sunbird.common.ElasticSearchUtil的用法示例。


在下文中一共展示了ElasticSearchUtil.getDataByIdentifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateOrg

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
public static Map<String, Object> validateOrg(String orgId) {
  try {
    Map<String, Object> result =
        ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(),
            ProjectUtil.EsType.organisation.getTypeName(), orgId);
    if (null == result || result.isEmpty()) {
      return null;
    }
    ProjectLogger.log("Result:" + result.toString());
    return result;
  } catch (Exception e) {
    ProjectLogger.log("Error occured", e);
    throw new ProjectCommonException(ResponseCode.esError.getErrorCode(),
        ResponseCode.esError.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
  }
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:17,代码来源:OrganisationMetricsUtil.java

示例2: validateOrg

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
private Map<String, Object> validateOrg(String orgId) {
  try {
    Map<String, Object> result =
        ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(),
            ProjectUtil.EsType.organisation.getTypeName(), orgId);
    if (null == result || result.isEmpty()) {
      return null;
    }
    ProjectLogger.log("Result:" + result.toString());
    return result;
  } catch (Exception e) {
    ProjectLogger.log("Error occured", e);
    throw new ProjectCommonException(ResponseCode.esError.getErrorCode(),
        ResponseCode.esError.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
  }
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:17,代码来源:OrganisationMetricsActor.java

示例3: getCourseBatch

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
private void getCourseBatch(Request actorMessage) {

    Map<String, Object> map = (Map<String, Object>) actorMessage.getRequest().get(JsonKey.BATCH);
    Map<String, Object> result =
        ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(),
            ProjectUtil.EsType.course.getTypeName(), (String) map.get(JsonKey.BATCH_ID));
    Response response = new Response();
    if (null != result) {
      response.put(JsonKey.RESPONSE, result);
    } else {
      result = new HashMap<>();
      response.put(JsonKey.RESPONSE, result);
    }
    sender().tell(response, self());

  }
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:17,代码来源:CourseBatchManagementActor.java

示例4: updateEs

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void updateEs(String userId) {

  //  get all records from cassandra as list and add that list to user in ElasticSearch ...
  Response response = cassandraOperation.getRecordsByProperty(userSkillDbInfo.getKeySpace() , userSkillDbInfo.getTableName(), JsonKey.USER_ID , userId);
  List<Map<String,Object>> responseList = (List<Map<String, Object>>) response.get(JsonKey.RESPONSE);
  Map<String , Object> esMap = new HashMap<>();
  esMap.put(JsonKey.SKILLS , responseList);
  Map<String,Object> profile = ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.user.getTypeName(), userId);
  if(null!= profile && !profile.isEmpty()){
    Map<String,String> visibility = (Map<String, String>) profile.get(JsonKey.PROFILE_VISIBILITY);
    if((null!=visibility && !visibility.isEmpty())&& visibility.containsKey(JsonKey.SKILLS)){
      Map<String,Object> visibilityMap = ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.userprofilevisibility.getTypeName(), userId);
      if (null != visibilityMap && !visibilityMap.isEmpty()) {
        visibilityMap.putAll(esMap);
        ElasticSearchUtil.createData(ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.userprofilevisibility.getTypeName(), userId , visibilityMap);
      }
    }else {
      ElasticSearchUtil.updateData(ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.user.getTypeName(), userId , esMap);
    }
  } 
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:23,代码来源:SkillmanagementActor.java

示例5: getOrgDetails

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
 * Provides the details of the organization
 */
@SuppressWarnings("unchecked")
private void getOrgDetails(Request actorMessage) {

  Map<String, Object> req =
      (Map<String, Object>) actorMessage.getRequest().get(JsonKey.ORGANISATION);
  if (!(validateOrgRequest(req))) {
    ProjectLogger.log("REQUESTED DATA IS NOT VALID");
    return;
  }
  String orgId = (String) req.get(JsonKey.ORGANISATION_ID);
  Map<String, Object> result =
      ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(),
          ProjectUtil.EsType.organisation.getTypeName(), orgId);
  Response response = new Response();
  if (result != null) {
    response.put(JsonKey.RESPONSE, result);
  } else {
    result = new HashMap<>();
    response.put(JsonKey.RESPONSE, result);
  }
  sender().tell(response, self());
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:26,代码来源:OrganisationManagementActor.java

示例6: updateUserRoleToEs

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void updateUserRoleToEs(Request actorMessage) {
  List<String> roles = (List<String>) actorMessage.getRequest().get(JsonKey.ROLES);
  String type = (String) actorMessage.get(JsonKey.TYPE);
  String orgId = (String) actorMessage.get(JsonKey.ORGANISATION_ID);
  Map<String, Object> result =
      ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(),
          ProjectUtil.EsType.user.getTypeName(), (String) actorMessage.get(JsonKey.USER_ID));
  if (type.equals(JsonKey.USER)) {
    result.put(JsonKey.ROLES, roles);
  } else if (type.equals(JsonKey.ORGANISATION)) {
    List<Map<String, Object>> roleMapList =
        (List<Map<String, Object>>) result.get(JsonKey.ORGANISATIONS);
    if (null != roleMapList) {
      for (Map<String, Object> map : roleMapList) {
        if ((orgId.equalsIgnoreCase((String) map.get(JsonKey.ORGANISATION_ID)))) {
          map.put(JsonKey.ROLES, roles);
        }
      }
    }
  }
  updateDataToElastic(ProjectUtil.EsIndex.sunbird.getIndexName(),
      ProjectUtil.EsType.user.getTypeName(), (String) result.get(JsonKey.IDENTIFIER), result);
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:25,代码来源:BackgroundJobManager.java

示例7: removeUserOrgInfoToEs

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void removeUserOrgInfoToEs(Request actorMessage) {
  Map<String, Object> orgMap = (Map<String, Object>) actorMessage.getRequest().get(JsonKey.USER);
  Map<String, Object> result =
      ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(),
          ProjectUtil.EsType.user.getTypeName(), (String) orgMap.get(JsonKey.USER_ID));
  if (result.containsKey(JsonKey.ORGANISATIONS) && null != result.get(JsonKey.ORGANISATIONS)) {
    List<Map<String, Object>> orgMapList =
        (List<Map<String, Object>>) result.get(JsonKey.ORGANISATIONS);
    if (null != orgMapList) {
      Iterator<Map<String, Object>> itr = orgMapList.iterator();
      while (itr.hasNext()) {
        Map<String, Object> map = itr.next();
        if ((((String) map.get(JsonKey.USER_ID))
            .equalsIgnoreCase((String) orgMap.get(JsonKey.USER_ID)))
            && (((String) map.get(JsonKey.ORGANISATION_ID))
                .equalsIgnoreCase((String) orgMap.get(JsonKey.ORGANISATION_ID)))) {
          itr.remove();
        }
      }
    }
  }
  updateDataToElastic(ProjectUtil.EsIndex.sunbird.getIndexName(),
      ProjectUtil.EsType.user.getTypeName(), (String) result.get(JsonKey.IDENTIFIER), result);

}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:27,代码来源:BackgroundJobManager.java

示例8: updateUserOrgInfoToEs

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void updateUserOrgInfoToEs(Request actorMessage) {
  Map<String, Object> orgMap = (Map<String, Object>) actorMessage.getRequest().get(JsonKey.USER);
  Map<String, Object> result =
      ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(),
          ProjectUtil.EsType.user.getTypeName(), (String) orgMap.get(JsonKey.USER_ID));
  if (result.containsKey(JsonKey.ORGANISATIONS) && null != result.get(JsonKey.ORGANISATIONS)) {
    List<Map<String, Object>> orgMapList =
        (List<Map<String, Object>>) result.get(JsonKey.ORGANISATIONS);
    orgMapList.add(orgMap);
  } else {
    List<Map<String, Object>> mapList = new ArrayList<>();
    mapList.add(orgMap);
    result.put(JsonKey.ORGANISATIONS, mapList);
  }
  updateDataToElastic(ProjectUtil.EsIndex.sunbird.getIndexName(),
      ProjectUtil.EsType.user.getTypeName(), (String) result.get(JsonKey.IDENTIFIER), result);
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:19,代码来源:BackgroundJobManager.java

示例9: Z17TestAssignRolesWithoutOrgId

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
@Test
public void Z17TestAssignRolesWithoutOrgId(){
  TestKit probe = new TestKit(system);
  ActorRef subject = system.actorOf(props);
  Request reqObj = new Request();
  reqObj.setOperation(ActorOperations.ASSIGN_ROLES.getValue());
  Map<String, Object> request = new HashMap<String, Object>();
  request.put(JsonKey.USERNAME,"sunbird_dummy_user_212121");
  request.put(JsonKey.EXTERNAL_ID, "EXT_ID_DUMMY");
  request.put(JsonKey.PROVIDER, "BLR");
  List<String> roles = new ArrayList<>();
  roles.add("CONTENT_REVIEWER");
  request.put(JsonKey.ROLES, roles);
  reqObj.setRequest(request);
  subject.tell(reqObj, probe.getRef());
  probe.expectMsgClass(duration("200 second"), Response.class);
  Map<String,Object> map = ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(), ProjectUtil.EsType.user.getTypeName(), userId);
  System.out.println("Login Id "+map.get(JsonKey.LOGIN_ID));
  List<Map<String,Object>> usrOrgList = (List<Map<String, Object>>) map.get(JsonKey.ORGANISATIONS);
  for(Map<String,Object> usrOrg : usrOrgList){
    if(orgId.equalsIgnoreCase((String)usrOrg.get(JsonKey.ID))){
      assertTrue(((List<String>)map.get(JsonKey.ROLES)).contains("CONTENT_REVIEWER"));
    }
  }
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:26,代码来源:UserManagementActorTest.java

示例10: isOrgValid

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
 * THis method will do the organization validation.
 * 
 * @param orgId String
 * @return boolean
 */
private boolean isOrgValid(String orgId) {
  Map<String, Object> resp =
      ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(),
          ProjectUtil.EsType.organisation.getTypeName(), orgId);
  if (resp != null && resp.size() > 0) {
    ProjectLogger.log("organisation found in ES with id ==" + orgId);
    return true;
  }
  ProjectLogger.log("organisation not found in ES with id ==" + orgId);
  return false;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:18,代码来源:CourseBatchManagementActor.java

示例11: validUser

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
 * Method to validate User based on userId from ElasticSearch Data
 * 
 * @param userId
 * @return true if user data is present in ES else false
 */
private Boolean validUser(String userId) {
  Boolean result = false;

  if (!ProjectUtil.isStringNullOREmpty(userId)) {
    Map<String, Object> data = ElasticSearchUtil.getDataByIdentifier(
        ProjectUtil.EsIndex.sunbird.getIndexName(), EsType.user.getTypeName(), userId);
    if (null != data && !data.isEmpty()) {
      result = true;
    }
  }
  return result;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:19,代码来源:NotesManagementActor.java

示例12: update

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
/**
 * This method will allow update Data in DB.
 * 
 * @return Promise<Result>
 */
@SuppressWarnings("unchecked")
public Promise<Result> update() {
  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("getting update data request = " + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.setEnv(getEnvironment());
    validateTableName(reqObj);
    Map<String, Object> payload = (Map<String, Object>) reqObj.getRequest().get(PAYLOAD);
    validateRequestData(payload);
    Response response = new Response();
    boolean esResult = false;
    if (!ProjectUtil.isStringNullOREmpty((String) reqObj.getRequest().get(ENTITY_NAME))
        && ((boolean) reqObj.getRequest().get(INDEXED))) {
      esResult = updateDataToElastic(ES_INDEX_NAME, (String) reqObj.getRequest().get(ENTITY_NAME),
          (String) payload.get(JsonKey.ID), payload);
      if (esResult) {
        response = cassandraOperation.updateRecord(JsonKey.SUNBIRD_PLUGIN,
            (String) reqObj.getRequest().get(ENTITY_NAME), payload);
        if (!((String) response.get(JsonKey.RESPONSE)).equals(JsonKey.SUCCESS)) {
          deleteDataFromElastic(ES_INDEX_NAME, (String) reqObj.getRequest().get(ENTITY_NAME),
              (String) payload.get(JsonKey.ID));
          throw new ProjectCommonException(ResponseCode.esUpdateFailed.getErrorCode(),
              ResponseCode.esUpdateFailed.getErrorMessage(),
              ResponseCode.SERVER_ERROR.getResponseCode());
        }
      } else {
        throw new ProjectCommonException(ResponseCode.updateFailed.getErrorCode(),
            ResponseCode.updateFailed.getErrorMessage(),
            ResponseCode.CLIENT_ERROR.getResponseCode());
      }
    } else {
      Map<String, Object> data = ElasticSearchUtil.getDataByIdentifier(ES_INDEX_NAME,
          (String) reqObj.getRequest().get(ENTITY_NAME), (String) payload.get(JsonKey.ID));
      if (data.isEmpty() || ((boolean) reqObj.getRequest().get(INDEXED))) {
        response = cassandraOperation.updateRecord(JsonKey.SUNBIRD_PLUGIN,
            (String) reqObj.getRequest().get(ENTITY_NAME), payload);
      } else {
        throw new ProjectCommonException(ResponseCode.updateFailed.getErrorCode(),
            ResponseCode.updateFailed.getErrorMessage(),
            ResponseCode.CLIENT_ERROR.getResponseCode());
      }
    }
    return Promise.<Result>pure(createCommonResponse(response, null, request()));
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-service,代码行数:55,代码来源:DbOperationController.java

示例13: createReportTrackingEntry

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
private String createReportTrackingEntry(Request actorMessage) {
  ProjectLogger.log("Create Report Tracking Entry");
  SimpleDateFormat simpleDateFormat= ProjectUtil.getDateFormatter();
  String requestedBy = (String) actorMessage.get(JsonKey.REQUESTED_BY);
  String orgId = (String) actorMessage.get(JsonKey.ORG_ID);
  String period = (String) actorMessage.get(JsonKey.PERIOD);

  Map<String, Object> requestedByInfo = ElasticSearchUtil.getDataByIdentifier(
      EsIndex.sunbird.getIndexName(), EsType.user.getTypeName(), requestedBy);
  if (ProjectUtil.isNull(requestedByInfo)
      || ProjectUtil.isStringNullOREmpty((String) requestedByInfo.get(JsonKey.FIRST_NAME))) {
    throw new ProjectCommonException(ResponseCode.invalidRequestData.getErrorCode(),
        ResponseCode.invalidRequestData.getErrorMessage(),
        ResponseCode.CLIENT_ERROR.getResponseCode());
  }

  Map<String, Object> orgData = validateOrg(orgId);
  if (null == orgData) {
    throw new ProjectCommonException(ResponseCode.invalidOrgData.getErrorCode(),
        ResponseCode.invalidOrgData.getErrorMessage(),
        ResponseCode.CLIENT_ERROR.getResponseCode());
  }

  String requestId = ProjectUtil.getUniqueIdFromTimestamp(1);

  Map<String, Object> requestDbInfo = new HashMap<>();
  requestDbInfo.put(JsonKey.ID, requestId);
  requestDbInfo.put(JsonKey.USER_ID, requestedBy);
  requestDbInfo.put(JsonKey.FIRST_NAME, requestedByInfo.get(JsonKey.FIRST_NAME));
  requestDbInfo.put(JsonKey.STATUS, ReportTrackingStatus.NEW.getValue());
  requestDbInfo.put(JsonKey.RESOURCE_ID, orgId);
  requestDbInfo.put(JsonKey.PERIOD, period);
  requestDbInfo.put(JsonKey.CREATED_DATE, simpleDateFormat.format(new Date()));
  requestDbInfo.put(JsonKey.UPDATED_DATE, simpleDateFormat.format(new Date()));
  String decryptedEmail =
      decryptionService.decryptData((String) requestedByInfo.get(JsonKey.ENC_EMAIL));
  requestDbInfo.put(JsonKey.EMAIL, decryptedEmail);
  requestDbInfo.put(JsonKey.FORMAT, actorMessage.get(JsonKey.FORMAT));

  cassandraOperation.insertRecord(reportTrackingdbInfo.getKeySpace(),
      reportTrackingdbInfo.getTableName(), requestDbInfo);

  return requestId;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:45,代码来源:OrganisationMetricsActor.java

示例14: sendSMS

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
private void sendSMS(Map<String, Object> userMap) {
  if (ProjectUtil.isStringNullOREmpty((String) userMap.get(JsonKey.EMAIL))
      && !ProjectUtil.isStringNullOREmpty((String) userMap.get(JsonKey.PHONE))) {
  UserUtility.decryptUserData(userMap);
  String orgName = "";
  String rootOrgName = "";
  String regOrgId = (String) userMap.get(JsonKey.REGISTERED_ORG_ID);
  if (!ProjectUtil.isStringNullOREmpty(regOrgId)) {
    Map<String, Object> result =
        ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(),
            ProjectUtil.EsType.organisation.getTypeName(), regOrgId);
    if (!result.isEmpty()) {
      orgName = (String) result.get(JsonKey.ORG_NAME);
      result = ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(),
          ProjectUtil.EsType.organisation.getTypeName(),
          (String) result.get(JsonKey.ROOT_ORG_ID));
      if (!result.isEmpty()) {
        rootOrgName = (String) result.get(JsonKey.ORG_NAME);
      }
    }
  }
  String loginId = (String) userMap.get(JsonKey.USERNAME);
  if (!ProjectUtil.isStringNullOREmpty((String) userMap.get(JsonKey.PROVIDER))) {
    loginId = loginId + "@" + (String) userMap.get(JsonKey.PROVIDER);
  }
  String envName = System.getenv(JsonKey.SUNBIRD_INSTALLATION);
  if (ProjectUtil.isStringNullOREmpty(envName)) {
    envName = propertiesCache.getProperty(JsonKey.SUNBIRD_INSTALLATION);
  }

  String webUrl = System.getenv(SUNBIRD_WEB_URL);
  if (ProjectUtil.isStringNullOREmpty(webUrl)) {
    webUrl = propertiesCache.getProperty(SUNBIRD_WEB_URL);
  }
  ProjectLogger.log("shortened url :: " + webUrl);

  String appUrl = System.getenv(SUNBIRD_APP_URL);
  if (ProjectUtil.isStringNullOREmpty(appUrl)) {
    appUrl = propertiesCache.getProperty(SUNBIRD_APP_URL);
  }
  String sms = ProjectUtil.getSMSBody(orgName, rootOrgName, loginId, webUrl, appUrl, envName);
  if (ProjectUtil.isStringNullOREmpty((String) sms)) {
    sms = PropertiesCache.getInstance().getProperty("sunbird_default_welcome_sms");
  }
  ProjectLogger.log("SMS text : " + sms);
  
    String countryCode = "";
    if (ProjectUtil.isStringNullOREmpty((String) userMap.get(JsonKey.COUNTRY_CODE))) {
      countryCode = PropertiesCache.getInstance().getProperty("sunbird_default_country_code");
    } else {
      countryCode = (String) userMap.get(JsonKey.COUNTRY_CODE);
    }
    ISmsProvider smsProvider = SMSFactory.getInstance("91SMS");
    boolean response = smsProvider.send((String) userMap.get(JsonKey.PHONE), countryCode, sms);
    if (response) {
      ProjectLogger
          .log("Welcome Message sent successfully to ." + (String) userMap.get(JsonKey.PHONE));
    } else {
      ProjectLogger.log("Welcome Message failed for ." + (String) userMap.get(JsonKey.PHONE));
    }
  }
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:63,代码来源:BulkUploadBackGroundJobActor.java

示例15: sendSMS

import org.sunbird.common.ElasticSearchUtil; //导入方法依赖的package包/类
private void sendSMS(Map<String, Object> userMap) {
  if (ProjectUtil.isStringNullOREmpty((String) userMap.get(JsonKey.EMAIL))
      && !ProjectUtil.isStringNullOREmpty((String) userMap.get(JsonKey.PHONE))) {
  UserUtility.decryptUserData(userMap);
  String orgName = "";
  String rootOrgName = "";
  String regOrgId = (String) userMap.get(JsonKey.REGISTERED_ORG_ID);
  if (!ProjectUtil.isStringNullOREmpty(regOrgId)) {
    Map<String, Object> result =
        ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(),
            ProjectUtil.EsType.organisation.getTypeName(), regOrgId);
    if (!result.isEmpty()) {
      orgName = (String) result.get(JsonKey.ORG_NAME);
      result = ElasticSearchUtil.getDataByIdentifier(ProjectUtil.EsIndex.sunbird.getIndexName(),
          ProjectUtil.EsType.organisation.getTypeName(),
          (String) result.get(JsonKey.ROOT_ORG_ID));
      if (!result.isEmpty()) {
        rootOrgName = (String) result.get(JsonKey.ORG_NAME);
      }
    }
  }
  String loginId = (String) userMap.get(JsonKey.USERNAME);
  if (!ProjectUtil.isStringNullOREmpty((String) userMap.get(JsonKey.PROVIDER))) {
    loginId = loginId + "@" + (String) userMap.get(JsonKey.PROVIDER);
  }
  String envName = System.getenv(JsonKey.SUNBIRD_INSTALLATION);
  if (ProjectUtil.isStringNullOREmpty(envName)) {
    envName = propertiesCache.getProperty(JsonKey.SUNBIRD_INSTALLATION);
  }

  String webUrl = System.getenv(SUNBIRD_WEB_URL);
  if (ProjectUtil.isStringNullOREmpty(webUrl)) {
    webUrl = propertiesCache.getProperty(SUNBIRD_WEB_URL);
  }
  ProjectLogger.log("shortened url :: " + webUrl);

  String appUrl = System.getenv(SUNBIRD_APP_URL);
  if (ProjectUtil.isStringNullOREmpty(appUrl)) {
    appUrl = propertiesCache.getProperty(SUNBIRD_APP_URL);
  }
  String sms = ProjectUtil.getSMSBody(orgName, rootOrgName, loginId, webUrl, appUrl, envName);
  if (ProjectUtil.isStringNullOREmpty((String) sms)) {
    sms = PropertiesCache.getInstance().getProperty("sunbird_default_welcome_sms");
  }
  ProjectLogger.log("SMS text : " + sms);
    String countryCode = "";
    if (ProjectUtil.isStringNullOREmpty((String) userMap.get(JsonKey.COUNTRY_CODE))) {
      countryCode = PropertiesCache.getInstance().getProperty("sunbird_default_country_code");
    } else {
      countryCode = (String) userMap.get(JsonKey.COUNTRY_CODE);
    }
    ISmsProvider smsProvider = SMSFactory.getInstance("91SMS");
    boolean response = smsProvider.send((String) userMap.get(JsonKey.PHONE), countryCode, sms);
    if (response) {
      ProjectLogger
          .log("Welcome Message sent successfully to ." + (String) userMap.get(JsonKey.PHONE));
    } else {
      ProjectLogger.log("Welcome Message failed for ." + (String) userMap.get(JsonKey.PHONE));
    }
  }
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:62,代码来源:UserManagementActor.java


注:本文中的org.sunbird.common.ElasticSearchUtil.getDataByIdentifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。