public void init(RawQueryDefinition rawQuery, QueryOptionsWriteHandle options, String qtext, String sparql) { this.rawQuery = rawQuery; this.options = options; this.qtext = qtext; this.sparql = sparql; // if a query has been supplied, it's either in JSON or in XML if (rawQuery != null) { this.format = HandleAccessor.as(rawQuery.getHandle()).getFormat(); } else { if (options != null) { this.format = HandleAccessor.as(options).getFormat(); } else { // there's only qtext -- we choose format. this.format = Format.JSON; } } if ( format != Format.XML && format != Format.JSON ) { throw new IllegalArgumentException("Format of rawQuery must be XML or JSON"); } }
private void addPointInTimeQueryParam(RequestParameters params, Object outputHandle) { HandleImplementation handleBase = HandleAccessor.as(outputHandle); if ( params != null && handleBase != null && handleBase.getPointInTimeQueryTimestamp() != -1 ) { logger.trace("param timestamp=[" + handleBase.getPointInTimeQueryTimestamp() + "]"); params.add("timestamp", Long.toString(handleBase.getPointInTimeQueryTimestamp())); } }
@Override public void replaceGraphs(QuadsWriteHandle handle, Transaction transaction) { @SuppressWarnings("rawtypes") HandleImplementation baseHandle = HandleAccessor.as(handle); String mimetype = validateGraphsMimetype(baseHandle); services.writeGraphs(requestLogger, handle, transaction); baseHandle.setMimetype(mimetype); }
@Override public void write(String uri, TriplesWriteHandle handle, GraphPermissions permissions, Transaction transaction) { @SuppressWarnings("rawtypes") HandleImplementation baseHandle = HandleAccessor.as(handle); String mimetype = validateGraphsMimetype(baseHandle); services.writeGraph(requestLogger, uri, handle, permissions, transaction); baseHandle.setMimetype(mimetype); }
@Override public void merge(String uri, TriplesWriteHandle handle, GraphPermissions permissions, Transaction transaction) { @SuppressWarnings("rawtypes") HandleImplementation baseHandle = HandleAccessor.as(handle); String mimetype = validateGraphsMimetype(baseHandle); services.mergeGraph(requestLogger, uri, handle, permissions, transaction); baseHandle.setMimetype(mimetype); }
@Override public void mergeGraphs(QuadsWriteHandle handle, Transaction transaction) { @SuppressWarnings("rawtypes") HandleImplementation baseHandle = HandleAccessor.as(handle); String mimetype = validateGraphsMimetype(baseHandle); services.mergeGraphs(requestLogger, handle, transaction); baseHandle.setMimetype(mimetype); }
public <R extends AbstractReadHandle> R getContent(R handle) { if (part == null) throw new IllegalStateException("Content already retrieved"); HandleImplementation handleBase = HandleAccessor.as(handle); extractHeaders(); updateFormat(handleBase, format); updateMimetype(handleBase, mimetype); updateLength(handleBase, length); try { Object contentEntity = getEntity(part, handleBase.receiveAs()); handleBase.receiveContent((reqlog != null) ? reqlog.copyContent(contentEntity) : contentEntity); return handle; } finally { part = null; reqlog = null; } }
out.flush(); if ( options != null ) { HandleImplementation handleBase = HandleAccessor.as(options); Object value = handleBase.sendContent(); if ( value instanceof OutputStreamSender ) {
if ( qdef.qtext != null ) searchNode.put("qtext", qdef.qtext); if ( qdef.options != null ) { HandleImplementation optionsBase = HandleAccessor.as(qdef.options); if ( Format.JSON != optionsBase.getFormat() ) { throw new IllegalStateException("Cannot combine a JSON-format structured " +
@Override public <T extends TriplesReadHandle> T read(String uri, T handle, Transaction transaction) { @SuppressWarnings("rawtypes") HandleImplementation baseHandle = HandleAccessor.as(handle); String mimetype = baseHandle.getMimetype(); if ( mimetype == null ) baseHandle.setMimetype(defaultMimetype); services.readGraph(requestLogger, uri, handle, transaction); baseHandle.setMimetype(mimetype); return handle; }
@Override public <R extends AbstractReadHandle> R getContent(R handle) { if (part == null) throw new IllegalStateException("Content already retrieved"); HandleImplementation handleBase = HandleAccessor.as(handle); extractHeaders(); updateFormat(handleBase, format); updateMimetype(handleBase, mimetype); updateLength(handleBase, length); Object contentEntity = part.getEntityAs(handleBase.receiveAs()); handleBase.receiveContent((reqlog != null) ? reqlog .copyContent(contentEntity) : contentEntity); part = null; reqlog = null; return handle; }
private void setRdfXmlOrJsonMimetype(TriplesReadHandle handle) { HandleImplementation baseHandle = HandleAccessor.as(handle); if ( baseHandle.getFormat() == Format.JSON ) { if ( Format.JSON.getDefaultMimetype().equals(baseHandle.getMimetype()) ) { baseHandle.setMimetype(RDFMimeTypes.RDFJSON); } } else if ( baseHandle.getFormat() == Format.XML ) { if ( Format.XML.getDefaultMimetype().equals(baseHandle.getMimetype())) { baseHandle.setMimetype(RDFMimeTypes.RDFXML); } } }
private RequestBody makeRequestBody(AbstractWriteHandle document) { if (document == null) { return new EmptyRequestBody(); } HandleImplementation handleBase = HandleAccessor.as(document); Format format = handleBase.getFormat(); String mimetype = (format == Format.BINARY) ? "application/x-unknown-content-type" : handleBase.getMimetype(); MediaType mediaType = MediaType.parse(mimetype); return (document instanceof OutputStreamSender) ? new StreamingOutputImpl((OutputStreamSender) document, null, mediaType) : new ObjectRequestBody(HandleAccessor.sendContent(document), mediaType); }
} else if ( valueObject instanceof AbstractWriteHandle ) { value = HandleAccessor.contentAsString((AbstractWriteHandle) valueObject); HandleImplementation valueBase = HandleAccessor.as((AbstractWriteHandle) valueObject); Format format = valueBase.getFormat();
addPointInTimeQueryParam(params, searchHandle); if ( format != null ) params.add("format", format.toString().toLowerCase()); HandleImplementation handleBase = HandleAccessor.as(searchHandle); if ( format == null && searchHandle != null ) { if ( Format.XML == handleBase.getFormat() ) {
AbstractWriteHandle paramValue = ((SingleNodeCallField) param).getParamValue(); if (paramValue != null) { HandleImplementation handleBase = HandleAccessor.as(paramValue); if(! handleBase.isResendable()) { hasStreamingPartCondition.set(); .filter(paramValue -> paramValue != null) .forEachOrdered(paramValue -> { HandleImplementation handleBase = HandleAccessor.as(paramValue); if(!handleBase.isResendable()) { hasStreamingPartCondition.set();
stringJoin(categories, ", ", "no")); HandleImplementation handleBase = HandleAccessor.as(handle);
stringJoin(categories, ", ", "no")); HandleImplementation handleBase = HandleAccessor.as(handle);