Java Code Examples for org.kohsuke.stapler.StaplerResponse#forwardToPreviousPage()

The following examples show how to use org.kohsuke.stapler.StaplerResponse#forwardToPreviousPage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LockableResourcesRootAction.java    From lockable-resources-plugin with MIT License 6 votes vote down vote up
public void doUnlock(StaplerRequest req, StaplerResponse rsp)
		throws IOException, ServletException {
	Jenkins.get().checkPermission(UNLOCK);

	String name = req.getParameter("resource");
	LockableResource r = LockableResourcesManager.get().fromName(name);
	if (r == null) {
		rsp.sendError(404, "Resource not found " + name);
		return;
	}

	List<LockableResource> resources = new ArrayList<>();
	resources.add(r);
	LockableResourcesManager.get().unlock(resources, null);

	rsp.forwardToPreviousPage(req);
}
 
Example 2
Source File: LockableResourcesRootAction.java    From lockable-resources-plugin with MIT License 6 votes vote down vote up
public void doReserve(StaplerRequest req, StaplerResponse rsp)
	throws IOException, ServletException {
	Jenkins.get().checkPermission(RESERVE);

	String name = req.getParameter("resource");
	LockableResource r = LockableResourcesManager.get().fromName(name);
	if (r == null) {
		rsp.sendError(404, "Resource not found " + name);
		return;
	}

	List<LockableResource> resources = new ArrayList<>();
	resources.add(r);
	String userName = getUserName();
	if (userName != null)
		LockableResourcesManager.get().reserve(resources, userName);

	rsp.forwardToPreviousPage(req);
}
 
Example 3
Source File: LockableResourcesRootAction.java    From lockable-resources-plugin with MIT License 6 votes vote down vote up
public void doUnreserve(StaplerRequest req, StaplerResponse rsp)
	throws IOException, ServletException {
	Jenkins.get().checkPermission(RESERVE);

	String name = req.getParameter("resource");
	LockableResource r = LockableResourcesManager.get().fromName(name);
	if (r == null) {
		rsp.sendError(404, "Resource not found " + name);
		return;
	}

	String userName = getUserName();
	if ((userName == null || !userName.equals(r.getReservedBy()))
			&& !Jenkins.get().hasPermission(Jenkins.ADMINISTER))
		throw new AccessDeniedException2(Jenkins.getAuthentication(),
				RESERVE);

	List<LockableResource> resources = new ArrayList<>();
	resources.add(r);
	LockableResourcesManager.get().unreserve(resources);

	rsp.forwardToPreviousPage(req);
}
 
Example 4
Source File: LockableResourcesRootAction.java    From lockable-resources-plugin with MIT License 6 votes vote down vote up
public void doReset(StaplerRequest req, StaplerResponse rsp)
	throws IOException, ServletException {
	Jenkins.get().checkPermission(UNLOCK);

	String name = req.getParameter("resource");
	LockableResource r = LockableResourcesManager.get().fromName(name);
	if (r == null) {
		rsp.sendError(404, "Resource not found " + name);
		return;
	}

	List<LockableResource> resources = new ArrayList<>();
	resources.add(r);
	LockableResourcesManager.get().reset(resources);

	rsp.forwardToPreviousPage(req);
}
 
Example 5
Source File: RefreshHookRepoAction.java    From DotCi with MIT License 4 votes vote down vote up
public void doRefreshHook(StaplerRequest request, StaplerResponse response) throws IOException, ServletException {
    new GithubRepositoryService(getGithubRepository(request)).addHook(getAccessToken(request), getCurrentUserLogin(request));
    response.forwardToPreviousPage(request);
}
 
Example 6
Source File: DynamicProject.java    From DotCi with MIT License 4 votes vote down vote up
public void doToggleNewUI(final StaplerRequest req, final StaplerResponse rsp) throws IOException, ServletException, InterruptedException {
    toggleNewUI();
    rsp.forwardToPreviousPage(req);
}
 
Example 7
Source File: DynamicProject.java    From DotCi with MIT License 4 votes vote down vote up
public void doBranchBuilds(final StaplerRequest req, final StaplerResponse rsp) throws IOException, ServletException, InterruptedException {
    final String tab = req.getRestOfPath().replace("/", "");
    handleBranchTabs(tab, req);
    rsp.forwardToPreviousPage(req);
}