hudson.model.Descriptor.FormException Java Examples

The following examples show how to use hudson.model.Descriptor.FormException. 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: EnvDashboardView.java    From environment-dashboard-plugin with MIT License 6 votes vote down vote up
@RequirePOST
public void doPurgeSubmit(final StaplerRequest req, StaplerResponse res)
		throws IOException, ServletException, FormException {
	checkPermission(Jenkins.ADMINISTER);

	Connection conn = null;
	Statement stat = null;
	conn = DBConnection.getConnection();
	try {
		assert conn != null;
		stat = conn.createStatement();
		stat.execute("TRUNCATE TABLE env_dashboard");
	} catch (SQLException e) {
		System.out.println("E15: Could not truncate table env_dashboard.\n" + e.getMessage());
	} finally {
		DBConnection.closeConnection();
	}
	res.forwardToPreviousPage(req);
}
 
Example #2
Source File: BuildMonitorView.java    From jenkins-build-monitor-plugin with MIT License 6 votes vote down vote up
@Override
protected void submit(StaplerRequest req) throws ServletException, IOException, FormException {
    super.submit(req);

    JSONObject json = req.getSubmittedForm();

    synchronized (this) {

        String requestedOrdering = req.getParameter("order");
        title                    = req.getParameter("title");

        currentConfig().setDisplayCommitters(json.optBoolean("displayCommitters", true));
        currentConfig().setBuildFailureAnalyzerDisplayedField(req.getParameter("buildFailureAnalyzerDisplayedField"));
        
        try {
            currentConfig().setOrder(orderIn(requestedOrdering));
        } catch (Exception e) {
            throw new FormException("Can't order projects by " + requestedOrdering, "order");
        }
    }
}
 
Example #3
Source File: KubernetesFolderProperty.java    From kubernetes-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public AbstractFolderProperty<?> reconfigure(StaplerRequest req, JSONObject form) throws FormException {
    if (form == null) {
        return null;
    }

    // ignore modifications silently and return the unmodified object if the user
    // does not have the ADMINISTER Permission
    if (!userHasAdministerPermission()) {
        return this;
    }

    try {
        Set<String> inheritedGrants = new HashSet<>();
        collectAllowedClouds(inheritedGrants, getOwner().getParent());

        Set<String> permittedClouds = new HashSet<>();
        JSONArray names = form.names();
        if (names != null) {
            for (Object name : names) {
                String strName = (String) name;

                if (strName.startsWith(PREFIX_USAGE_PERMISSION) && form.getBoolean(strName)) {
                    String cloud = StringUtils.replaceOnce(strName, PREFIX_USAGE_PERMISSION, "");

                    if (isUsageRestrictedKubernetesCloud(Jenkins.get().getCloud(cloud))
                            && !inheritedGrants.contains(cloud)) {
                        permittedClouds.add(cloud);
                    }
                }
            }
        }
        this.permittedClouds.clear();
        this.permittedClouds.addAll(permittedClouds);
    } catch (JSONException e) {
        LOGGER.log(Level.SEVERE, e, () -> "reconfigure failed: " + e.getMessage());
    }
    return this;
}
 
Example #4
Source File: DockerSlaveTemplate.java    From yet-another-docker-plugin with MIT License 5 votes vote down vote up
/**
 * Custom specified ID. When editing existed UI entry, UI sends it back.
 */
public DockerSlaveTemplate(@Nonnull String id) throws FormException {
    super(id);
    if (isNull(id)) {
        throw new FormException("Hidden id must not be null", "id");
    }
}
 
Example #5
Source File: DockerSlaveTemplate.java    From yet-another-docker-plugin with MIT License 5 votes vote down vote up
/**
 * FIXME DescribableList doesn't work with DBS https://gist.github.com/KostyaSha/3414f4f453ea7c7406b4
 */
@DataBoundConstructor
public DockerSlaveTemplate(@Nonnull String id, List<NodeProperty<?>> nodeProperties)
        throws FormException {
    this(id);
    setNodeProperties(nodeProperties);
}
 
Example #6
Source File: EnvDashboardView.java    From environment-dashboard-plugin with MIT License 5 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
	envOrder = formData.getString("envOrder");
	compOrder = formData.getString("compOrder");
	deployHistory = formData.getString("deployHistory");
	save();
	return super.configure(req, formData);
}
 
Example #7
Source File: PretendSlave.java    From jenkins-test-harness with MIT License 4 votes vote down vote up
public PretendSlave(String name, String remoteFS, int numExecutors, Mode mode, String labelString, ComputerLauncher launcher, FakeLauncher faker) throws IOException, FormException {
    super(name, "pretending a slave", remoteFS, String.valueOf(numExecutors), mode, labelString, launcher, RetentionStrategy.NOOP, Collections.emptyList());
    this.faker = faker;
}
 
Example #8
Source File: PretendSlave.java    From jenkins-test-harness with MIT License 4 votes vote down vote up
public PretendSlave(String name, String remoteFS, String labelString, ComputerLauncher launcher, FakeLauncher faker) throws IOException, FormException {
	this(name, remoteFS, 1, Mode.NORMAL, labelString, launcher, faker);
}
 
Example #9
Source File: EnvDashboardView.java    From environment-dashboard-plugin with MIT License 4 votes vote down vote up
@Override
protected void submit(final StaplerRequest req) throws IOException, ServletException, FormException {
	req.bindJSON(this, req.getSubmittedForm());
}
 
Example #10
Source File: MyBuildsView.java    From DotCi with MIT License 4 votes vote down vote up
@Override
protected void submit(final StaplerRequest req) throws IOException, ServletException, FormException {
    // noop
}
 
Example #11
Source File: AllListView.java    From DotCi with MIT License 4 votes vote down vote up
@Override
protected void submit(final StaplerRequest req) throws IOException, ServletException, FormException {
    throw new UnsupportedOperationException();
}
 
Example #12
Source File: AuthenticatedViewTest.java    From DotCi with MIT License 2 votes vote down vote up
@Override
protected void submit(StaplerRequest req) throws IOException, ServletException, FormException {

}