本文整理匯總了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());
}