Java Code Examples for org.apache.commons.httpclient.HttpStatus#getStatusText()
The following examples show how to use
org.apache.commons.httpclient.HttpStatus#getStatusText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MarkdownRender.java From openapi-diff with Apache License 2.0 | 5 votes |
protected String itemResponse(String title, String code, String description) { StringBuilder sb = new StringBuilder(); String status = ""; if (!code.equals("default")) { status = HttpStatus.getStatusText(Integer.parseInt(code)); } sb.append(format("%s : **%s %s**\n", title, code, status)); sb.append(metadata(description)); return sb.toString(); }
Example 2
Source File: ConsoleRender.java From openapi-diff with Apache License 2.0 | 5 votes |
private String itemResponse(String title, String code) { StringBuilder sb = new StringBuilder(); String status = ""; if (!code.equals("default")) { status = HttpStatus.getStatusText(Integer.parseInt(code)); } sb.append(StringUtils.repeat(' ', 4)) .append("- ") .append(title) .append(code) .append(' ') .append(status) .append(System.lineSeparator()); return sb.toString(); }
Example 3
Source File: DeadLink.java From wpcleaner with Apache License 2.0 | 5 votes |
/** * Constructor. * * @param page Page title. * @param link External link. * @param status HTTP status. */ public DeadLink(String page, PageElementExternalLink link, Integer status) { super(link); this.page = page; this.link = link; this.status = status; this.statusText = (status != null) ? HttpStatus.getStatusText(status) : null; }
Example 4
Source File: AbstractRedditExtractor.java From wandora with GNU General Public License v3.0 | 5 votes |
protected static String statusToPhrase(int status) { String phrase = HttpStatus.getStatusText(status); if(phrase == null && additionalPhrases.containsKey(status)){ phrase = additionalPhrases.get(status); } return phrase; }
Example 5
Source File: ZohoServlet.java From document-management-system with GNU General Public License v2.0 | 4 votes |
/** * */ private Map<String, String> sendToZoho(String zohoUrl, String nodeUuid, String lang) throws PathNotFoundException, AccessDeniedException, RepositoryException, DatabaseException, IOException, OKMException { Map<String, String> result = new HashMap<String, String>(); File tmp = null; try { String path = OKMRepository.getInstance().getNodePath(null, nodeUuid); String fileName = PathUtils.getName(path); tmp = File.createTempFile("okm", ".tmp"); InputStream is = OKMDocument.getInstance().getContent(null, path, false); Document doc = OKMDocument.getInstance().getProperties(null, path); FileOutputStream fos = new FileOutputStream(tmp); IOUtils.copy(is, fos); fos.flush(); fos.close(); String id = UUID.randomUUID().toString(); String saveurl = Config.APPLICATION_BASE + "/extension/ZohoFileUpload"; Part[] parts = {new FilePart("content", tmp), new StringPart("apikey", Config.ZOHO_API_KEY), new StringPart("output", "url"), new StringPart("mode", "normaledit"), new StringPart("filename", fileName), new StringPart("skey", Config.ZOHO_SECRET_KEY), new StringPart("lang", lang), new StringPart("id", id), new StringPart("format", getFormat(doc.getMimeType())), new StringPart("saveurl", saveurl)}; PostMethod filePost = new PostMethod(zohoUrl); filePost.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8"); filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams())); HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); int status = client.executeMethod(filePost); if (status == HttpStatus.SC_OK) { log.debug("OK: " + filePost.getResponseBodyAsString()); ZohoToken zot = new ZohoToken(); zot.setId(id); zot.setUser(getThreadLocalRequest().getRemoteUser()); zot.setNode(nodeUuid); zot.setCreation(Calendar.getInstance()); ZohoTokenDAO.create(zot); // Get the response BufferedReader rd = new BufferedReader(new InputStreamReader(filePost.getResponseBodyAsStream())); String line; while ((line = rd.readLine()) != null) { if (line.startsWith("URL=")) { result.put("url", line.substring(4)); result.put("id", id); break; } } rd.close(); } else { String error = HttpStatus.getStatusText(status) + "\n\n" + filePost.getResponseBodyAsString(); log.error("ERROR: {}", error); throw new OKMException(ErrorCode.get(ErrorCode.ORIGIN_OKMZohoService, ErrorCode.CAUSE_Zoho), error); } } finally { FileUtils.deleteQuietly(tmp); } return result; }