Java Code Examples for org.springframework.web.bind.annotation.RequestMapping

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project banshun, under directory /banshun/web/src/main/java/com/griddynamics/banshun/web/.

Source file: ContextParentAnnotationHandlerMapping.java

  22 
vote

protected void validateHandler(Object handler,HttpServletRequest request) throws Exception {
  RequestMapping mapping=this.cachedMappings.get(handler.getClass());
  if (mapping == null) {
    mapping=AnnotationUtils.findAnnotation(handler.getClass(),RequestMapping.class);
  }
  if (mapping != null) {
    validateMapping(mapping,request);
  }
}
 

Example 2

From project banshun, under directory /banshun/web/src/main/java/com/griddynamics/banshun/web/.

Source file: ContextParentAnnotationHandlerMapping.java

  21 
vote

protected String[] determineUrlsByAnnotations(Object handler){
  Class<? extends Object> handlerType=handler.getClass();
  RequestMapping mapping=AnnotationUtils.findAnnotation(handlerType,RequestMapping.class);
  if (mapping != null) {
    this.cachedMappings.put(handlerType,mapping);
    Set<String> urls=new LinkedHashSet<String>();
    String[] paths=mapping.value();
    if (paths.length > 0) {
      for (      String path : paths) {
        addUrlsForPath(urls,path);
      }
      return StringUtils.toStringArray(urls);
    }
 else {
      return determineUrlsForHandlerMethods(handlerType);
    }
  }
 else   if (AnnotationUtils.findAnnotation(handlerType,Controller.class) != null) {
    return determineUrlsForHandlerMethods(handlerType);
  }
 else {
    return null;
  }
}
 

Example 3

From project addressbook-sample-mongodb, under directory /web-ui/src/main/java/nl/enovation/addressbook/cqrs/webui/controllers/.

Source file: ContactsController.java

  19 
vote

@RequestMapping(value="{identifier}",method=RequestMethod.GET) public String details(@PathVariable String identifier,Model model){
  ContactEntry contactEntry=contactRepositoryImpl.findOne(identifier);
  model.addAttribute("identifier",identifier);
  model.addAttribute("contact",contactEntry);
  return "contacts/details";
}
 

Example 4

From project addressbook-sample-mongodb, under directory /web-ui/src/main/java/nl/enovation/addressbook/cqrs/webui/controllers/.

Source file: ContactsController.java

  19 
vote

@RequestMapping(value="{identifier}/delete",method=RequestMethod.POST) public String formDelete(@ModelAttribute("contact") ContactEntry contact,BindingResult bindingResult){
  if (!bindingResult.hasErrors()) {
    AggregateIdentifier identifier=new StringAggregateIdentifier(contact.getIdentifier());
    RemoveContactCommand command=new RemoveContactCommand(identifier);
    LOGGER.debug("Dispatching command with name : {}",command.toString());
    commandBus.dispatch(command);
    return "redirect:/contacts";
  }
  return "contacts/delete";
}
 

Example 5

From project ALP, under directory /workspace/alp-reporter-fe/src/main/java/com/lohika/alp/reporter/fe/controller/.

Source file: LogController.java

  19 
vote

@RequestMapping(method=RequestMethod.POST,value="/results/test-method/{testMethodId}/log") void saveLog(@PathVariable("testMethodId") long id,@ModelAttribute("uploadItem") UploadItem uploadItem,HttpServletRequest request,HttpServletResponse response) throws IOException {
  CommonsMultipartFile fileData=uploadItem.getFileData();
  String name=fileData.getOriginalFilename();
  InputStream is=fileData.getInputStream();
  ServletContext sc=request.getSession().getServletContext();
  String datalogsPath=sc.getInitParameter("datalogsPath");
  if (name.toLowerCase().endsWith(".xml") || !name.matches(".*\\.\\w{1,3}$")) {
    logStorage.saveLog(id,"index.xml",is,datalogsPath);
    TestMethod testMethod=testMethodDAO.getTestMethod(id);
    testMethod.setHasLog(true);
    testMethodDAO.saveTestMethod(testMethod);
  }
 else {
    logStorage.saveLog(id,name,is,datalogsPath);
  }
  response.setStatus(HttpServletResponse.SC_CREATED);
}
 

