@Override public void setDefaultElementTypeNamespace(String uri) throws XQException { if (uri == null) { throw new XQException("Default element type namespace URI is null"); } defaultElementTypeNamespace = uri; }
e.printStackTrace(); throw new XQException("result is empty");
/** * a utility method to extract XQ exception information from the error stack provided * * @param ex the full error chain * @return XQ exception */ public static XQException getXQException(Throwable ex) { int errorCode = 0; Throwable cause = null; String message = ""; while (ex != null) { if (ex instanceof XQException) { return (XQException) ex; } else if (/*errorCode == 0 &&*/ ex instanceof BagriException) { // deeper is better! message += ex.getMessage() + "; "; errorCode = ((BagriException) ex).getErrorCode(); cause = ex; } ex = ex.getCause(); } XQException xqe = new XQException(message, String.valueOf(errorCode)); xqe.initCause(cause); return xqe; }
@Override public void dispose() { try { connection.close(); } catch (XQException e) { logger.warn(e.getMessage()); } }
ex.printStackTrace(); throw new XQException("result is empty");
@ManagedOperation(description="Cancel currently running query started from the same JMX connection") public void cancelQuery() { try { // are we in exec state now? XQProcessor xqp = ((BagriXQConnection) xqConn).getProcessor(); xqp.cancelExecution(); } catch (XQException ex) { logger.error("cancelQuery.error", ex); throw new RuntimeException(ex.getMessage()); } }
@Override public void setDefaultCollation(String uri) throws XQException { if (uri == null) { throw new XQException("Default collation URI is null"); } this.defaultCollationUri = uri; }
String em = ex.getMessage(); if (em == null) { em = ex.getClass().getName();
@Override public void setQueryLanguageTypeAndVersion(int langType) throws XQException { if (langType != LANGTYPE_XQUERY && langType != LANGTYPE_XQUERYX) { throw new XQException("Wrong language type and version value: " + langType); } // we do not support XQueryX, don't see how it can be set.. this.queryLanguageTypeAndVersion = langType; }
@ManagedOperation(description="Parse XQuery. Return array of parameter names, if any") @ManagedOperationParameters({ @ManagedOperationParameter(name = "query", description = "A query request provided in XQuery syntax"), @ManagedOperationParameter(name = "props", description = "Query processing properties")}) public String[] parseQuery(String query, Properties props) { XQPreparedExpression xqpExp = null; try { XQStaticContext ctx = xqConn.getStaticContext(); props2Context(schemaManager.getEntity().getProperties(), ctx); props2Context(props, ctx); xqpExp = xqConn.prepareExpression(query, ctx); QName[] vars = xqpExp.getAllExternalVariables(); String[] result = null; if (vars != null) { result = new String[vars.length]; for (int i=0; i < vars.length; i++) { result[i] = vars[i].toString(); } } xqpExp.close(); return result; } catch (XQException ex) { logger.error("parseQuery.error", ex); throw new RuntimeException(ex.getMessage()); } }
@Override public void setQueryTimeout(int seconds) throws XQException { if (seconds < 0) { throw new XQException("Wrong query timeout value: " + seconds); } this.queryTimeout = seconds; }
protected void checkAccess(boolean checkPosition) throws XQException { if (checkPosition && !positioned) { throw new XQException("Not positioned on an Item"); } if (accessed) { throw new XQException("Item has been already accessed"); } }
@Override public <T> ResultCursor<T> executeXQuery(String query, XQStaticContext ctx) throws XQException { // implement it? what for..? throw new XQException("Not implemented on the server side. Use another executeXQuery method taking Properties as a parameter instead"); }
@Override public XQItemType getItemType() throws XQException { if (closed) { throw new XQException(ex_item_closed); } if (!positioned) { throw new XQException("not positioned on the Item"); } return type; }
@Override public Object getObject() throws XQException { if (closed) { throw new XQException(ex_item_closed); } return value; }
@Override public void setCopyNamespacesModePreserve(int mode) throws XQException { if (mode != COPY_NAMESPACES_MODE_PRESERVE && mode != COPY_NAMESPACES_MODE_NO_PRESERVE) { throw new XQException("Wrong copy namespace mode preserve value: " + mode); } this.copyNamespacesModePreserve = mode; }
@Override public void setDefaultFunctionNamespace(String uri) throws XQException { if (uri == null) { throw new XQException("Default function namespace URI is null"); } defaultFunctionNamespace = uri; }
@Override public void setDefaultOrderForEmptySequences(int order) throws XQException { if (order != DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_GREATEST && order != DEFAULT_ORDER_FOR_EMPTY_SEQUENCES_LEAST) { throw new XQException("Wrong default order for empty sequences value: " + order); } this.defaultOrderForEmptySequences = order; }
@Override public void setScrollability(int scrollability) throws XQException { if (scrollability != SCROLLTYPE_FORWARD_ONLY && scrollability != SCROLLTYPE_SCROLLABLE) { throw new XQException("Wrong scrollability value: " + scrollability); } this.scrollability = scrollability; }