示例#1
0
  @RequestMapping(value = "/users/edit/{id}", method = RequestMethod.GET)
  public String editUser(@PathVariable(value = "id") Long id, ModelMap model) {
    RESTUser user = geoStoreClient.getUser(id);
    model.addAttribute("user", user);

    return "snipplets/modal/createuser";
  }
示例#2
0
  @RequestMapping(value = "/users/delete/{id}", method = RequestMethod.GET)
  public String deleteUser(@PathVariable(value = "id") Long id, ModelMap model) {
    RESTUser user = geoStoreClient.getUser(id);
    model.addAttribute("user", user);
    model.addAttribute("resource", user.getName());

    return "snipplets/modal/confirmdelete";
  }
示例#3
0
  @RequestMapping(value = "/users/create", method = RequestMethod.POST)
  public String createUser(@ModelAttribute("user") User user, ModelMap model) {

    try {
      geoStoreClient.insert(user);
    } catch (Exception e) {
      model.addAttribute("messageType", "error");
      model.addAttribute("notLocalizedMessage", "Couldn't save User");
      return "common/messages";
    }
    model.addAttribute("messageType", "success");
    model.addAttribute("notLocalizedMessage", "User Saved successfully");

    return "common/messages";
  }
示例#4
0
  @RequestMapping(value = "/users/{page}", method = RequestMethod.GET)
  public String userList(@PathVariable(value = "page") Integer page, ModelMap model) {
    UserList ul = geoStoreClient.getUsers(page, pageSize);
    // UserList ul1 = geoStoreClient.getUsers(page + 1, pageSize);
    if (ul.getList().size() > 0) {
      model.addAttribute("next", page + 1);
    }
    if (ul != null) {
      List<RESTUser> users = ul.getList();
      model.addAttribute("users", users);
    }
    ControllerUtils.setCommonModel(model);
    model.addAttribute("context", "context/users");
    model.addAttribute("pagesize", pageSize);
    model.addAttribute("page", page);

    return "template";
  }
示例#5
0
  @RequestMapping(value = "/users/edit/{id}", method = RequestMethod.POST)
  public String editUser(
      @PathVariable(value = "id") Long id, @ModelAttribute("user") User user, ModelMap model) {

    // List<UserAttribute> attrs = new ArrayList<UserAttribute>();
    // UserAttribute email = new UserAttribute();

    try {
      geoStoreClient.update(id, user);
    } catch (Exception e) {
      model.addAttribute("messageType", "error");
      model.addAttribute("notLocalizedMessage", "Couldn't save User");
      return "common/messages";
    }
    model.addAttribute("messageType", "success");
    model.addAttribute("notLocalizedMessage", "User Saved successfully");

    return "common/messages";
  }
示例#6
0
  @Test
  public void testupdateSecurityRules() {
    AdministratorGeoStoreClient adminClient = new AdministratorGeoStoreClient();
    adminClient.setGeostoreRestUrl("http://localhost:9191/geostore/rest");
    adminClient.setUsername("admin");
    adminClient.setPassword("admin");

    createDefaultCategory();

    RESTResource res = new RESTResource();
    res.setCategory(new RESTCategory(DEFAULTCATEGORYNAME));

    String timeid = Long.toString(System.currentTimeMillis());
    res.setName("rest_test_resource_" + timeid);

    User u1 = new User();
    u1.setName("u1_" + timeid);
    u1.setRole(Role.USER);
    Long userId = adminClient.insert(u1);

    UserGroup g1 = new UserGroup();
    g1.setGroupName("g1_" + timeid);
    Long groupId = adminClient.insertUserGroup(g1);

    Long id = client.insert(res);
    List<SecurityRule> ruleList = new ArrayList<SecurityRule>();

    SecurityRule rule = new SecurityRule();
    rule.setCanRead(true);
    rule.setCanWrite(true);
    User user = new User();
    user.setId(userId);
    rule.setUser(user);
    ruleList.add(rule);

    rule = new SecurityRule();
    rule.setCanRead(true);
    rule.setCanWrite(false);
    UserGroup group = new UserGroup();
    group.setId(groupId);
    rule.setGroup(group);
    ruleList.add(rule);

    SecurityRuleList rules = new SecurityRuleList(ruleList);
    client.updateSecurityRules(id, rules);

    SecurityRuleList writtenRules = client.getSecurityRules(id);
    assertNotNull(writtenRules.getList());
    assertEquals(2, rules.getList().size());
  }