/** * Converts the http entity to string. If entity is null, returns empty string. * @param entity * @return * @throws IOException */ public static String entityToString(HttpEntity entity) throws IOException { if (entity != null) { InputStream is = entity.getContent(); return IOUtils.toString(is, "UTF-8"); } return ""; }
/** * Get the BUILDOUT bootstrap module content. * * @return The BUILDOUT bootstrap module content * @throws IOException */ public String getBootstrapPyContent() throws IOException { return IOUtils.toString(getClass().getResourceAsStream(BOOTSTRAP)); }
/** * Get the VIRTUALENV module content. * * @return The VIRTUALENV module content * @throws IOException */ public String getVirtualenvPyContent() throws IOException { return IOUtils.toString(getClass().getResourceAsStream(VIRTUALENV)); }
@SuppressWarnings("deprecation") private String getRequestBody(HttpServletRequest request) throws IOException { String charset = request.getCharacterEncoding() == null ? CHARSET_UTF_8 : request.getCharacterEncoding(); String requestBody = IOUtils.toString(request.getInputStream(), charset); if (StringUtils.isBlank(requestBody)) { throw new IllegalArgumentException("request-body is empty"); } return requestBody; } }
/** * Reads this file into a string, by using the current system encoding. */ public String readToString() throws IOException { InputStream in = read(); try { return IOUtils.toString(in); } finally { in.close(); } }
/** * Reads this file into a string, by using the current system encoding. */ public String readToString() throws IOException { InputStream in = read(); try { return IOUtils.toString(in); } finally { in.close(); } }
/** * Reads this file into a string, by using the current system encoding. */ public String readToString() throws IOException { InputStream in = read(); try { return IOUtils.toString(in); } finally { in.close(); } }
/** * Reads this file into a string, by using the current system encoding. */ public String readToString() throws IOException { InputStream in = read(); try { return IOUtils.toString(in); } finally { in.close(); } }
private int readSmbFile(SmbFile f) throws IOException { InputStream in=null; try { in = f.getInputStream(); return Integer.parseInt(IOUtils.toString(in)); } finally { IOUtils.closeQuietly(in); } }
private int readSmbFile(SmbFile f) throws IOException { InputStream in=null; try { in = f.getInputStream(); return Integer.parseInt(IOUtils.toString(in)); } finally { IOUtils.closeQuietly(in); } }
/** * This is where the browser sends us the data. */ public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException { long dataTimestamp = System.currentTimeMillis(); TextFile df = getDataFile(); df.write(IOUtils.toString(req.getInputStream(),"UTF-8")); df.file.setLastModified(dataTimestamp); due = dataTimestamp+getInterval(); LOGGER.info("Obtained the updated data file for "+id); rsp.setContentType("text/plain"); // So browser won't try to parse response }
/** * This is where the browser sends us the data. */ public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException { long dataTimestamp = System.currentTimeMillis(); TextFile df = getDataFile(); df.write(IOUtils.toString(req.getInputStream(),"UTF-8")); df.file.setLastModified(dataTimestamp); due = dataTimestamp+getInterval(); LOGGER.info("Obtained the updated data file for "+id); rsp.setContentType("text/plain"); // So browser won't try to parse response }
/** * This is where the browser sends us the data. */ public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException { long dataTimestamp = System.currentTimeMillis(); TextFile df = getDataFile(); df.write(IOUtils.toString(req.getInputStream(), "UTF-8")); df.file.setLastModified(dataTimestamp); due = dataTimestamp + getInterval(); LOGGER.info("Obtained the updated data file for " + id); rsp.setContentType("text/plain"); // So browser won't try to parse response }
/** * This is where the browser sends us the data. */ public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException { long dataTimestamp = System.currentTimeMillis(); TextFile df = getDataFile(); df.write(IOUtils.toString(req.getInputStream(),"UTF-8")); df.file.setLastModified(dataTimestamp); due = dataTimestamp+getInterval(); LOGGER.info("Obtained the updated data file for "+id); rsp.setContentType("text/plain"); // So browser won't try to parse response }
public void ensureWorkflowDefinition(String wfName) throws Exception{ // due to lazy loading of engine: // the engine startup would try to deploy the file we're about to create, leading to a double deploy JenkowEngine.getEngine(); String relName = mkWfPath(wfName); File wff = new File(getRepositoryDir(),relName); if (!wff.exists()){ LOGGER.info("generating workflow definition "+wff); Map<String,String> vars = new HashMap<String,String>(); vars.put("WORKFLOW_ID",WfUtil.mkWorkflowId(wfName)); vars.put("WORKFLOW_NAME",wfName); String wfd = IOUtils.toString(getClass().getResourceAsStream("/templates/new.bpmn")); wfd = Util.replaceMacro(wfd,vars); FileUtils.writeStringToFile(wff,wfd); Repository r = openRepository(); addAndCommit(r,relName,"added generated workflow definition "+wfName); r.close(); } WfUtil.deployToEngine(wff); }
/** * This is the endpoint that receives the update center data file from the browser. */ public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException, GeneralSecurityException { dataTimestamp = System.currentTimeMillis(); String json = IOUtils.toString(req.getInputStream(),"UTF-8"); JSONObject o = JSONObject.fromObject(json); int v = o.getInt("updateCenterVersion"); if(v !=1) { LOGGER.warning("Unrecognized update center version: "+v); return; } if (signatureCheck) verifySignature(o); LOGGER.info("Obtained the latest update center data file for UpdateSource "+ id); getDataFile().write(json); rsp.setContentType("text/plain"); // So browser won't try to parse response }
/** * This is the endpoint that receives the update center data file from the browser. */ public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException, GeneralSecurityException { dataTimestamp = System.currentTimeMillis(); String json = IOUtils.toString(req.getInputStream(),"UTF-8"); JSONObject o = JSONObject.fromObject(json); int v = o.getInt("updateCenterVersion"); if(v !=1) { LOGGER.warning("Unrecognized update center version: "+v); return; } if (signatureCheck) verifySignature(o); LOGGER.info("Obtained the latest update center data file for UpdateSource "+ id); getDataFile().write(json); rsp.setContentType("text/plain"); // So browser won't try to parse response }
/** * This is the endpoint that receives the update center data file from the browser. */ public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException, GeneralSecurityException { dataTimestamp = System.currentTimeMillis(); String json = IOUtils.toString(req.getInputStream(),"UTF-8"); JSONObject o = JSONObject.fromObject(json); int v = o.getInt("updateCenterVersion"); if(v !=1) { LOGGER.warning("Unrecognized update center version: "+v); return; } if (signatureCheck) verifySignature(o); LOGGER.info("Obtained the latest update center data file for UpdateSource "+ id); getDataFile().write(json); rsp.setContentType("text/plain"); // So browser won't try to parse response }
/** * This is the endpoint that receives the update center data file from the * browser. */ public void doPostBack(StaplerRequest req, StaplerResponse rsp) throws IOException, GeneralSecurityException { dataTimestamp = System.currentTimeMillis(); String json = IOUtils.toString(req.getInputStream(), "UTF-8"); JSONObject o = JSONObject.fromObject(json); int v = o.getInt("updateCenterVersion"); if (v != 1) { LOGGER.warning("Unrecognized update center version: " + v); return; } if (signatureCheck) { verifySignature(o); } LOGGER.info("Obtained the latest update center data file for UpdateSource " + id); getDataFile().write(json); rsp.setContentType("text/plain"); // So browser won't try to parse response }
/** * Retrieves the Gerrit command. * * @param request the request * @param response the response * @throws IOException if so. */ public void doDynamic(StaplerRequest request, StaplerResponse response) throws IOException { lastPath = request.getRestOfPath(); lastContent = IOUtils.toString(request.getReader()); response.setContentType("application/json"); PrintWriter writer = response.getWriter(); writer.write(new JSONObject(true).toString()); writer.flush(); } }