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


Java PropertiesCache类代码示例

本文整理汇总了Java中org.sunbird.common.models.util.PropertiesCache的典型用法代码示例。如果您正苦于以下问题:Java PropertiesCache类的具体用法?Java PropertiesCache怎么用?Java PropertiesCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getSalt

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
/**
 * 
 * @return
 */
public static String getSalt() {
  if (!ProjectUtil.isStringNullOREmpty(encryption_key)) {
    return encryption_key;
  } else {
    encryption_key = System.getenv(JsonKey.ENCRYPTION_KEY);
    if (ProjectUtil.isStringNullOREmpty(encryption_key)) {
      ProjectLogger.log("Salt value is not provided by Env");
      encryption_key = PropertiesCache.getInstance().getProperty(JsonKey.ENCRYPTION_KEY);
    }
  }
  if (ProjectUtil.isStringNullOREmpty(encryption_key)) {
    ProjectLogger.log("throwing exception for invalid salt==", LoggerEnum.INFO.name());
    throw new ProjectCommonException(ResponseCode.saltValue.getErrorCode(),
        ResponseCode.saltValue.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
  }
  return encryption_key;
}
 
开发者ID:project-sunbird,项目名称:sunbird-utils,代码行数:22,代码来源:DefaultEncryptionServivceImpl.java

示例2: verifyUserAccesToken

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
/**
 * This method will verify the incoming user access token against store data base /cache. If token
 * is valid then it would be associated with some user id. In case of token matched it will
 * provide user id. else will provide empty string.
 * @param token String
 * @return String
 */
@SuppressWarnings("unchecked")
public static String verifyUserAccesToken(String token) {
  SSOManager ssoManager = SSOServiceFactory.getInstance();
  String userId = ""; 
  try { 
    boolean response = Boolean.parseBoolean(PropertiesCache.getInstance().getProperty(JsonKey.IS_SSO_ENABLED));
    if (response) {
    userId = ssoManager.verifyToken(token);
    } else {
     Response authResponse = cassandraOperation.getRecordById(userAuth.getKeySpace(), userAuth.getTableName(), token);
     if(authResponse != null && authResponse.get(JsonKey.RESPONSE) != null) {
      List<Map<String, Object>> authList =
           (List<Map<String, Object>>) authResponse.get(JsonKey.RESPONSE);
        if (authList != null && authList.size()>0) {
          Map<String,Object> authMap = authList.get(0);
           userId = (String) authMap.get(JsonKey.USER_ID);
        }
     }
    }
  } catch (Exception e) {
    ProjectLogger.log("invalid auth token =" + token, e);
  }
  return userId;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-service,代码行数:32,代码来源:AuthenticationHelper.java

示例3: testupdateSystemSettings

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
@Test
public void testupdateSystemSettings() {
  PowerMockito.mockStatic(RequestInterceptor.class);
  when( RequestInterceptor.verifyRequestData(Mockito.anyObject()) ).thenReturn("{userId} uuiuhcf784508 8y8c79-fhh");
  Map<String , Object> requestMap = new HashMap<>();
  Map<String , Object> innerMap = new HashMap<>();
  List<String> list = new ArrayList(Arrays.asList(PropertiesCache.getInstance().getProperty("system_settings_properties").split(",")));

  if(list.size()>0){
    innerMap.put(list.get(0),list.get(0));
    requestMap.put(JsonKey.REQUEST , innerMap);
    String data = mapToJson(requestMap);

    JsonNode json = Json.parse(data);
    RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/system/settings").method("POST");
    req.headers(headerMap);
    Result result = route(req);
    assertEquals(200, result.status());
  }

}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-service,代码行数:22,代码来源:ApplicationConfigControllerTest.java

示例4: postDataEkstep

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
protected static String postDataEkstep(String apiUrl, String request) {
  Map<String, String> headers = new HashMap<>();
  String response = null;
  try {
    String baseSearchUrl = System.getenv(JsonKey.EKSTEP_BASE_URL);
    if (ProjectUtil.isStringNullOREmpty(baseSearchUrl)) {
      baseSearchUrl = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_BASE_URL);
    }
    headers.put(JsonKey.AUTHORIZATION, JsonKey.BEARER
        + System.getenv(JsonKey.EKSTEP_AUTHORIZATION));
    if (ProjectUtil.isStringNullOREmpty((String) headers.get(JsonKey.AUTHORIZATION))) {
      headers.put(JsonKey.AUTHORIZATION, PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_AUTHORIZATION));
      headers.put("Content_Type", "application/json; charset=utf-8");
    }
    response = HttpUtil.sendPostRequest(
        baseSearchUrl + PropertiesCache.getInstance().getProperty(apiUrl), request, headers);

  } catch (Exception e) {
    ProjectLogger.log("Error occured", e);
    throw new ProjectCommonException(ResponseCode.unableToConnect.getErrorCode(),
        ResponseCode.unableToConnect.getErrorMessage(),
        ResponseCode.SERVER_ERROR.getResponseCode());
  }
  return response;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:26,代码来源:BaseMetricsActor.java

示例5: getDataFromEkstep

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
protected static String getDataFromEkstep(String apiUrl) {
  Map<String, String> headers = new HashMap<>();
  String response = null;
  try {
    String baseSearchUrl = System.getenv(JsonKey.EKSTEP_BASE_URL);
    if (ProjectUtil.isStringNullOREmpty(baseSearchUrl)) {
      baseSearchUrl = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_BASE_URL);
    }
    headers.put(JsonKey.AUTHORIZATION, JsonKey.BEARER
        + System.getenv(JsonKey.EKSTEP_AUTHORIZATION));
    if (ProjectUtil.isStringNullOREmpty((String) headers.get(JsonKey.AUTHORIZATION))) {
      headers.put(JsonKey.AUTHORIZATION, 
          PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_AUTHORIZATION));
      headers.put("Content_Type", "application/json; charset=utf-8");
    }
    response = HttpUtil.sendGetRequest(
        baseSearchUrl + apiUrl , headers);

  } catch (Exception e) {
    ProjectLogger.log("Error occured", e);
    throw new ProjectCommonException(ResponseCode.unableToConnect.getErrorCode(),
        ResponseCode.unableToConnect.getErrorMessage(),
        ResponseCode.SERVER_ERROR.getResponseCode());
  }
  return response;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:27,代码来源:BaseMetricsActor.java

