Example usage for org.springframework.http HttpStatus FORBIDDEN

List of usage examples for org.springframework.http HttpStatus FORBIDDEN

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus FORBIDDEN.

Prototype

HttpStatus FORBIDDEN

To view the source code for org.springframework.http HttpStatus FORBIDDEN.

Click Source Link

Document

403 Forbidden .

Usage

From source file:com.siblinks.ws.service.impl.VideoServiceImpl.java

/**
 * {@inheritDoc}/*w ww  . j  a  v  a  2  s.co  m*/
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@RequestMapping(value = "/getVideosWithSubTopicPN", method = RequestMethod.POST)
public ResponseEntity<Response> getVideosWithSubTopicPN(@RequestBody final RequestData request) {
    SimpleResponse response = null;
    try {
        String entityName = null;

        if (!AuthenticationFilter.isAuthed(context)) {
            response = new SimpleResponse(SibConstants.FAILURE, "Authentication required.");
            return new ResponseEntity<Response>(response, HttpStatus.FORBIDDEN);
        }

        CommonUtil util = CommonUtil.getInstance();

        Map<String, String> map = util.getLimit(request.getRequest_data().getPageno(),
                request.getRequest_data().getLimit());

        Map<String, String> queryParams = new HashMap<String, String>();

        queryParams.put("vid", request.getRequest_data().getVid());
        queryParams.put("subject", request.getRequest_data().getSubject().trim());
        queryParams.put("nameTopic", request.getRequest_data().getTopic().trim());
        queryParams.put("subtopic", request.getRequest_data().getSubtopic().trim());
        queryParams.put("from", map.get("from"));
        queryParams.put("to", map.get("to"));

        entityName = SibConstants.SqlMapper.SQL_SIB_GET_VIDEO_WITH_SUB_TOPIC_PN;

        List<Object> readObject1 = null;
        List<Object> readObject = dao.readObjects(entityName, queryParams);
        if (readObject != null) {
            entityName = SibConstants.SqlMapper.SQL_SIB_GET_TAGS;
            readObject1 = dao.readObjects(entityName, queryParams);

            Map<String, Object> tags = null;

            try {
                for (Object obj : readObject1) {
                    tags = (Map) obj;
                    Iterator<Entry<String, Object>> it = tags.entrySet().iterator();
                    while (it.hasNext()) {
                        Map.Entry pairs = it.next();
                        if (pairs.getKey().equals("vid")) {
                            it.remove();
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            response = new SimpleResponse(SibConstants.SUCCESS, request.getRequest_data_type(),
                    request.getRequest_data_method(), "No Data Found");
            ResponseEntity<Response> entity = new ResponseEntity<Response>(response, HttpStatus.OK);
            return entity;
        }

        String count = null;
        if ("true".equalsIgnoreCase(request.getRequest_data().getTotalCountFlag())) {
            count = dao.getCount(SibConstants.SqlMapper.SQL_SIB_GET_VIDEO_WITH_SUB_TOPIC_PN_COUNT,
                    new Object[] { request.getRequest_data().getSubject().trim(),
                            request.getRequest_data().getSubtopic().trim(),
                            request.getRequest_data().getTopic().trim() });
        }

        Map<String, Object> mymap = new HashMap<String, Object>();
        mymap.put("tags", readObject1);
        readObject.add(mymap);

        response = new SimpleResponse("true", request.getRequest_data_type(), request.getRequest_data_method(),
                readObject, count);
    } catch (Exception e) {
        e.printStackTrace();
        response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                request.getRequest_data_method(), e.getMessage());
    }
    return new ResponseEntity<Response>(response, HttpStatus.OK);
}

From source file:com.siblinks.ws.service.impl.VideoServiceImpl.java

/**
 * {@inheritDoc}//  w  ww. j  ava 2  s  . c  o  m
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@RequestMapping(value = "/getVideosWithSubjectPN", method = RequestMethod.POST)
public ResponseEntity<Response> getVideosWithSubjectPN(@RequestBody final RequestData request) {
    SimpleResponse response = null;
    try {
        String entityName = null;

        if (!AuthenticationFilter.isAuthed(context)) {
            response = new SimpleResponse(SibConstants.FAILURE, "Authentication required.");
            return new ResponseEntity<Response>(response, HttpStatus.FORBIDDEN);
        }

        CommonUtil util = CommonUtil.getInstance();

        Map<String, String> map = util.getLimit(request.getRequest_data().getPageno(),
                request.getRequest_data().getLimit());

        Map<String, String> queryParams = new HashMap<String, String>();

        queryParams.put("subject", request.getRequest_data().getSubjectId().trim());
        queryParams.put("from", map.get("from"));
        queryParams.put("to", map.get("to"));

        entityName = SibConstants.SqlMapper.SQL_SIB_GET_VIDEO_WITH_SUBJECT_PN;

        List<Object> readObject1 = null;
        List<Object> readObject = dao.readObjects(entityName, queryParams);
        if (readObject != null) {
            entityName = SibConstants.SqlMapper.SQL_SIB_GET_TAGS;
            readObject1 = dao.readObjects(entityName, queryParams);

            Map<String, Object> tags = null;

            try {
                for (Object obj : readObject1) {
                    tags = (Map) obj;
                    Iterator<Entry<String, Object>> it = tags.entrySet().iterator();
                    while (it.hasNext()) {
                        Map.Entry pairs = it.next();
                        if (pairs.getKey().equals("vid")) {
                            it.remove();
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            response = new SimpleResponse("true", request.getRequest_data_type(),
                    request.getRequest_data_method(), "No Data Found");
            ResponseEntity<Response> entity = new ResponseEntity<Response>(response, HttpStatus.OK);
            return entity;
        }

        Map<String, Object> mymap = new HashMap<String, Object>();
        mymap.put("tags", readObject1);

        readObject.add(mymap);
        String count = null;
        if ("true".equalsIgnoreCase(request.getRequest_data().getTotalCountFlag())) {
            count = dao.getCount(SibConstants.SqlMapper.SQL_SIB_GET_VIDEO_WITH_SUBJECT_PN_COUNT,
                    new Object[] { request.getRequest_data().getSubjectId().trim() });
        }

        response = new SimpleResponse(SibConstants.SUCCESS, request.getRequest_data_type(),
                request.getRequest_data_method(), readObject, count);
    } catch (Exception e) {
        e.printStackTrace();
        response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                request.getRequest_data_method(), e.getMessage());
    }
    return new ResponseEntity<Response>(response, HttpStatus.OK);
}

From source file:com.siblinks.ws.service.impl.VideoServiceImpl.java

/**
 * {@inheritDoc}// w  w  w  .j a  va2s.co  m
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@RequestMapping(value = "/getVideosWithSubject", method = RequestMethod.POST)
public ResponseEntity<Response> getVideosWithSubject(@RequestBody final RequestData request) {
    SimpleResponse response = null;
    try {
        String entityName = null;

        if (!AuthenticationFilter.isAuthed(context)) {
            response = new SimpleResponse(SibConstants.FAILURE, "Authentication required.");
            return new ResponseEntity<Response>(response, HttpStatus.FORBIDDEN);
        }

        Map<String, String> queryParams = new HashMap<String, String>();

        queryParams.put("subjectId", request.getRequest_data().getSubjectId().trim());

        entityName = SibConstants.SqlMapper.SQL_SIB_GET_VIDEO_WITH_SUBJECT;

        List<Object> readObject1 = null;
        List<Object> readObject = dao.readObjects(entityName, queryParams);
        if (readObject != null) {
            entityName = SibConstants.SqlMapper.SQL_SIB_GET_TAGS;
            readObject1 = dao.readObjects(entityName, queryParams);

            Map<String, Object> tags = null;

            try {
                for (Object obj : readObject1) {
                    tags = (Map) obj;
                    Iterator<Entry<String, Object>> it = tags.entrySet().iterator();
                    while (it.hasNext()) {
                        Map.Entry pairs = it.next();
                        if (pairs.getKey().equals("vid")) {
                            it.remove();
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            response = new SimpleResponse("true", request.getRequest_data_type(),
                    request.getRequest_data_method(), "No Data Found");
            ResponseEntity<Response> entity = new ResponseEntity<Response>(response, HttpStatus.OK);
            return entity;
        }

        Map<String, Object> mymap = new HashMap<String, Object>();
        mymap.put("tags", readObject1);
        readObject.add(mymap);

        response = new SimpleResponse(SibConstants.SUCCESS, request.getRequest_data_type(),
                request.getRequest_data_method(), readObject);
    } catch (Exception e) {
        e.printStackTrace();
        response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                request.getRequest_data_method(), e.getMessage());
    }
    return new ResponseEntity<Response>(response, HttpStatus.OK);
}

From source file:com.siblinks.ws.service.impl.VideoServiceImpl.java

/**
 * {@inheritDoc}/*  w w  w .  j a va  2 s  .  c  om*/
 */
@Override
@RequestMapping(value = "/searchVideos", method = RequestMethod.POST)
public ResponseEntity<Response> searchVideos(@RequestBody final RequestData request) {
    SimpleResponse response = null;
    try {
        if (!AuthenticationFilter.isAuthed(context)) {
            response = new SimpleResponse(SibConstants.FAILURE, "Authentication required.");
            return new ResponseEntity<Response>(response, HttpStatus.FORBIDDEN);
        }

        String entityName = "";
        Object[] queryParams = null;
        // String term =
        // StringEscapeUtils.escapeJava(request.getRequest_data().getKeySearch().trim());
        String term = request.getRequest_data().getKeySearch().trim();
        term = term.replace("'", "\\'");
        int subjectId = request.getRequest_data().getSubjectId() != null
                ? Integer.parseInt(request.getRequest_data().getSubjectId())
                : 0;
        int offset = request.getRequest_data().getOffset() != null
                ? Integer.parseInt(request.getRequest_data().getOffset())
                : 0;
        int type = request.getRequest_data().getType() != null
                ? Integer.parseInt(request.getRequest_data().getType())
                : 0;

        if (subjectId == 0) {
            queryParams = new Object[] { request.getRequest_data().getUid() };
            entityName = SibConstants.SqlMapperBROT126.SQL_SEARCH_VIDEOS;
        } else {
            queryParams = new Object[] { request.getRequest_data().getUid(), subjectId };
            entityName = SibConstants.SqlMapperBROT163.SQL_SEARCH_VIDEOS_WITH_SUBJECT;
        }
        String whereClause = "";
        if (type == 1) {
            whereClause = String.format(" and a.title like '%%%s%%' order by a.vid DESC limit 10 offset %d",
                    term, offset);
        } else if (type == 2) {
            whereClause = String.format(
                    " and a.title like '%%%s%%' order by a.numViews DESC limit 10 offset %d", term, offset);
        } else {
            whereClause = String.format(
                    " and a.title like '%%%s%%' order by a.averageRating DESC limit 10 offset %d", term,
                    offset);
        }

        List<Object> readObject = dao.readObjectsWhereClause(entityName, whereClause, queryParams);
        if (readObject != null && readObject.size() > 0) {
            response = new SimpleResponse(SibConstants.SUCCESS, "videos", "searchVideos", readObject);
        } else {
            response = new SimpleResponse(SibConstants.SUCCESS, "videos", "searchVideos", SibConstants.NO_DATA);
        }
    } catch (Exception e) {
        e.printStackTrace();
        response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                request.getRequest_data_method(), e.getMessage());
    }
    return new ResponseEntity<Response>(response, HttpStatus.OK);
}

From source file:com.siblinks.ws.service.impl.VideoServiceImpl.java

/**
 * {@inheritDoc}//from   ww w .ja  v a  2s. c  om
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@RequestMapping(value = "/searchVideosPN", method = RequestMethod.POST)
public ResponseEntity<Response> searchVideosPN(@RequestBody final RequestData request) {
    SimpleResponse response = null;
    try {
        String entityName = null;

        if (!AuthenticationFilter.isAuthed(context)) {
            response = new SimpleResponse(SibConstants.FAILURE, "Authentication required.");
            return new ResponseEntity<Response>(response, HttpStatus.FORBIDDEN);
        }

        CommonUtil util = CommonUtil.getInstance();

        Map<String, String> map = util.getLimit(request.getRequest_data().getPageno(),
                request.getRequest_data().getLimit());

        Map<String, String> queryParams = new HashMap<String, String>();
        queryParams.put("title", request.getRequest_data().getTitle().trim());
        queryParams.put("description", request.getRequest_data().getTitle().trim());
        queryParams.put("from", map.get("from"));
        queryParams.put("to", map.get("to"));

        entityName = SibConstants.SqlMapper.SQL_SIB_SEARCH_VIDEOS_PN;

        List<Object> readObject = dao.readObjects(entityName, queryParams);

        entityName = SibConstants.SqlMapper.SQL_SIB_GET_TAGS;
        List<Object> readObject1 = dao.readObjects(entityName, queryParams);

        Map<String, Object> tags = null;

        try {
            for (Object obj : readObject1) {
                tags = (Map) obj;
                Iterator<Entry<String, Object>> it = tags.entrySet().iterator();
                while (it.hasNext()) {
                    Map.Entry pairs = it.next();
                    if (pairs.getKey().equals("vid")) {
                        it.remove();
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        Map<String, Object> mymap = new HashMap<String, Object>();
        mymap.put("tags", readObject1);

        readObject.add(mymap);
        String count = null;
        if ("true".equalsIgnoreCase(request.getRequest_data().getTotalCountFlag())) {
            count = dao.getCount(SibConstants.SqlMapper.SQL_SIB_SEARCH_VIDEOS_PN_COUNT,
                    new Object[] { "%" + request.getRequest_data().getTitle().trim() + "%" });
        }

        response = new SimpleResponse(SibConstants.SUCCESS, request.getRequest_data_type(),
                request.getRequest_data_method(), readObject, count);
    } catch (Exception e) {
        e.printStackTrace();
        response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                request.getRequest_data_method(), e.getMessage());
    }
    return new ResponseEntity<Response>(response, HttpStatus.OK);
}

From source file:com.siblinks.ws.service.impl.VideoServiceImpl.java

/**
 * {@inheritDoc}/*from  www. j a  v a 2 s .c om*/
 */
@Override
@RequestMapping(value = "/remove", method = RequestMethod.POST)
public ResponseEntity<Response> removeVideo(@RequestBody final RequestData request) {
    SimpleResponse response = null;
    try {
        String entityName = null;

        if (!AuthenticationFilter.isAuthed(context)) {
            response = new SimpleResponse(SibConstants.FAILURE, "Authentication required.");
            return new ResponseEntity<Response>(response, HttpStatus.FORBIDDEN);
        }

        Map<String, String> queryParams = new HashMap<String, String>();

        queryParams.put("vid", request.getRequest_data().getVid());

        entityName = SibConstants.SqlMapper.SQL_SIB_REMOVE_VIDEO;
        boolean status = dao.insertUpdateObject(entityName, queryParams);

        response = new SimpleResponse("" + status, request.getRequest_data_type(),
                request.getRequest_data_method(), status);
    } catch (Exception e) {
        e.printStackTrace();
        response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                request.getRequest_data_method(), e.getMessage());
    }
    return new ResponseEntity<Response>(response, HttpStatus.OK);
}

From source file:com.siblinks.ws.service.impl.VideoServiceImpl.java

/**
 * {@inheritDoc}//from  w  w  w .  j  av  a  2s .c  o m
 */
@Override
@RequestMapping(value = "/rateVideo", method = RequestMethod.POST)
public ResponseEntity<Response> rateVideo(@RequestBody final RequestData request) {
    String entityName = null;
    boolean status = false;
    SimpleResponse response = null;
    TransactionStatus statusDao = null;
    try {
        if (!AuthenticationFilter.isAuthed(context)) {
            response = new SimpleResponse(SibConstants.FAILURE, "Authentication required.");
            return new ResponseEntity<Response>(response, HttpStatus.FORBIDDEN);
        }

        String vid = request.getRequest_data().getVid();
        String uid = request.getRequest_data().getUid();
        String rate = request.getRequest_data().getRating();

        // Return if vid or uid
        if (StringUtil.isNull(vid) || StringUtil.isNull(uid) || StringUtil.isNull(rate)) {
            response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                    request.getRequest_data_method(), "Parameter cannot null or Emppty.");
            return new ResponseEntity<Response>(response, HttpStatus.OK);
        }

        TransactionDefinition def = new DefaultTransactionDefinition();
        statusDao = transactionManager.getTransaction(def);

        Object[] queryParams = new Object[] { uid, vid };

        entityName = SibConstants.SqlMapper.SQL_SIB_GET_USER_RATE_VIDEO;

        List<Object> videoRated = dao.readObjects(entityName, queryParams);

        boolean isRated = videoRated.size() > 0 ? true : false;

        if (!isRated) {
            entityName = SibConstants.SqlMapper.SQL_SIB_RATE_VIDEO;
            queryParams = new Object[] { vid, uid, rate };

            Object[] queryUpdateRate = { rate, vid };
            dao.insertUpdateObject(SibConstants.SqlMapper.SQL_UPDATE_AVG_RATE, queryUpdateRate);
            status = dao.insertUpdateObject(entityName, queryParams);
        } else {
            int newRate = Integer.parseInt(rate);
            int rateOld = ((Map<String, Integer>) videoRated.get(0)).get(Parameters.RATING);
            if (newRate != rateOld) {
                queryParams = new Object[] { rate, vid, uid };
                entityName = SibConstants.SqlMapper.SQL_SIB_RATE_UPDATE_VIDEO;

                // Update again
                Object[] queryUpdateRate = { newRate - rateOld, vid };
                dao.insertUpdateObject(SibConstants.SqlMapper.SQL_UPDATE_AVG_RATE_AGAIN, queryUpdateRate);
                status = dao.insertUpdateObject(entityName, queryParams);
            }
        }

        transactionManager.commit(statusDao);
        logger.info("Rate video success " + new Date());
        response = new SimpleResponse("" + status, request.getRequest_data_type(),
                request.getRequest_data_method(), request.getRequest_data().getVid());
    } catch (Exception e) {
        e.printStackTrace();
        if (transactionManager != null) {
            transactionManager.rollback(statusDao);
        }
        response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                request.getRequest_data_method(), e.getMessage());
    }
    return new ResponseEntity<Response>(response, HttpStatus.OK);
}

