Example usage for org.springframework.web.bind.annotation RequestMethod HEAD

List of usage examples for org.springframework.web.bind.annotation RequestMethod HEAD

Introduction

In this page you can find the example usage for org.springframework.web.bind.annotation RequestMethod HEAD.

Prototype

RequestMethod HEAD

To view the source code for org.springframework.web.bind.annotation RequestMethod HEAD.

Click Source Link

Usage

From source file:edu.isi.misd.scanner.network.registry.web.controller.StudyController.java

@RequestMapping(value = BASE_PATH, method = { RequestMethod.GET,
        RequestMethod.HEAD }, produces = HEADER_JSON_MEDIA_TYPE)
public @ResponseBody List<Study> getStudies(@RequestParam Map<String, String> paramMap) {
    Map<String, String> params = validateParameterMap(paramMap, REQUEST_PARAM_STUDY_NAME,
            REQUEST_PARAM_USER_NAME);//w  ww .  j a  v  a  2  s  .  com

    String studyName = params.get(REQUEST_PARAM_STUDY_NAME);
    String userName = params.get(REQUEST_PARAM_USER_NAME);
    List<Study> studies = new ArrayList<Study>();
    if (studyName != null) {
        Study study = studyRepository.findByStudyName(studyName);
        if (study == null) {
            throw new ResourceNotFoundException(studyName);
        }
        studies.add(study);
    } else if (userName != null) {
        return studyRepository.findStudiesForUserName(userName);
    } else {
        Iterator iter = studyRepository.findAll().iterator();
        CollectionUtils.addAll(studies, iter);
    }
    return studies;
}

From source file:org.mashupmedia.controller.remote.RemoteLibraryController.java

@RequestMapping(value = "/stream/{uniqueName}/{mediaItemId}", method = { RequestMethod.GET,
        RequestMethod.HEAD })
public ModelAndView handleStreamMediaItem(HttpServletRequest request, @PathVariable String uniqueName,
        @PathVariable Long mediaItemId, Model model) throws IOException {
    Library remoteLibrary = getRemoteLibrary(uniqueName, request, true);
    if (remoteLibrary == null) {
        logger.info("Unable to stream remote media, unknown host: " + request.getRemoteHost());
        return null;
    }/*from  ww  w  . java2 s  .  co  m*/

    logInAsSystemuser(request);

    StringBuilder servletPathBuilder = new StringBuilder(request.getServletPath());
    servletPathBuilder.append("/streaming/media");
    servletPathBuilder.append("/" + mediaItemId);
    return new ModelAndView("forward:" + servletPathBuilder.toString());
}

From source file:edu.isi.misd.scanner.network.registry.web.controller.AnalysisPolicyStatementController.java

@RequestMapping(value = BASE_PATH, method = { RequestMethod.GET,
        RequestMethod.HEAD }, produces = HEADER_JSON_MEDIA_TYPE)
public @ResponseBody List<AnalysisPolicyStatement> getAnalysisPolicyStatements(
        @RequestParam Map<String, String> paramMap) {
    Map<String, String> params = validateParameterMap(paramMap, REQUEST_PARAM_USER_NAME,
            REQUEST_PARAM_INSTANCE_ID, REQUEST_PARAM_ANALYSIS_TOOL_ID);

    if (!params.isEmpty()) {
        ArrayList<String> missingParams = new ArrayList<String>();
        String userName = params.get(REQUEST_PARAM_USER_NAME);
        if (userName == null) {
            missingParams.add(REQUEST_PARAM_USER_NAME);
        }//from   www  .  ja va  2s .  com
        String instanceId = params.get(REQUEST_PARAM_INSTANCE_ID);
        if (instanceId == null) {
            missingParams.add(REQUEST_PARAM_INSTANCE_ID);
        }
        String toolId = params.get(REQUEST_PARAM_ANALYSIS_TOOL_ID);
        if (toolId == null) {
            missingParams.add(REQUEST_PARAM_ANALYSIS_TOOL_ID);
        }
        if (!missingParams.isEmpty()) {
            throw new BadRequestException("Required parameter(s) missing: " + missingParams);
        }
        return analysisPolicyStatementRepository.findAnalysisPolicyStatementByUserNameAndInstanceIdAndToolId(
                userName, validateIntegerParameter(REQUEST_PARAM_INSTANCE_ID, instanceId),
                validateIntegerParameter(REQUEST_PARAM_ANALYSIS_TOOL_ID, toolId));
    }

    List<AnalysisPolicyStatement> analysisPolicyStatements = new ArrayList<AnalysisPolicyStatement>();
    Iterator iter = analysisPolicyStatementRepository.findAll().iterator();
    CollectionUtils.addAll(analysisPolicyStatements, iter);

    return analysisPolicyStatements;
}