Example 6

From project ALP, under directory /workspace/alp-reporter-fe/src/main/java/com/lohika/alp/reporter/fe/controller/.

Source file: LogController.java

  19 
vote

@RequestMapping(method=RequestMethod.GET,value="/results/test-method/{testMethodId}/log/") String getLog(Model model,HttpServletRequest request,@PathVariable("testMethodId") long id) throws IOException {
  ServletContext sc=request.getSession().getServletContext();
  String datalogsPath=sc.getInitParameter("datalogsPath");
  InputStream is=logStorage.getLog(id,"index.xml",datalogsPath);
  model.addAttribute(is);
  model.addAttribute("backButtonUrl",request.getHeader("referer"));
  model.addAttribute("contextPath","../../../..");
  return "log";
}
 

Example 7

From project alphaportal_dev, under directory /sys-src/alphaportal/web/src/main/java/alpha/portal/webapp/controller/.

Source file: CardAssignFormController.java

  19 
vote

/** 
 * Handles the viewing of all users who have the card's ContributorRole.
 * @param request the request
 * @param model the model
 */
@RequestMapping(method=RequestMethod.GET) protected void showForm(final HttpServletRequest request,final Model model){
  final String caseId=request.getParameter("case");
  final String cardId=request.getParameter("card");
  AlphaCard card=null;
  try {
    card=this.cardManager.get(new AlphaCardIdentifier(caseId,cardId));
  }
 catch (  final ObjectRetrievalFailureException e) {
    this.saveError(request,this.getText("cardassign.noCard",request.getLocale()));
  }
  if (card == null)   return;
  final Adornment contributorRole=card.getAlphaCardDescriptor().getAdornment(AdornmentType.ContributorRole.getName());
  if (contributorRole == null) {
    this.saveError(request,this.getText("cardassign.noContributorRole",request.getLocale()));
    return;
  }
  final ContributorRole role=this.contributorRoleManager.getContributorRoleByName(contributorRole.getValue());
  List<UserExtension> users=new LinkedList<UserExtension>();
  if ((role == null) || StringUtils.isBlank(role.getName())) {
    final List<User> list=this.getUserManager().getAll();
    for (    final User u : list) {
      users.add(new UserExtension(u));
    }
  }
 else {
    users=this.userExtensionManager.getUserExtensionsByContributorRole(role);
  }
  model.addAttribute("users",users);
}
 

Example 8

From project alphaportal_dev, under directory /sys-src/alphaportal/web/src/main/java/alpha/portal/webapp/controller/.

Source file: CardFileUploadController.java

  19 
vote

/** 
 * shows the card file upload site.
 * @param request the request
 * @return FileUpload
 * @see cardfileupload.jsp
 */
@ModelAttribute @RequestMapping(method=RequestMethod.GET) public FileUpload showForm(final HttpServletRequest request){
  final String caseId=request.getParameter("case");
  final String cardId=request.getParameter("card");
  final Locale locale=request.getLocale();
  request.setAttribute("case",caseId);
  request.setAttribute("card",cardId);
  this.setCancelView("redirect:/caseform?caseId=" + caseId + "&activeCardId="+ cardId);
  this.setSuccessView("redirect:/caseform?caseId=" + caseId + "&activeCardId="+ cardId);
  return new FileUpload();
}
 

Example 9

From project amber, under directory /oauth-2.0/client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/.

Source file: AuthzController.java

  19 
vote

