use of com.ctc.wstx.exc.WstxEOFException in project RecordManager2 by moravianlibrary.
the class ZakonyProLidiFulltextXmlStreamReader method next.
public String next() {
boolean fulltext = false;
String result = "";
int countDiv = 0;
while (eventReader.hasNext()) {
try {
XMLEvent xmlEvent = eventReader.nextEvent();
if (xmlEvent.isStartElement()) {
switch(xmlEvent.asStartElement().getName().getLocalPart()) {
case ELEMENT_DIV:
if (isAttribute(xmlEvent.asStartElement(), ATTR_NAME_CLASS, ATTR_VALUE_FRAGS_NOVEL)) {
fulltext = true;
}
if (fulltext)
++countDiv;
break;
case ELEMENT_H3:
case ELEMENT_P:
if (fulltext) {
String xmlFragment = readElementBody(eventReader);
result += xmlFragment + "\n";
}
break;
default:
break;
}
} else if (xmlEvent.isEndElement()) {
switch(xmlEvent.asEndElement().getName().getLocalPart()) {
case ELEMENT_DIV:
if (fulltext)
--countDiv;
if (countDiv == 0)
fulltext = false;
break;
default:
break;
}
}
} catch (WstxEOFException e) {
break;
} catch (WstxParsingException e) {
} catch (XMLStreamException e) {
e.printStackTrace();
}
}
return result;
}
use of com.ctc.wstx.exc.WstxEOFException in project RecordManager2 by moravianlibrary.
the class ManuscriptoriumFulltextXmlStreamReader method next.
public String next() {
String result = "";
List<String> titles = new ArrayList<>();
while (eventReader.hasNext()) {
try {
XMLEvent xmlEvent = eventReader.nextEvent();
if (xmlEvent.isStartElement()) {
switch(xmlEvent.asStartElement().getName().getLocalPart()) {
case ELEMENT_UNCIPIT:
case ELEMENT_EXPLICIT:
case ELEMENT_COLOFON:
case ELEMENT_QUOTE:
case ELEMENT_TITLE:
case ELEMENT_RUBRIC:
String xmlFragment = readElementBody(eventReader);
if (!titles.contains(xmlFragment)) {
result += xmlFragment + "\n";
titles.add(xmlFragment);
}
break;
default:
break;
}
}
} catch (WstxEOFException e) {
break;
} catch (WstxParsingException e) {
} catch (XMLStreamException e) {
e.printStackTrace();
}
}
return result;
}
use of com.ctc.wstx.exc.WstxEOFException in project tomee by apache.
the class AbstractJAXBProvider method handleExceptionEnd.
protected static void handleExceptionEnd(Throwable t, String message, boolean read) throws NoContentException {
if (t instanceof WstxEOFException && t.getMessage().startsWith("Unexpected EOF in prolog")) {
String noContent = new org.apache.cxf.common.i18n.Message("EMPTY_BODY", BUNDLE).toString();
LOG.warning(noContent);
throw new NoContentException(noContent);
}
Response.Status status = read ? Response.Status.BAD_REQUEST : Response.Status.INTERNAL_SERVER_ERROR;
Response r = JAXRSUtils.toResponseBuilder(status).type(MediaType.TEXT_PLAIN).entity(message).build();
throw read ? ExceptionUtils.toBadRequestException(t, r) : ExceptionUtils.toInternalServerErrorException(t, r);
}
Aggregations