samples/xml/contacts/src/main/java/sample/contact/AdminPermissionController.java
@RequestMapping(value = "/secure/addPermission.htm", method = RequestMethod.POST)
	public String addPermission(AddPermission addPermission, BindingResult result,
			ModelMap model) {
		addPermissionValidator.validate(addPermission, result);

		if (result.hasErrors()) {
			model.put("recipients", listRecipients());
			model.put("permissions", listPermissions());

			return "addPermission";
		}

		PrincipalSid sid = new PrincipalSid(addPermission.getRecipient());
		Permission permission = permissionFactory.buildFromMask(addPermission
				.getPermission());

		try {
			contactManager.addPermission(addPermission.getContact(), sid, permission);
		}
		catch (DataAccessException existingPermission) {
			existingPermission.printStackTrace();
			result.rejectValue("recipient", "err.recipientExistsForContact",
					"Addition failure.");

			model.put("recipients", listRecipients());
			model.put("permissions", listPermissions());
			return "addPermission";
		}

		return "redirect:/secure/index.htm";
	}
@RequestMapping(value = "/secure/addPermission.htm", method = RequestMethod.POST)
	public String addPermission(AddPermission addPermission, BindingResult result,
			ModelMap model) {
		addPermissionValidator.validate(addPermission, result);

		if (result.hasErrors()) {
			model.put("recipients", listRecipients());
			model.put("permissions", listPermissions());

			return "addPermission";
		}

		PrincipalSid sid = new PrincipalSid(addPermission.getRecipient());
		Permission permission = permissionFactory.buildFromMask(addPermission
				.getPermission());

		try {
			contactManager.addPermission(addPermission.getContact(), sid, permission);
		}
		catch (DataAccessException existingPermission) {
			existingPermission.printStackTrace();
			result.rejectValue("recipient", "err.recipientExistsForContact",
					"Addition failure.");

			model.put("recipients", listRecipients());
			model.put("permissions", listPermissions());
			return "addPermission";
		}

		return "redirect:/secure/index.htm";
	}
Handles submission of the "add permission" form.