From source file:org.owasp.dependencytrack.controller.LoginController.java

/**
 * Login action./*from  ww w  .j  a  va  2 s.c o  m*/
 *
 * @param request a HttpServletRequest object
 * @param response a HttpServletResponse object
 * @return a String
 */
@RequestMapping(value = "/login", method = { RequestMethod.GET, RequestMethod.HEAD })
public String login(HttpServletRequest request, HttpServletResponse response) {
    setLdapStatus(request, false);
    response.addCookie(new Cookie("CONTEXTPATH", getServletContext().getContextPath()));
    final String s = "loginPage";
    if (SecurityUtils.getSubject().isAuthenticated()) {
        return "redirect:/dashboard";
    }
    return s;
}

From source file:ru.org.linux.topic.TopicListController.java

@RequestMapping(value = "/view-news.jsp", method = { RequestMethod.GET, RequestMethod.HEAD }, params = {
        "tag" })//from   w ww. ja v a  2  s. co m
public View tagFeedOld(TopicListRequest topicListForm) {
    return new RedirectView(tagListUrl(topicListForm.getTag()));
}

From source file:edu.isi.misd.scanner.network.registry.web.controller.StudyRequestedSiteController.java

@RequestMapping(value = BASE_PATH, method = { RequestMethod.GET,
        RequestMethod.HEAD }, produces = HEADER_JSON_MEDIA_TYPE)
public @ResponseBody List<StudyRequestedSite> getStudyRequestedSites(
        @RequestParam Map<String, String> paramMap) {
    Map<String, String> params = validateParameterMap(paramMap, REQUEST_PARAM_SITE_ID, REQUEST_PARAM_STUDY_ID);

    String siteId = params.get(REQUEST_PARAM_SITE_ID);
    String studyId = params.get(REQUEST_PARAM_STUDY_ID);
    List<StudyRequestedSite> studyRequestedSites = new ArrayList<StudyRequestedSite>();
    if (siteId != null) {
        return studyRequestedSiteRepository
                .findBySiteSiteId(validateIntegerParameter(REQUEST_PARAM_SITE_ID, siteId));
    } else if (studyId != null) {
        return studyRequestedSiteRepository
                .findByStudyStudyId(validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId));
    } else {//from   w  ww.j  a  va 2  s .c  o m
        Iterator iter = studyRequestedSiteRepository.findAll().iterator();
        CollectionUtils.addAll(studyRequestedSites, iter);
    }
    return studyRequestedSites;
}

From source file:edu.isi.misd.scanner.network.registry.web.controller.StudyRoleController.java

@RequestMapping(value = BASE_PATH, method = { RequestMethod.GET,
        RequestMethod.HEAD }, produces = HEADER_JSON_MEDIA_TYPE)
public @ResponseBody List<StudyRole> getStudyRoles(@RequestParam Map<String, String> paramMap) {
    Map<String, String> params = validateParameterMap(paramMap, REQUEST_PARAM_STUDY_ID, REQUEST_PARAM_SITE_ID,
            REQUEST_PARAM_USER_NAME);/*from ww  w .j  a  va 2 s  . com*/

    String studyId = params.get(REQUEST_PARAM_STUDY_ID);
    String siteId = params.get(REQUEST_PARAM_SITE_ID);
    String userName = params.get(REQUEST_PARAM_USER_NAME);
    if ((studyId != null) && (userName != null)) {
        return studyRoleRepository.findByStudyStudyIdAndScannerUsersUserName(
                validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId), userName);
    } else if (studyId != null) {
        return studyRoleRepository
                .findByStudyStudyId(validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId));
    } else if (siteId != null) {
        return studyRoleRepository.findByStudyStudyRequestedSitesSiteSiteId(
                validateIntegerParameter(REQUEST_PARAM_SITE_ID, siteId));
    } else if (userName != null) {
        return studyRoleRepository.findByScannerUsersUserName(userName);
    } else {
        List<StudyRole> roles = new ArrayList<StudyRole>();
        Iterator iter = studyRoleRepository.findAll().iterator();
        CollectionUtils.addAll(roles, iter);
        return roles;
    }
}

From source file:de.codecentric.boot.admin.actuate.LogfileMvcEndpoint.java

@RequestMapping(method = RequestMethod.HEAD)
@ResponseBody/*from  w ww . java 2 s .  c  o  m*/
public ResponseEntity<Object> available() {
    if (isAvailable()) {
        return new ResponseEntity<Object>(HttpStatus.OK);
    } else {
        return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
    }
}

