/** * Loads the contents of this file into an existing object. * * @return * The unmarshalled object. Usually the same as {@code o}, but would be different * if the XML representation is completely new. */ public Object unmarshal( Object o ) throws IOException { return unmarshal(o, false); }
/** * Variant of {@link #unmarshal(Object)} applying {@link XStream2#unmarshal(HierarchicalStreamReader, Object, DataHolder, boolean)}. * @since 2.99 */ public Object unmarshalNullingOut(Object o) throws IOException { return unmarshal(o, true); }
/** * Reloads the build record from disk. * * @since 1.410 */ public void reload() throws IOException { this.state = State.COMPLETED; // TODO ABORTED would perhaps make more sense than FAILURE: this.result = Result.FAILURE; // defensive measure. value should be overwritten by unmarshal, but just in case the saved data is inconsistent getDataFile().unmarshal(this); // load the rest of the data if (state == State.COMPLETED) { LOGGER.log(FINER, "reload {0} @{1}", new Object[] {this, hashCode()}); } else { LOGGER.log(WARNING, "reload {0} @{1} with anomalous state {2}", new Object[] {this, hashCode(), state}); } // not calling onLoad upon reload. partly because we don't want to call that from Run constructor, // and partly because some existing use of onLoad isn't assuming that it can be invoked multiple times. }
@VisibleForTesting static @CheckForNull ApiTokenStats internalLoad(@Nonnull File userFolder) { ApiTokenStats apiTokenStats = null; XmlFile statsFile = getConfigFile(userFolder); if (statsFile.exists()) { try { apiTokenStats = (ApiTokenStats) statsFile.unmarshal(ApiTokenStats.class); apiTokenStats.parent = userFolder; } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to load " + statsFile, e); } } return apiTokenStats; }
private void loadFromUserConfigFile(String userId) { XmlFile config = getConfigFile(); try { if ( config != null && config.exists()) { config.unmarshal(this); this.id = userId; } } catch (IOException e) { LOGGER.log(Level.SEVERE, "Failed to load " + config, e); } }
/** * Loads the settings from a file. */ public synchronized void load() throws IOException { getConfigFile().unmarshal(this); for (Target t : targets) t.enable(); }
/** * Loads serializable fields of this instance from the persisted storage. * * <p> * If there was no previously persisted state, this method is no-op. * * @since 1.245 */ protected void load() throws IOException { XmlFile xml = getConfigXml(); if(xml.exists()) xml.unmarshal(this); }
/** * Loads the data from the disk into this object. * * <p> * The constructor of the derived class must call this method. * (If we do that in the base class, the derived class won't * get a chance to set default values.) */ public synchronized void load() { XmlFile file = getConfigFile(); if(!file.exists()) return; try { file.unmarshal(this); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to load "+file, e); } }
private void loadConfig() throws IOException { XmlFile cfg = getConfigFile(); if (cfg.exists()) { // reset some data that may not exist in the disk file // so that we can take a proper compensation action later. primaryView = null; views.clear(); // load from disk cfg.unmarshal(Jenkins.this); } try { checkRawBuildsDir(buildsDir); setBuildsAndWorkspacesDir(); } catch (InvalidBuildsDir invalidBuildsDir) { throw new IOException(invalidBuildsDir); } }
public void load() { XmlFile file = getConfigFile(); if(file.exists()) { try { file.unmarshal(this); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to load "+file, e); } } properties.setOwner(this); updateTransientActions(); }
private void load() throws IOException { UserIdMigrator migrator = new UserIdMigrator(usersDirectory, getIdStrategy()); if (migrator.needsMigration()) { try { migrator.migrateUsers(this); } catch (IOException ioe) { LOGGER.log(Level.SEVERE, "Error migrating users.", ioe); throw ioe; } } else { XmlFile config = getXmlConfigFile(); try { config.unmarshal(this); } catch (NoSuchFileException e) { LOGGER.log(Level.FINE, "User id mapping file does not exist. It will be created when a user is saved."); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to load " + config, e); throw e; } } }
@Override public synchronized void load() { // for backward compatibility, if we don't have our own data yet, then // load from Mailer. XmlFile file = getConfigFile(); if(!file.exists()) { XStream2 xs = new XStream2(); xs.addCompatibilityAlias("hudson.tasks.Mailer$DescriptorImpl",JenkinsLocationConfiguration.class); file = new XmlFile(xs,new File(Jenkins.get().getRootDir(),"hudson.tasks.Mailer.xml")); if (file.exists()) { try { file.unmarshal(this); if (jenkinsUrl==null) jenkinsUrl = hudsonUrl; } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to load "+file, e); } } } else { super.load(); } updateSecureSessionFlag(); }
if(file.exists()) { try { sites.replaceBy(((PersistedList)file.unmarshal(sites)).toList()); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to load "+file, e);
/** * 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()); }
private void loadConfig() throws IOException { XmlFile cfg = getConfigFile(); if (cfg.exists()) { // reset some data that may not exist in the disk file // so that we can take a proper compensation action later. primaryView = null; views.clear(); // load from disk cfg.unmarshal(Jenkins.this); } }
public void load() throws IOException { XmlFile config = getXmlFile(); try { if (config.exists()) { config.unmarshal(this); } } catch (IOException e) { logger.error("Failed to load " + config, e); } }
/** Hack to allow {@link #execution} to use an {@link Owner} referring to this run, even when it has not yet been loaded. */ @Override public void reload() throws IOException { synchronized (LOADING_RUNS) { LOADING_RUNS.put(key(), this); } // super.reload() forces result to be FAILURE, so working around that new XmlFile(XSTREAM,new File(getRootDir(),"build.xml")).unmarshal(this); }
/** * Loads the settings from a file. */ public synchronized void load() throws IOException { getConfigFile().unmarshal(this); for (Target t : targets) t.enable(); }
public void load() { XmlFile file = getConfigFile(); if(file.exists()) { try { file.unmarshal(this); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to load "+file, e); } } properties.setOwner(this); updateTransientActions(); }
public void load() throws IOException { XmlFile xml = getConfigXml(trigger.getActualProject()); if (xml.exists()) { xml.unmarshal(this); } save(); }