@RequestMapping("/authorize") public ModelAndView authorize(@ModelAttribute("oauthParams") OAuthParams oauthParams,HttpServletRequest req,HttpServletResponse res) throws OAuthSystemException, IOException {
  try {
    Utils.validateAuthorizationParams(oauthParams);
    res.addCookie(new Cookie("clientId",oauthParams.getClientId()));
    res.addCookie(new Cookie("clientSecret",oauthParams.getClientSecret()));
    res.addCookie(new Cookie("authzEndpoint",oauthParams.getAuthzEndpoint()));
    res.addCookie(new Cookie("tokenEndpoint",oauthParams.getTokenEndpoint()));
    res.addCookie(new Cookie("redirectUri",oauthParams.getRedirectUri()));
    res.addCookie(new Cookie("scope",oauthParams.getScope()));
    res.addCookie(new Cookie("app",oauthParams.getApplication()));
    OAuthClientRequest request=OAuthClientRequest.authorizationLocation(oauthParams.getAuthzEndpoint()).setClientId(oauthParams.getClientId()).setRedirectURI(oauthParams.getRedirectUri()).setResponseType(ResponseType.CODE.toString()).setScope(oauthParams.getScope()).buildQueryMessage();
    return new ModelAndView(new RedirectView(request.getLocationUri()));
  }
 catch (  ApplicationException e) {
    oauthParams.setErrorMessage(e.getMessage());
    return new ModelAndView("get_authz");
  }
}
 

Example 10

From project amber, under directory /oauth-2.0/client-demo/src/main/java/org/apache/amber/oauth2/client/demo/controller/.

Source file: MainController.java

  19 
vote

@RequestMapping("/main/{app}") public ModelAndView authorize(@ModelAttribute("oauthParams") OAuthParams oauthParams,@ModelAttribute("oauthRegParams") OAuthRegParams oauthRegParams,@PathVariable("app") String app,HttpServletResponse res) throws OAuthSystemException, IOException {
  boolean selected=false;
  if (Utils.GITHUB.equals(app)) {
    selected=true;
    oauthParams.setAuthzEndpoint(Utils.GITHUB_AUTHZ);
    oauthParams.setTokenEndpoint(Utils.GITHUB_TOKEN);
  }
 else   if (Utils.FACEBOOK.equals(app)) {
    selected=true;
    oauthParams.setAuthzEndpoint(Utils.FACEBOOK_AUTHZ);
    oauthParams.setTokenEndpoint(Utils.FACEBOOK_TOKEN);
  }
 else   if (Utils.GOWALLA.equals(app)) {
    selected=true;
    oauthParams.setAuthzEndpoint(Utils.GOWALLA_AUTHZ);
    oauthParams.setTokenEndpoint(Utils.GOWALLA_TOKEN);
  }
 else   if (Utils.SMART_GALLERY.equals(app)) {
    selected=true;
    oauthRegParams.setAuthzEndpoint(Utils.SMART_GALLERY_AUTHZ);
    oauthRegParams.setTokenEndpoint(Utils.SMART_GALLERY_TOKEN);
    oauthRegParams.setRegistrationEndpoint(Utils.SMART_GALLERY_REGISTER);
    oauthRegParams.setApplication(app);
    oauthRegParams.setRedirectUri(Utils.REDIRECT_URI);
    return new ModelAndView("register");
  }
  if (selected) {
    oauthParams.setApplication(app);
    oauthParams.setRedirectUri(Utils.REDIRECT_URI);
    return new ModelAndView("get_authz");
  }
  return new ModelAndView("index");
}
 

Example 11

From project android-joedayz, under directory /Proyectos/server/src/main/java/org/springframework/android/showcase/.

Source file: FileUploadController.java

  19 
vote

/** 
 * Accepts a POST request with multipart/form-data content
 * @param name the name of the file being uploaded
 * @param file the binary file
 * @return response message indicating success or failure
 */
@RequestMapping(value="postformdata",method=RequestMethod.POST,headers="Content-Type=multipart/form-data") public @ResponseBody String handleFormUpload(@RequestParam("description") String description,@RequestParam("file") MultipartFile file){
  if (!file.isEmpty()) {
    byte[] bytes=null;
    try {
      bytes=file.getBytes();
    }
 catch (    IOException e) {
      logger.info("error processing uploaded file",e);
    }
    return "file upload received! Name:[" + description + "] Size:["+ bytes.length+ "]";
  }
 else {
    return "file upload failed!";
  }
}
 

Example 12

