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}/*from  w  ww  . j  av  a 2s .  c  o m*/
 */
@Override
@RequestMapping(value = "/getMentorsOfVideo", method = RequestMethod.POST)
public ResponseEntity<Response> getMentorsOfVideo(@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);
        }

        Object[] queryParams = new Object[] { request.getRequest_data().getSubjectId() };
        List<Object> readObject = dao.readObjects(SibConstants.SqlMapper.SQL_SIB_VIDEO_MENTORS_READ,
                queryParams);

        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}/*from w w  w .jav  a 2s  . c  o m*/
 */
@Override
@RequestMapping(value = "/getMentorReviewsPN", method = RequestMethod.POST)
public ResponseEntity<Response> getMentorReviewsPN(@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);
        }

        //
        CommonUtil util = CommonUtil.getInstance();
        Map<String, String> map = util.getLimit(request.getRequest_data().getPageno(),
                request.getRequest_data().getLimit());
        Object[] queryParams = { request.getRequest_data().getUid(), map.get(Parameters.FROM),
                map.get(Parameters.TO) };
        String entityName = SibConstants.SqlMapper.SQL_SIB_MENTOR_REVIEWS_READ;

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

        String count = null;
        if ("true".equalsIgnoreCase(request.getRequest_data().getTotalCountFlag())) {
            count = dao.getCount(SibConstants.SqlMapper.SQL_SIB_MENTOR_REVIEWS_READ_COUNT, queryParams);
        }

        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  ww  .  ja  v a  2s  .com*/
 */
@Override
@RequestMapping(value = "/getVideoDetailsPN", method = RequestMethod.POST)
public ResponseEntity<Response> getVideoDetailsPN(@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);
        }

        CommonUtil util = CommonUtil.getInstance();

        Map<String, String> map = util.getLimit(request.getRequest_data().getPageno(),
                request.getRequest_data().getLimit());
        Object[] queryParams = { request.getRequest_data().getStringJson(), map.get(Parameters.FROM),
                map.get(Parameters.TO) };

        List<Object> readObject = dao.readObjects(SibConstants.SqlMapper.SQL_VIDEO_SUBJECT_MAPPING_DATA_READ_PN,
                queryParams);
        String count = null;
        if ("true".equalsIgnoreCase(request.getRequest_data().getTotalCountFlag())) {
            count = dao.getCount(SibConstants.SqlMapper.SQL_VIDEO_SUBJECT_MAPPING_DATA_READ_PN_COUNT,
                    queryParams);
        }

        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  w w  w  .j  a v  a  2s  .  c  o  m*/
 */
@Override
@RequestMapping(value = "/updateVideoDetails", method = RequestMethod.POST)
public ResponseEntity<Response> updateVideoDetails(@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);
        }

        ObjectMapper mapper = new ObjectMapper();
        ManageVideoModel manageVideoModel = null;
        try {
            manageVideoModel = mapper.readValue(request.getRequest_data().getStringJson(),
                    ManageVideoModel.class);
        } catch (JsonParseException e) {
            e.printStackTrace();
        } catch (JsonMappingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        Object[] queryParams = null;
        boolean insertFlag = false;
        if (manageVideoModel != null) {
            queryParams = new Object[] { manageVideoModel.getSubject_category_id(),
                    manageVideoModel.getSubject_category_name(), manageVideoModel.getDescription(),
                    manageVideoModel.getActive() };
            insertFlag = dao.insertUpdateObject(SibConstants.SqlMapper.SQL_VIDEO_SUBJECT_MAPPING_DATA_UPDATE,
                    queryParams);
        }

        response = new SimpleResponse(SibConstants.SUCCESS, request.getRequest_data_type(),
                request.getRequest_data_method(), insertFlag);
    } 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  ww  .jav  a  2  s .  c  o  m
 */
@Override
@RequestMapping(value = "/createVideo", method = RequestMethod.POST)
public ResponseEntity<Response> createVideo(@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);
        }

        List<ManageVideoModel> newVideoDetails = new ArrayList<ManageVideoModel>();
        ObjectMapper mapper = new ObjectMapper();
        try {
            newVideoDetails = mapper.readValue(request.getRequest_data().getStringJson(),
                    new TypeReference<List<ManageVideoModel>>() {
                    });
        } catch (JsonParseException e) {
            e.printStackTrace();
        } catch (JsonMappingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        String entityName = SibConstants.SqlMapper.SQL_VIDEO_SUBJECT_MAPPING_DATA_INSERT;

        Map<String, String> queryParams = new HashMap<String, String>();
        String active = null;
        boolean flag = true;
        if (!CollectionUtils.isEmpty(newVideoDetails)) {
            for (ManageVideoModel manageVideoModel : newVideoDetails) {
                queryParams.put("subject_id", "" + manageVideoModel.getSubject_id());
                queryParams.put("subject_category_name", manageVideoModel.getSubject_category_name());
                queryParams.put("description", manageVideoModel.getDescription());
                if (null != manageVideoModel.getActive()) {
                    if (manageVideoModel.getActive().equalsIgnoreCase("1")) {
                        active = "Y";
                    } else {
                        active = "N";
                    }
                }
                queryParams.put("active", active);
                queryParams.put("createdBy", loggedInChecker.getLoggedInUser().getUserid());
                boolean insertFlag = dao.insertUpdateObject(entityName, queryParams);
                if (!insertFlag) {
                    flag = false;
                    break;
                }
            }
        }

        response = new SimpleResponse(SibConstants.SUCCESS, request.getRequest_data_type(),
                request.getRequest_data_method(), flag);
    } 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 ww .j  a  v a2s  .c om*/
 */
