<commit_before>package ru.nbakaev.hishop.purchaseorder;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import ru.nbakaev.hishop.auth.UserAccountRoles;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by <NAME>, <EMAIL> on 1/10/2016.
 * All Rights Reserved
 */
@Controller
@RequestMapping("/api/v1/purchase")
public class PurchaseOrderController {

    private final PurchaseOrderRepository purchaseOrderRepository;

    @Autowired
    public PurchaseOrderController(final PurchaseOrderRepository purchaseOrderRepository) {
        this.purchaseOrderRepository = purchaseOrderRepository;
    }

    @Secured({UserAccountRoles.ROLE_USER, UserAccountRoles.ROLE_ADMIN})
    @RequestMapping(value = "", method = RequestMethod.POST)
    public
    @ResponseBody
    PurchaseOrder addNewPurchaseOrder(@RequestBody PurchaseOrder purchaseOrder, HttpServletRequest request) {
        purchaseOrderRepository.createNewPurchaseOrder(purchaseOrder);
        return purchaseOrder;
    }

    @RequestMapping(value = "", method = RequestMethod.GET)
    public
    @ResponseBody
    List<PurchaseOrder> getAllPurchases() {
        return purchaseOrderRepository.getAllPurchaseOrder();
    }

    @Secured({UserAccountRoles.ROLE_ADMIN})
    @RequestMapping(value = "", method = RequestMethod.PUT)
    public
    @ResponseBody
    PurchaseOrder updatePurchaseOrder(@RequestBody PurchaseOrder purchaseOrder, HttpServletRequest request) {
        purchaseOrderRepository.updatePurchaseOrder(purchaseOrder);
        return purchaseOrder;
    }

    @Secured({UserAccountRoles.ROLE_ADMIN})
    @RequestMapping(value = "{id}", method = RequestMethod.DELETE)
    public void deletePurchaseById(@PathVariable("id") String id) {
        purchaseOrderRepository.deletePurchaseOrderById(id);
    }

}<commit_msg>only admin can see all purchases<commit_after>package ru.nbakaev.hishop.purchaseorder;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import ru.nbakaev.hishop.auth.UserAccountRoles;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by <NAME>, <EMAIL> on 1/10/2016.
 * All Rights Reserved
 */
@Controller
@RequestMapping("/api/v1/purchase")
public class PurchaseOrderController {

    private final PurchaseOrderRepository purchaseOrderRepository;

    @Autowired
    public PurchaseOrderController(final PurchaseOrderRepository purchaseOrderRepository) {
        this.purchaseOrderRepository = purchaseOrderRepository;
    }

    @Secured({UserAccountRoles.ROLE_USER, UserAccountRoles.ROLE_ADMIN})
    @RequestMapping(value = "", method = RequestMethod.POST)
    public
    @ResponseBody
    PurchaseOrder addNewPurchaseOrder(@RequestBody PurchaseOrder purchaseOrder, HttpServletRequest request) {
        purchaseOrderRepository.createNewPurchaseOrder(purchaseOrder);
        return purchaseOrder;
    }

    @Secured({UserAccountRoles.ROLE_ADMIN})
    @RequestMapping(value = "", method = RequestMethod.GET)
    public
    @ResponseBody
    List<PurchaseOrder> getAllPurchases() {
        return purchaseOrderRepository.getAllPurchaseOrder();
    }

    @Secured({UserAccountRoles.ROLE_ADMIN})
    @RequestMapping(value = "", method = RequestMethod.PUT)
    public
    @ResponseBody
    PurchaseOrder updatePurchaseOrder(@RequestBody PurchaseOrder purchaseOrder, HttpServletRequest request) {
        purchaseOrderRepository.updatePurchaseOrder(purchaseOrder);
        return purchaseOrder;
    }

    @Secured({UserAccountRoles.ROLE_ADMIN})
    @RequestMapping(value = "{id}", method = RequestMethod.DELETE)
    public void deletePurchaseById(@PathVariable("id") String id) {
        purchaseOrderRepository.deletePurchaseOrderById(id);
    }

}
{'fraction_non_alphanumeric': 0.08899521531100478, 'fraction_numerical': 0.003827751196172249, 'mean_word_length': 4.193788819875777, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3438661', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1109, 'n_words': 190}