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

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

Introduction

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

Prototype

RequestMethod POST

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

Click Source Link

Usage

From source file:com.kabaso.askweb.presentation.rest.ClubRestController.java

@RequestMapping(value = "create", method = RequestMethod.POST) // This the uri e.g http://localhost:8084/askweb/api/club/create
@ResponseBody //Converts output or response to JSON String
public String create(@RequestBody Club club) { // @RequestBody for converting incoming JSON call to Object
    clubService.persist(club);//ww  w. ja  v  a 2  s.  c  o  m

    System.out.println(" Create the Called ");
    return "Club Created";
}

From source file:cs425.yogastudio.controller.AdminController.java

@RequestMapping(value = "/addAdmin", method = RequestMethod.POST)
public String addAdmin(String firstname, String lastname, String email, String username, String password,
        Model model, HttpSession session) {

    Admin newAdmin = new Admin(firstname, lastname, email, username, password);

    adminService.addAdmin(newAdmin);//from   w  w w . j  a v  a  2  s  .  co  m
    session.setAttribute("added", newAdmin.getFirstName());
    return "redirect:/signUpSuccess";
}

From source file:edu.eci.arsw.controllers.BlueprintController.java

@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<?> addBlueprint(@RequestBody Blueprint p) {
    services.addNewBlueprint(p.getName(), p);
    return new ResponseEntity<>(HttpStatus.ACCEPTED);
}

From source file:tld.example.resources.UsersResource.java

@Override
@RequestMapping(value = "/users", method = RequestMethod.POST)
public void postUsers(@RequestBody User user) {
    throw new UnsupportedOperationException();
}

From source file:wad.booklibrary.controller.UserController.java

@RequestMapping(value = "userform", method = RequestMethod.POST)
public String create(@Valid @ModelAttribute(value = "user") User user, BindingResult bindingResult,
        RedirectAttributes redirectAttributes, Model model) {
    if (bindingResult.hasErrors()) {
        return "userform";
    }//  w  w w  .j  a va2s  .  c o m
    if (userService.findByUsername(user.getUsername()) != null) {
        model.addAttribute("error", "Username is already in use.");
        user.setUsername("");
        return "userform";
    }
    user.setEnabled(1);
    user.setAuthority("user");
    userService.create(user);
    redirectAttributes.addFlashAttribute("message", "New user registered!");
    return "redirect:/app/userform";
}

From source file:fr.epsi.controllers.rest.OrderController.java

/**
 * Methode pour les commandes/*from   ww w  .  j  a va2 s  .com*/
 * @param reference la reference du produit
 * @param quantity la quantite voulue
 * @param guid l'identifiant de l'utilisateur
 * @return Un message selon le statut de la commande
 */