From project android-joedayz, under directory /Proyectos/server/src/main/java/org/springframework/android/showcase/.

Source file: HomeController.java

  19 
vote

/** 
 * Retrieve a list of states. Accepts a GET request for XML
 * @return An XML array of states
 */
@RequestMapping(value="states",method=RequestMethod.GET,headers="Accept=application/xml") public @ResponseBody StateList fetchStatesXml(){
  logger.info("fetching XML states");
  List<State> states=getStates();
  StateList stateList=new StateList(states);
  return stateList;
}
 

Example 13

From project aranea, under directory /server/src/main/java/no/dusken/aranea/admin/control/.

Source file: EditPageImageParagraphController.java

  19 
vote

@RequestMapping("/chooseImage") public String getImageSelectionView(@RequestParam Integer paragraphNumber,@RequestParam Long ID,Model model){
  List<PageImage> pageImages=pageService.getEntity(ID).getPageImages();
  model.addAttribute("pageImages",pageImages);
  model.addAttribute("pageId",ID);
  model.addAttribute("paragraphNumber",paragraphNumber);
  return "no/dusken/aranea/base/admin/pageImage/imageChooser";
}
 

Example 14

From project aranea, under directory /server/src/main/java/no/dusken/aranea/admin/control/.

Source file: EditPageImageParagraphController.java

  19 
vote

@RequestMapping("/updateParagraph") public String updatePageImageParagraph(@RequestParam Long pageImageID,@RequestParam Long pageID,@RequestParam Integer paragraphNumber){
  PageImage pageImage=pageImageService.getEntity(pageImageID);
  pageImage.setParagraph(paragraphNumber);
  pageImageService.saveOrUpdate(pageImage);
  Page p=pageService.getEntity(pageID);
  return "no/dusken/aranea/base/admin/pageImage/paragraphSuccess";
}
 

Example 15

From project arquillian-extension-spring, under directory /arquillian-warp-spring-ftest/src/main/java/org/jboss/as/quickstarts/spring/controller/.

Source file: LoginController.java

  19 
vote

@RequestMapping(method=RequestMethod.POST) public String login(@Valid UserCredentials userCredentials,BindingResult result){
  if (result.hasErrors()) {
    return "login";
  }
  return "welcome";
}
 

Example 16

From project Axon-trader, under directory /web-ui/src/main/java/org/axonframework/samples/trader/webui/admin/.

Source file: AdminController.java

  19 
vote

@RequestMapping(value="/portfolio/{identifier}") public String showPortfolio(@PathVariable("identifier") String portfolioIdentifier,Model model){
  PortfolioEntry portfolio=portfolioQueryRepository.findOne(portfolioIdentifier);
  model.addAttribute("portfolio",portfolio);
  Iterable<OrderBookEntry> orderBooks=orderBookQueryRepository.findAll();
  model.addAttribute("orderbooks",orderBooks);
  return "admin/portfolio/detail";
}
 

Example 17

From project Axon-trader, under directory /web-ui/src/main/java/org/axonframework/samples/trader/webui/companies/.

Source file: CompanyController.java

  19 
vote

@RequestMapping(value="/{companyId}",method=RequestMethod.GET) public String details(@PathVariable String companyId,Model model){
  CompanyEntry company=companyRepository.findOne(companyId);
  OrderBookEntry bookEntry=orderBookRepository.findByCompanyIdentifier(company.getIdentifier()).get(0);
  List<TradeExecutedEntry> executedTrades=tradeExecutedRepository.findByOrderBookIdentifier(bookEntry.getIdentifier());
  model.addAttribute("company",company);
  model.addAttribute("sellOrders",bookEntry.sellOrders());
  model.addAttribute("buyOrders",bookEntry.buyOrders());
  model.addAttribute("executedTrades",executedTrades);
  return "company/details";
}
 

Example 18

From project CalendarPortlet, under directory /src/main/java/org/jasig/portlet/calendar/mvc/controller/.

Source file: EditCalendarDefinitionController.java

  19 
vote

