Refine search
public void save() throws IOException { if(BulkChange.contains(this)) return; XmlFile config = getXmlFile(); config.write(this); SaveableListener.fireOnChange(this, config); }
/** * Fires the {@link #onChange} event. */ public static void fireOnChange(Saveable o, XmlFile file) { for (SaveableListener l : all()) { try { l.onChange(o,file); } catch (ThreadDeath t) { throw t; } catch (Throwable t) { Logger.getLogger(SaveableListener.class.getName()).log(Level.WARNING, null, t); } } }
/** * {@inheritDoc} */ @Override public void save() throws IOException { if (BulkChange.contains(this)) { return; } final File nodesDir = getNodesDir(); final Set<String> existing = new HashSet<String>(); for (Node n : nodes.values()) { if (n instanceof EphemeralNode) { continue; } existing.add(n.getNodeName()); XmlFile xmlFile = new XmlFile(Jenkins.XSTREAM, new File(new File(nodesDir, n.getNodeName()), "config.xml")); xmlFile.write(n); SaveableListener.fireOnChange(this, xmlFile); } for (File forDeletion : nodesDir.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.isDirectory() && !existing.contains(pathname.getName()); } })) { Util.deleteRecursive(forDeletion); } }
/** * Actually persists a node on disk. * * @param node the node to be persisted. * @throws IOException if the node could not be persisted. */ private void persistNode(final @Nonnull Node node) throws IOException { // no need for a full save() so we just do the minimum if (node instanceof EphemeralNode) { Util.deleteRecursive(new File(getNodesDir(), node.getNodeName())); } else { XmlFile xmlFile = new XmlFile(Jenkins.XSTREAM, new File(new File(getNodesDir(), node.getNodeName()), "config.xml")); xmlFile.write(node); SaveableListener.fireOnChange(this, xmlFile); } jenkins.getQueue().scheduleMaintenance(); }
checkPermission(CONFIGURE); XmlFile configXmlFile = getConfigFile(); final AtomicFileWriter out = new AtomicFileWriter(configXmlFile.getFile()); try { try { Object o = new XmlFile(Items.XSTREAM, out.getTemporaryFile()).unmarshalNullingOut(this); if (o!=this) { SaveableListener.fireOnChange(this, getConfigFile());
public void save() throws IOException { getConfigFile().write(monitors); SaveableListener.fireOnChange(this, getConfigFile()); } };
/** * Reloads this job from the disk. * * Exposed through CLI as well. * * TODO: think about exposing this to UI * * @since 1.556 */ @RequirePOST public void doReload() throws IOException { checkPermission(CONFIGURE); // try to reflect the changes by reloading getConfigFile().unmarshal(this); Items.whileUpdatingByXml(new NotReallyRoleSensitiveCallable<Void, IOException>() { @Override public Void call() throws IOException { onLoad(getParent(), getRootDir().getName()); return null; } }); Jenkins.getInstance().rebuildDependencyGraphAsync(); SaveableListener.fireOnChange(this, getConfigFile()); }
/** * Save the settings to a file. * @throws IOException Save error */ public synchronized void save() throws IOException { if(BulkChange.contains(this)) return; long start=0; if(logger.isLoggable(Level.FINE)) start = System.currentTimeMillis(); File file = getFingerprintFile(md5sum); save(file); SaveableListener.fireOnChange(this, getConfigFile(file)); if(logger.isLoggable(Level.FINE)) logger.fine("Saving fingerprint "+file+" took "+(System.currentTimeMillis()-start)+"ms"); }
@Override public void onChange(Saveable o, XmlFile file) { super.onChange(o, file); ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance(); if(plugin != null){ ScmSyncStrategy strategy = plugin.getStrategyForSaveable(o, file.getFile()); if(strategy != null){ WeightedMessage message = strategy.getCommitMessageFactory().getMessageWhenSaveableUpdated(o, file); plugin.getTransaction().defineCommitMessage(message); String path = JenkinsFilesHelper.buildPathRelativeToHudsonRoot(file.getFile()); plugin.getTransaction().registerPath(path); } } } }
/** * Reverse operation of {@link #register()}. */ public void unregister() { all().remove(this); }
public void superOnChange(Saveable o, XmlFile file) { super.onChange(o, file); }
public void superRegister() { super.register(); }
/** * Save the user configuration. */ public synchronized void save() throws IOException { if (!isIdOrFullnameAllowed(id)) { throw FormValidation.error(Messages.User_IllegalUsername(id)); } if (!isIdOrFullnameAllowed(fullName)) { throw FormValidation.error(Messages.User_IllegalFullname(fullName)); } if (BulkChange.contains(this)) { return; } XmlFile xmlFile = new XmlFile(XSTREAM, constructUserConfigFile()); xmlFile.write(this); SaveableListener.fireOnChange(this, xmlFile); }
public void save() throws IOException { getConfigFile().write(monitors); SaveableListener.fireOnChange(this, getConfigFile()); } };
/** * Registers this object as an active listener so that it can start getting * callbacks invoked. * * @deprecated as of 1.281 * Put {@link Extension} on your class to get it auto-registered. */ @Deprecated public void register() { all().add(this); }
@Override public void onChange(Saveable o, XmlFile file) { initPython(); if (pexec.isImplemented(0)) { pexec.execPythonVoid("on_change", o, file); } else { super.onChange(o, file); } }
@Override public void register() { initPython(); if (pexec.isImplemented(1)) { pexec.execPythonVoid("register"); } else { super.register(); } }
/** * Saves serializable fields of this instance to the persisted storage. * * @since 1.245 */ public void save() throws IOException { if(BulkChange.contains(this)) return; XmlFile config = getConfigXml(); config.write(this); SaveableListener.fireOnChange(this, config); }
/** * Persists the queue contents to the disk. */ public void save() { if(BulkChange.contains(this)) return; if (Jenkins.getInstanceOrNull() == null) { return; } XmlFile queueFile = new XmlFile(XSTREAM, getXMLQueueFile()); lock.lock(); try { // write out the queue state we want to save State state = new State(); state.counter = WaitingItem.COUNTER.longValue(); // write out the tasks on the queue for (Item item: getItems()) { if(item.task instanceof TransientTask) continue; state.items.add(item); } try { queueFile.write(state); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to write out the queue file " + getXMLQueueFile(), e); } } finally { lock.unlock(); } SaveableListener.fireOnChange(this, queueFile); }