private void checkMultipartContent(Document<Entry> entry, Map<String, String> dataHeaders, RequestContext request) throws ParseException { if (entry == null) { throw new ParseException("multipart/related stream invalid, media link entry is missing"); } if (!dataHeaders.containsKey(CONTENT_TYPE_HEADER)) { throw new ParseException("multipart/related stream invalid, data content-type is missing"); } if (!isContentTypeAccepted(dataHeaders.get(CONTENT_TYPE_HEADER), request)) { throw new ParseException("multipart/related stream invalid, content-type " + dataHeaders .get(CONTENT_TYPE_HEADER) + " not accepted into this multipart file"); } }
/** * Method next. * * @return Returns int. * @throws OMException */ public int next() throws OMException { try { return super.next(); } catch (OMException e) { // TODO: transforming the OMException here is not ideal! throw new ParseException(e); } }
private MultipartInputStream getMultipartStream(RequestContext request) throws IOException, ParseException, IllegalArgumentException { String boundary = request.getContentType().getParameter(BOUNDARY_PARAM); if (boundary == null) { throw new IllegalArgumentException("multipart/related stream invalid, boundary parameter is missing."); } boundary = "--" + boundary; String type = request.getContentType().getParameter(TYPE_PARAM); if (!(type != null && MimeTypeHelper.isAtom(type))) { throw new ParseException( "multipart/related stream invalid, type parameter should be " + Constants.ATOM_MEDIA_TYPE); } PushbackInputStream pushBackInput = new PushbackInputStream(request.getInputStream(), 2); pushBackInput.unread("\r\n".getBytes()); return new MultipartInputStream(pushBackInput, boundary.getBytes()); }
public <T extends Element> Document<T> parse(XMLStreamReader reader, String base, ParserOptions options) throws ParseException { try { FOMBuilder builder = new FOMBuilder(getFomFactory(options), reader, options); return getDocument(builder, base != null ? new IRI(base) : null, options); } catch (Exception e) { if (!(e instanceof ParseException)) e = new ParseException(e); throw (ParseException)e; } }
public <T extends Element> Document<T> parse(Reader in, String base, ParserOptions options) throws ParseException { if (in == null) throw new IllegalArgumentException(Localizer.get("READER.NOT.NULL")); try { if (options == null) options = getDefaultParserOptions(); if (options.getFilterRestrictedCharacters() && !(in instanceof FOMXmlRestrictedCharReader)) { in = new FOMXmlRestrictedCharReader(in, options.getFilterRestrictedCharacterReplacement()); } // return parse(StAXUtils.createXMLStreamReader(in), base, options); return parse(createXMLStreamReader(in), base, options); } catch (Exception e) { if (!(e instanceof ParseException)) e = new ParseException(e); throw (ParseException)e; } }
private <T extends Element> Document<T> getDocument(FOMBuilder builder, IRI base, ParserOptions options) throws ParseException { Document<T> document = builder.getFomDocument(); try { if (base != null) document.setBaseUri(base.toString()); if (options != null && options.getCharset() != null) ((OMDocument)document).setCharsetEncoding(options.getCharset()); if (options != null) document.setMustPreserveWhitespace(options.getMustPreserveWhitespace()); } catch (Exception e) { if (!(e instanceof ParseException)) e = new ParseException(e); throw (ParseException)e; } return document; }
String val = parserOptions.resolveEntity(getLocalName()); if (val == null) { throw new ParseException("Unresolved undeclared entity: " + getLocalName()); } else { altEventType = CHARACTERS;
e = new ParseException(e); throw (ParseException)e;
return doc; } catch (Exception e) { throw new ParseException(e);