From source file:com.siblinks.ws.service.impl.VideoServiceImpl.java

/**
 * {@inheritDoc}/*from ww  w .  j  a  v  a  2s . c o m*/
 */
@Override
@RequestMapping(value = "/rateVideoAdmission", method = RequestMethod.POST)
public ResponseEntity<Response> rateVideoAdmission(@RequestBody final RequestData request) {
    String entityName = null;
    boolean status = false;
    SimpleResponse response = null;
    TransactionStatus statusDao = null;
    try {
        if (!AuthenticationFilter.isAuthed(context)) {
            response = new SimpleResponse(SibConstants.FAILURE, "Authentication required.");
            return new ResponseEntity<Response>(response, HttpStatus.FORBIDDEN);
        }

        String vid = request.getRequest_data().getVid();
        String uid = request.getRequest_data().getUid();
        String rate = request.getRequest_data().getRating();
        // Return if vid or uid
        if (StringUtil.isNull(vid) || StringUtil.isNull(uid) || StringUtil.isNull(rate)) {
            response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                    request.getRequest_data_method(), "Parameter cannot null or Emppty.");
            return new ResponseEntity<Response>(response, HttpStatus.OK);
        }
        TransactionDefinition def = new DefaultTransactionDefinition();
        statusDao = transactionManager.getTransaction(def);
        // Check user rated yet
        Object[] queryParams = new Object[] { request.getRequest_data().getUid(),
                request.getRequest_data().getVid() };
        List<Object> videoRated = dao.readObjects(SibConstants.SqlMapper.SQL_SIB_GET_USER_RATE_VIDEO_ADMISSION,
                queryParams);

        boolean isRated = videoRated.size() > 0 ? true : false;

        if (!isRated) {
            // New rating
            entityName = SibConstants.SqlMapper.SQL_SIB_RATE_VIDEO_ADMISSION;
            queryParams = new Object[] { vid, uid, rate };
            status = dao.insertUpdateObject(entityName, queryParams);

            Object[] queryUpdateRate = { rate, vid };
            status = dao.insertUpdateObject(SibConstants.SqlMapper.SQL_UPDATE_AVG_RATE_VIDEO_ADMISSION,
                    queryUpdateRate);
            // Activity Log
            activiLogService.insertActivityLog(new ActivityLogData(SibConstants.TYPE_VIDEO, "C",
                    "You rated a video", uid, String.valueOf(vid)));
        } else {
            Map<String, Integer> object = (Map<String, Integer>) videoRated.get(0);
            int rateOld = object.get(Parameters.RATING);
            int rateNew = Integer.parseInt(rate);
            if (rateNew != rateOld) {
                // Update rating
                queryParams = new Object[] { rate, vid, uid };
                entityName = SibConstants.SqlMapper.SQL_SIB_RATE_UPDATE_VIDEO_ADMISSION;
                status = dao.insertUpdateObject(entityName, queryParams);

                Object[] queryUpdateRate = { rateNew - rateOld, vid };
                status = dao.insertUpdateObject(
                        SibConstants.SqlMapper.SQL_UPDATE_AVG_RATE_VIDEO_ADMISSION_AGAIN, queryUpdateRate);
                // Activity Log
                activiLogService.insertActivityLog(new ActivityLogData(SibConstants.TYPE_VIDEO, "U",
                        "You updated the rating a video", uid, String.valueOf(vid)));
            }
        }

        transactionManager.commit(statusDao);
        logger.info("Rating video addmission successful" + new Date());

        response = new SimpleResponse("" + status, request.getRequest_data_type(),
                request.getRequest_data_method(), request.getRequest_data().getVid());
    } catch (Exception e) {
        if (statusDao != null) {
            transactionManager.rollback(statusDao);
        }
        e.printStackTrace();
        response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                request.getRequest_data_method(), e.getMessage());
    }
    return new ResponseEntity<Response>(response, HttpStatus.OK);
}

