@Override public void verify(String hostname, String[] cns, String[] subjectAlts) throws SSLException { throw new MarkLogicInternalException( "SSLHostnameVerifier.Builtin called directly instead of passed as parameter"); } /**
@Override public void verify(String hostname, String[] cns, String[] subjectAlts) throws SSLException { throw new MarkLogicInternalException( "SSLHostnameVerifier.Builtin called directly instead of passed as parameter"); } /**
private OkHttpClient getConnection() { if ( client != null ) { return client; } else if ( released ) { throw new IllegalStateException( "You cannot use this connected object anymore--connection has already been released"); } else { throw new MarkLogicInternalException("Cannot proceed--connection is null for unknown reason"); } }
static public DatatypeFactory getDatatypeFactory() { if (datatypeFactory == null) { try { datatypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new MarkLogicInternalException(e); } } return datatypeFactory; } }
static private DatatypeFactory getFactory() { if (datatypeFactory == null) { try { datatypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new MarkLogicInternalException(e); } } return datatypeFactory; } }
private Request.Builder addTelemetryAgentId(Request.Builder requestBldr) { if ( requestBldr == null ) throw new MarkLogicInternalException("no requestBldr available to set ML-Agent-ID header"); return requestBldr.header("ML-Agent-ID", "java"); }
private String createUri(ID id) { if ( id == null ) { throw new IllegalStateException("id cannot be null"); } try { return entityClass.getName() + "/" + URLEncoder.encode(id.toString(), "UTF-8") + EXTENSION; } catch (UnsupportedEncodingException e) { throw new MarkLogicInternalException(e); } }
private RowRecord.ColumnKind getColumnKind(String datatype, RowRecord.ColumnKind defaultKind) { if ("cid".equals(datatype)) { return RowRecord.ColumnKind.CONTENT; } else if ("null".equals(datatype)) { return RowRecord.ColumnKind.NULL; } else if (datatype.contains(":")) { return RowRecord.ColumnKind.ATOMIC_VALUE; } else if (datatype != null && defaultKind != null) { return defaultKind; } throw new MarkLogicInternalException("Column value with unsupported datatype: "+datatype); } }
/** * Reads the input source, sending SAX events to the supplied content handler. * @param handler the SAX content handler */ public void process(ContentHandler handler) { try { if (logger.isInfoEnabled()) logger.info("Processing input source with SAX content handler"); XMLReader reader = makeReader(false); reader.setContentHandler(handler); reader.parse(content); } catch (SAXException e) { logger.error("Failed to process input source with SAX content handler",e); throw new MarkLogicInternalException(e); } catch (IOException e) { logger.error("Failed to process input source with SAX content handler",e); throw new MarkLogicInternalException(e); } }
/** * Reads the input source, sending SAX events to the supplied content handler. * @param handler the SAX content handler */ public void process(ContentHandler handler) { try { if (logger.isInfoEnabled()) logger.info("Processing input source with SAX content handler"); XMLReader reader = makeReader(false); reader.setContentHandler(handler); reader.parse(content); } catch (SAXException e) { logger.error("Failed to process input source with SAX content handler",e); throw new MarkLogicInternalException(e); } catch (IOException e) { logger.error("Failed to process input source with SAX content handler",e); throw new MarkLogicInternalException(e); } }
@Override protected void receiveContent(InputStream content) { if (content == null) { this.content = null; return; } try { if (logger.isInfoEnabled()) logger.info("Parsing StAX stream from input stream"); XMLInputFactory factory = getFactory(); if (factory == null) { throw new MarkLogicInternalException("Failed to make StAX input factory"); } if (resolver != null) factory.setXMLResolver(resolver); this.content = factory.createXMLStreamReader(content, "UTF-8"); } catch (XMLStreamException e) { logger.error("Failed to parse StAX stream from input stream",e); throw new MarkLogicInternalException(e); } catch (FactoryConfigurationError e) { logger.error("Failed to parse StAX stream from input stream",e); throw new MarkLogicInternalException(e); } } @Override
@Override protected void receiveContent(InputStream content) { if (content == null) { this.content = null; return; } try { if (logger.isInfoEnabled()) logger.info("Parsing StAX events from input stream"); XMLInputFactory factory = getFactory(); if (factory == null) { throw new MarkLogicInternalException("Failed to make StAX input factory"); } if (resolver != null) factory.setXMLResolver(resolver); this.content = factory.createXMLEventReader(content, "UTF-8"); } catch (XMLStreamException e) { logger.error("Failed to parse StAX events from input stream",e); throw new MarkLogicInternalException(e); } catch (FactoryConfigurationError e) { logger.error("Failed to parse StAX events from input stream",e); throw new MarkLogicInternalException(e); } } @Override
@Override protected void receiveContent(InputStream content) { if (content == null) { this.content = null; return; } try { if (logger.isInfoEnabled()) logger.info("Parsing StAX stream from input stream"); XMLInputFactory factory = getFactory(); if (factory == null) { throw new MarkLogicInternalException("Failed to make StAX input factory"); } if (resolver != null) factory.setXMLResolver(resolver); this.content = factory.createXMLStreamReader(content, "UTF-8"); this.contentSource = content; } catch (XMLStreamException e) { logger.error("Failed to parse StAX stream from input stream",e); throw new MarkLogicInternalException(e); } catch (FactoryConfigurationError e) { logger.error("Failed to parse StAX stream from input stream",e); throw new MarkLogicInternalException(e); } } @Override
@Override protected void receiveContent(InputStream content) { try { if (logger.isInfoEnabled()) logger.info("Parsing metadata structure from input stream"); Document document = null; if (content != null) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(false); DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.parse(new InputSource(new InputStreamReader(content, "UTF-8"))); content.close(); } receiveMetadataImpl(document); } catch (SAXException e) { logger.error("Failed to parse metadata structure from input stream",e); throw new MarkLogicInternalException(e); } catch (IOException e) { logger.error("Failed to parse metadata structure from input stream",e); throw new MarkLogicInternalException(e); } catch (ParserConfigurationException e) { logger.error("Failed to parse metadata structure from input stream",e); throw new MarkLogicInternalException(e); } } @Override
@Override protected void receiveContent(InputStream content) { try { if (logger.isInfoEnabled()) logger.info("Parsing metadata structure from input stream"); Document document = null; if (content != null) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(false); DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.parse(new InputSource(new InputStreamReader(content, "UTF-8"))); content.close(); } receiveMetadataImpl(document); } catch (SAXException e) { logger.error("Failed to parse metadata structure from input stream",e); throw new MarkLogicInternalException(e); } catch (IOException e) { logger.error("Failed to parse metadata structure from input stream",e); throw new MarkLogicInternalException(e); } catch (ParserConfigurationException e) { logger.error("Failed to parse metadata structure from input stream",e); throw new MarkLogicInternalException(e); } } @Override
@Override protected void receiveContent(InputStream content) { if (content == null) { this.content = null; return; } this.underlyingStream = content; try { if (logger.isInfoEnabled()) logger.info("Parsing StAX events from input stream"); XMLInputFactory factory = getFactory(); if (factory == null) { throw new MarkLogicInternalException("Failed to make StAX input factory"); } if (resolver != null) factory.setXMLResolver(resolver); this.content = factory.createXMLEventReader(content, "UTF-8"); } catch (XMLStreamException e) { logger.error("Failed to parse StAX events from input stream",e); throw new MarkLogicInternalException(e); } catch (FactoryConfigurationError e) { logger.error("Failed to parse StAX events from input stream",e); throw new MarkLogicInternalException(e); } } @Override
/** * Returns the default mime type for the format. * @return the default mime type */ public String getDefaultMimetype() { switch(this) { case UNKNOWN: return null; case BINARY: // TODO: or possibly "application/x-unknown-content-type" return "application/octet-stream"; case JSON: return "application/json"; case TEXT: return "text/plain"; case XML: return "application/xml"; default: throw new MarkLogicInternalException("Unknown format "+this.toString()); } }
/** * Returns the default mime type for the format. * @return the default mime type */ public String getDefaultMimetype() { switch(this) { case UNKNOWN: return null; case BINARY: // TODO: or possibly "application/x-unknown-content-type" return "application/octet-stream"; case JSON: return "application/json"; case TEXT: return "text/plain"; case XML: return "application/xml"; default: throw new MarkLogicInternalException("Unknown format "+this.toString()); } } }
private static String getHeader(BodyPart part, String name) { if ( part == null ) throw new MarkLogicInternalException("part must not be null"); try { String[] values = part.getHeader(name); if ( values != null && values.length > 0 ) { return values[0]; } return null; } catch (MessagingException e) { throw new MarkLogicIOException(e); } }
protected XMLReader makeReader(boolean isForWrite) { try { SAXParserFactory factory = getFactory(); if (factory == null) { throw new MarkLogicInternalException("Failed to make SAX parser factory"); } boolean useDefaultSchema = (isForWrite && defaultWriteSchema != null && factory.getSchema() == null); if (useDefaultSchema) { factory.setSchema(defaultWriteSchema); } XMLReader reader = factory.newSAXParser().getXMLReader(); if (useDefaultSchema) { factory.setSchema(null); } if (resolver != null) reader.setEntityResolver(resolver); if (errorHandler != null) reader.setErrorHandler(errorHandler); return reader; } catch (SAXException e) { logger.error("Failed to process input source with SAX content handler",e); throw new MarkLogicInternalException(e); } catch (ParserConfigurationException e) { logger.error("Failed to process input source with SAX content handler",e); throw new MarkLogicInternalException(e); } }