當前位置: 首頁>>代碼示例>>Java>>正文


Java Promise類代碼示例

本文整理匯總了Java中play.libs.F.Promise的典型用法代碼示例。如果您正苦於以下問題:Java Promise類的具體用法?Java Promise怎麽用?Java Promise使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Promise類屬於play.libs.F包,在下文中一共展示了Promise類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendNotification

import play.libs.F.Promise; //導入依賴的package包/類
public Promise<Result> sendNotification() {
  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("Send notification api call" + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    RequestValidator.validateSendNotification(reqObj);
    reqObj.setOperation(ActorOperations.SEND_NOTIFICATION.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.setEnv(getEnvironment());
    Map<String, Object> innerMap = reqObj.getRequest();
    innerMap.put(JsonKey.REQUESTED_BY, ctx().flash().get(JsonKey.USER_ID));
    reqObj.setRequest(innerMap);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:18,代碼來源:GeoLocationController.java

示例2: updateSystemSettings

import play.libs.F.Promise; //導入依賴的package包/類
/**
 * This method will update system settings.
 * 
 * @return Promise<Result>
 */
public Promise<Result> updateSystemSettings() {
  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("making a call to update system settings api = " + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    RequestValidator.validateUpdateSystemSettingsRequest(reqObj);
    reqObj.setOperation(ActorOperations.UPDATE_SYSTEM_SETTINGS.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.getRequest().put(JsonKey.CREATED_BY, ctx().flash().get(JsonKey.USER_ID));
    reqObj.setEnv(getEnvironment());
    HashMap<String, Object> map = new HashMap<>();
    map.put(JsonKey.DATA, reqObj.getRequest());
    reqObj.setRequest(map);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:24,代碼來源:ApplicationConfigController.java

示例3: updateDatasetCompliance

import play.libs.F.Promise; //導入依賴的package包/類
public static Promise<Result> updateDatasetCompliance(int datasetId) {
    String username = session("user");
    if (StringUtils.isNotBlank(username)) {
        final String queryUrl = BACKEND_URL + DATASET_COMPLIANCE_PATH;

        final JsonNode queryNode = Json.newObject()
            .put("datasetId", datasetId)
            .set("privacyCompliancePolicy", request().body().asJson());

        return WS.url(queryUrl)
            .setRequestTimeout(1000)
            .post(queryNode)
            .map(response ->
                ok(response.asJson())
            );
    } else {
        final JsonNode result = Json.newObject()
            .put("status", "failed")
            .put("error", "true")
            .put("msg", "Unauthorized User.");

        return Promise.promise(() -> ok(result));
    }
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:25,代碼來源:Dataset.java

示例4: getPageData

import play.libs.F.Promise; //導入依賴的package包/類
/**
 * This method will provide completed data for a particular page.
 * 
 * @return Promise<Result>
 */
public Promise<Result> getPageData() {

  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("requested data for get page  = " + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    RequestValidator.validateGetPageData(reqObj);
    reqObj.setOperation(ActorOperations.GET_PAGE_DATA.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.setEnv(getEnvironment());
    reqObj.getRequest().put(JsonKey.CREATED_BY, ctx().flash().get(JsonKey.USER_ID));
    HashMap<String, Object> map = new HashMap<>();
    map.put(JsonKey.PAGE, reqObj.getRequest());
    map.put(JsonKey.HEADER, getAllRequestHeaders(request()));
    reqObj.setRequest(map);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:26,代碼來源:PageController.java

示例5: addSkill

import play.libs.F.Promise; //導入依賴的package包/類
public Promise<Result> addSkill() {
  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("add/endorse user skills=" + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    reqObj.setOperation(ActorOperations.ADD_SKILL.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.setEnv(getEnvironment());
    Map<String, Object> innerMap = reqObj.getRequest();
    innerMap.put(JsonKey.REQUESTED_BY, ctx().flash().get(JsonKey.USER_ID));
    reqObj.setRequest(innerMap);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:17,代碼來源:SkillController.java

示例6: getAssessment

import play.libs.F.Promise; //導入依賴的package包/類
/**
 * This method will provide user assessment details based on userid and course id. if only course
 * id is coming then it will provide all the user assessment for that course. if course id and
 * user id's both coming then it will provide only those users assessment for that course.
 * 
 * @return Promise<Result>
 */
public Promise<Result> getAssessment() {

  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("get assessment request=" + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    RequestValidator.validateGetAssessment(reqObj);
    reqObj.setOperation(ActorOperations.GET_ASSESSMENT.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.setEnv(getEnvironment());
    HashMap<String, Object> innerMap = new HashMap<>();
    innerMap.put(JsonKey.ASSESSMENT, reqObj.getRequest());
    innerMap.put(JsonKey.REQUESTED_BY,ctx().flash().get(JsonKey.USER_ID));
    reqObj.setRequest(innerMap);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:27,代碼來源:AssessmentController.java

示例7: updateContentState

import play.libs.F.Promise; //導入依賴的package包/類
/**
 * This method will update learner current state with last store state.
 * 
 * @return Result
 */
public Promise<Result> updateContentState() {
  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log(" get content request data=" + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    RequestValidator.validateUpdateContent(reqObj);
    reqObj.setOperation(ActorOperations.ADD_CONTENT.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.setEnv(getEnvironment());
    HashMap<String, Object> innerMap = new HashMap<>();
    innerMap.put(JsonKey.CONTENTS, reqObj.getRequest().get(JsonKey.CONTENTS));
    innerMap.put(JsonKey.REQUESTED_BY,ctx().flash().get(JsonKey.USER_ID));
    innerMap.put(JsonKey.USER_ID, reqObj.getRequest().get(JsonKey.USER_ID));
    reqObj.setRequest(innerMap);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:25,代碼來源:LearnerController.java

示例8: addUserBadges

import play.libs.F.Promise; //導入依賴的package包/類
/**
 * This method will add badges to user profile.
 * @return Promise<Result>
 */
public Promise<Result> addUserBadges() {
  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("call to add user badges api." + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    RequestValidator.validateAddUserBadge(reqObj);
    reqObj.setOperation(ActorOperations.ADD_USER_BADGE.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.getRequest().put(JsonKey.CREATED_BY,ctx().flash().get(JsonKey.USER_ID));
    reqObj.setEnv(getEnvironment());
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:20,代碼來源:BadgesController.java

示例9: createPageSection

import play.libs.F.Promise; //導入依賴的package包/類
/**
 * This method will allow admin to create sections for page view
 * 
 * @return Promise<Result>
 */
public Promise<Result> createPageSection() {

  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("getting create page section data request=" + requestData,
        LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    RequestValidator.validateCreateSection(reqObj);
    reqObj.setOperation(ActorOperations.CREATE_SECTION.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.getRequest().put(JsonKey.CREATED_BY, ctx().flash().get(JsonKey.USER_ID));
    reqObj.setEnv(getEnvironment());
    HashMap<String, Object> map = new HashMap<>();
    map.put(JsonKey.SECTION, reqObj.getRequest());
    reqObj.setRequest(map);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:26,代碼來源:PageController.java

示例10: getUserCount

import play.libs.F.Promise; //導入依賴的package包/類
public Promise<Result> getUserCount() {
  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("get User Count api call" + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    RequestValidator.validateGetUserCount(reqObj);
    reqObj.setOperation(ActorOperations.GET_USER_COUNT.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.setEnv(getEnvironment());
    Map<String, Object> innerMap = reqObj.getRequest();
    innerMap.put(JsonKey.REQUESTED_BY, ctx().flash().get(JsonKey.USER_ID));
    reqObj.setRequest(innerMap);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:18,代碼來源:GeoLocationController.java

示例11: removeUsersFromBatch

import play.libs.F.Promise; //導入依賴的package包/類
/**
 * This method will remove user batch enrollment.
 * 
 * @return Promise<Result>
 */
public Promise<Result> removeUsersFromBatch() {
  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("Remove user to batch=" + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    RequestValidator.validateAddBatchCourse(reqObj);
    reqObj.setOperation(ActorOperations.REMOVE_USER_FROM_BATCH.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.setEnv(getEnvironment());
    HashMap<String, Object> innerMap = new HashMap<>();
    innerMap.put(JsonKey.BATCH, reqObj.getRequest());
    innerMap.put(JsonKey.REQUESTED_BY, ctx().flash().get(JsonKey.USER_ID));
    reqObj.setRequest(innerMap);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:24,代碼來源:CourseBatchController.java

示例12: createGeoLocation

import play.libs.F.Promise; //導入依賴的package包/類
public Promise<Result> createGeoLocation() {
  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("create geo location" + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    reqObj.setOperation(ActorOperations.CREATE_GEO_LOCATION.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.setEnv(getEnvironment());
    Map<String, Object> innerMap = reqObj.getRequest();
    innerMap.put(JsonKey.REQUESTED_BY, ctx().flash().get(JsonKey.USER_ID));
    reqObj.setRequest(innerMap);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:17,代碼來源:GeoLocationController.java

示例13: getCourseById

import play.libs.F.Promise; //導入依賴的package包/類
/**
 * This method will do the course search based on course id. search will happen under ES.
 * 
 * @param courseId Stirng
 * @return Promise<Result>
 */
public Promise<Result> getCourseById(String courseId) {
  try {
    ProjectLogger.log("get course request =" + courseId, LoggerEnum.INFO.name());
    Request reqObj = new Request();
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.setEnv(getEnvironment());
    reqObj.setOperation(ActorOperations.GET_COURSE_BY_ID.getValue());
    HashMap<String, Object> innerMap = new HashMap<>();
    innerMap.put(JsonKey.ID, courseId);
    innerMap.put(JsonKey.REQUESTED_BY, ctx().flash().get(JsonKey.USER_ID));
    reqObj.setRequest(innerMap);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:23,代碼來源:CourseController.java

示例14: approveOrg

import play.libs.F.Promise; //導入依賴的package包/類
/**
 * Method to approve an organization
 * 
 * @return Promise<Result>
 */
public Promise<Result> approveOrg() {

  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("Approve organisation request: " + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    ProjectUtil.updateMapSomeValueTOLowerCase(reqObj);
    RequestValidator.validateOrg(reqObj);
    reqObj.setOperation(ActorOperations.APPROVE_ORG.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.setEnv(getEnvironment());
    HashMap<String, Object> innerMap = new HashMap<>();
    innerMap.put(JsonKey.ORGANISATION, reqObj.getRequest());
    innerMap.put(JsonKey.REQUESTED_BY, ctx().flash().get(JsonKey.USER_ID));
    reqObj.setRequest(innerMap);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, null);
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, null));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:26,代碼來源:OrganisationController.java

示例15: getBatch

import play.libs.F.Promise; //導入依賴的package包/類
/**
 * This method will fetch batch details from ES.
 * 
 * @return Promise<Result>
 */
public Promise<Result> getBatch(String batchId) {
  try {
    ProjectLogger.log("get batch=" + batchId, LoggerEnum.INFO.name());
    Request reqObj = new Request();
    reqObj.setOperation(ActorOperations.GET_BATCH.getValue());
    reqObj.setRequestId(ExecutionContext.getRequestId());
    reqObj.setEnv(getEnvironment());
    HashMap<String, Object> innerMap = new HashMap<>();
    reqObj.getRequest().put(JsonKey.BATCH_ID, batchId);
    innerMap.put(JsonKey.BATCH, reqObj.getRequest());
    innerMap.put(JsonKey.REQUESTED_BY, ctx().flash().get(JsonKey.USER_ID));
    reqObj.setRequest(innerMap);
    return actorResponseHandler(getActorRef(), reqObj, timeout, null, request());
  } catch (Exception e) {
    return Promise.<Result>pure(createCommonExceptionResponse(e, request()));
  }
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-service,代碼行數:23,代碼來源:CourseBatchController.java


注:本文中的play.libs.F.Promise類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。