@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); } }
/** * 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); } }
@Override public void write(OutputStream out) throws IOException { try { XMLInputFactory inputFactory = getFactory(); if (inputFactory == null) { throw new MarkLogicInternalException("Failed to make StAX input factory"); } // TODO: rework to copy straight from stream reader to stream writer XMLEventReader reader = inputFactory.createXMLEventReader(content); XMLOutputFactory outputFactory = XMLOutputFactory.newFactory(); XMLEventWriter writer = outputFactory.createXMLEventWriter(out, "UTF-8"); writer.add(reader); writer.flush(); writer.close(); content.close(); } catch (XMLStreamException e) { logger.error("Failed to parse StAX events from input stream",e); throw new MarkLogicInternalException(e); } } }
private Request.Builder addTransactionScopedCookies(Request.Builder requestBldr, Transaction transaction) { if ( transaction != null && transaction.getCookies() != null ) { if ( requestBldr == null ) { throw new MarkLogicInternalException("no requestBldr available to get the URI"); } requestBldr = addCookies( requestBldr, transaction.getCookies(), ((TransactionImpl) transaction).getCreatedTimestamp() ); } return requestBldr; }
protected RequestParameters getWriteParams() { if (repair == null) return null; RequestParameters params = new RequestParameters(); if (repair == DocumentRepair.FULL) params.put("repair", "full"); else if (repair == DocumentRepair.NONE) params.put("repair", "none"); else throw new MarkLogicInternalException("Internal error - unknown repair policy: "+repair.name()); return params; } }
protected RequestParameters getWriteParams() { if (metadataExtraction == null || metadataExtraction == MetadataExtraction.NONE) return null; RequestParameters params = new RequestParameters(); if (metadataExtraction == MetadataExtraction.PROPERTIES) params.put("extract", "properties"); else if (metadataExtraction == MetadataExtraction.DOCUMENT) params.put("extract", "document"); else throw new MarkLogicInternalException("Internal error - unknown metadata extraction policy: "+metadataExtraction.name()); return params; } }
@Override protected RequestParameters getWriteParams() { if (metadataExtraction == null || metadataExtraction == MetadataExtraction.NONE) return null; RequestParameters params = new RequestParameters(); if (metadataExtraction == MetadataExtraction.PROPERTIES) params.put("extract", "properties"); else if (metadataExtraction == MetadataExtraction.DOCUMENT) params.put("extract", "document"); else throw new MarkLogicInternalException("Internal error - unknown metadata extraction policy: "+metadataExtraction.name()); return params; } }
@Override public void write(OutputStream out) throws IOException { try { XMLOutputFactory factory = XMLOutputFactory.newFactory(); XMLEventWriter writer = factory.createXMLEventWriter(out, "UTF-8"); writer.add(content); writer.flush(); writer.close(); content.close(); } catch (XMLStreamException e) { logger.error("Failed to parse StAX events from input stream",e); throw new MarkLogicInternalException(e); } }
@Override public void write(OutputStream out) throws IOException { try { XMLOutputFactory factory = XMLOutputFactory.newFactory(); XMLEventWriter writer = factory.createXMLEventWriter(out, "UTF-8"); writer.add(content); writer.flush(); writer.close(); content.close(); } catch (XMLStreamException e) { logger.error("Failed to parse StAX events from input stream",e); throw new MarkLogicInternalException(e); } } }
@Override protected RequestParameters getWriteParams() { if (repair == null) return null; RequestParameters params = new RequestParameters(); if (repair == DocumentRepair.FULL) params.put("repair", "full"); else if (repair == DocumentRepair.NONE) params.put("repair", "none"); else throw new MarkLogicInternalException("Internal error - unknown repair policy: "+repair.name()); return params; } }