List of usage examples for org.apache.commons.httpclient URIException URIException
public URIException()
From source file:ru.org.linux.util.LorURI.java
/** * ? url ? ? mainUrl /* www . j a v a2s .com*/ * url id ? * ? url ? * @param mainURI ? URI ? * @param url url * @throws URIException ? url */ public LorURI(URI mainURI, String url) throws URIException { this.mainURI = mainURI; URI uri; try { uri = new URI(url, true, "UTF-8"); } catch (URIException e) { uri = new URI(url, false, "UTF-8"); } lorURI = uri; if (lorURI.getHost() == null) { throw new URIException(); } /* ? uri lorsouce ? ? ? scheme http https */ trueLorUrl = (mainURI.getHost().equals(lorURI.getHost()) && mainURI.getPort() == lorURI.getPort() && ("http".equals(lorURI.getScheme()) || "https".equals(lorURI.getScheme()))); if (trueLorUrl) { // find message id in lor url int msgId = 0; int commId = 0; boolean isMsg = false; boolean isComm = false; if (lorURI.getPath() != null && lorURI.getQuery() != null) { Matcher oldJumpPathMatcher = requestOldJumpPathPattern.matcher(lorURI.getPath()); Matcher oldJumpQueryMatcher = requestOldJumpQueryPattern.matcher(lorURI.getQuery()); if (oldJumpPathMatcher.find() && oldJumpQueryMatcher.find()) { try { msgId = Integer.parseInt(oldJumpQueryMatcher.group(1)); commId = Integer.parseInt(oldJumpQueryMatcher.group(2)); isMsg = true; isComm = true; } catch (NumberFormatException e) { msgId = 0; commId = 0; isMsg = false; isComm = false; } } } String path = lorURI.getPath(); if (path != null && !isMsg) { Matcher messageMatcher = requestMessagePattern.matcher(path); if (messageMatcher.find()) { try { msgId = Integer.parseInt(messageMatcher.group(1)); isMsg = true; } catch (NumberFormatException e) { msgId = 0; isMsg = false; } } else { msgId = 0; isMsg = false; } if (path.endsWith("/history")) { isMsg = false; } } messageId = msgId; messageUrl = isMsg; // find comment id in lor url String fragment = lorURI.getFragment(); if (fragment != null) { Matcher commentMatcher = requestCommentPattern.matcher(fragment); if (commentMatcher.find()) { try { commId = Integer.parseInt(commentMatcher.group(1)); isComm = true; } catch (NumberFormatException e) { commId = 0; isComm = false; } } } if (lorURI.getQuery() != null) { Matcher commentMatcher = requestConmmentPatternNew.matcher(lorURI.getQuery()); if (commentMatcher.find()) { try { commId = Integer.parseInt(commentMatcher.group(1)); isComm = true; } catch (NumberFormatException e) { commId = 0; isComm = false; } } } commentId = commId; commentUrl = isComm; } else { messageId = 0; messageUrl = false; commentId = 0; commentUrl = false; } }