@RequestMapping(params="action=createCalendarDefinition") public String showNewCalendarDefinitionForm(PortletRequest request,Model model){
  if (!model.containsAttribute(FORM_NAME)) {
    final CalendarDefinitionForm form=new CalendarDefinitionForm();
    model.addAttribute(FORM_NAME,form);
  }
  model.addAttribute("adapters",adapters);
  return "/createCalendarDefinition";
}
 

Example 19

From project CalendarPortlet, under directory /src/main/java/org/jasig/portlet/calendar/mvc/controller/.

Source file: EditCalendarDefinitionController.java

  19 
vote

@RequestMapping(params="action=createCalendarDefinition2") public String showEditCalendarDefinitionForm2(PortletRequest request,Model model,@ModelAttribute(FORM_NAME) CalendarDefinitionForm form){
  ICalendarAdapter adapter=context.getBean(form.getClassName(),ICalendarAdapter.class);
  for (  Parameter pref : adapter.getParameters()) {
    SingleValuedParameterInput input=(SingleValuedParameterInput)pref.getInput();
    form.addParameter(pref.getName(),input.getDefaultValue());
  }
  model.addAttribute("adapter",context.getBean(form.getClassName()));
  return "/editCalendarDefinition";
}
 

Example 20

From project Carolina-Digital-Repository, under directory /access/src/main/java/edu/unc/lib/dl/ui/controller/.

Source file: AdvancedSearchFormController.java

  19 
vote

@RequestMapping(method=RequestMethod.GET) public String handleRequest(Model model,HttpServletRequest request){
  if (request.getQueryString() == null || request.getQueryString().length() == 0) {
    AccessGroupSet accessGroups=getUserAccessGroups(request);
    SearchResultResponse resultResponse=queryLayer.getCollectionList(accessGroups);
    model.addAttribute("collectionList",resultResponse.getResultList());
    model.addAttribute("pageSubtitle","Advanced Search");
    model.addAttribute("formatMap",LookupMappingsSettings.getMapping("advancedFormats"));
    model.addAttribute("accessMap",LookupMappingsSettings.getMapping("advancedAccess"));
    return "advancedSearch";
  }
  @SuppressWarnings("unchecked") SearchState searchState=SearchStateFactory.createSearchStateAdvancedSearch(request.getParameterMap());
  request.getSession().setAttribute("searchState",searchState);
  model.addAllAttributes(SearchStateUtil.generateStateParameters(searchState));
  return "redirect:/search";
}
 

Example 21

From project Carolina-Digital-Repository, under directory /access/src/main/java/edu/unc/lib/dl/ui/controller/.

Source file: BrowseDepartmentsController.java

  19 
vote

@RequestMapping(method=RequestMethod.GET) public String handleRequest(Model model,HttpServletRequest request){
  SearchResultResponse results=queryLayer.getDepartmentList(this.getUserAccessGroups(request));
  model.addAttribute("departmentFacets",results.getFacetFields().get(0));
  model.addAttribute("resultType","departmentBrowse");
  return "browseDepartments";
}
 

Example 22

From project cloudify, under directory /restful/src/main/java/org/cloudifysource/rest/controllers/.

Source file: ServiceController.java

  19 
vote

/** 
 * Get the dump of a given machine, by its ip.
 * @param ip
 * @param processors The list of processors to be used.
 * @param fileSizeLimit
 * @return A byte array of the dump file in case ip is not null and a map contains byte array of the dump file for each machine otherwise.
 * @throws IOException
 */
