List of usage examples for org.springframework.http HttpStatus FORBIDDEN
HttpStatus FORBIDDEN
To view the source code for org.springframework.http HttpStatus FORBIDDEN.
Click Source Link
From source file:com.siblinks.ws.service.impl.CommentServiceImpl.java
/** * {@inheritDoc}//from w w w . jav a 2 s . com */ @Override @RequestMapping(value = "/addCommentVideoAdmission", method = RequestMethod.POST) public ResponseEntity<Response> addCommentVideoAdmission(@RequestBody final RequestData request) { SimpleResponse simpleResponse = null; TransactionStatus statusDB = null; try { String content = request.getRequest_data().getContent(); if (content != null && content.length() > 1024) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, MSG_LONGER_THAN_1024); } else { if (!AuthenticationFilter.isAuthed(context)) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, "Authentication required."); return new ResponseEntity<Response>(simpleResponse, HttpStatus.FORBIDDEN); } String authorId = request.getRequest_data().getAuthorID(); String authorName = request.getRequest_data().getAuthor(); String vId = request.getRequest_data().getVid(); if (StringUtil.isNull(content) || StringUtil.isNull(authorId) || StringUtil.isNull(vId)) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(), request.getRequest_data_method(), "Comment content is not empty"); return new ResponseEntity<Response>(simpleResponse, HttpStatus.OK); } boolean flag = true; TransactionDefinition def = new DefaultTransactionDefinition(); statusDB = transactionManager.getTransaction(def); String strContent = CommonUtil.filterWord(content, cachedDao.getAllWordFilter()); Object[] queryParams = { authorName, authorId, strContent }; long commentId = dao.insertObject(SibConstants.SqlMapper.SQL_SIB_ADD_COMMENT, queryParams); if (commentId > 0) { Object[] queryParamsIns = { vId, commentId }; flag = dao.insertUpdateObject(SibConstants.SqlMapper.SQL_SIB_INSERT_VIDEO_ADMISSION_COMMENT, queryParamsIns); // Update number comment into video adminission table. if (flag) { flag = dao.insertUpdateObject(SibConstants.SqlMapper.SQL_UPDATE_NUMCOMMENT_VIDEO_ADMISSION, new Object[] { vId }); } } transactionManager.commit(statusDB); simpleResponse = new SimpleResponse("" + flag, request.getRequest_data_type(), request.getRequest_data_method(), (flag) ? "Add comment successful" : "Add comment failure"); } } catch (Exception e) { e.printStackTrace(); if (statusDB != null) { transactionManager.rollback(statusDB); } simpleResponse = new SimpleResponse(SibConstants.FAILURE, e.getMessage()); } return new ResponseEntity<Response>(simpleResponse, HttpStatus.OK); }
From source file:com.siblinks.ws.service.impl.CommentServiceImpl.java
/** * {@inheritDoc}/*from ww w . j av a2 s . c o m*/ */ @Override @RequestMapping(value = "/getAllComment", method = RequestMethod.POST) public ResponseEntity<Response> getAllComment(@RequestBody final RequestData request) { SimpleResponse simpleResponse = null; try { if (!AuthenticationFilter.isAuthed(context)) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, "Authentication required."); ResponseEntity<Response> entity = new ResponseEntity<Response>(simpleResponse, HttpStatus.FORBIDDEN); return entity; } Object[] queryParams = {}; List<Object> readObject = dao.readObjects(SibConstants.SqlMapper.SQL_GET_ALL_COMMENT, queryParams); simpleResponse = new SimpleResponse(SibConstants.SUCCESS, request.getRequest_data_type(), request.getRequest_data_method(), readObject); } catch (DAOException e) { e.printStackTrace(); simpleResponse = new SimpleResponse(SibConstants.FAILURE, e.getMessage()); } return new ResponseEntity<Response>(simpleResponse, HttpStatus.OK); }
From source file:com.siblinks.ws.service.impl.CommentServiceImpl.java
@Override @RequestMapping(value = "/addCommentEssay", method = RequestMethod.POST) public ResponseEntity<Response> addCommentEssay(@RequestBody final RequestData request) { SimpleResponse simpleResponse = null; try {/*from w w w . j a v a 2 s . com*/ if (!AuthenticationFilter.isAuthed(context)) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, "Authentication required."); return new ResponseEntity<Response>(simpleResponse, HttpStatus.FORBIDDEN); } String uid = request.getRequest_data().getUid(); String essayId = request.getRequest_data().getEssayId(); String content = request.getRequest_data().getContent(); if (content != null && content.length() > 1024) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, MSG_LONGER_THAN_1024); } else { String strContent = CommonUtil.filterWord(content, cachedDao.getAllWordFilter()); Object[] queryParams = { request.getRequest_data().getAuthorID(), strContent, essayId }; int cid = 0; boolean status = dao.insertUpdateObject(SibConstants.SqlMapper.SQL_SIB_ADD_COMMENT, queryParams); if (status) { List<Object> readObject = dao.readObjects(SibConstants.SqlMapper.SQL_SIB_LAST_INSERTED_COMMENT, queryParams); cid = Integer.valueOf(((Map) readObject.get(0)).get("cid").toString()); Object[] queryParamsIns = { ((Map) readObject.get(0)).get("cid").toString(), essayId }; dao.insertUpdateObject(SibConstants.SqlMapper.SQL_SIB_INSERT_ESSAY_COMMENT, queryParamsIns); readObject = dao.readObjects(SibConstants.SqlMapper.SQL_GET_INFO_ESSAY, queryParamsIns); ((Map) readObject.get(0)).get("userId").toString(); request.getRequest_data().getAuthorID(); ((Map) readObject.get(0)).get("nameOfEssay").toString(); // Add reply essay if (!((Map) readObject.get(0)).get("userId").toString() .equalsIgnoreCase(request.getRequest_data().getAuthorID())) { queryParamsIns = new Object[] { uid, request.getRequest_data().getAuthorID(), SibConstants.TYPE_ESSAY, SibConstants.NOTIFICATION_TITLE_REPLY_ESSAY, strContent, essayId }; boolean isSuccess = dao.insertUpdateObject(SibConstants.SqlMapper.SQL_CREATE_NOTIFICATION, queryParamsIns); if (isSuccess) { // Send message fire base String toTokenId = userservice.getTokenUser(uid); if (!StringUtil.isNull(toTokenId)) { fireBaseNotification.sendMessage(toTokenId, SibConstants.NOTIFICATION_TITLE_REPLY_ESSAY, SibConstants.TYPE_ESSAY, essayId, strContent, SibConstants.NOTIFICATION_ICON, SibConstants.NOTIFICATION_PRIPORITY_HIGH); } // Log activity activityLogSerservice.insertActivityLog( new ActivityLogData(SibConstants.TYPE_ESSAY, "C", "Reply essay", uid, essayId)); } } // if(flag) { // SibConstants.SqlMapper.SQL_="SIB_UPDATE_ARTICLE_COMMENT"; // Object[] queryParamsUpdate = null; // queryParamsUpdate = new HashMap<String, String>(); // queryParamsUpdate.put("essayId", // request.getRequest_data().getEssayId()); // boolean flagUpdate = // dao.insertUpdateObject(SibConstants.SqlMapper.SQL_, // queryParamsUpdate); // } } simpleResponse = new SimpleResponse("" + status, request.getRequest_data_type(), request.getRequest_data_method(), cid); } } catch (Exception e) { e.printStackTrace(); simpleResponse = new SimpleResponse(SibConstants.FAILURE, e.getMessage()); } return new ResponseEntity<Response>(simpleResponse, HttpStatus.OK); }
From source file:com.siblinks.ws.service.impl.faqServiceImpl.java
@Override @RequestMapping(value = "/fetchFaqs/top", method = RequestMethod.POST) public ResponseEntity<Response> topFetchFaqs(@RequestBody final RequestData request) { SimpleResponse simpleResponse = null; try {/*from w w w . j av a2s. c om*/ if (!AuthenticationFilter.isAuthed(context)) { simpleResponse = new SimpleResponse("" + Boolean.FALSE, "Authentication required."); return new ResponseEntity<Response>(simpleResponse, HttpStatus.FORBIDDEN); } Object[] queryParams = { request.getRequest_data().getLimit(), request.getRequest_data().getOrder() }; List<Object> readObject = dao.readObjects(SibConstants.SqlMapper.SQL_FETCH_FAQ_TOP, queryParams); simpleResponse = new SimpleResponse("" + Boolean.TRUE, request.getRequest_data_type(), request.getRequest_data_method(), readObject); } catch (DAOException e) { simpleResponse = new SimpleResponse("" + Boolean.TRUE, request.getRequest_data_type(), request.getRequest_data_method(), e.getMessage()); } return new ResponseEntity<Response>(simpleResponse, HttpStatus.OK); }
From source file:com.siblinks.ws.service.impl.faqServiceImpl.java
@Override @RequestMapping(value = "/fetchFaqs", method = RequestMethod.POST) public ResponseEntity<Response> fetchFaqs(@RequestBody final RequestData request) { SimpleResponse simpleResponse = null; try {//w w w . j a va 2 s . co m if (!AuthenticationFilter.isAuthed(context)) { simpleResponse = new SimpleResponse("" + Boolean.FALSE, "Authentication required."); return new ResponseEntity<Response>(simpleResponse, HttpStatus.FORBIDDEN); } Object[] queryParams = { request.getRequest_data().getFaqCategory(), request.getRequest_data().getLimit(), request.getRequest_data().getPage() }; List<Object> readObject = dao.readObjects(SibConstants.SqlMapper.SQL_FETCH_FAQ, queryParams); simpleResponse = new SimpleResponse("" + Boolean.TRUE, request.getRequest_data_type(), request.getRequest_data_method(), readObject); } catch (DAOException e) { simpleResponse = new SimpleResponse("" + Boolean.TRUE, request.getRequest_data_type(), request.getRequest_data_method(), e.getMessage()); } return new ResponseEntity<Response>(simpleResponse, HttpStatus.OK); }
From source file:com.siblinks.ws.service.impl.LikeServiceImpl.java
/** * {@inheritDoc}/*from ww w.j ava2 s . co m*/ */ @Override @RequestMapping(value = "/likeAnswer", method = RequestMethod.POST) public @ResponseBody ResponseEntity<Response> likeAnswer(@RequestBody final RequestData request) { SimpleResponse simpleResponse = null; try { if (!AuthenticationFilter.isAuthed(context)) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, "Authentication required."); return new ResponseEntity<Response>(simpleResponse, HttpStatus.FORBIDDEN); } Object[] queryParams = { request.getRequest_data().getAuthorID(), request.getRequest_data().getAid() }; String entityName = SibConstants.SqlMapper.SQL_LIKE_ANSWER_READ; List<Object> readObject = dao.readObjects(entityName, queryParams); boolean status = true; String statusType = "like"; if (readObject != null && readObject.size() > 0) { entityName = SibConstants.SqlMapper.SQL_UPDATE_LIKE_ANSWER; status = dao.insertUpdateObject(entityName, queryParams); String subscribe = (String) ((Map) readObject.get(0)).get(Parameters.LIKEANSWER); if (subscribe != null && subscribe.equals("Y")) { statusType = "unlike"; } } else { entityName = SibConstants.SqlMapper.SQL_ANSWER_ID_LIKE; status = dao.insertUpdateObject(entityName, queryParams); statusType = "like"; } simpleResponse = new SimpleResponse("" + status, statusType, request.getRequest_data_method(), readObject); } catch (DAOException e) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(), request.getRequest_data_method(), e.getMessage()); } return new ResponseEntity<Response>(simpleResponse, HttpStatus.OK); }
From source file:com.siblinks.ws.service.impl.LikeServiceImpl.java
/** * {@inheritDoc}//w w w. ja v a 2s.co m */ @Override @RequestMapping(value = "/getPostLikeByUser", method = RequestMethod.POST) public ResponseEntity<Response> getPostLikeByUser(@RequestBody final RequestData request) { SimpleResponse simpleResponse = null; try { if (!AuthenticationFilter.isAuthed(context)) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, "Authentication required."); return new ResponseEntity<Response>(simpleResponse, HttpStatus.FORBIDDEN); } Map<String, String> queryParams = new HashMap<String, String>(); queryParams.put("uid", request.getRequest_data().getUid()); List<Object> readObject = dao.readObjects(SibConstants.SqlMapper.SQL_GET_LIKE_POST_BY_USER, queryParams); simpleResponse = new SimpleResponse("" + true, request.getRequest_data_type(), request.getRequest_data_method(), readObject); } catch (DAOException e) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(), request.getRequest_data_method(), e.getMessage()); } ResponseEntity<Response> entity = new ResponseEntity<Response>(simpleResponse, HttpStatus.OK); return entity; }
From source file:com.siblinks.ws.service.impl.ManagerQAServiceImpl.java
/** * {@inheritDoc}// www.ja v a 2 s . c o m */ @Override @RequestMapping(value = "/getListQuestionQA", method = RequestMethod.POST) public ResponseEntity<Response> getListQuestionQA(@RequestBody final RequestData request) { SimpleResponse simpleResponse = null; try { if (!AuthenticationFilter.isAuthed(context)) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, "Authentication required."); return new ResponseEntity<Response>(simpleResponse, HttpStatus.FORBIDDEN); } String subjectId = request.getRequest_data().getSubjectId(); String userId = request.getRequest_data().getUid(); String limit = request.getRequest_data().getLimit(); String offset = request.getRequest_data().getOffset(); String type = request.getRequest_data().getType(); String search = request.getRequest_data().getContent(); String subjects = request.getRequest_data().getSubjects(); String whereCause = ""; if (!StringUtil.isNull(search)) { search = StringEscapeUtils.escapeJava(search); whereCause += " AND X.content like '%" + search + "%' "; } if (Parameters.UNANSWERED.equals(type)) { whereCause += " AND X.numReplies = 0 "; } if (Parameters.ANSWERED.equals(type)) { whereCause += " AND X.numReplies > 0 "; } if (!StringUtil.isNull(subjectId) && !"-1".equals(subjectId)) { whereCause += " AND X.subjectId = " + subjectId; } else { if (StringUtil.isNull(subjects)) { whereCause += " AND FIND_IN_SET(X.subjectId , (SELECT defaultSubjectId FROM Sib_Users where userid = " + userId + " ))"; } else { whereCause += " AND FIND_IN_SET(X.subjectId , '" + subjects + "')"; } } Object[] queryParams = {}; boolean status = true; whereCause += " ORDER BY X.datetime DESC "; if (!StringUtil.isNull(limit)) { whereCause += " LIMIT " + limit; } if (!StringUtil.isNull(offset)) { whereCause += " OFFSET " + offset; } List<Object> readObject = dao.readObjectsWhereClause( SibConstants.SqlMapper.SQL_GET_ALL_QUESTION_MENTOR_BY_SUBJ, whereCause, queryParams); simpleResponse = new SimpleResponse("" + status, request.getRequest_data_type(), request.getRequest_data_method(), readObject); } catch (DAOException e) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(), request.getRequest_data_method(), e.getMessage()); } ResponseEntity<Response> entity = new ResponseEntity<Response>(simpleResponse, HttpStatus.OK); return entity; }
From source file:com.siblinks.ws.service.impl.ManagerQAServiceImpl.java
@Override @RequestMapping(value = "/getCountQuestionAnswerByMentor", method = RequestMethod.GET) public ResponseEntity<Response> getCountQuestionAnswerByMentor( @RequestParam(required = false) final String subjectId, @RequestParam final String uid, @RequestParam(required = false) final String content, @RequestParam(required = false) final String subjects) { SimpleResponse simpleResponse = null; try {// ww w. j a va2 s .co m if (!AuthenticationFilter.isAuthed(context)) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, "Authentication required."); return new ResponseEntity<Response>(simpleResponse, HttpStatus.FORBIDDEN); } List<Object> queryParams = new ArrayList<Object>(); String whereClause = ""; if (!StringUtil.isNull(subjectId) && !"-1".equals(subjectId)) { whereClause += " AND x.subjectId = ? "; queryParams.add(subjectId); } else { if (StringUtil.isNull(subjects)) { whereClause += " AND FIND_IN_SET(x.subjectId , (SELECT defaultSubjectId FROM Sib_Users where userid = ?)) "; queryParams.add(uid); } else { whereClause += " AND FIND_IN_SET(x.subjectId , '" + subjects + "') "; } } if (!StringUtil.isNull(content)) { whereClause += " AND x.content like(?) "; queryParams.add("%" + content + "%"); } whereClause += " GROUP BY x.numReplies"; List<Object> readObject = dao.readObjectsWhereClause( SibConstants.SqlMapper.SQL_GET_COUNT_ALL_QUESTION_BY_SUBJ, whereClause, queryParams.toArray()); simpleResponse = new SimpleResponse(SibConstants.SUCCESS, "managerQA", "getCountQuestionAnswerByMentor", readObject); } catch (DAOException e) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, "managerQA", "getCountQuestionAnswerByMentor", e.getMessage()); } ResponseEntity<Response> entity = new ResponseEntity<Response>(simpleResponse, HttpStatus.OK); return entity; }
From source file:com.siblinks.ws.service.impl.MentorServiceImpl.java
/** * {@inheritDoc}/*from w w w . j av a2s . c om*/ */ @Override @RequestMapping(value = "/topMetorEachSubject", method = RequestMethod.POST) public ResponseEntity<Response> topMetorEachSubject(@RequestBody final RequestData request) { SimpleResponse simpleResponse = null; try { if (!AuthenticationFilter.isAuthed(context)) { simpleResponse = new SimpleResponse(SibConstants.FAILURE, "Authentication required."); return new ResponseEntity<Response>(simpleResponse, HttpStatus.FORBIDDEN); } List<Object> readObject = dao.readObjects(SibConstants.SqlMapper.SQL_TOP_MENTOR, new Object[] { request.getRequest_data().getSubjectId() }); simpleResponse = new SimpleResponse(SibConstants.SUCCESS, request.getRequest_data_type(), request.getRequest_data_method(), readObject); } catch (DAOException e) { e.printStackTrace(); simpleResponse = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(), request.getRequest_data_method(), e.getMessage()); } return new ResponseEntity<Response>(simpleResponse, HttpStatus.OK); }