@RequestMapping(value = "/order", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Product order(@RequestParam("reference") String reference,
        @RequestParam("quantity") int quantity, @RequestParam("token") String token, HttpServletResponse resp) {

    Users userModel = Users.getInstance(); //Recupere l'instance de user

    try {
        // Si on trouve un user correspondant au guid
        if (userModel.findByGUID(token) != null) {
            Products productModel = Products.getInstance();

            // On recupere le produit par reference
            Product product = productModel.findByRef(reference);

            if (product == null || quantity <= 0 || product.getQuantity() == 0
                    || product.getQuantity() < quantity) {
                resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            } else {
                //On decremente la quantite du produit
                product.setQuantity(product.getQuantity() - quantity);

                return new Product(product.getReference(), product.getName(), quantity);
            }
        } else {
            resp.setStatus(HttpServletResponse.SC_FORBIDDEN);
        }
        return null;
    } catch (Exception e) {
        resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        return null;
    }
}

From source file:com.dm.platform.user.ctrl.UserController.java

@RequestMapping(value = "/{id}", method = RequestMethod.POST)
public String get(@PathVariable long id) {
    return null;
}

From source file:json.ApplicantController.java

@RequestMapping(value = "/getAppliedJobByUser", method = RequestMethod.POST, produces = "application/json")
public @ResponseBody ArrayList<Applicant> getAppliedJobByUser(@RequestBody Applicant applicant) {
    Connection conn = null;/*w  ww  .j  a  v a 2  s  . c  o m*/
    PreparedStatement stmt = null;
    ResultSet rs = null;

    ArrayList<Applicant> appliedJobList = new ArrayList<Applicant>();
    String query = "SELECT a.username, j.postingTitle, j.businessUnit, j.location, j.createdBy, j.createdOn, j.statusCode, j.employmentType, j.shift, j.description, j.requirement, j.validity, a.jobIDApplied, appID, a.dateApplied, status FROM application a INNER JOIN job j on j.jobID = a.jobIDApplied where a.username = \""
            + applicant.getUsername() + "\"";
    try {
        //Set up connection with database
        conn = ConnectionManager.getConnection();
        stmt = conn.prepareStatement(query);
        //stmt.setString(1, username);

        //Execute sql satatement to obtain account from database
        rs = stmt.executeQuery();
        //Execute sql satatement to obtain jobs from database
        // rs = stmt.executeQuery("SELECT a.username, j.postingTitle, j.businessUnit, j.location, j.createdBy, j.CreatedOn, J.statusCode, j.employmentType, j.shift, j.description, j.requirement, j.validity,a.jobIDApplied, appID, a.dateApplied, status FROM application a INNER JOIN job j on j.jobID = a.jobIDApplied where a.username = + '" + username  + "' ORDER BY appID desc ");

        while (rs != null && rs.next()) {
            String name = rs.getString(1);
            String postingTitle = rs.getString(2);
            String businessUnit = rs.getString(3);
            String location = rs.getString(4);
            String createdBy = rs.getString(5);
            String createdOn = rs.getString(6);
            String employmentType = rs.getString(8);
            String shift = rs.getString(9);
            String description = rs.getString(10);
            String requirement = rs.getString(11);
            String validity = rs.getString(12);
            int jobID = rs.getInt(13);
            int appID = rs.getInt(14);
            String dateApplied = rs.getString(15);
            String status = rs.getString(16);

            Jobs job = new Jobs(jobID, businessUnit, postingTitle, createdBy, createdOn, location,
                    employmentType, shift, description, requirement, validity);
            Applicant a = new Applicant(appID, jobID, name, dateApplied, status, jobID, businessUnit,
                    postingTitle, createdBy, createdOn, location, employmentType, shift, description,
                    requirement, validity);
            //                /int appID, int jobIDApplied, String username, String dateApplied, String status, 
            appliedJobList.add(a);
            System.out.println(requirement);

        }
    } catch (SQLException ex) {
        ex.printStackTrace();
    } finally {
        ConnectionManager.close(conn, stmt, rs);
    }
    System.out.println(appliedJobList.size());
    return appliedJobList;

}

From source file:com.softcrylic.dockeryamlcatalog.controller.tomcat7jdk7.java

@RequestMapping(value = "/tm7jd7", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity<String> post_Tomcat7Jdk7_Yml(@RequestBody String inputJson) {

    FigCommandClassDef fccd = new FigCommandClassDef();

    StringBuilder sb = new StringBuilder();

    try {/*from w  ww  .j  a va  2  s .c om*/
        /**
         * Get the Json and Assigned to class definition
         */
        fccd = gson.fromJson(inputJson, FigCommandClassDef.class);

        /**
         * Check parent should be present
         */
        if (fccd.getContainer_id().equals("") || fccd.getContainer_id().equals(null)) {
            return new ResponseEntity<String>("Container_Id can't be null or left blank",
                    HttpStatus.BAD_REQUEST);
        }

        /**
         * Generate the Yaml
         */

        sb = YmlBuilder.buildYaml(fccd);

    } catch (Exception e) {
        return new ResponseEntity<String>(e.getMessage(), HttpStatus.BAD_REQUEST);
    }
    return new ResponseEntity<String>(sb.toString(), HttpStatus.OK);
}

From source file:controller.LightController.java

@RequestMapping(value = { "light" }, method = RequestMethod.POST)
public String onSubmit(@ModelAttribute Lamp lamp, Model model) {

    colourService.setColour(lamp.getLampId(), lamp.getRood(), lamp.getGeel(), lamp.getBlauw());

    return "light";

}