@Override
@RequestMapping(value = "/uploadVideo", method = RequestMethod.POST)
public ResponseEntity<Response> uploadVideo(@RequestBody final RequestData request) {
    String entityName = null;
    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("title", request.getRequest_data().getTitle());
        queryParams.put("author", request.getRequest_data().getAuthor());
        queryParams.put("authorID", request.getRequest_data().getAuthorID());
        queryParams.put("subject", request.getRequest_data().getSubject());
        queryParams.put("topic", request.getRequest_data().getTopic());
        queryParams.put("subTopic", request.getRequest_data().getSubtopic());
        queryParams.put("description", request.getRequest_data().getDescription());
        queryParams.put("image", request.getRequest_data().getImage());
        queryParams.put("url", request.getRequest_data().getUrl());
        queryParams.put("runningtime", request.getRequest_data().getRunningTime());
        queryParams.put("timeStamp", "now()");

        entityName = SibConstants.SqlMapper.SQL_SIB_INSERT_VIDEO;
        boolean status = dao.insertUpdateObject(entityName, queryParams);
        boolean tagStatus = true;
        Map<String, String> queryParams1 = null;
        if (status) {
            entityName = SibConstants.SqlMapper.SQL_SIB_GET_VID;
            queryParams1 = new HashMap<String, String>();
            queryParams1.put("authorID", request.getRequest_data().getAuthorID());
            queryParams1.put("url", request.getRequest_data().getUrl());

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

            for (Tag tag : request.getRequest_data().getTags()) {
                entityName = SibConstants.SqlMapper.SQL_SIB_INSERT_TAG;
                queryParams1 = new HashMap<String, String>();
                queryParams1.put("vid", ((Map) readObject.get(0)).get("vid").toString());
                queryParams1.put("tag", tag.getTag());
                boolean flag = dao.insertUpdateObject(entityName, queryParams1);
                if (!flag) {
                    tagStatus = false;
                    break;
                }
            }
        }

        int vid = 0;
        if (queryParams1 != null) {
            String svid = queryParams1.get("vid");
            if (svid != null && !"".equals(svid)) {
                vid = Integer.parseInt(svid);
            }
        }
        if (!status) {
            vid = 0;
        } else if (!tagStatus) {
            vid = 0;
        }

        response = new SimpleResponse("" + status, request.getRequest_data_type(),
                request.getRequest_data_method(), vid);
    } 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 a2  s .  co m*/
 */
@Override
@RequestMapping(value = "/getVideoCommentsPN", method = RequestMethod.POST)
public ResponseEntity<Response> getVideoCommentsPN(@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());

        Object[] queryParams = { request.getRequest_data().getVid(), map.get(Parameters.FROM),
                map.get(Parameters.TO) };

        entityName = SibConstants.SqlMapper.SQL_SIB_GET_COMMENTS_PN;

        List<Object> readObject = dao.readObjects(entityName, queryParams);
        String count = null;
        if ("true".equalsIgnoreCase(request.getRequest_data().getTotalCountFlag())) {
            count = dao.getCount(SibConstants.SqlMapper.SQL_SIB_GET_COMMENTS_PN_COUNT, queryParams);
        }

        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 ww  w. j a v a2s . co  m*/
 */
@Override
@RequestMapping(value = "/getVideoComments", method = RequestMethod.POST)
public ResponseEntity<Response> getVideoComments(@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_GET_COMMENTS;

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

        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.  java2s . com*/
 */
@Override
@RequestMapping(value = "/editVideoInfo", method = RequestMethod.POST)
public ResponseEntity<Response> editVideoInfo(@RequestBody final RequestData request) {

    String entityName = null;
    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());
        queryParams.put("title", request.getRequest_data().getTitle());
        queryParams.put("description", request.getRequest_data().getDescription());

        entityName = SibConstants.SqlMapper.SQL_SIB_EDIT_VIDEO;

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

        if (status) {
            entityName = SibConstants.SqlMapper.SQL_SIB_DELETE_TAGS;
            status = dao.insertUpdateObject(entityName, queryParams);

            entityName = SibConstants.SqlMapper.SQL_SIB_INSERT_TAG;
            Map<String, String> queryParams1 = null;
            for (Tag tag : request.getRequest_data().getTags()) {
                queryParams1 = new HashMap<String, String>();
                queryParams1.put("vid", request.getRequest_data().getVid());
                queryParams1.put("tag", tag.getTag());
                dao.insertUpdateObject(entityName, queryParams1);
            }
        }
        response = new SimpleResponse("" + status, request.getRequest_data_type(),
                request.getRequest_data_method(), request.getRequest_data().getVid());
    } 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}// ww  w.  ja  v a2  s  . c  o m
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@RequestMapping(value = "/getVideosWithSubTopic", method = RequestMethod.POST)
public ResponseEntity<Response> getVideosWithSubTopic(@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());
        queryParams.put("subjectId", request.getRequest_data().getSubjectId().trim());
        queryParams.put("topic", request.getRequest_data().getTopic().trim());
        queryParams.put("subtopic", request.getRequest_data().getSubtopic().trim());

        entityName = SibConstants.SqlMapper.SQL_SIB_GET_VIDEO_WITH_SUB_TOPIC;

        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");
            return new ResponseEntity<Response>(response, HttpStatus.OK);
        }

        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);
    } 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);
}