From source file:com.siblinks.ws.service.impl.VideoServiceImpl.java

/**
 * {@inheritDoc}/*from  w  ww  .  j a  v  a2s . c om*/
 */
@Override
@RequestMapping(value = "/updateVideo", method = RequestMethod.POST)
public @ResponseBody ResponseEntity<Response> updateVideo(@RequestBody final RequestData request) {
    SimpleResponse response = null;
    TransactionStatus statusDao = null;
    try {
        if (!AuthenticationFilter.isAuthed(context)) {
            response = new SimpleResponse(SibConstants.FAILURE, "Authentication required.");
            return new ResponseEntity<Response>(response, HttpStatus.FORBIDDEN);
        }

        TransactionDefinition def = new DefaultTransactionDefinition();
        statusDao = transactionManager.getTransaction(def);
        boolean status = true;
        String message = "";
        String description = request.getRequest_data().getDescription();
        String strTitle = request.getRequest_data().getTitle();
        if (description != null && description.length() > 1024) {
            response = new SimpleResponse(SibConstants.SUCCESS, request.getRequest_data_type(),
                    request.getRequest_data_method(), "Description cannot longer than 1024 characters");
        } else {
            List<Map<String, String>> allWordFilter = cachedDao.getAllWordFilter();
            description = CommonUtil.filterWord(description, allWordFilter);
            strTitle = CommonUtil.filterWord(strTitle, allWordFilter);

            String vid = request.getRequest_data().getVid();
            Object[] queryParams = new Object[] { strTitle, description,
                    request.getRequest_data().getSubjectId(), vid };
            status = dao.insertUpdateObject(SibConstants.SqlMapper.SQL_UPDATE_VIDEO, queryParams);
            if (status) {
                String plid = request.getRequest_data().getPlid();
                if (plid != null && plid.length() > 0) {
                    // remove old playlist
                    queryParams = new Object[] { vid };
                    status = dao.insertUpdateObject(SibConstants.SqlMapperBROT43.SQL_DELETE_VIDEO_PLAYLIST,
                            queryParams);

                    // insert new playlist
                    queryParams = new Object[] { plid, vid };
                    status = dao.insertUpdateObject(SibConstants.SqlMapperBROT126.SQL_ADD_VIDEOS_PLAYLIST,
                            queryParams);
                } else {
                    // remove playlist if exists
                    queryParams = new Object[] { vid };
                    dao.insertUpdateObject(SibConstants.SqlMapperBROT43.SQL_DELETE_VIDEO_PLAYLIST, queryParams);
                }
            }
            if (status) {
                activiLogService.insertActivityLog(new ActivityLogData(SibConstants.TYPE_VIDEO, "U",
                        "You updateded a video", request.getRequest_data().getAuthorID(), String.valueOf(vid)));
                transactionManager.commit(statusDao);
                Map<String, String> dataChange = new HashMap<String, String>();
                dataChange.put("title", strTitle);
                dataChange.put("description", description);
                response = new SimpleResponse(SibConstants.SUCCESS, request.getRequest_data_type(),
                        request.getRequest_data_method(), dataChange);
            } else {
                transactionManager.rollback(statusDao);
                response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                        request.getRequest_data_method(), message);
            }

        }
    } catch (Exception e) {
        if (statusDao != null) {
            transactionManager.rollback(statusDao);
        }
        e.printStackTrace();
        response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                request.getRequest_data_method(), e.getMessage());
    }
    return new ResponseEntity<Response>(response, HttpStatus.OK);
}

