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

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 ALP, under directory /workspace/alp-reporter-fe/src/main/java/com/lohika/alp/reporter/fe/controller/.

Source file: LogController.java

  20 
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 2

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 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}/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 4

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 5

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 6

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 7

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

Source file: RedirectController.java

  19 
vote

@RequestMapping(method=RequestMethod.GET) public ModelAndView handleRedirect(@ModelAttribute("oauthParams") OAuthParams oauthParams,HttpServletRequest request,HttpServletResponse response){
  try {
    OAuthAuthzResponse oar=null;
    oar=OAuthAuthzResponse.oauthCodeAuthzResponse(request);
    String code=oar.getCode();
    String clientId=Utils.findCookieValue(request,"clientId");
    String clientSecret=Utils.findCookieValue(request,"clientSecret");
    String authzEndpoint=Utils.findCookieValue(request,"authzEndpoint");
    String tokenEndpoint=Utils.findCookieValue(request,"tokenEndpoint");
    String redirectUri=Utils.findCookieValue(request,"redirectUri");
    String scope=Utils.findCookieValue(request,"scope");
    String app=Utils.findCookieValue(request,"app");
    response.addCookie(new Cookie("app",app));
    oauthParams.setAuthzCode(code);
    oauthParams.setClientId(clientId);
    oauthParams.setClientSecret(clientSecret);
    oauthParams.setAuthzEndpoint(authzEndpoint);
    oauthParams.setTokenEndpoint(tokenEndpoint);
    oauthParams.setRedirectUri(redirectUri);
    oauthParams.setScope(Utils.isIssued(scope));
    oauthParams.setApplication(app);
  }
 catch (  OAuthProblemException e) {
    StringBuffer sb=new StringBuffer();
    sb.append("</br>");
    sb.append("Error code: ").append(e.getError()).append("</br>");
    sb.append("Error description: ").append(e.getDescription()).append("</br>");
    sb.append("Error uri: ").append(e.getUri()).append("</br>");
    sb.append("State: ").append(e.getState()).append("</br>");
    oauthParams.setErrorMessage(sb.toString());
    return new ModelAndView("main");
  }
  return new ModelAndView("request_token");
}
 

Example 8

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 9

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 10

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

Source file: SectionPageController.java

  19 
vote

@RequestMapping(value="/page/prioritize.do",method=RequestMethod.GET) public String handleSectionPages(@RequestParam(value="sectionID",defaultValue="0") Long sectionID,Model model) throws PageNotFoundException {
  Section section=null;
  if (sectionID == 0) {
    section=sectionService.getSectionByUrl("frontpage",null);
  }
 else {
    section=sectionService.getEntity(sectionID);
  }
  if (section == null) {
    throw new PageNotFoundException("Section with id " + sectionID);
  }
  List<Section> topLevelSections=sectionService.getTopLevelSections(false);
  if (!section.getHidden() && topLevelSections.size() > 0) {
    model.addAttribute("toplevelSections",topLevelSections);
  }
  model.addAttribute("section",section);
  model.addAttribute("sectionpages",sectionPageService.getSectionPageByOwner(section));
  return prioritizeView;
}
 

Example 11

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

Source file: SectionPageController.java

  19 
vote

@RequestMapping(value="/page/prioritizeName.do",method=RequestMethod.GET) public String handleSectionPages(@RequestParam String sectionName,Model model) throws PageNotFoundException {
  Section section=sectionService.getSectionByUrl(sectionName,null);
  if (section == null) {
    throw new PageNotFoundException("Section with name " + sectionName);
  }
  return handleSectionPages(section.getID(),model);
}
 

Example 12

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 13

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 14

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="/buy/{companyId}",method=RequestMethod.GET) public String buyForm(@PathVariable String companyId,Model model){
  addPortfolioMoneyInfoToModel(model);
  BuyOrder order=new BuyOrder();
  prepareInitialOrder(companyId,order);
  model.addAttribute("order",order);
  return "company/buy";
}
 

Example 15

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 16

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 17

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 18

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 19

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 20

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

Example 21

From project ddd-cqrs-sample, under directory /src/main/java/pl/com/bottega/erp/sales/webui/.

Source file: BasketController.java

  19 
vote

