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 TemplateServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	public TemplateServlet(JeeBase jeethrows IOException {
		super(jee);
	}
	public void doGet(String tokenUser uHttpServletRequest requestHttpServletResponse responsethrows ServletExceptionIOException {
			throw new IllegalStateException("You do not have permission to manage templates.");
		}
		String error = null;
		// Set header value
		if(request.getParameter("name") != null && request.getParameter("content") != null) {
			if(request.getParameter("a") == null || !request.getParameter("a").equals(u.getFormAuthToken())) {
				throw new IllegalArgumentException("Invalid authentication token.");
			}
			.getAPI().upsertSetting(urequest.getParameter("name"), request.getParameter("value"));
			response.setHeader("Location".get("base.url""") + "/template?s=added");
			response.setStatus(302);
			return;
		}
		Template template = .getTemplateManager().getTemplate(request.getParameter("name"));
		List<Resourceresources = new LinkedList<>();
		for(Resource resource : template.getResources()) {
			resources.add(resource);
		}
		Collections.sort(resources);
		ST page = .getPage(u"template");
		page.add("t"template);
		page.add("resources"resources);
		page.add("isdefault"template.getName().equalsIgnoreCase("default"));
		page.add("error"error);
		page.add("breadcrumbs"new Breadcrumb("Templates""/templates"));
		page.add("breadcrumbs"new Breadcrumb(template.getName(), null));
		page.add("auth"u.getFormAuthToken());
		response.getWriter().write(page.render());
	}
New to GrepCode? Check out our FAQ X