From source file:edu.isi.misd.scanner.network.registry.web.controller.UserRoleController.java

@RequestMapping(value = BASE_PATH, method = { RequestMethod.GET,
        RequestMethod.HEAD }, produces = HEADER_JSON_MEDIA_TYPE)
public @ResponseBody List<UserRole> getUserRoles(@RequestParam Map<String, String> paramMap) {
    Map<String, String> params = validateParameterMap(paramMap, REQUEST_PARAM_USER_NAME, REQUEST_PARAM_STUDY_ID,
            REQUEST_PARAM_SITE_ID, REQUEST_PARAM_NODE_ID, REQUEST_PARAM_DATASET_INSTANCE_ID);

    String userName = params.get(REQUEST_PARAM_USER_NAME);
    String studyId = params.get(REQUEST_PARAM_STUDY_ID);
    String siteId = params.get(REQUEST_PARAM_SITE_ID);
    String nodeId = params.get(REQUEST_PARAM_NODE_ID);
    String dataSetInstanceId = params.get(REQUEST_PARAM_DATASET_INSTANCE_ID);

    if (userName != null) {
        if (studyId != null) {
            return userRoleRepository.findByUserUserNameAndStudyRoleStudyStudyId(userName,
                    validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId));
        } else if (siteId != null) {
            return userRoleRepository.findByUserUserNameAndStudyRoleSitePoliciesSiteSiteId(userName,
                    validateIntegerParameter(REQUEST_PARAM_SITE_ID, siteId));
        } else if (nodeId != null) {
            return userRoleRepository.findByUserUserNameAndStudyRoleSitePoliciesSiteNodesNodeId(userName,
                    validateIntegerParameter(REQUEST_PARAM_NODE_ID, nodeId));
        } else if (dataSetInstanceId != null) {
            return userRoleRepository
                    .findByUserUserNameAndStudyRoleSitePoliciesSiteNodesDataSetInstancesDataSetInstanceId(
                            userName,/*from w w w  .j a  va  2s  .c  om*/
                            validateIntegerParameter(REQUEST_PARAM_DATASET_INSTANCE_ID, dataSetInstanceId));
        } else {
            return userRoleRepository.findByUserUserName(userName);
        }
    } else if (studyId != null) {
        if (siteId != null) {
            return userRoleRepository.findByStudyRoleStudyStudyIdAndStudyRoleSitePoliciesSiteSiteId(
                    validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId),
                    validateIntegerParameter(REQUEST_PARAM_SITE_ID, siteId));
        } else {
            return userRoleRepository
                    .findByStudyRoleStudyStudyId(validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId));
        }
    } else if (siteId != null || nodeId != null || dataSetInstanceId != null) {
        throw new BadRequestException("Required parameter missing: " + REQUEST_PARAM_USER_NAME);
    } else {
        List<UserRole> roles = new ArrayList<UserRole>();
        Iterator iter = userRoleRepository.findAll().iterator();
        CollectionUtils.addAll(roles, iter);
        return roles;
    }
}

From source file:com.kolich.pusachat.spring.controllers.api.Chat.java

@RequestMapping(method = { RequestMethod.GET, RequestMethod.HEAD }, value = "/event/{token}")
public ModelAndView event(@PathVariable final String token) {
    return new PusaChatControllerClosure<ModelAndView>("GET:/api/chat/event/" + token, logger__) {
        @Override/*w  w  w . j av a 2 s.  com*/
        public ModelAndView doit() throws Exception {
            final PusaChatSession session = getSession(token);
            // NOTE: We used to wait here forever, then we realized that we
            // can use the poll() method to only wait up-to a certain amount
            // of time. This works great becuase now we don't need to waste
            // resources on a special "ping" method.  We simply have the
            // client wait for 10-seconds then return a NOOP if no events
            // are to be delivered to the waiting client within that
            // 10-second interval. Upon receiving the NOOP, the client
            // should immeaditely kick off another BOSH transaction which
            // calls this method again, hence acting like a "ping".
            //final PusaChatEvent event = session.getEventQueue().take();
            final PusaChatEvent event = session.getEventQueue().poll(
                    // Wait at least this long for a new event to fall into
                    // the queue.
                    DEFAULT_BOSH_WAIT_IN_SECONDS,
                    // Seconds.
                    SECONDS);
            return getModelAndView(VIEW_NAME,
                    // The poll() method may expire before there are any events
                    // worth sending to the client.
                    (event != null) ?
            // Real event.
            event :
            // Nothing, event was null, so just return a NOOP.
            new NoOp());
        }
    }.execute();
}