Beispiel #1
0
  @RequestMapping(value = "/deleteInfo/{id}", method = RequestMethod.POST)
  @ResponseBody
  public Result deleteModule(@PathVariable Integer id) {
    Result result = new Result();
    if (id != null && id > 1) {
      Permission permission = new Permission();
      permission.setModuleId(Long.valueOf(id));
      if (permissionService.get(permission).size() > 0) {
        result.setMsg("该模块配置了权限,不可以删除");
        result.setSuccessful(false);
        return result;
      }

      Module module1 = new Module();
      module1.setParentId(Long.valueOf(id));
      if (moduleService.find(module1).size() > 0) {
        result.setMsg("该模块有子模块,不可以删除");
        result.setSuccessful(false);
        return result;
      } else {
        try {
          moduleService.delete(Long.valueOf(id));
          result.setMsg("操作成功");
          result.setSuccessful(true);
        } catch (ServiceException s) {
          result.setMsg(s.getMessage());
          result.setSuccessful(false);
          return result;
        }
      }
    }
    return result;
  }
Beispiel #2
0
  @RequestMapping(value = "/{id}", method = RequestMethod.POST, produces = "application/json")
  public ResponseEntity<Share> shareNotebook(
      @PathVariable(value = "id") String ownerId,
      @Valid @RequestBody Share share,
      BindingResult result) {

    if (share.getShareWithEmailId() == null || share.getShareWithEmailId().trim().equals(""))
      throw new BadRequestException("Please tell whome with you want to share.");
    if (share.getShareNotebookId() == null || share.getShareNotebookId().trim().equals(""))
      throw new BadRequestException("Valid notebook must be shared.");
    Share shareObj = null;

    User user1 = userService.getUserById(Long.parseLong(ownerId));

    User user2;
    try {
      user2 = userService.getUserByEmail(share.getShareWithEmailId());
    } catch (Exception e) {
      emailNotification.sendEmailUserNotExist(
          share.getShareWithEmailId(), share.getShareWithEmailId(), user1.getName());
      throw new BadRequestException(
          "User "
              + share.getShareWithEmailId()
              + " is not on TagIt. Invitation Email has been sent. Try Sharing later.");
    }

    Notebook notebook = notebookService.getNotebookByID(Long.parseLong(share.getShareNotebookId()));
    if (notebook.getName() == null || notebook.getName().trim().equals("")) {
      throw new BadRequestException("Given notebook is not valid. Please share a valid notebook.");
    }

    if (notebookService.validateOwner(ownerId, share.getShareNotebookId())) {

      try {
        shareObj =
            new Share(share.getShareWithEmailId(), share.getShareNotebookId(), share.getWrite());

      } catch (Exception e) {
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
      }

      Long shareid =
          shareService.verifyIfAlredyShared(
              share.getShareWithEmailId(), Long.parseLong(share.getShareNotebookId()));

      if (shareid != null) {
        throw new BadRequestException(
            "This notebook has already shared with the user : "******"Unauthorized Access....This notebook does not belong to this owner.");
    }
  }
 @RequestMapping(value = "/foreign_{kind}.html")
 public String QueryforList(
     @PathVariable("kind") String kind, HttpServletRequest request, Model model) {
   foreignServices = (ForeignServices) springContextUtil.getBean("ForeignServices");
   PageMybatis page = foreignServices.QueryCount("");
   page.setNowpage(Long.parseLong("1"));
   List<FiForeigner> list = foreignServices.QueryList(page);
   page.setPageurl(Untils.requestPath(request) + "kind=" + kind);
   model.addAttribute("foreign_list", list);
   model.addAttribute("page", page);
   if (kind.equals("edit")) {
     return "/foreign/foreign_edit";
   } else if (kind.equals("inout")) {
     return "/foreign/foreign_inout";
   } else if (kind.equals("ishere")) {
     return "/foreign/foreign_ishere";
   } else if (kind.equals("extension")) {
     return "/foreign/foreign_extension";
   } else if (kind.equals("query")) {
     return "/query/queryforeign";
   } else if (kind.equals("foreigninoutquery")) {
     return "/query/queryforeigninout";
   } else {
     return "";
   }
 }
  @RequestMapping(value = "/delete/{deviceId}", method = RequestMethod.DELETE)
  public String deleteUser(@PathVariable(value = "deviceId") String deviceId) {

    deviceService.delete(Long.parseLong(deviceId));

    return "delete device success.";
  }
Beispiel #5
0
  @RequestMapping(value = "/{needId}", method = RequestMethod.GET)
  public String viewNeed(@PathVariable String needId, Model model) {

    model.addAttribute("needId", needId);

    List<Need> needs = needRepository.findById(Long.valueOf(needId));
    if (needs.isEmpty()) return "noNeedFound";

    Need need = needs.get(0);
    model.addAttribute("active", need.getState() != NeedState.ACTIVE ? "activate" : "deactivate");
    model.addAttribute("needURI", need.getNeedURI());
    List<Facet> facets = facetRepository.findByNeedURI(need.getNeedURI());

    NeedPojo needCommandPojo = new NeedPojo(facets);
    model.addAttribute("command", needCommandPojo);

    NeedPojo pojo =
        new NeedPojo(
            need.getNeedURI(),
            linkedDataSource.getDataForResource(need.getNeedURI()).getDefaultModel());
    pojo.setState(need.getState());
    model.addAttribute("pojo", pojo);

    // set facets on 'command': (needed for the dropdown list in the 'connect' control TODO:
    // deuglify
    needCommandPojo.setNeedFacetURIs(pojo.getNeedFacetURIs());

    return "viewNeed";
  }
Beispiel #6
0
  @RequestMapping(value = "/{needId}/listConnections", method = RequestMethod.GET)
  public String listConnections(@PathVariable String needId, Model model) {

    List<Need> needs = needRepository.findById(Long.valueOf(needId));
    if (needs.isEmpty()) return "noNeedFound";
    Need need = needs.get(0);
    List<Connection> connections = connectionRepository.findByNeedURI(need.getNeedURI());
    model.addAttribute("connections", connections);

    // create an URI iterator from the matches and fetch the linked data descriptions for the needs.
    final Iterator<Connection> connectionIterator = connections.iterator();
    Iterator<Dataset> datasetIterator =
        WonLinkedDataUtils.getModelForURIs(
            new ProjectingIterator<Connection, URI>(connectionIterator) {
              @Override
              public URI next() {
                return connectionIterator.next().getRemoteNeedURI();
              }
            },
            this.linkedDataSource);
    Iterator<NeedPojo> needPojoIterator = WonOwnerWebappUtils.toNeedPojos(datasetIterator);

    // create a list of models and add all the descriptions:
    List<NeedPojo> remoteNeeds = new ArrayList<NeedPojo>(connections.size());
    while (connectionIterator.hasNext()) {
      remoteNeeds.add(needPojoIterator.next());
    }
    model.addAttribute("remoteNeeds", remoteNeeds);
    return "listConnections";
  }
 @Transactional(readOnly = true)
 @RequestMapping(value = "/showListAgreements", method = RequestMethod.GET)
 @ResponseBody
 public Object simpleAgrimentsList(
     @RequestParam(required = false) Integer page_num,
     @RequestParam(required = false) Integer per_page,
     @RequestParam(value = "pkey_val[]", required = false) String pkey,
     @RequestParam(value = "q_word[]", required = false) String[] qword,
     HttpServletRequest request) {
   Long counterpart_id = Utils.getLongParameter("counterpart_id", request);
   // Sort sort= FormSort.formSortFromSortDescription(orderby);
   Sort sort = new Sort(Sort.Direction.ASC, "name");
   PageRequest pager = null;
   if (page_num != null && per_page != null) {
     page_num = page_num < 1 ? 1 : page_num;
     pager = new PageRequest(page_num - 1, per_page, sort);
   }
   if (pager != null) {
     Page<Agreement> page;
     if (qword != null && qword.length > 0) {
       if (counterpart_id != null) {
         page = agreementRepository.findAgreement(counterpart_id, qword[0], pager);
       } else {
         page = agreementRepository.findAgreement(qword[0], pager);
       }
     } else {
       if (counterpart_id != null) {
         page = agreementRepository.findAgreement(counterpart_id, pager);
       } else {
         page = agreementRepository.findAgreement(pager);
       }
     }
     return new JSComboExpenseResp<>(page);
   } else {
     if (pkey != null && !pkey.isEmpty()) {
       Long key = Long.valueOf(pkey);
       Agreement ft = null;
       if (key != null) {
         ft = agreementRepository.findOne(key);
       }
       return ft;
     } else {
       List<Agreement> page;
       if (qword != null && qword.length > 0) {
         if (counterpart_id != null) {
           page = agreementRepository.findAgreement(counterpart_id, qword[0], sort);
         } else {
           page = agreementRepository.findAgreement(qword[0], sort);
         }
       } else {
         if (counterpart_id != null) {
           page = agreementRepository.findAgreement(counterpart_id, sort);
         } else {
           page = agreementRepository.findAgreement(sort);
         }
       }
       return new JSComboExpenseResp<>(page);
     }
   }
 }
 private void checkUrlAndBodyForId(Long id, LunchMenuDto lunchMenuDto) {
   if (!id.equals(lunchMenuDto.getIdLunchMenu())) {
     throw new ExceptionDifferentIdBetweenUrlAndBody(
         String.format(
             "'idLunchMenu' in URL (%s) must be as same as in request body (%s).",
             id, lunchMenuDto.getIdLunchMenu()));
   }
 }
Beispiel #9
0
 @RequestMapping(value = "/getModuleByP/{pid}", method = RequestMethod.GET)
 @ResponseBody
 public List<Module> getModuleByParentId(@PathVariable Integer pid) {
   List<Module> modules = moduleService.getModuleByParentId(Long.valueOf(pid));
   Subject subject = SecurityUtils.getSubject();
   List<Module> modules_me = check(modules, subject);
   return modules_me;
 }
 @ModelAttribute("poolSettings")
 public PoolSettings getPoolSettings(
     /*@PathVariable("accountId") Long accountId,
     @PathVariable("poolId") Long poolId */ HttpServletRequest request) {
   //        return getAccountPool( accountId, poolId ).getPoolSettings();
   Map pathVariables =
       (Map)
           request.getAttribute(
               "org.springframework.web.servlet.HandlerMapping.uriTemplateVariables");
   if (pathVariables.containsKey("accountId") && pathVariables.containsKey("poolId")) {
     long accountId = Long.parseLong((String) pathVariables.get("accountId"));
     long poolId = Long.parseLong((String) pathVariables.get("poolId"));
     return poolDao.readPoolByIdAndAccountId(poolId, accountId).getPoolSettings();
   } else {
     return null;
   }
 }
 private Bill warmupRestaurant(String billId, Model uiModel) {
   Bill bill = billService.findById(Long.valueOf(billId));
   Collection<Restaurant> restaurants = restaurantService.findAll();
   uiModel.addAttribute("restaurants", restaurants);
   Restaurant restaurant =
       restaurantService.fetchWarmedUp(bill.getDiningTable().getRestaurant().getId());
   uiModel.addAttribute("restaurant", restaurant);
   return bill;
 }
 private Order warmupRestaurantByOrder(String orderId, Model uiModel) {
   Order order = orderService.findById(Long.valueOf(orderId));
   Collection<Restaurant> restaurants = restaurantService.findAll();
   uiModel.addAttribute("restaurants", restaurants);
   Restaurant restaurant =
       restaurantService.fetchWarmedUp(order.getBill().getDiningTable().getRestaurant().getId());
   uiModel.addAttribute("restaurant", restaurant);
   return order;
 }
  @RequestMapping("/user/list")
  public ModelAndView listUser(
      HttpServletRequest request, @ModelAttribute("userManageForm") UserManageForm form) {
    ModelAndView mav = new ModelAndView("user-list");
    if (BooleanUtils.isFalse(form.getUseAdvancedFilter())) {
      Long count = personService.countPersonWithAccount(form.getKeyword());
      mav.addObject("userCount", count);

      int start = pagingUtils.getStartRow(form.getPage());
      mav.addObject("startRow", start);

      List<Person> users =
          personService.findPersonWithAccount(
              form.getKeyword(), start, pagingUtils.getRowPerPage());
      mav.addObject("users", users);

      mav.addObject("pages", pagingUtils.getPageList(form.getPage(), count.intValue()));

    } else {
      Long count =
          personService.countPersonWithAccount(
              form.getKeyword(),
              form.getAdvanceFilter().getConfirmed(),
              form.getAdvanceFilter().getApproved(),
              form.getAdvanceFilter().getActive());
      mav.addObject("userCount", count);

      int start = pagingUtils.getStartRow(form.getPage());
      mav.addObject("startRow", start);

      List<Person> users =
          personService.findPersonWithAccount(
              form.getKeyword(),
              form.getAdvanceFilter().getConfirmed(),
              form.getAdvanceFilter().getApproved(),
              form.getAdvanceFilter().getActive(),
              start,
              pagingUtils.getRowPerPage());
      mav.addObject("users", users);

      mav.addObject("pages", pagingUtils.getPageList(form.getPage(), count.intValue()));
    }
    return mav;
  }
 private void orderHasBeenServed(Order order) {
   try {
     orderService.orderServed(order);
   } catch (StateException e) {
     log.error(
         "Internal error has occurred! Order "
             + Long.valueOf(order.getId())
             + "has not been changed to served state!",
         e);
   }
 }
 @RequestMapping(
     value = "/deluser.jsn",
     method = {RequestMethod.POST, RequestMethod.GET})
 @ResponseBody
 public Object delUser(
     HttpServletRequest request, @RequestParam(value = "userId", required = true) String userId) {
   HttpSession session = request.getSession(true);
   User user = (User) session.getAttribute("currestUser");
   LogWirterUtil.saveLogsToFile(user.getFullName() + "于" + new Date() + "执行删除用户操作用户id" + userId);
   return userService.moveUserById(Long.parseLong(userId));
 }
 /** DELETE /purchasedRiskItems/:id -> delete the "id" purchasedRiskItem. */
 @RequestMapping(
     value = "/purchasedRiskItems/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 public ResponseEntity<Void> deletePurchasedRiskItem(@PathVariable Long id) {
   log.debug("REST request to delete PurchasedRiskItem : {}", id);
   purchasedRiskItemRepository.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("purchasedRiskItem", id.toString()))
       .build();
 }
  @RequestMapping(
      value = "/{id}",
      method = RequestMethod.DELETE,
      produces = MediaType.APPLICATION_JSON_VALUE)
  @ResponseBody
  public ResponseEntity<Void> delete(@PathVariable("id") String deleteId) {
    ResponseEntity<Void> respEntity = null;
    if (StringUtils.isBlank(deleteId) && !StringUtils.isNumeric(deleteId)) {
      return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
    repository.delete(Long.valueOf(deleteId));

    boolean result = repository.exists(Long.valueOf(deleteId));

    if (!result) respEntity = new ResponseEntity<>(HttpStatus.OK);
    else {
      respEntity = new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
    return respEntity;
  }
 @RequestMapping(
     value = "/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @ResponseStatus(HttpStatus.OK)
 public @ResponseBody ResponseEntity<MonitorEntity> getById(@PathVariable("id") String id) {
   MonitorEntity entity = new MonitorEntity();
   entity = repository.findOne(Long.valueOf(id));
   if (entity == null) return new ResponseEntity<MonitorEntity>(HttpStatus.NOT_FOUND);
   return new ResponseEntity<MonitorEntity>(entity, HttpStatus.OK);
 }
 private void billHasBeenPaid(Bill bill) {
   try {
     billService.billHasBeenPaid(bill);
   } catch (StateException e) {
     log.error(
         "Internal error has occurred! Order "
             + Long.valueOf(bill.getId())
             + "has not been changed to served state!",
         e);
   }
 }
 @RequestMapping(value = "/delete", method = RequestMethod.POST)
 public @ResponseBody String deletePermission(@RequestParam String permissionIds) {
   SecurityUtils.getSubject().checkPermission("shiro/permission:delete");
   String[] strIds = permissionIds.split(",");
   Long[] permissionsId = new Long[strIds.length];
   for (int i = 0; i < strIds.length; i++) {
     permissionsId[i] = Long.valueOf(strIds[i]);
   }
   permissionService.deletePermission(permissionsId);
   String stringView = JsonUtil.getJsonStr(AjaxResult.SUCCESS);
   return stringView;
 }
Beispiel #21
0
  @RequestMapping(value = "/message", method = RequestMethod.GET)
  public String messageViewGet(HttpServletRequest request, Model model) {

    User receiver = userService.findOne(Long.parseLong(request.getParameter("user_id")));
    Ad relevantAd = new Ad();

    try {
      relevantAd = adService.findOne(Long.parseLong(request.getParameter("ad_id")));
    } catch (Exception e) {
      System.out.println(e.getMessage());
    }

    if (relevantAd.getId() != null) {
      model.addAttribute("ad", relevantAd);
    }

    model.addAttribute("receiver", receiver);
    model.addAttribute("message", new Message());

    return "messages/new_message";
  }
 @RequestMapping(value = "/allPermissions", method = RequestMethod.GET)
 public @ResponseBody String allPermissions(@RequestParam String roleId) {
   //        SecurityUtils.getSubject().checkPermission("shiro/permission:allPermissions");
   System.out.println(
       "------------------------------------------"
           + roleId
           + "-----------------------------------------------------------");
   Long rId = Long.valueOf(roleId);
   DataGridResult dataGridResult = permissionService.getAllPermissions(rId);
   String stringView = JsonUtil.getJsonStr(dataGridResult);
   return stringView;
 }
 /** DELETE /evolutionPrescriptions/:id -> delete the "id" evolutionPrescription. */
 @RequestMapping(
     value = "/evolutionPrescriptions/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> delete(@PathVariable Long id) {
   log.debug("REST request to delete EvolutionPrescription : {}", id);
   evolutionPrescriptionRepository.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("evolutionPrescription", id.toString()))
       .build();
 }
 /** DELETE /customAdmissionDetailss/:id -> delete the "id" customAdmissionDetails. */
 @RequestMapping(
     value = "/customAdmissionDetailss/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> deleteCustomAdmissionDetails(@PathVariable Long id) {
   log.debug("REST request to delete CustomAdmissionDetails : {}", id);
   customAdmissionDetailsRepository.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("customAdmissionDetails", id.toString()))
       .build();
 }
 private void setControlActive(
     List<Control> controlList, List<Control> controlListForTable, String[] controlIds) {
   for (Control control : controlList) {
     control.setActive(false);
     for (int i = 0; i < controlIds.length; i++) {
       if (control.getId() == Long.parseLong(Utils.isEmpty(controlIds[i]) ? "0" : controlIds[i])) {
         control.setActive(true);
       }
     }
     controlListForTable.add(control);
   }
 }
 /** DELETE /organizers/:id -> delete the "id" organizer. */
 @RequestMapping(
     value = "/organizers/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> deleteOrganizer(@PathVariable Long id) {
   log.debug("REST request to delete Organizer : {}", id);
   organizerService.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("organizer", id.toString()))
       .build();
 }
  @RequestMapping(value = "/edit.html")
  public ModelAndView goEdit(@RequestParam(value = "userId", required = false) String userId) {

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("timp", System.currentTimeMillis());

    if (userId != null && !userId.trim().isEmpty()) {
      User user = userService.getUserById(Long.parseLong(userId));
      map.put("user", user);
    }

    return new ModelAndView("vrs/user/edit.html", map);
  }
