@Override protected int run() throws IOException { node.checkPermission(Computer.EXTENDED_READ); Jenkins.XSTREAM2.toXMLUTF8(node, stdout); return 0; } }
/** * @since 1.538 */ public void writeXml(OutputStream out) throws IOException { // pity we don't have a handy way to clone Jenkins.XSTREAM to temp add the omit Field XStream2 xStream2 = new XStream2(); xStream2.omitField(View.class, "owner"); xStream2.toXMLUTF8(View.this, out); }
/** * Accepts {@code config.xml} submission, as well as serve it. */ @WebMethod(name = "config.xml") public void doConfigDotXml(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { if (req.getMethod().equals("GET")) { // read checkPermission(EXTENDED_READ); rsp.setContentType("application/xml"); Node node = getNode(); if (node == null) { throw HttpResponses.notFound(); } Jenkins.XSTREAM2.toXMLUTF8(node, rsp.getOutputStream()); return; } if (req.getMethod().equals("POST")) { // submission updateByXml(req.getInputStream()); return; } // huh? rsp.sendError(SC_BAD_REQUEST); }
@Override protected int run() throws IOException { node.checkPermission(Computer.EXTENDED_READ); Jenkins.XSTREAM2.toXMLUTF8(node, stdout); return 0; } }
/** Verify that all the arguments WILL serialize and if not replace with {@link org.jenkinsci.plugins.workflow.actions.ArgumentsAction.NotStoredReason#UNSERIALIZABLE} * See JENKINS-50752 for details, but the gist is we need to avoid problems before physical persistence to prevent data loss. * @return Arguments */ Map<String, Object> serializationCheck(@Nonnull Map<String, Object> arguments) { boolean isMutated = false; HashMap<String, Object> out = Maps.newHashMapWithExpectedSize(arguments.size()); for (Map.Entry<String, Object> entry : arguments.entrySet()) { Object val = entry.getValue(); try { if (val != null && !(val instanceof String) && !(val instanceof Boolean) && !(val instanceof Number) && !(val instanceof NotStoredReason) && !(val instanceof TimeUnit)) { // We only need to check serialization for nontrivial types Jenkins.XSTREAM2.toXMLUTF8(entry.getValue(), NullOutputStream.NULL_OUTPUT_STREAM); // Hacky but can't find a better way } out.put(entry.getKey(), entry.getValue()); } catch (Exception ex) { out.put(entry.getKey(), NotStoredReason.UNSERIALIZABLE); isMutated = true; LOGGER.log(Level.FINE, "Failed to serialize argument "+entry.getKey(), ex); } } if (isMutated) { this.isUnmodifiedBySanitization = false; } return out; }
/** * @since 1.538 */ public void writeXml(OutputStream out) throws IOException { // pity we don't have a handy way to clone Jenkins.XSTREAM to temp add the omit Field XStream2 xStream2 = new XStream2(); xStream2.omitField(View.class, "owner"); xStream2.toXMLUTF8(View.this, out); }
Jenkins.XSTREAM2.toXMLUTF8(this, gzos);
Jenkins.XSTREAM2.toXMLUTF8(this, gzos);
private void doCheck(JCloudsComputer c) { if (c.isPendingDelete()) return; // No need to do it again if (c.isConnecting()) return; // Do not discard slave while launching for the first time when "idle time" does not make much sense if (!c.isIdle() || c.getOfflineCause() instanceof OfflineCause.UserCause) return; // Occupied by user initiated activity final JCloudsSlave node = c.getNode(); if (node == null) return; // Node is gone already final int retentionTime = node.getSlaveOptions().getRetentionTime(); if (retentionTime < 0) return; // Keep forever final long idleSince = c.getIdleStartMilliseconds(); final long idleMilliseconds = System.currentTimeMillis() - idleSince; if (idleMilliseconds > TimeUnit.MINUTES.toMillis(retentionTime)) { if (JCloudsPreCreationThread.shouldSlaveBeRetained(node)) { LOGGER.info("Keeping " + c .getName() + " to meet minimum requirements"); return; } LOGGER.info("Scheduling " + c .getName() + " for termination as it was idle since " + new Date(idleSince)); try { ByteArrayOutputStream out = new ByteArrayOutputStream(); Jenkins.XSTREAM2.toXMLUTF8(node, out); LOGGER.fine(out.toString("UTF-8")); } catch (IOException e) { LOGGER.log(Level.WARNING,"Failed to dump node config", e); } c.setPendingDelete(true); } }
/** * Accepts <tt>config.xml</tt> submission, as well as serve it. */ @WebMethod(name = "config.xml") public void doConfigDotXml(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { if (req.getMethod().equals("GET")) { // read checkPermission(EXTENDED_READ); rsp.setContentType("application/xml"); Node node = getNode(); if (node == null) { throw HttpResponses.notFound(); } Jenkins.XSTREAM2.toXMLUTF8(node, rsp.getOutputStream()); return; } if (req.getMethod().equals("POST")) { // submission updateByXml(req.getInputStream()); return; } // huh? rsp.sendError(SC_BAD_REQUEST); }
Items.XSTREAM2.toXMLUTF8(mod, out); } finally {