示例6: conceptList

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static Map<String, String> conceptList() {
  List<String> domains = getDomains();
  for (String domain : domains) {
    String url = PropertiesCache.getInstance().getProperty((JsonKey.EKSTEP_CONCEPT_URL));
    url = StringUtils.replace(url, "{domain}", domain);
    String resposne = getDataFromEkstep(url);
    try {
      Map<String, Object> responseMap = mapper.readValue(resposne, Map.class);
      responseMap = (Map<String, Object>) responseMap.get(JsonKey.RESULT);
      List<Map<String, Object>> conceptData =
          (List<Map<String, Object>>) responseMap.get("concepts");
      for (Map<String, Object> concept : conceptData) {
        String id = (String) concept.get(JsonKey.IDENTIFIER);
        String name = (String) concept.get(JsonKey.NAME);
        conceptsList.put(id, name);
      }
    } catch (IOException e) {
      ProjectLogger.log("Error occured", e);
    }
  }
  return conceptsList;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:24,代码来源:OrganisationMetricsBackgroundActor.java

示例7: getDomains

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static List<String> getDomains() {
  String domainUrl = PropertiesCache.getInstance().getProperty((JsonKey.EKSTEP_DOMAIN_URL));
  String resposne = getDataFromEkstep(domainUrl);
  List<String> domainList = new ArrayList<>();
  try {
    Map<String, Object> responseMap = mapper.readValue(resposne, Map.class);
    responseMap = (Map<String, Object>) responseMap.get(JsonKey.RESULT);
    List<Map<String, Object>> domainData = (List<Map<String, Object>>) responseMap.get("domains");
    for (Map<String, Object> domain : domainData) {
      String id = (String) domain.get(JsonKey.IDENTIFIER);
      domainList.add(id);
    }
  } catch (IOException e) {
    ProjectLogger.log("Error occured", e);
  }
  return domainList;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:19,代码来源:OrganisationMetricsBackgroundActor.java

示例8: getCourseData

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
/**
 * Method to get the course data.
 *
 * @param contnetId String
 * @return String
 */
private String getCourseData(String contnetId) {
  String responseData = null;
  try {
    String ekStepBaseUrl = System.getenv(JsonKey.EKSTEP_BASE_URL);
    if (ProjectUtil.isStringNullOREmpty(ekStepBaseUrl)) {
      ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_BASE_URL);
    }

    responseData = HttpUtil.sendGetRequest(ekStepBaseUrl
        + PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_CONTENT_URL) + contnetId,
        headerMap);
  } catch (IOException e) {
    ProjectLogger.log(e.getMessage(), e);
  }
  return responseData;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:23,代码来源:BackgroundJobManager.java

示例9: registertag

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
/**
 * This method will make EkStep api call register the tag.
 * 
 * @param tagId String unique tag id.
 * @param body String requested body
 * @param header Map<String,String>
 * @return String
 */
private String registertag(String tagId, String body, Map<String, String> header) {
  String tagStatus = "";
  try {
    ProjectLogger.log("start call for registering the tag ==" + tagId);
    String ekStepBaseUrl = System.getenv(JsonKey.EKSTEP_BASE_URL);
    if (ProjectUtil.isStringNullOREmpty(ekStepBaseUrl)) {
      ekStepBaseUrl = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_BASE_URL);
    }
    tagStatus = HttpUtil.sendPostRequest(
        ekStepBaseUrl
            + PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_TAG_API_URL) + "/" + tagId,
        body, header);
    ProjectLogger
        .log("end call for tag registration id and status  ==" + tagId + " " + tagStatus);
  } catch (Exception e) {
    ProjectLogger.log(e.getMessage(), e);
  }

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