Beispiel #28
0
 @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET)
 public ModelAndView edit(@PathVariable Integer id) {
   ModelAndView mav = new ModelAndView(MODULE_EDIT);
   try {
     Module module = moduleService.get(Long.parseLong(id + ""));
     ObjectMapper mapper = JacksonMapper.getInstance();
     String json = mapper.writeValueAsString(module);
     mav.addObject("message", "success");
     mav.addObject("module", json);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return mav;
 }
Beispiel #29
0
 @RequestMapping(value = "regist", method = RequestMethod.POST)
 @ResponseStatus(HttpStatus.OK)
 @ResponseBody
 public Response regist(@RequestBody Map<String, String> params) {
   Response response = new Response();
   try {
     String jobId =
         jobService.regist(
             Long.parseLong(params.get("engineId")),
             params.get("jobName"),
             Long.parseLong(params.get("wid")),
             params.get("cron"),
             new HashMap());
     response.setSuccess(true);
     response.getMap().put("jobId", jobId);
   } catch (Exception ex) {
     response.setSuccess(false);
     response.getError().setMessage("배치 작업을 등록할 수 없습니다.");
     if (ex.getCause() != null) response.getError().setCause(ex.getMessage());
     response.getError().setException(ExceptionUtils.getFullStackTrace(ex));
   }
   return response;
 }
Beispiel #30
0
  @RequestMapping(value = "/message", method = RequestMethod.POST)
  public String messageViewPost(
      HttpServletRequest request, @ModelAttribute("message") Message message, Model model) {

    User sender = (User) request.getSession().getAttribute("user");
    User receiver = userService.findOne(Long.parseLong(request.getParameter("receiver_id")));

    message.setSender(sender);
    message.setReceiver(receiver);
    message.setSendTime((new Date()).getTime());

    try {
      Ad relevantAd = adService.findOne(Long.parseLong(request.getParameter("ad_id")));
      message.setRelevantAd(relevantAd);
    } catch (Exception e) {
      System.out.println(e.getMessage());
    }

    messageService.save(message);

    model.addAttribute("receiver", receiver);

    return "messages/success";
  }