/** * 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)); } }
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())); } }
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); }
@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()); }
@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()); }
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); }
@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(); }
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); }
@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()); }
/** * 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())); } }
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); }
@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); }
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); }
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())); } }
@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()); }
public static Result putDatasetColumnComment(int id, int columnId, int commentId) { ObjectNode result = Json.newObject(); String username = session("user"); Map<String, String[]> params = request().body().asFormUrlEncoded(); if (StringUtils.isNotBlank(username)) { String errorMsg = DatasetsDAO.postColumnComment(id, commentId, 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); }
@Restrict({@Group("ADMIN"), @Group("TEACHER")}) public Result createInspection() { DynamicForm df = formFactory.form().bindFromRequest(); Long examId = Long.parseLong(df.get("examId")); Exam exam = Ebean.find(Exam.class, examId); if (exam == null) { return notFound("sitnet_error_exam_not_found"); } if (exam.getLanguageInspection() != null) { return forbidden("already sent for inspection"); } if (!exam.getSubjectToLanguageInspection()) { return forbidden("not allowed to send for inspection"); } LanguageInspection inspection = new LanguageInspection(); User user = getLoggedUser(); AppUtil.setCreator(inspection, user); inspection.setExam(exam); inspection.save(); return ok(); }
@Test public void testaddUserBadges() { 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("badgeTypeId" , "org123"); innerMap.put("receiverId" , "user01"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/user/badges/add").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Restrict({@Group("STUDENT")}) public CompletionStage<Result> listOrganisations() throws MalformedURLException { URL url = parseUrl(); WSRequest request = wsClient.url(url.toString()); String localRef = ConfigFactory.load().getString("sitnet.integration.iop.organisationRef"); Function<WSResponse, Result> onSuccess = response -> { JsonNode root = response.asJson(); if (response.getStatus() != 200) { return internalServerError(root.get("message").asText("Connection refused")); } if (root instanceof ArrayNode) { ArrayNode node = (ArrayNode) root; for (JsonNode n : node) { ((ObjectNode) n).put("homeOrg", n.get("_id").asText().equals(localRef)); } } return ok(root); }; return request.get().thenApplyAsync(onSuccess); }
@Restrict({@Group("TEACHER"), @Group("ADMIN")}) public Result listNoShows(Long eid) { List<ExamEnrolment> enrolments = Ebean.find(ExamEnrolment.class) .fetch("exam", "id, name, state, gradedTime, customCredit, trialCount") .fetch("exam.executionType") .fetch("reservation") .fetch("user", "id, firstName, lastName, email, userIdentifier") .fetch("exam.course", "code, credits") .fetch("exam.grade", "id, name") .where() .eq("exam.id", eid) .eq("reservation.noShow", true) .orderBy("reservation.endAt") .findList(); if (enrolments == null) { return notFound(); } else { return ok(enrolments); } }
@Test(timeout = 5000) @Category({UnitTest.class}) public void itGetAlarms() throws Exception { ArrayList<AlarmServiceModel> alarmResult = new ArrayList<AlarmServiceModel>() {{ add(new AlarmServiceModel()); add(new AlarmServiceModel()); }}; IAlarms alarms = mock(IAlarms.class); AlarmsController controller = new AlarmsController(alarms); when(alarms.getList( DateTime.now(), DateTime.now(), "asc", 0, 100, new String[0])) .thenReturn(alarmResult); // Act Result response = controller.list(null, null, null, 0, 0, null); // Assert assertThat(response.body().isKnownEmpty(), is(false)); }
public CompletionStage<Result> onClientError(RequestHeader request, int statusCode, String message) { String errorMessage; switch (statusCode) { case 400: errorMessage = "BadRequest"; break; case 403: errorMessage = "Forbidden"; break; case 404: errorMessage = "NotFound"; break; default: errorMessage = "OtherClientError"; } HashMap<String, Object> errorResult = new HashMap<String, Object>() { { put("Message", "Client error occurred."); put("ExceptionMessage", errorMessage); } }; return CompletableFuture.completedFuture( Results.status(statusCode, toJson(errorResult)) ); }
@Test @RunAsStudent public void testCreateReservationStartIsPast() throws Exception { // Setup DateTime start = DateTime.now().withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0).minusHours(1); DateTime end = DateTime.now().withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0).plusHours(2); // Execute Result result = request(Helpers.POST, "/app/calendar/reservation", Json.newObject().put("roomId", room.getId()) .put("examId", exam.getId()) .put("start", ISODateTimeFormat.dateTime().print(start)) .put("end", ISODateTimeFormat.dateTime().print(end))); assertThat(result.status()).isEqualTo(400); // Verify ExamEnrolment ee = Ebean.find(ExamEnrolment.class, enrolment.getId()); assertThat(ee.getReservation()).isNull(); }
@Test @RunAsAdmin public void testDisableRoom() throws Exception { // Setup ExamRoom room = Ebean.find(ExamRoom.class, 1L); assertThat(room.getState()).isNotEqualTo(ExamRoom.State.INACTIVE.toString()); // Execute Result result = request(Helpers.DELETE, "/app/rooms/" + 1, null); assertThat(result.status()).isEqualTo(200); // Verify (both response and database) JsonNode node = Json.parse(contentAsString(result)); ExamRoom deserialized = deserialize(ExamRoom.class, node); assertThat(deserialized.getState()).isEqualTo(ExamRoom.State.INACTIVE.toString()); room = Ebean.find(ExamRoom.class, 1L); assertThat(room.getState()).isEqualTo(ExamRoom.State.INACTIVE.toString()); }
@Restrict({@Group("TEACHER")}) public Result updateAssessmentInfo(Long id) { String info = request().body().asJson().get("assessmentInfo").asText(); Optional<Exam> option = Ebean.find(Exam.class).fetch("parent.creator") .where() .idEq(id) .eq("state", Exam.State.GRADED_LOGGED) .findOneOrEmpty(); if (!option.isPresent()) { return notFound("sitnet_exam_not_found"); } Exam exam = option.get(); if (exam.getState() != Exam.State.GRADED_LOGGED || !isAllowedToModify(exam, getLoggedUser(), exam.getState())) { return forbidden("You are not allowed to modify this object"); } exam.setAssessmentInfo(info); exam.update(); return ok(); }
@Test @RunAsStudent public void testDoPrivateExam() throws Exception { Exam studentExam = createPrivateStudentExam(); Result result = request(Helpers.PUT, String.format("/app/student/exam/%s", studentExam.getHash()), null); assertThat(result.status()).isEqualTo(200); // Check that correct mail was sent assertThat(greenMail.waitForIncomingEmail(MAIL_TIMEOUT, 1)).isTrue(); MimeMessage[] mails = greenMail.getReceivedMessages(); assertThat(mails).hasSize(1); assertThat(mails[0].getFrom()[0].toString()).contains(ConfigFactory.load().getString("sitnet.email.system.account")); assertThat(mails[0].getSubject()).isEqualTo("Personal exam has been returned"); String body = GreenMailUtil.getBody(mails[0]); String reviewLink = String.format("%s/assessments/%d", ConfigFactory.load().getString("sitnet.application.hostname"), studentExam.getId()); String reviewLinkElement = String.format("<a href=\"%s\">%s</a>", reviewLink, "Link to evaluation"); assertThat(body).contains(reviewLinkElement); }
public static Result getDatasetDependentsById(Long datasetId) throws SQLException { ObjectNode resultJson = Json.newObject(); if (datasetId > 0) { try { List<Map<String, Object>> dependents = DatasetDao.getDatasetDependents(datasetId); resultJson.put("return_code", 200); resultJson.set("dependents", Json.toJson(dependents)); } catch (EmptyResultDataAccessException e) { ContrUtil.failure(resultJson, 404, "no dependent datasets can be found!"); Logger.error(e.getMessage()); } return ok(resultJson); } // if no parameter, return an error message ContrUtil.failure(resultJson, "Dataset Id is not provided or invalid"); return ok(resultJson); }
@Restrict({@Group("STUDENT")}) public CompletionStage<Result> listFacilities(Optional<String> organisation) throws MalformedURLException { if (!organisation.isPresent()) { return wrapAsPromise(badRequest()); } URL url = parseExternalUrl(organisation.get()); WSRequest request = wsClient.url(url.toString()); Function<WSResponse, Result> onSuccess = response -> { JsonNode root = response.asJson(); if (response.getStatus() != 200) { return internalServerError(root.get("message").asText("Connection refused")); } return ok(root); }; return request.get().thenApplyAsync(onSuccess); }
public Promise<Result> updateGeoLocation(String locationId) { try { JsonNode requestData = request().body().asJson(); ProjectLogger.log("update geo location" + requestData, LoggerEnum.INFO.name()); Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class); reqObj.setOperation(ActorOperations.UPDATE_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)); innerMap.put(JsonKey.LOCATION_ID , locationId); reqObj.setRequest(innerMap); return actorResponseHandler(getActorRef(), reqObj, timeout, null, request()); } catch (Exception e) { return Promise.<Result>pure(createCommonExceptionResponse(e, request())); } }
/** * Method to update the note * @param noteId * @return Promise<Result> */ public Promise<Result> updateNote(String noteId) { try { JsonNode requestData = request().body().asJson(); ProjectLogger.log("Update note request: " + requestData, LoggerEnum.INFO.name()); Request reqObj = (Request) mapper.RequestMapper.mapRequest(requestData, Request.class); RequestValidator.validateNoteId(noteId); reqObj.setOperation(ActorOperations.UPDATE_NOTE.getValue()); reqObj.setRequestId(ExecutionContext.getRequestId()); reqObj.setEnv(getEnvironment()); HashMap<String, Object> innerMap = new HashMap<>(); innerMap.put(JsonKey.NOTE_ID, noteId); innerMap.put(JsonKey.NOTE, 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) { ProjectLogger.log("Error in controller", e); return Promise.<Result>pure(createCommonExceptionResponse(e, null)); } }
public CompletionStage<Result> getJobsAsync() throws InvalidInputException, ExternalDependencyException { String type = request().getQueryString("jobType"); String status = request().getQueryString("jobStatus"); String size = request().getQueryString("pageSize"); String from = request().getQueryString("from"); String to = request().getQueryString("to"); JobType jobType; JobStatus jobStatus; long jobFrom; long jobTo; Integer pageSize; try { DateTime temp; jobType = type == null || type.isEmpty() ? null : JobType.from(Integer.parseInt(type)); jobStatus = status == null || status.isEmpty() ? null : JobStatus.from(Integer.parseInt(status)); from = (from == null || from.isEmpty()) ? "" : from; to = (to == null || to.isEmpty()) ? "" : to; pageSize = size == null || size.isEmpty() ? 100 : Integer.parseInt(size); temp = DateHelper.parseDate(from); jobFrom = (temp == null) ? Long.MIN_VALUE : temp.getMillis(); temp = DateHelper.parseDate(to); jobTo = (temp == null) ? Long.MAX_VALUE : temp.getMillis(); } catch (IllegalArgumentException e) { String message = String.format("Invalid query string: %s, %s, %s", type, status, size); log.error(message, e); throw new InvalidInputException(message, e); } return this.jobService.getJobsAsync(jobType, jobStatus, pageSize, jobFrom, jobTo) .thenApply(jobs -> { List jobList = new ArrayList<JobApiModel>(); jobs.forEach(job -> jobList.add(new JobApiModel(job))); return ok(toJson(jobList)); }); }
@Test public void testcourseCreationReport() { PowerMockito.mockStatic(RequestInterceptor.class); when( RequestInterceptor.verifyRequestData(Mockito.anyObject()) ).thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); RequestBuilder req = new RequestBuilder().uri("/v1/dashboard/progress/course/courseId/export?period=7d&format=excel").method("GET"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Restrict({@Group("TEACHER"), @Group("ADMIN")}) public Result addExamRecord() throws IOException { DynamicForm df = formFactory.form().bindFromRequest(); final Exam exam = Ebean.find(Exam.class) .fetch("parent") .fetch("parent.creator") .fetch("examSections.sectionQuestions.question") .where() .idEq(Long.parseLong(df.get("id"))) .findUnique(); return validateExamState(exam, true).orElseGet(() -> { exam.setState(Exam.State.GRADED_LOGGED); exam.update(); ExamParticipation participation = Ebean.find(ExamParticipation.class) .fetch("user") .where() .eq("exam.id", exam.getId()) .findUnique(); if (participation == null) { return notFound(); } ExamRecord record = createRecord(exam, participation); ExamScore score = createScore(record, participation.getEnded()); score.save(); record.setExamScore(score); record.save(); final User user = getLoggedUser(); final Set<User> examinators = exam.getExecutionType().getType().equals( ExamExecutionType.Type.MATURITY.toString()) ? exam.getParent().getExamOwners() : Collections.emptySet(); actor.scheduler().scheduleOnce(Duration.create(1, TimeUnit.SECONDS), () -> { emailComposer.composeInspectionReady(exam.getCreator(), user, exam, examinators); Logger.info("Inspection ready notification email sent"); }, actor.dispatcher()); return ok(); }); }
@ApiAction public Result getPipelineBranchRun(String organization,String pipeline,String branch,String run) throws Exception { PipelineRun obj = imp.getPipelineBranchRun(organization, pipeline, branch, run); obj.validate(); JsonNode result = mapper.valueToTree(obj); return ok(result); }
public static Result getFlowListViewFlows(String application, String project) { ObjectNode result = Json.newObject(); result.put("status", "ok"); result.set("nodes", Json.toJson(FlowsDAO.getFlowListViewFlows(application, project))); return ok(result); }
public static Result getSearchAutoCompleteForDataset() { //Logger.debug("Entering v1/Search.java:getSearchAutoCompleteForDataset()"); ObjectNode result = Json.newObject(); result.put("status", "ok"); result.set("source", Json.toJson(SearchDAO.getAutoCompleteListForDataset())); return ok(result); }
public static Result getLoggedInUser() { ObjectNode result = Json.newObject(); result.put("status", "ok"); String username = session("user"); result.set("user", Json.toJson(UserDAO.getCurrentUser(username))); return ok(result); }
@ApiAction public Result postPipelineRuns(String organization,String pipeline) throws Exception { QueueItemImpl obj = imp.postPipelineRuns(organization, pipeline); obj.validate(); JsonNode result = mapper.valueToTree(obj); return ok(result); }
@Restrict({@Group("TEACHER"), @Group("ADMIN")}) public Result getUnenrolledStudents(Long eid, String criteria) { List<ExamEnrolment> enrolments = Ebean.find(ExamEnrolment.class).where().eq("exam.id", eid).findList(); List<User> users = findUsersByRoleAndName("STUDENT", criteria); users.removeAll(enrolments.stream().map((ExamEnrolment::getUser)).collect(Collectors.toList())); return ok(Json.toJson(asArray(users))); }
/** * This method will provide completed data for all sections stored in cassandra DAC. * * @return Promise<Result> */ public Promise<Result> getSections() { try { ProjectLogger.log("get page all section method called = ", LoggerEnum.INFO.name()); Request reqObj = new Request(); reqObj.setOperation(ActorOperations.GET_ALL_SECTION.getValue()); reqObj.setRequestId(ExecutionContext.getRequestId()); reqObj.setEnv(getEnvironment()); return actorResponseHandler(getActorRef(), reqObj, timeout, null, request()); } catch (Exception e) { return Promise.<Result>pure(createCommonExceptionResponse(e, request())); } }