本文整理汇总了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;
}
示例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;
}
示例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());
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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;
}
}
示例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;
}