private void applyDisabled(I item, boolean disabled) { try { // TODO revisit once https://github.com/jenkinsci/jenkins/pull/2866 available in baseline Jenkins if (item instanceof AbstractFolder) { ((AbstractFolder) item).makeDisabled(disabled); } else if (item instanceof AbstractProject) { ((AbstractProject) item).makeDisabled(disabled); } else { try { Method makeDisabled = item.getClass().getMethod("makeDisabled", boolean.class); makeDisabled.invoke(item, disabled); } catch (NoSuchMethodException | IllegalAccessException e) { // it's just not supported, so we cannot expect it to succeed LOGGER.log(Level.FINE, "Cannot not " + (disabled ? "disable " : "enanble ") + item.getFullName(), e); } catch (InvocationTargetException e) { // it's supported but something went wrong LOGGER.log(Level.WARNING, "Could not " + (disabled ? "disable " : "enanble ") + item.getFullName(), e); } } } catch (IOException e) { LOGGER.log(Level.WARNING, "Could not " + (disabled ? "disable " : "enanble ") + item.getFullName(), e); } }
private void applyDisabled(I item, boolean disabled) { try { // TODO revisit once on 2.61+ for https://github.com/jenkinsci/jenkins/pull/2866 if (item instanceof AbstractFolder) { ((AbstractFolder) item).makeDisabled(disabled); } else if (item instanceof AbstractProject) { ((AbstractProject) item).makeDisabled(disabled); } else { try { Method makeDisabled = item.getClass().getMethod("makeDisabled", boolean.class); makeDisabled.invoke(item, disabled); } catch (NoSuchMethodException | IllegalAccessException e) { // it's just not supported, so we cannot expect it to succeed LOGGER.log(Level.FINE, "Cannot not " + (disabled ? "disable " : "enable ") + item.getFullName(), e); } catch (InvocationTargetException e) { // it's supported but something went wrong LOGGER.log(Level.WARNING, "Could not " + (disabled ? "disable " : "enable ") + item.getFullName(), e); } } } catch (IOException e) { LOGGER.log(Level.WARNING, "Could not " + (disabled ? "disable " : "enable ") + item.getFullName(), e); } }
/** * Stapler action method to enable the folder. * * @return the response. * @throws IOException if the folder could not be disabled. * @throws ServletException if something goes wrong. * @since 6.1.0 */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler action method public HttpResponse doEnable() throws IOException, ServletException { checkPermission(CONFIGURE); makeDisabled(false); return new HttpRedirect("."); }
/** * Stapler action method to disable the folder. * * @return the response. * @throws IOException if the folder could not be disabled. * @throws ServletException if something goes wrong. * @since 6.1.0 */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler action method public HttpResponse doDisable() throws IOException, ServletException { checkPermission(CONFIGURE); makeDisabled(true); return new HttpRedirect("."); }
/** * Stapler action method to disable the folder. * * @return the response. * @throws IOException if the folder could not be disabled. * @throws ServletException if something goes wrong. * @since 6.1.0 */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler action method public HttpResponse doDisable() throws IOException, ServletException { checkPermission(CONFIGURE); makeDisabled(true); return new HttpRedirect("."); }
/** * Stapler action method to enable the folder. * * @return the response. * @throws IOException if the folder could not be disabled. * @throws ServletException if something goes wrong. * @since 6.1.0 */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler action method public HttpResponse doEnable() throws IOException, ServletException { checkPermission(CONFIGURE); makeDisabled(false); return new HttpRedirect("."); }
makeDisabled(json.optBoolean("disable"));
makeDisabled(json.optBoolean("disable"));