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


Java Result类代码示例

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


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

示例1: updateOrgStatus

import play.mvc.Result; //导入依赖的package包/类
/**
 * Method to update the status of the organization
 * 
 * @return Promise<Result>
 */
public Promise<Result> updateOrgStatus() {

  try {
    JsonNode requestData = request().body().asJson();
    ProjectLogger.log("Update organisation request: " + requestData, LoggerEnum.INFO.name());
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    ProjectUtil.updateMapSomeValueTOLowerCase(reqObj);
    RequestValidator.validateUpdateOrgStatus(reqObj);
    reqObj.setOperation(ActorOperations.UPDATE_ORG_STATUS.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

示例2: createGeoLocation

import play.mvc.Result; //导入依赖的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

示例3: postDatasetColumnComment

import play.mvc.Result; //导入依赖的package包/类
public static Result postDatasetColumnComment(int id, int columnId)
{
    ObjectNode result = Json.newObject();
    String username = session("user");
    Map<String, String[]> params = request().body().asFormUrlEncoded();
    if (StringUtils.isNotBlank(username))
    {
        String errorMsg = DatasetsDAO.postColumnComment(id, columnId, params, username);
        if (StringUtils.isBlank(errorMsg))
        {
            result.put("status", "success");
        }
        else
        {
            result.put("status", "failed");
            result.put("msg", errorMsg);
        }
    }
    else
    {
        result.put("status", "failed");
        result.put("msg", "Authentication Required");
    }

    return ok(result);
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:27,代码来源:Dataset.java

示例4: testlogin

import play.mvc.Result; //导入依赖的package包/类
@Test
public void testlogin() {
  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<>();
  innerMap.put(JsonKey.USERNAME , "userName");
  innerMap.put(JsonKey.PASSWORD , "john");
  innerMap.put(JsonKey.SOURCE , "src");

  requestMap.put(JsonKey.REQUEST , innerMap);
  String data = mapToJson(requestMap);

  JsonNode json = Json.parse(data);
  RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/user/login").method("POST");
  req.headers(headerMap);
  Result result = route(req);
  assertEquals(200, result.status());
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-service,代码行数:20,代码来源:UserControllerTest.java

示例5: testgetOrgDetails

import play.mvc.Result; //导入依赖的package包/类
@Test
public void testgetOrgDetails() {
  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<>();
  innerMap.put(JsonKey.ORGANISATION_ID , "org123");
  innerMap.put(JsonKey.STATUS, new BigInteger("1"));
  requestMap.put(JsonKey.REQUEST , innerMap);
  String data = mapToJson(requestMap);

  JsonNode json = Json.parse(data);
  RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/read").method("POST");
  req.headers(headerMap);
  Result result = route(req);
  assertEquals(200, result.status());
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-service,代码行数:18,代码来源:OrganisationControllerTest.java

示例6: addFilenamePattern

import play.mvc.Result; //导入依赖的package包/类
public static Result addFilenamePattern() {
  JsonNode filename = request().body().asJson();
  ObjectNode resultJson = Json.newObject();
  try {
    int key = PatternDao.insertFilenamePattern(filename);
    resultJson.put("return_code", 200);
    resultJson.put("generated_key", key);
    resultJson.put("message", "New filename pattern created!");
  } catch (Exception e) {
    e.printStackTrace();
    resultJson.put("return_code", 404);
    resultJson.put("error_message", e.getMessage());
  }

  return ok(resultJson);
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:17,代码来源:PatternController.java

示例7: updateExamLanguage

import play.mvc.Result; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result updateExamLanguage(Long eid, String code) {
    Exam exam = Ebean.find(Exam.class, eid);
    if (exam == null) {
        return notFound("sitnet_error_exam_not_found");
    }
    User user = getLoggedUser();
    if (!isPermittedToUpdate(exam, user)) {
        return forbidden("sitnet_error_access_forbidden");
    }

    Language language = Ebean.find(Language.class, code);
    if (exam.getExamLanguages().contains(language)) {
        exam.getExamLanguages().remove(language);
    } else {
        exam.getExamLanguages().add(language);
    }
    exam.update();
    return ok();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:21,代码来源:ExamController.java

示例8: getDatasetColumnsByID

import play.mvc.Result; //导入依赖的package包/类
public static Result getDatasetColumnsByID(int id)
{
    List<DatasetColumn> datasetColumnList = DatasetsDAO.getDatasetColumnsByID(id);

    ObjectNode result = Json.newObject();

    if (datasetColumnList != null && datasetColumnList.size() > 0)
    {
        result.put("status", "ok");
        result.set("columns", Json.toJson(datasetColumnList));
    }
    else
    {
        result.put("status", "error");
        result.put("message", "record not found");
    }

    return ok(result);
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:20,代码来源:Dataset.java

示例9: testchangePassword

import play.mvc.Result; //导入依赖的package包/类
@Test
public void testchangePassword() {
  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<>();

  innerMap.put(JsonKey.PASSWORD , "password");
  innerMap.put(JsonKey.NEW_PASSWORD , "newpssword");

  requestMap.put(JsonKey.REQUEST , innerMap);
  String data = mapToJson(requestMap);

  JsonNode json = Json.parse(data);
  RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/user/changepassword").method("POST");
  req.headers(headerMap);
  Result result = route(req);
  assertEquals(200, result.status());
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-service,代码行数:20,代码来源:UserControllerTest.java

示例10: getPageData

import play.mvc.Result; //导入依赖的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

示例11: getDatasetImpactAnalysisByID

import play.mvc.Result; //导入依赖的package包/类
public static Result getDatasetImpactAnalysisByID(int id)
{
    List<ImpactDataset> impactDatasetList = DatasetsDAO.getImpactAnalysisByID(id);

    ObjectNode result = Json.newObject();

    if (impactDatasetList != null)
    {
        result.put("status", "ok");
        result.set("impacts", Json.toJson(impactDatasetList));
    }
    else
    {
        result.put("status", "error");
        result.put("message", "record not found");
    }

    return ok(result);
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:20,代码来源:Dataset.java

示例12: getDatasetDependency

import play.mvc.Result; //导入依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public static Result getDatasetDependency() {
  String queryString = request().getQueryString("query");
  JsonNode input = Json.parse(queryString);
  ObjectNode resultJson = Json.newObject();

  try {
    resultJson = DatasetDao.getDatasetDependency(input);
  } catch (Exception e) {
    Logger.error(e.getMessage());
    resultJson.put("return_code", 404);
    resultJson.put("error_message", e.getMessage());
  }

  return ok(resultJson);
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:17,代码来源:DatasetController.java

示例13: favoriteDataset

import play.mvc.Result; //导入依赖的package包/类
public static Result favoriteDataset(int id)
{
    ObjectNode result = Json.newObject();
    String username = session("user");
    if (StringUtils.isNotBlank(username))
    {
        if (DatasetsDAO.favorite(id, username))
        {
            result.put("status", "success");
        }
        else
        {
            result.put("status", "failed");
        }
    }
    else
    {
        result.put("status", "failed");
    }

    return ok(result);
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:23,代码来源:Dataset.java

示例14: updateTCStatusOfUser

import play.mvc.Result; //导入依赖的package包/类
public Promise<Result> updateTCStatusOfUser() {
  try {
    ProjectLogger.log("get list of skills ");
    JsonNode requestData = request().body().asJson();
    Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class);
    reqObj.setOperation(ActorOperations.UPDATE_TC_STATUS_OF_USER.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,代码来源:TenantPreferenceController.java

示例15: testupdatePage

import play.mvc.Result; //导入依赖的package包/类
@Test
public void testupdatePage() {
  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<>();
  innerMap.put("name" , "page1");
  innerMap.put(JsonKey.ID , "page1");
  requestMap.put(JsonKey.REQUEST , innerMap);
  String data = mapToJson(requestMap);

  JsonNode json = Json.parse(data);
  RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/page/update").method("PATCH");
  req.headers(headerMap);
  Result result = route(req);
  assertEquals(200, result.status());
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-service,代码行数:18,代码来源:PageControllerTest.java


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