Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Creative commons Attribution-NonCommercial license. http://creativecommons.org/licenses/by-nc/2.5/au/deed.en_GB NO WARRANTY IS GIVEN OR IMPLIED, USE AT YOUR OWN RISK.
 
 package base.jee.servlet;
 
Display and allow updating all current system configuration settings.
public class GroupsServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	public GroupsServlet(JeeBase jeethrows IOException {
		super(jee);
	}
	@SuppressWarnings("unchecked")
	public void doGet(String tokenUser uHttpServletRequest requestHttpServletResponse responsethrows ServletExceptionIOException {
		String error = null;
		Integer type = null;
		if(request.getParameter("type") != null) {
			try {
				type = Integer.parseInt(request.getParameter("type"));
catch(NumberFormatException e) {
				type = null;
			}
		}
		if(type == null || type == 0) {
			type = 1;
		}
		if(request.getParameter("name") != null && type != null) {
			if(request.getParameter("a") == null || !request.getParameter("a").equals(u.getFormAuthToken())) {
				throw new IllegalArgumentException("Invalid authentication token.");
			}
			.getAPI().upsertGroup(urequest.getParameter("name"), type);
			response.setHeader("Location".get("base.url""") + "/groups?s=added");
			response.setStatus(302);
			return;
		}
		if(request.getParameter("name") != null && request.getParameter("update") != null && type != null) {
			if(request.getParameter("a") == null || !request.getParameter("a").equals(u.getFormAuthToken())) {
				throw new IllegalArgumentException("Invalid authentication token.");
			}
			.getAPI().upsertGroup(urequest.getParameter("name"), type);
			response.setHeader("Location".get("base.url""") + "/groups?s=added");
			response.setStatus(302);
			return;
		}
		List<Groupgroups = .getAPI().getGroups(u);
		ST page = .getPage(u"groups");
		for(Group g : groups) {
			if(g.getType() > 0) {
				page.add("groups"g);
			}
		}
		page.add("groups"null);
		for(Group g : groups) {
			if(g.getType() == 0) {
				page.add("builtin_groups"g);
			}
		}
		page.add("builtin_groups"null);
		page.add("error"error);
		page.add("breadcrumbs"new Breadcrumb("People""/people"));
		page.add("breadcrumbs"new Breadcrumb("Groups"null));
		page.add("auth"u.getFormAuthToken());
		response.getWriter().write(page.render());
	}
New to GrepCode? Check out our FAQ X