示例10: processData

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Map<String, Object> processData(Map<String, Object> requestBody, String objectProperty) {
  Map<String, Object> relationsMap = new HashMap<>();
  Map<String, Object> logRecords = new HashMap<>();
  String userRelations = PropertiesCache.getInstance().getProperty(objectProperty);
  String[] relations = userRelations.split(",");
  for (String relation : relations) {
    if (requestBody.containsKey(relation)) {
      List<Map<String, Object>> data = new ArrayList<>();
      Object dataObject = requestBody.get(relation);
      if (dataObject instanceof List) {
        data = (List<Map<String, Object>>) dataObject;
      } else if (dataObject instanceof Map) {
        data.add((Map<String, Object>) dataObject);
      }
      relationsMap.put(relation, data);
      requestBody.remove(relation);
    }
  }
  logRecords.put(JsonKey.PROPERTIES, requestBody);
  logRecords.put(JsonKey.RELATIONS, relationsMap);
  return logRecords;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:24,代码来源:ActorAuditLogServiceImpl.java

示例11: startLocalActorSystem

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
public static ActorRef startLocalActorSystem() {
  try{
  system = ActorSystem.create(LOCAL_ACTOR_SYSTEM_NAME,
      ConfigFactory.load().getConfig(ACTOR_LOCAL_CONFIG_NAME));
  ActorRef learnerActorSelectorRef = system.actorOf(Props.create(RequestRouterActor.class),
      RequestRouterActor.class.getSimpleName());
  ProjectLogger.log("normal local ActorSelectorRef " + learnerActorSelectorRef);
  ProjectLogger.log("NORNAL ACTOR LOCAL SYSTEM STARTED " + learnerActorSelectorRef,
      LoggerEnum.INFO.name());
  checkCassandraConnection();
  PropertiesCache cache = PropertiesCache.getInstance();
  if ("local".equalsIgnoreCase(cache.getProperty("background_actor_provider"))) {
    ProjectLogger.log("Initializing Local Background Actor System");
    startBackgroundLocalActorSystem();
  }
  return learnerActorSelectorRef;
  }catch(Exception ex){
    ProjectLogger.log("Exception occurred while starting local Actor System in Application.java startLocalActorSystem method "+ex);
  }
  return null;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:22,代码来源:Application.java

示例12: validateUpdateSystemSettingsRequest

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
public static void validateUpdateSystemSettingsRequest(Request request) {
  List<String> list = new ArrayList<>(Arrays.asList(
      PropertiesCache.getInstance().getProperty("system_settings_properties").split(",")));
  for(String str : request.getRequest().keySet()){
    if (!list.contains(str)) {
      throw new ProjectCommonException(ResponseCode.invalidPropertyError.getErrorCode(),
          MessageFormat.format(ResponseCode.invalidPropertyError.getErrorMessage(),str), ERROR_CODE);
    }
  }
}
 
开发者ID:project-sunbird,项目名称:sunbird-utils,代码行数:11,代码来源:RequestValidator.java

示例13: initialiseFromProperty

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
/**
 * This method will initialize values from property files.
 */
public static void initialiseFromProperty () {
  host = PropertiesCache.getInstance().getProperty(JsonKey.EMAIL_SERVER_HOST);
  port = PropertiesCache.getInstance().getProperty(JsonKey.EMAIL_SERVER_PORT);
  userName = PropertiesCache.getInstance().getProperty(JsonKey.EMAIL_SERVER_USERNAME);
  password = PropertiesCache.getInstance().getProperty(JsonKey.EMAIL_SERVER_PASSWORD);
  fromEmail = PropertiesCache.getInstance().getProperty(JsonKey.EMAIL_SERVER_FROM);
}
 
开发者ID:project-sunbird,项目名称:sunbird-utils,代码行数:11,代码来源:SendMail.java

示例14: getUrl

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
/**
 * @return the url
 */
public String getUrl() {
  if (ProjectUtil.isStringNullOREmpty(resUrl)) {
    String webUrl = System.getenv(SUNBIRD_WEB_URL);
    if(ProjectUtil.isStringNullOREmpty(webUrl)){
      webUrl = PropertiesCache.getInstance().getProperty(SUNBIRD_WEB_URL);
    }
    return shortUrl(webUrl);
  } else {
    return resUrl;
  }
}
 
开发者ID:project-sunbird,项目名称:sunbird-utils,代码行数:15,代码来源:URLShortnerImpl.java

示例15: findMissingAttribute

import org.sunbird.common.models.util.PropertiesCache; //导入依赖的package包/类
/**
 * This method will provide all the missing filed list
 * 
 * @param profileData Map<String, Object>
 * @return List<String>
 */
private List<String> findMissingAttribute(Map<String, Object> profileData) {
  List<String> attribute = new ArrayList<>();
  Iterator<Entry<String, Float>> itr =
      PropertiesCache.getInstance().attributePercentageMap.entrySet()
          .iterator();
  while (itr.hasNext()) {
    Entry<String, Float> entry = itr.next();
    if (profileData==null || !profileData.containsKey(entry.getKey())) {
      attribute.add(entry.getKey());
    } else {
       Object val = profileData.get(entry.getKey());
       if (val == null) {
         attribute.add(entry.getKey());
       } else if (val instanceof List) {
          List list = (List) val;
          if (list.size()==0){
            attribute.add(entry.getKey()); 
          }
       }else if (val instanceof Map) {
          Map map = (Map) val;
          if (map == null || map.size()==0) {
            attribute.add(entry.getKey()); 
          }
       }else {
         if (ProjectUtil.isStringNullOREmpty(val.toString())) {
           attribute.add(entry.getKey()); 
         }
       }
    }
  }
  return attribute;
}
 
开发者ID:project-sunbird,项目名称:sunbird-utils,代码行数:39,代码来源:ProfileCompletenessServiceImpl.java


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