From source file:com.siblinks.ws.service.impl.VideoServiceImpl.java

/**
 * {@inheritDoc}/*  ww w.j  a  va  2s  .c  om*/
 */
@Override
@RequestMapping(value = "/updateViewVideo", method = RequestMethod.POST)
public @ResponseBody ResponseEntity<Response> updateViewVideo(@RequestBody final RequestData request) {
    SimpleResponse response = null;
    try {
        if (!AuthenticationFilter.isAuthed(context)) {
            response = new SimpleResponse(SibConstants.FAILURE, "Authentication required.");
            return new ResponseEntity<Response>(response, HttpStatus.FORBIDDEN);
        }

        // Map<String, String> queryParams = new HashMap<String, String>();
        // queryParams.put("vid", request.getRequest_data().getVid());
        Object[] queryParams = { request.getRequest_data().getVid() };
        String entityName = SibConstants.SqlMapper.SQL_UPDATE_NUMVIEW_VIDEO;
        boolean status = true;
        status = dao.insertUpdateObject(entityName, queryParams);
        String message = "";
        if (status) {
            message = "Done";
        } else {
            message = "Fail";
        }

        response = new SimpleResponse("" + status, request.getRequest_data_type(),
                request.getRequest_data_method(), message);
    } catch (Exception e) {
        e.printStackTrace();
        response = new SimpleResponse(SibConstants.FAILURE, request.getRequest_data_type(),
                request.getRequest_data_method(), e.getMessage());
    }
    return new ResponseEntity<Response>(response, HttpStatus.OK);
}