List of usage examples for org.springframework.http MediaType TEXT_PLAIN_VALUE
String TEXT_PLAIN_VALUE
To view the source code for org.springframework.http MediaType TEXT_PLAIN_VALUE.
Click Source Link
From source file:org.egov.api.controller.CitizenController.java
/** * It will return user information belongs to identity Identity may be the user email or mobile number. * * @param request/*from w w w . j a v a 2s .c o m*/ * @return User * @since version 1.0 */ @RequestMapping(value = ApiUrl.CITIZEN_GET_PROFILE, method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) public ResponseEntity<String> getProfle() { final ApiResponse res = ApiResponse.newInstance(); try { final User user = userService.getUserByUsername(securityUtils.getCurrentUser().getUsername()); if (user == null) return res.error(getMessage("user.not.found")); return res.setDataAdapter(new UserAdapter()).success(user); } catch (final Exception ex) { LOGGER.error(EGOV_API_ERROR, ex); return res.error(getMessage(SERVER_ERROR_KEY)); } }
From source file:org.egov.api.controller.EmployeeController.java
@RequestMapping(value = ApiUrl.EMPLOYEE_INBOX_LIST_WFT_COUNT, method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) public ResponseEntity<String> getWorkFlowTypesWithItemsCount(final HttpServletRequest request) { final ApiResponse res = ApiResponse.newInstance(); try {//from w w w . j ava 2 s .c o m final List<Long> ownerpostitions = new ArrayList<Long>(); ownerpostitions .add(posMasterService.getPositionByUserId(securityUtils.getCurrentUser().getId()).getId()); return res.setDataAdapter(new UserAdapter()) .success(getWorkflowTypesWithCount(securityUtils.getCurrentUser().getId(), ownerpostitions)); } catch (final Exception ex) { LOGGER.error("EGOV-API ERROR ", ex); return res.error(getMessage("server.error")); } }
From source file:org.egov.api.controller.EmployeeController.java
@RequestMapping(value = ApiUrl.EMPLOYEE_INBOX_LIST_FILTER_BY_WFT, method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) public ResponseEntity<String> getInboxListByWorkFlowType(@PathVariable final String workFlowType, @PathVariable final int resultsFrom, @PathVariable final int resultsTo) { final ApiResponse res = ApiResponse.newInstance(); try {/*from w w w.j a va 2 s.c o m*/ final List<Long> ownerpostitions = new ArrayList<Long>(); ownerpostitions .add(posMasterService.getPositionByUserId(securityUtils.getCurrentUser().getId()).getId()); return res.setDataAdapter(new UserAdapter()) .success(createInboxData(getWorkflowItemsByUserAndWFType(securityUtils.getCurrentUser().getId(), ownerpostitions, workFlowType, resultsFrom, resultsTo))); } catch (final Exception ex) { LOGGER.error("EGOV-API ERROR ", ex); return res.error(getMessage("server.error")); } }
From source file:org.egov.api.controller.EmployeeController.java
@RequestMapping(value = ApiUrl.EMPLOYEE_SEARCH_INBOX, method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE) public ResponseEntity<String> searchEmployeeInbox(@PathVariable final Integer pageno, @PathVariable final Integer limit, @RequestBody final ComplaintSearchRequest searchRequest) { try {/* ww w .ja v a 2s . c o m*/ org.egov.search.domain.Page page = org.egov.search.domain.Page.at(pageno); page.ofSize(limit); final SearchResult searchResult = searchService.search(asList(Index.PGR.toString()), asList(IndexType.COMPLAINT.toString()), searchRequest.searchQuery(), searchRequest.searchFilters(), Sort.by().field("common.createdDate", SortOrder.DESC), page); String jsonString = searchResult.rawResponse(); JSONObject respObj = (JSONObject) new JSONParser().parse(jsonString); JSONObject jObjHits = (JSONObject) respObj.get("hits"); Long total = (Long) jObjHits.get("total"); boolean hasNextPage = total > pageno * limit; ArrayList<Document> inboxItems = new ArrayList<Document>(); for (Document document : searchResult.getDocuments()) { JSONObject jResourceObj = document.getResource(); LinkedHashMap<String, Object> jSearchableObj = (LinkedHashMap<String, Object>) jResourceObj .get("searchable"); LinkedHashMap<String, Object> jOwnerObj = (LinkedHashMap<String, Object>) jSearchableObj .get("owner"); if ((int) jOwnerObj.get("id") == posMasterService .getPositionByUserId(securityUtils.getCurrentUser().getId()).getId()) { inboxItems.add(document); } } JsonArray result = (JsonArray) new Gson().toJsonTree(inboxItems, new TypeToken<List<Document>>() { }.getType()); JsonObject jsonResp = new JsonObject(); jsonResp.add("searchItems", result); jsonResp.addProperty("hasNextPage", hasNextPage); return getResponseHandler().success(jsonResp); } catch (final Exception e) { LOGGER.error("EGOV-API ERROR ", e); return getResponseHandler().error(getMessage("server.error")); } }
From source file:org.egov.api.controller.EmployeeController.java
@RequestMapping(value = ApiUrl.EMPLOYEE_FORWARD_DEPT_DESIGNATION_USER, method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) public ResponseEntity<String> getForwardDetails( @RequestParam(value = "department", required = true) Integer departmentId, @RequestParam(value = "designation", required = false) Integer designationId) { try {/*from w w w . java 2 s . c o m*/ ForwardDetails forwardDetails = new ForwardDetails(); //identify requesting for users or designations with this if condition if (departmentId != null && designationId != null) { final Set<User> users = new HashSet<>(); eisService.getUsersByDeptAndDesig(departmentId, designationId, new Date()).stream() .forEach(user -> { user.getRoles().stream().forEach(role -> { if (role.getName() .matches("Redressal Officer|Grievance Officer|Grievance Routing Officer")) users.add(user); }); }); forwardDetails.setUsers(users); } else if (departmentId != null) { forwardDetails.setDesignations(eisService.getAllDesignationByDept(departmentId, new Date())); } return getResponseHandler().setDataAdapter(new ForwardDetailsAdapter()).success(forwardDetails); } catch (final Exception e) { LOGGER.error("EGOV-API ERROR ", e); return getResponseHandler().error(getMessage("server.error")); } }
From source file:org.egov.commons.web.controller.EducationalQualificationController.java
@RequestMapping(value = "/searchresult/{mode}", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE) @ResponseBody/*from www. ja v a 2s .c o m*/ public String ajaxsearch(@PathVariable("mode") final String mode, Model model, @ModelAttribute final EducationalQualification educationalQualification) { List<EducationalQualification> searchResultList = qualificationService.search(educationalQualification); return new StringBuilder("{ \"data\":").append( toJSON(searchResultList, EducationalQualification.class, EducationalQualificationJsonAdaptor.class)) .append("}").toString(); }
From source file:org.egov.council.web.controller.CouncilCasteController.java
@RequestMapping(value = "/ajaxsearch/{mode}", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE) @ResponseBody// w w w. j a v a 2 s . c o m public String ajaxsearch(@PathVariable("mode") final String mode, Model model, @ModelAttribute final CouncilCaste councilCaste) { List<CouncilCaste> searchResultList = councilCasteService.search(councilCaste); return new StringBuilder("{ \"data\":") .append(toJSON(searchResultList, CouncilCaste.class, CouncilCasteJsonAdaptor.class)).append("}") .toString(); }
From source file:org.egov.council.web.controller.CouncilCommitteeTypeController.java
@RequestMapping(value = "/ajaxsearch/{mode}", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE) @ResponseBody// w w w . j a va2s. c o m public String ajaxsearch(@PathVariable("mode") final String mode, Model model, @ModelAttribute final CommitteeType committeeType) { List<CommitteeType> searchResultList = committeeTypeService.search(committeeType); return new StringBuilder("{ \"data\":") .append(toJSON(searchResultList, CommitteeType.class, CouncilCommitteeTypeJsonAdaptor.class)) .append("}").toString(); }
From source file:org.egov.council.web.controller.CouncilDesignationController.java
@RequestMapping(value = "/ajaxsearch/{mode}", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE) @ResponseBody//from w w w . j a va 2 s. c om public String ajaxsearch(@PathVariable("mode") final String mode, Model model, @ModelAttribute final CouncilDesignation councilDesignation) { List<CouncilDesignation> searchResultList = councilDesignationService.search(councilDesignation); return new StringBuilder("{ \"data\":") .append(toJSON(searchResultList, CouncilDesignation.class, CouncilDesignationJsonAdaptor.class)) .append("}").toString(); }
From source file:org.egov.council.web.controller.CouncilPartyController.java
@RequestMapping(value = "/ajaxsearch/{mode}", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE) @ResponseBody/*from ww w. jav a2s . co m*/ public String ajaxsearch(@PathVariable("mode") final String mode, Model model, @ModelAttribute final CouncilParty councilParty) { List<CouncilParty> searchResultList = councilPartyService.search(councilParty); return new StringBuilder("{ \"data\":") .append(toJSON(searchResultList, CouncilParty.class, CouncilPartyJsonAdaptor.class)).append("}") .toString(); }