@JsonRequestExample(requestBody="{\"fileSizeLimit\" : 50000000, \"processors\" : \"summary, network, log\"}") @JsonResponseExample(status="success",responseBody="{\"&ltmachine's ip&gt;\":\"&ltbyte array of the dump file&gt;\"}") @PossibleResponseStatuses(codes={200,200,200,200,500},descriptions={"success",ResponseConstants.MACHINE_NOT_FOUND,ResponseConstants.DUMP_FILE_TOO_LARGE,"Failed to generate dump","IOException"}) @RequestMapping(value="/dump/machine/{ip}/",method=RequestMethod.GET) public @ResponseBody Map<String,Object> getMachineDumpFile(@PathVariable final String ip,@RequestParam(defaultValue=DEFAULT_DUMP_PROCESSORS) final String processors,@RequestParam(defaultValue="" + DEFAULT_DUMP_FILE_SIZE_LIMIT) final long fileSizeLimit) throws IOException {
  final String[] actualProcessors=getProcessorsFromRequest(processors);
  try {
    if (ip != null && ip.length() > 0) {
      Machine machine=this.admin.getMachines().getHostsByAddress().get(ip);
      if (machine == null) {
        machine=this.admin.getMachines().getHostsByName().get(ip);
      }
      if (machine == null) {
        return errorStatus(ResponseConstants.MACHINE_NOT_FOUND,ip);
      }
      final byte[] dumpBytes=generateMachineDumpData(fileSizeLimit,machine,actualProcessors);
      return successStatus(dumpBytes);
    }
 else {
      long totalSize=0;
      final Iterator<Machine> iterator=this.admin.getMachines().iterator();
      final Map<String,Object> map=new HashMap<String,Object>();
      while (iterator.hasNext()) {
        final Machine machine=iterator.next();
        final byte[] dumpBytes=generateMachineDumpData(fileSizeLimit,machine,actualProcessors);
        totalSize+=dumpBytes.length;
        if (totalSize > fileSizeLimit) {
          throw new RestServiceException(ResponseConstants.DUMP_FILE_TOO_LARGE,Long.toString(dumpBytes.length),Long.toString(totalSize));
        }
        map.put(machine.getHostAddress(),dumpBytes);
      }
      return successStatus(map);
    }
  }
 catch (  final RestServiceException e) {
    return errorStatus(e.getMessageName(),e.getParams());
  }
}
 

Example 23

From project cloudify, under directory /restful/src/main/java/org/cloudifysource/rest/controllers/.

Source file: ServiceController.java

  19 
vote

/** 
 * Get the dump of all the processing units.
 * @param fileSizeLimit
 * @return the dump of all the processing units
 * @throws IOException
 */
@JsonRequestExample(requestBody="{\"fileSizeLimit\" : 50000000}") @PossibleResponseStatuses(codes={200,200,200,500},descriptions={"success",ResponseConstants.DUMP_FILE_TOO_LARGE,"Failed to generate dump","IOException"}) @RequestMapping(value="/dump/processing-units/",method=RequestMethod.GET) public @ResponseBody Map<String,Object> getPUDumpFile(@RequestParam(defaultValue="" + DEFAULT_DUMP_FILE_SIZE_LIMIT) final long fileSizeLimit) throws IOException {
  final DumpResult dump=admin.generateDump("Rest Service user request",null,ProcessingUnitsDumpProcessor.NAME);
  byte[] data;
  try {
    data=getDumpRawData(dump,fileSizeLimit);
    return successStatus(data);
  }
 catch (  final RestServiceException e) {
    return errorStatus(e.getMessageName(),e.getParams());
  }
}
 

Example 24

From project CMM-data-grabber, under directory /paul/src/main/java/au/edu/uq/cmm/paul/servlet/.

Source file: WebUIController.java

  19 
vote

@RequestMapping(value="/control",method=RequestMethod.POST) public String controlAction(Model model,HttpServletRequest request){
  processStatusChange("watcher",request.getParameter("watcher"));
  processStatusChange("atomFeed",request.getParameter("atomFeed"));
  addStateAndStatus(model);
  return "control";
}
 

Example 25

From project CMM-data-grabber, under directory /paul/src/main/java/au/edu/uq/cmm/paul/servlet/.

Source file: WebUIController.java

  19 
vote

@RequestMapping(value="/facilities",method=RequestMethod.GET) public String facilities(Model model){
  Collection<FacilityConfig> facilities=getFacilities();
  for (  FacilityConfig fc : facilities) {
    getFacilityStatusManager().attachStatus((Facility)fc);
  }
  model.addAttribute("facilities",facilities);
  return "facilities";
}