List of usage examples for javax.naming SizeLimitExceededException SizeLimitExceededException
public SizeLimitExceededException(String explanation)
From source file:net.yacy.document.parser.xml.GenericXMLContentHandler.java
/** * Try to detect URLs eventually contained in attributes * @throws SAXException when the calling parser reached the maximum bytes limit on the input source */// w ww . j a v a 2 s. com @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { this.currentElementText.setLength(0); this.currentElementTextChunks = 0; if (attributes != null) { for (int i = 0; i < attributes.getLength(); i++) { String attribute = attributes.getValue(i); this.detectedURLs += ContentScraper.findAbsoluteURLs(attribute, this.urls, null, this.maxURLs - this.detectedURLs); if (this.detectedURLs >= this.maxURLs) { throw new SAXException( new SizeLimitExceededException("Reached maximum URLs to parse : " + this.maxURLs)); } } } }
From source file:net.yacy.document.parser.xml.GenericXMLContentHandler.java
/** * Perform URLs detection on the ending element text * @throws SAXException when whe maxURLs limit has been reached *//* ww w . j a v a2s . c om*/ @Override public void endElement(String uri, String localName, String qName) throws SAXException { this.detectedURLs += ContentScraper.findAbsoluteURLs(this.currentElementText.toString(), this.urls, null, this.maxURLs - this.detectedURLs); if (this.detectedURLs >= this.maxURLs) { throw new SAXException( new SizeLimitExceededException("Reached maximum URLs to parse : " + this.maxURLs)); } this.currentElementText.setLength(0); this.currentElementTextChunks = 0; }
From source file:net.yacy.document.parser.xml.OOXMLSpreeadsheetHandler.java
/** * Perform URLs detection on the ending element text * /*from w w w .j a v a 2 s . c o m*/ * @throws SAXException * when the maxURLs limit has been reached */ @Override public void endElement(String uri, String localName, String qName) throws SAXException { if (CELL_VALUE_TAG.equals(qName)) { String cellText = null; if (this.sharedStringCell) { /* Try to retrieve the cell text from the shared strings list */ try { int index = Integer.parseInt(this.cellValue.toString()); if (this.sharedStrings != null && this.sharedStrings.size() > index) { cellText = this.sharedStrings.get(index); } } catch (NumberFormatException ignored) { /* Do not terminate parsing if one shared strings index value is malformed */ } } else { /* Use directly the cell value as text */ cellText = this.cellValue.toString(); } try { if (cellText != null && !cellText.isEmpty()) { this.detectedURLs += ContentScraper.findAbsoluteURLs(cellText, this.urls, null, this.maxURLs - this.detectedURLs); /* * Iif necessary we add a space to separate text content of different elements */ if (!this.lastAppendedIsSpace && !Character.isWhitespace(cellText.charAt(0))) { this.out.write(" "); } this.out.write(cellText); this.lastAppendedIsSpace = Character.isWhitespace(cellText.charAt(cellText.length() - 1)); } } catch (IOException ioe) { throw new SAXException("Error while appending characters to the output writer", ioe); } finally { this.cellValue.setLength(0); this.inCellValue = false; } if (this.detectedURLs >= this.maxURLs) { throw new SAXException( new SizeLimitExceededException("Reached maximum URLs to parse : " + this.maxURLs)); } } else if (CELL_TAG.equals(qName)) { this.inCell = false; this.inCellValue = false; } }
From source file:org.lsc.jndi.JndiServices.java
private SearchResult doGetEntry(final String base, final String filter, final SearchControls sc, final int scope) throws NamingException { //sanity checks String searchBase = base == null ? "" : base; String searchFilter = filter == null ? DEFAULT_FILTER : filter; NamingEnumeration<SearchResult> ne = null; try {//from w w w. j a v a 2 s. c om sc.setSearchScope(scope); String rewrittenBase = null; if (contextDn != null && searchBase.toLowerCase().endsWith(contextDn.toString().toLowerCase())) { if (!searchBase.equalsIgnoreCase(contextDn.toString())) { rewrittenBase = searchBase.substring(0, searchBase.toLowerCase().lastIndexOf(contextDn.toString().toLowerCase()) - 1); } else { rewrittenBase = ""; } } else { rewrittenBase = searchBase; } ne = ctx.search(rewrittenBase, searchFilter, sc); } catch (NamingException nex) { LOGGER.error("Error while looking for {} in {}: {}", new Object[] { searchFilter, searchBase, nex }); throw nex; } SearchResult sr = null; if (ne.hasMoreElements()) { sr = (SearchResult) ne.nextElement(); if (ne.hasMoreElements()) { LOGGER.error("Too many entries returned (base: \"{}\", filter: \"{}\")", searchBase, searchFilter); throw new SizeLimitExceededException("Too many entries returned (base: \"" + searchBase + "\", filter: \"" + searchFilter + "\")"); } else { return sr; } } else { // try hasMore method to throw exceptions if there are any and we didn't get our entry ne.hasMore(); } return sr; }