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