@RequestMapping(value="/basketItems",method=RequestMethod.GET) public String getBasketItems(Model model){
  if (basket.hasItems()) {
    Map<Long,Integer> productIdsWithCounts=basket.getProductIdsWithCounts();
    List<ProductListItemDto> productsInBasket=findProductsByIds(productIdsWithCounts.keySet());
    List<BasketItemDto> basketItems=productsToBasketItems(productsInBasket,productIdsWithCounts);
    model.addAttribute("basketItems",basketItems);
  }
  return "sales/basketItems";
}
 

Example 22

From project ddd-cqrs-sample, under directory /src/main/java/pl/com/bottega/erp/sales/webui/.

Source file: ProductsListController.java

  19 
vote

@RequestMapping(value="/list",method=RequestMethod.GET) public String productsList(Model model,@RequestParam(value="sortBy",required=false) String sortBy,@RequestParam(value="ascending",required=false) Boolean ascending,@RequestParam(value="page",required=false) Integer page,@RequestParam(value="maxPrice",required=false) Double maxPrice,@RequestParam(value="containsText",required=false) String containsText){
  ProductSearchCriteria criteria=new ProductSearchCriteria();
  addFiltering(criteria,containsText,maxPrice);
  addPagination(criteria,page,RESULTS_PER_PAGE);
  addOrdering(criteria,sortBy,ascending);
  model.addAttribute("products",productFinder.findProducts(criteria));
  model.addAttribute("sortBy",criteria.getOrderBy().toString());
  model.addAttribute("ascending",criteria.isAscending());
  model.addAttribute("containsTextFilter",criteria.getContainsText());
  model.addAttribute("maxPriceFilter",criteria.getMaxPrice());
  return "sales/productsList";
}
 

Example 23

From project egov-data, under directory /easyCompany2/src/main/java/egovframework/rte/tex/cgr/web/.

Source file: EgovCategoryController.java

  19 
vote

/** 
 * ?????? ???? ??????.
 * @param request
 * @param model
 * @return "cgr/egovCategoryList"
 * @throws Exception
 */
@RequestMapping(value="/springrest/cgr",method=RequestMethod.GET) public String selectCategoryList(HttpServletRequest request,Model model) throws Exception {
  List categoryList=categoryService.selectCategoryList();
  List category1=new ArrayList();
  for (int i=categoryList.size() - 1; i >= 0; i--) {
    category1.add(categoryList.get(i));
  }
  model.addAttribute("categoryList",category1);
  MemberVO loginVO=EgovUserUtil.getMemberInfo();
  model.addAttribute("loginVO",loginVO);
  if ("popup".equals(request.getParameter("name")))   return "cgr/EgovCategoryPopup";
 else   return "cgr/egovCategoryList";
}
 

Example 24

From project egov-data, under directory /easyCompany2/src/main/java/egovframework/rte/tex/cgr/web/.

Source file: EgovCategoryController.java

  19 
vote

/** 
 * ?????? ??? ?????? ??????.
 * @param model
 * @return "cgr/egovCategoryRegister"
 * @throws Exception
 */
@RequestMapping(value="/springrest/cgr/new",method=RequestMethod.GET) public String insertCategoryView(Model model) throws Exception {
  model.addAttribute("categoryVO",new CategoryVO());
  MemberVO loginVO=EgovUserUtil.getMemberInfo();
  model.addAttribute("loginVO",loginVO);
  return "cgr/egovCategoryRegister";
}
 

Example 25

From project elw, under directory /web/src/main/java/elw/web/.

Source file: AdminController.java

  19 
vote

@RequestMapping(value="index",method=RequestMethod.GET) public ModelAndView do_index(final HttpServletRequest req,final HttpServletResponse resp) throws IOException {
  final HashMap<String,Object> model=auth(req,resp,true,false);
  if (model == null) {
    return null;
  }
  return new ModelAndView("a/index",model);
}
 

Example 26

From project elw, under directory /web/src/main/java/elw/web/.

Source file: AdminController.java

  19 
vote

@RequestMapping(value="rest/index",method=RequestMethod.GET) public ModelAndView do_restIndex(final HttpServletRequest req,final HttpServletResponse resp) throws IOException {
  final HashMap<String,Object> model=auth(req,resp,false,false);
  if (model == null) {
    return null;
  }
  final List<Enrollment> enrolls=core.getQueries().enrollments();
  final List<IndexRow> indexData=core.index(enrolls);
  return new ModelAndView(ViewJackson.success(indexData));
}