[OLINGO-852] Fix server analysis issues
This commit is contained in:
parent
9333c090fd
commit
a408e2226c
|
@ -20,7 +20,6 @@ package org.apache.olingo.server.api.debug;
|
|||
|
||||
import org.apache.olingo.server.api.OData;
|
||||
import org.apache.olingo.server.api.ODataResponse;
|
||||
import org.apache.olingo.server.api.OlingoExtension;
|
||||
|
||||
/**
|
||||
* Register this interface to add debug support to your service.
|
||||
|
|
|
@ -301,7 +301,8 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
|
|||
static void copyHeaders(ODataRequest odRequest, final HttpServletRequest req) {
|
||||
for (final Enumeration<?> headerNames = req.getHeaderNames(); headerNames.hasMoreElements();) {
|
||||
final String headerName = (String) headerNames.nextElement();
|
||||
@SuppressWarnings("unchecked") // getHeaders() says it returns an Enumeration of String.
|
||||
@SuppressWarnings("unchecked")
|
||||
// getHeaders() says it returns an Enumeration of String.
|
||||
final List<String> headerValues = Collections.list(req.getHeaders(headerName));
|
||||
odRequest.addHeader(headerName, headerValues);
|
||||
}
|
||||
|
|
|
@ -51,18 +51,15 @@ public class ODataWritableContent implements ODataContent {
|
|||
private StreamContent streamContent;
|
||||
|
||||
private static abstract class StreamContent {
|
||||
protected ODataSerializer serializer;
|
||||
protected EntityIterator iterator;
|
||||
protected ServiceMetadata metadata;
|
||||
protected EdmEntityType entityType;
|
||||
protected EntityCollectionSerializerOptions options;
|
||||
|
||||
public StreamContent(EntityIterator iterator, EdmEntityType entityType,
|
||||
ODataSerializer serializer, ServiceMetadata metadata,
|
||||
EntityCollectionSerializerOptions options) {
|
||||
public StreamContent(EntityIterator iterator, EdmEntityType entityType, ServiceMetadata metadata,
|
||||
EntityCollectionSerializerOptions options) {
|
||||
this.iterator = iterator;
|
||||
this.entityType = entityType;
|
||||
this.serializer = serializer;
|
||||
this.metadata = metadata;
|
||||
this.options = options;
|
||||
}
|
||||
|
@ -74,7 +71,7 @@ public class ODataWritableContent implements ODataContent {
|
|||
writeEntity(iterator, out);
|
||||
} catch (SerializerException e) {
|
||||
final ODataContentWriteErrorCallback errorCallback = options.getODataContentWriteErrorCallback();
|
||||
if(errorCallback != null) {
|
||||
if (errorCallback != null) {
|
||||
final WriteErrorContext errorContext = new WriteErrorContext(e);
|
||||
errorCallback.handleError(errorContext, Channels.newChannel(out));
|
||||
}
|
||||
|
@ -88,7 +85,7 @@ public class ODataWritableContent implements ODataContent {
|
|||
public StreamContentForJson(EntityIterator iterator, EdmEntityType entityType,
|
||||
ODataJsonSerializer jsonSerializer, ServiceMetadata metadata,
|
||||
EntityCollectionSerializerOptions options) {
|
||||
super(iterator, entityType, jsonSerializer, metadata, options);
|
||||
super(iterator, entityType, metadata, options);
|
||||
|
||||
this.jsonSerializer = jsonSerializer;
|
||||
}
|
||||
|
@ -98,7 +95,7 @@ public class ODataWritableContent implements ODataContent {
|
|||
jsonSerializer.entityCollectionIntoStream(metadata, entityType, entity, options, outputStream);
|
||||
outputStream.flush();
|
||||
} catch (final IOException e) {
|
||||
throw new ODataRuntimeException("Failed entity serialization");
|
||||
throw new ODataRuntimeException("Failed entity serialization", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +106,7 @@ public class ODataWritableContent implements ODataContent {
|
|||
public StreamContentForXml(EntityIterator iterator, EdmEntityType entityType,
|
||||
ODataXmlSerializer xmlSerializer, ServiceMetadata metadata,
|
||||
EntityCollectionSerializerOptions options) {
|
||||
super(iterator, entityType, xmlSerializer, metadata, options);
|
||||
super(iterator, entityType, metadata, options);
|
||||
|
||||
this.xmlSerializer = xmlSerializer;
|
||||
}
|
||||
|
@ -119,7 +116,7 @@ public class ODataWritableContent implements ODataContent {
|
|||
xmlSerializer.entityCollectionIntoStream(metadata, entityType, entity, options, outputStream);
|
||||
outputStream.flush();
|
||||
} catch (final IOException e) {
|
||||
throw new ODataRuntimeException("Failed entity serialization");
|
||||
throw new ODataRuntimeException("Failed entity serialization", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,13 +136,14 @@ public class ODataWritableContent implements ODataContent {
|
|||
}
|
||||
|
||||
public static ODataWritableContentBuilder with(EntityIterator iterator, EdmEntityType entityType,
|
||||
ODataSerializer serializer, ServiceMetadata metadata,
|
||||
ODataSerializer serializer, ServiceMetadata metadata,
|
||||
EntityCollectionSerializerOptions options) {
|
||||
return new ODataWritableContentBuilder(iterator, entityType, serializer, metadata, options);
|
||||
}
|
||||
|
||||
public static class WriteErrorContext implements ODataContentWriteErrorContext {
|
||||
private ODataLibraryException exception;
|
||||
|
||||
public WriteErrorContext(ODataLibraryException exception) {
|
||||
this.exception = exception;
|
||||
}
|
||||
|
@ -154,6 +152,7 @@ public class ODataWritableContent implements ODataContent {
|
|||
public Exception getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataLibraryException getODataLibraryException() {
|
||||
return exception;
|
||||
|
@ -168,8 +167,8 @@ public class ODataWritableContent implements ODataContent {
|
|||
private EntityCollectionSerializerOptions options;
|
||||
|
||||
public ODataWritableContentBuilder(EntityIterator entities, EdmEntityType entityType,
|
||||
ODataSerializer serializer,
|
||||
ServiceMetadata metadata, EntityCollectionSerializerOptions options) {
|
||||
ODataSerializer serializer,
|
||||
ServiceMetadata metadata, EntityCollectionSerializerOptions options) {
|
||||
this.entities = entities;
|
||||
this.entityType = entityType;
|
||||
this.serializer = serializer;
|
||||
|
@ -178,17 +177,18 @@ public class ODataWritableContent implements ODataContent {
|
|||
}
|
||||
|
||||
public ODataContent buildContent() {
|
||||
if(serializer instanceof ODataJsonSerializer) {
|
||||
if (serializer instanceof ODataJsonSerializer) {
|
||||
StreamContent input = new StreamContentForJson(entities, entityType,
|
||||
(ODataJsonSerializer) serializer, metadata, options);
|
||||
return new ODataWritableContent(input);
|
||||
} else if(serializer instanceof ODataXmlSerializer) {
|
||||
} else if (serializer instanceof ODataXmlSerializer) {
|
||||
StreamContentForXml input = new StreamContentForXml(entities, entityType,
|
||||
(ODataXmlSerializer) serializer, metadata, options);
|
||||
return new ODataWritableContent(input);
|
||||
}
|
||||
throw new ODataRuntimeException("No suitable serializer found");
|
||||
}
|
||||
|
||||
public SerializerStreamResult build() {
|
||||
return SerializerStreamResultImpl.with().content(buildContent()).build();
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
@ -70,17 +70,18 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
|
|||
ODataResponse response = new ODataResponse();
|
||||
final String contentTypeString;
|
||||
final InputStream body;
|
||||
if(requestedFormat == DebugFormat.DOWNLOAD || requestedFormat == DebugFormat.HTML) {
|
||||
if (requestedFormat == DebugFormat.DOWNLOAD || requestedFormat == DebugFormat.HTML) {
|
||||
String title = debugInfo.getRequest() == null ?
|
||||
"V4 Service" : "V4 Service: " + debugInfo.getRequest().getRawODataPath();
|
||||
body = wrapInHtml(parts, title);
|
||||
contentTypeString = ContentType.TEXT_HTML.toContentTypeString();
|
||||
} else { // for JSON and also default response handling
|
||||
} else {
|
||||
// for JSON and also default response handling
|
||||
body = wrapInJson(parts);
|
||||
contentTypeString = ContentType.APPLICATION_JSON.toContentTypeString();
|
||||
}
|
||||
// for download add additional Content-Disposition header
|
||||
if(requestedFormat == DebugFormat.DOWNLOAD) {
|
||||
if (requestedFormat == DebugFormat.DOWNLOAD) {
|
||||
response.setHeader("Content-Disposition", "attachment; filename=OData-Response."
|
||||
+ new Date().toString().replace(' ', '_').replace(':', '.') + ".html");
|
||||
}
|
||||
|
@ -163,11 +164,7 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
|
|||
return csb.getInputStream();
|
||||
} finally {
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
}
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,61 +185,61 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
|
|||
StringWriter writer = new StringWriter();
|
||||
|
||||
writer.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n")
|
||||
.append(" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n")
|
||||
.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n")
|
||||
.append("<head>\n")
|
||||
.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n")
|
||||
.append("<title>")
|
||||
.append(escapeHtml(title))
|
||||
.append("</title>\n")
|
||||
.append("<style type=\"text/css\">\n")
|
||||
.append("body { font-family: Arial, sans-serif; font-size: 13px;\n")
|
||||
.append(" line-height: 16px; margin: 0;\n")
|
||||
.append(" background-color: #eeeeee; color: #333333; }\n")
|
||||
.append(".header { float: left; }\n")
|
||||
.append(".header a { line-height: 22px; padding: 10px 18px;\n")
|
||||
.append(" text-decoration: none; color: #333333; }\n")
|
||||
.append(":target, .header:nth-last-child(2) { background-color: #cccccc; }\n")
|
||||
.append(":target ~ .header:nth-last-child(2) { background-color: inherit; }\n")
|
||||
.append(".header:focus, .header:hover,\n")
|
||||
.append(" .header:nth-last-child(2):focus, .header:nth-last-child(2):hover\n")
|
||||
.append(" { background-color: #999999; }\n")
|
||||
.append(".section { position: absolute; top: 42px; min-width: 100%;\n")
|
||||
.append(" padding-top: 18px; border-top: 1px solid #dddddd; }\n")
|
||||
.append(".section > * { margin-left: 18px; }\n")
|
||||
.append(":target + .section, .section:last-child { display: block; }\n")
|
||||
.append(".section, :target + .section ~ .section { display: none; }\n")
|
||||
.append("h1 { font-size: 18px; font-weight: normal; margin: 10px 0; }\n")
|
||||
.append("h2 { font-size: 15px; }\n")
|
||||
.append("h2:not(:first-child) { margin-top: 2em; }\n")
|
||||
.append("table { border-collapse: collapse; border-spacing: 0;\n")
|
||||
.append(" margin-top: 1.5em; }\n")
|
||||
.append("table, thead { border-width: 1px 0; border-style: solid;\n")
|
||||
.append(" border-color: #dddddd; text-align: left; }\n")
|
||||
.append("th.name, td.name { padding: 1ex 2em 1ex 0; }\n")
|
||||
.append("tbody > tr:hover { background-color: #cccccc; }\n")
|
||||
.append(".code { font-family: \"Courier New\", monospace; }\n")
|
||||
.append(".code, .tree li { line-height: 15px; }\n")
|
||||
.append("ul, .tree { padding-left: 0; list-style-type: none; }\n")
|
||||
.append(".null, .numeric { padding-left: 1.5em; }\n")
|
||||
.append(".json { white-space: pre-wrap; }\n")
|
||||
.append("</style>\n")
|
||||
.append("</head>\n")
|
||||
.append("<body>\n");
|
||||
.append(" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n")
|
||||
.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n")
|
||||
.append("<head>\n")
|
||||
.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n")
|
||||
.append("<title>")
|
||||
.append(escapeHtml(title))
|
||||
.append("</title>\n")
|
||||
.append("<style type=\"text/css\">\n")
|
||||
.append("body { font-family: Arial, sans-serif; font-size: 13px;\n")
|
||||
.append(" line-height: 16px; margin: 0;\n")
|
||||
.append(" background-color: #eeeeee; color: #333333; }\n")
|
||||
.append(".header { float: left; }\n")
|
||||
.append(".header a { line-height: 22px; padding: 10px 18px;\n")
|
||||
.append(" text-decoration: none; color: #333333; }\n")
|
||||
.append(":target, .header:nth-last-child(2) { background-color: #cccccc; }\n")
|
||||
.append(":target ~ .header:nth-last-child(2) { background-color: inherit; }\n")
|
||||
.append(".header:focus, .header:hover,\n")
|
||||
.append(" .header:nth-last-child(2):focus, .header:nth-last-child(2):hover\n")
|
||||
.append(" { background-color: #999999; }\n")
|
||||
.append(".section { position: absolute; top: 42px; min-width: 100%;\n")
|
||||
.append(" padding-top: 18px; border-top: 1px solid #dddddd; }\n")
|
||||
.append(".section > * { margin-left: 18px; }\n")
|
||||
.append(":target + .section, .section:last-child { display: block; }\n")
|
||||
.append(".section, :target + .section ~ .section { display: none; }\n")
|
||||
.append("h1 { font-size: 18px; font-weight: normal; margin: 10px 0; }\n")
|
||||
.append("h2 { font-size: 15px; }\n")
|
||||
.append("h2:not(:first-child) { margin-top: 2em; }\n")
|
||||
.append("table { border-collapse: collapse; border-spacing: 0;\n")
|
||||
.append(" margin-top: 1.5em; }\n")
|
||||
.append("table, thead { border-width: 1px 0; border-style: solid;\n")
|
||||
.append(" border-color: #dddddd; text-align: left; }\n")
|
||||
.append("th.name, td.name { padding: 1ex 2em 1ex 0; }\n")
|
||||
.append("tbody > tr:hover { background-color: #cccccc; }\n")
|
||||
.append(".code { font-family: \"Courier New\", monospace; }\n")
|
||||
.append(".code, .tree li { line-height: 15px; }\n")
|
||||
.append("ul, .tree { padding-left: 0; list-style-type: none; }\n")
|
||||
.append(".null, .numeric { padding-left: 1.5em; }\n")
|
||||
.append(".json { white-space: pre-wrap; }\n")
|
||||
.append("</style>\n")
|
||||
.append("</head>\n")
|
||||
.append("<body>\n");
|
||||
char count = '0';
|
||||
for (final DebugTab part : parts) {
|
||||
writer.append("<div class=\"header\" id=\"sec").append(++count).append("\">\n")
|
||||
.append("<h1><a href=\"#sec").append(count).append("\">")
|
||||
.append(part.getName())
|
||||
.append("</a></h1>\n")
|
||||
.append("</div>\n")
|
||||
.append("<div class=\"section\">\n");
|
||||
.append("<h1><a href=\"#sec").append(count).append("\">")
|
||||
.append(part.getName())
|
||||
.append("</a></h1>\n")
|
||||
.append("</div>\n")
|
||||
.append("<div class=\"section\">\n");
|
||||
part.appendHtml(writer);
|
||||
writer.append("</div>\n");
|
||||
}
|
||||
writer.append("</body>\n")
|
||||
.append("</html>\n")
|
||||
.close();
|
||||
.append("</html>\n")
|
||||
.close();
|
||||
byte[] bytes = writer.toString().getBytes("UTF-8");
|
||||
return new ByteArrayInputStream(bytes);
|
||||
}
|
||||
|
@ -271,14 +268,14 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
|
|||
|
||||
protected static void appendHtmlTable(final Writer writer, final Map<String, String> entries) throws IOException {
|
||||
writer.append("<table>\n<thead>\n")
|
||||
.append("<tr><th class=\"name\">Name</th><th class=\"value\">Value</th></tr>\n")
|
||||
.append("</thead>\n<tbody>\n");
|
||||
.append("<tr><th class=\"name\">Name</th><th class=\"value\">Value</th></tr>\n")
|
||||
.append("</thead>\n<tbody>\n");
|
||||
if (entries != null && !entries.isEmpty()) {
|
||||
for (final Map.Entry<String, String> entry : entries.entrySet()) {
|
||||
writer.append("<tr><td class=\"name\">").append(entry.getKey()).append("</td>")
|
||||
.append("<td class=\"value\">")
|
||||
.append(escapeHtml(entry.getValue()))
|
||||
.append("</td></tr>\n");
|
||||
.append("<td class=\"value\">")
|
||||
.append(escapeHtml(entry.getValue()))
|
||||
.append("</td></tr>\n");
|
||||
}
|
||||
}
|
||||
writer.append("</tbody>\n</table>\n");
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
|||
*/
|
||||
public class DebugTabRuntime implements DebugTab {
|
||||
|
||||
private static final int TO_MILLIS_DIVISOR = 1000;
|
||||
private final RuntimeNode rootNode;
|
||||
|
||||
public DebugTabRuntime(final List<RuntimeMeasurement> runtimeInformation) {
|
||||
|
@ -69,7 +70,7 @@ public class DebugTabRuntime implements DebugTab {
|
|||
if (node.timeStopped == 0) {
|
||||
gen.writeNullField("duration");
|
||||
} else {
|
||||
gen.writeStringField("duration", Long.toString((node.timeStopped - node.timeStarted) / 1000));
|
||||
gen.writeStringField("duration", Long.toString((node.timeStopped - node.timeStarted) / TO_MILLIS_DIVISOR));
|
||||
gen.writeStringField("unit", "µs");
|
||||
}
|
||||
|
||||
|
@ -96,7 +97,7 @@ public class DebugTabRuntime implements DebugTab {
|
|||
.append("<span class=\"class\">").append(node.className).append("</span>.")
|
||||
.append("<span class=\"method\">").append(node.methodName).append("(…)")
|
||||
.append("</span></span>");
|
||||
long time = node.timeStopped == 0 ? 0 : (node.timeStopped - node.timeStarted) / 1000;
|
||||
long time = node.timeStopped == 0 ? 0 : (node.timeStopped - node.timeStarted) / TO_MILLIS_DIVISOR;
|
||||
writer.append("<span class=\"").append(time == 0 ? "null" : "numeric")
|
||||
.append("\" title=\"").append(time == 0 ? "Stop time missing" : "Gross duration")
|
||||
.append("\">").append(time == 0 ? "unfinished" : Long.toString(time) + " µs")
|
||||
|
|
|
@ -44,10 +44,12 @@ import org.apache.olingo.server.core.deserializer.json.ODataJsonDeserializer;
|
|||
|
||||
public class FixedFormatDeserializerImpl implements FixedFormatDeserializer {
|
||||
|
||||
private static final int DEFAULT_BUFFER_SIZE = 128;
|
||||
|
||||
@Override
|
||||
public byte[] binary(final InputStream content) throws DeserializerException {
|
||||
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[128];
|
||||
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
|
||||
int count;
|
||||
try {
|
||||
while ((count = content.read(buffer)) > -1) {
|
||||
|
|
|
@ -96,6 +96,7 @@ public class BatchLineReader {
|
|||
private void updateCurrentCharset(final String currentLine) {
|
||||
if (currentLine != null) {
|
||||
if (currentLine.startsWith(HttpHeader.CONTENT_TYPE)) {
|
||||
//13 is content-type.length() + 1 for header value
|
||||
String clValue = currentLine.substring(13, currentLine.length() - 2).trim();
|
||||
ContentType ct = ContentType.parse(clValue);
|
||||
if (ct != null) {
|
||||
|
@ -134,14 +135,13 @@ public class BatchLineReader {
|
|||
}
|
||||
|
||||
ByteBuffer innerBuffer = ByteBuffer.allocate(BUFFER_SIZE);
|
||||
boolean foundLineEnd = false; // EOF will be considered as line ending
|
||||
// EOF will be considered as line ending
|
||||
boolean foundLineEnd = false;
|
||||
|
||||
while (!foundLineEnd) {
|
||||
// Is buffer refill required?
|
||||
if (limit == offset) {
|
||||
if (fillBuffer() == EOF) {
|
||||
foundLineEnd = true;
|
||||
}
|
||||
if (limit == offset && fillBuffer() == EOF) {
|
||||
foundLineEnd = true;
|
||||
}
|
||||
|
||||
if (!foundLineEnd) {
|
||||
|
|
|
@ -38,7 +38,7 @@ public class HttpRequestStatusLine {
|
|||
private static final String HTTP_VERSION = "HTTP/1.1";
|
||||
|
||||
final private Line statusLine;
|
||||
final String requestBaseUri;
|
||||
final private String requestBaseUri;
|
||||
|
||||
private HttpMethod method;
|
||||
private String httpVersion;
|
||||
|
@ -60,9 +60,9 @@ public class HttpRequestStatusLine {
|
|||
private void parse() throws BatchDeserializerException {
|
||||
final String[] parts = statusLine.toString().split(" ");
|
||||
|
||||
//Status line consists of 3 parts: Method, URI and HTTP Version
|
||||
if (parts.length == 3) {
|
||||
method = parseMethod(parts[0]);
|
||||
// uri = new ODataURI(parts[1], requestBaseUri, statusLine.getLineNumber(), header.getHeaders(HttpHeader.HOST));
|
||||
parseUri(parts[1], requestBaseUri);
|
||||
httpVersion = parseHttpVersion(parts[2]);
|
||||
} else {
|
||||
|
|
|
@ -50,14 +50,14 @@ import org.apache.olingo.server.api.prefer.Preferences.Preference;
|
|||
*/
|
||||
public class PreferParser {
|
||||
|
||||
private static final String token = "(?:[-!#$%&'*+.^_`|~]|\\w)+";
|
||||
private static final String quotedString = "(?:\"(?:[\\t !#-\\[\\]-~\\x80-\\xFF]|"
|
||||
private static final String TOKEN = "(?:[-!#$%&'*+.^_`|~]|\\w)+";
|
||||
private static final String QUOTED_STRING = "(?:\"(?:[\\t !#-\\[\\]-~\\x80-\\xFF]|"
|
||||
+ "(?:\\\\[\\t !-~\\x80-\\xFF]))*\")";
|
||||
private static final String namedValue =
|
||||
"(" + token + ")(?:\\s*=\\s*(" + token + "|" + quotedString + "))?";
|
||||
private static final String NAMED_VALUE =
|
||||
"(" + TOKEN + ")(?:\\s*=\\s*(" + TOKEN + "|" + QUOTED_STRING + "))?";
|
||||
private static final Pattern PREFERENCE = Pattern.compile("\\s*(,\\s*)+|"
|
||||
+ "(?:" + namedValue + "((?:\\s*;\\s*(?:" + namedValue + ")?)*))");
|
||||
private static final Pattern PARAMETER = Pattern.compile("\\s*(;\\s*)+|(?:" + namedValue + ")");
|
||||
+ "(?:" + NAMED_VALUE + "((?:\\s*;\\s*(?:" + NAMED_VALUE + ")?)*))");
|
||||
private static final Pattern PARAMETER = Pattern.compile("\\s*(;\\s*)+|(?:" + NAMED_VALUE + ")");
|
||||
|
||||
private PreferParser() {
|
||||
// Private constructor for utility classes
|
||||
|
|
|
@ -33,7 +33,8 @@ import org.apache.olingo.server.api.prefer.Preferences;
|
|||
*/
|
||||
public class PreferencesImpl implements Preferences {
|
||||
|
||||
private static final String URL = "url"; // parameter name for odata.callback
|
||||
//parameter name for odata.callback
|
||||
private static final String URL = "url";
|
||||
|
||||
private final Map<String, Preference> preferences;
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ public class BatchResponseSerializer {
|
|||
*/
|
||||
private static class BodyBuilder {
|
||||
private static final Charset CHARSET_ISO_8859_1 = Charset.forName("iso-8859-1");
|
||||
private ByteBuffer buffer = ByteBuffer.allocate(8192);
|
||||
private ByteBuffer buffer = ByteBuffer.allocate(BUFFER_SIZE);
|
||||
private boolean isClosed = false;
|
||||
|
||||
public byte[] getContent() {
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
@ -186,11 +186,10 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
return ODataWritableContent.with(entities, entityType, this, metadata, options).build();
|
||||
}
|
||||
|
||||
|
||||
public void entityCollectionIntoStream(final ServiceMetadata metadata,
|
||||
final EdmEntityType entityType, final EntityIterator entitySet,
|
||||
final EntityCollectionSerializerOptions options, final OutputStream outputStream)
|
||||
throws SerializerException {
|
||||
throws SerializerException {
|
||||
|
||||
SerializerException cachedException;
|
||||
try {
|
||||
|
@ -235,9 +234,9 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
JsonGenerator json = new JsonFactory().createGenerator(outputStream);
|
||||
writeEntity(metadata, entityType, entity, contextURL,
|
||||
options == null ? null : options.getExpand(),
|
||||
options == null ? null : options.getSelect(),
|
||||
options == null ? false : options.getWriteOnlyReferences(),
|
||||
json);
|
||||
options == null ? null : options.getSelect(),
|
||||
options == null ? false : options.getWriteOnlyReferences(),
|
||||
json);
|
||||
|
||||
json.close();
|
||||
outputStream.close();
|
||||
|
@ -277,26 +276,27 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
json.writeEndArray();
|
||||
}
|
||||
|
||||
private boolean areKeyPredicateNamesSelected(SelectOption select, EdmEntityType type) {
|
||||
private boolean areKeyPredicateNamesSelected(SelectOption select, EdmEntityType type) {
|
||||
if (select == null || ExpandSelectHelper.isAll(select)) {
|
||||
return true;
|
||||
}
|
||||
final Set<String> selected = ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
|
||||
for (String key: type.getKeyPredicateNames()) {
|
||||
for (String key : type.getKeyPredicateNames()) {
|
||||
if (!selected.contains(key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void writeEntity(final ServiceMetadata metadata, final EdmEntityType entityType, final Entity entity,
|
||||
final ContextURL contextURL, final ExpandOption expand, final SelectOption select, final boolean onlyReference,
|
||||
final JsonGenerator json)
|
||||
throws IOException, SerializerException {
|
||||
throws IOException, SerializerException {
|
||||
json.writeStartObject();
|
||||
if (!isODataMetadataNone) {
|
||||
if (contextURL != null) { // top-level entity
|
||||
// top-level entity
|
||||
if (contextURL != null) {
|
||||
writeContextURL(contextURL, json);
|
||||
writeMetadataETag(metadata, json);
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
}
|
||||
throw new SerializerException("Wrong base type",
|
||||
SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, baseType
|
||||
.getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
.getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
}
|
||||
|
||||
protected EdmComplexType resolveComplexType(final ServiceMetadata metadata, final EdmComplexType baseType,
|
||||
|
@ -379,22 +379,22 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
}
|
||||
throw new SerializerException("Wrong base type",
|
||||
SerializerException.MessageKeys.WRONG_BASE_TYPE, derivedTypeName, baseType
|
||||
.getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
.getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
}
|
||||
|
||||
protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type,
|
||||
final List<Property> properties,
|
||||
final SelectOption select, final JsonGenerator json)
|
||||
throws IOException, SerializerException {
|
||||
throws IOException, SerializerException {
|
||||
final boolean all = ExpandSelectHelper.isAll(select);
|
||||
final Set<String> selected = all ? new HashSet<String>() :
|
||||
ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
|
||||
ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
|
||||
for (final String propertyName : type.getPropertyNames()) {
|
||||
if (all || selected.contains(propertyName)) {
|
||||
final EdmProperty edmProperty = type.getStructuralProperty(propertyName);
|
||||
final Property property = findProperty(propertyName, properties);
|
||||
final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null :
|
||||
ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName);
|
||||
ExpandSelectHelper.getSelectedPaths(select.getSelectItems(), propertyName);
|
||||
writeProperty(metadata, edmProperty, property, selectedPaths, json);
|
||||
}
|
||||
}
|
||||
|
@ -406,36 +406,36 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
if (ExpandSelectHelper.hasExpand(expand)) {
|
||||
final boolean expandAll = ExpandSelectHelper.isExpandAll(expand);
|
||||
final Set<String> expanded = expandAll ? new HashSet<String>() :
|
||||
ExpandSelectHelper.getExpandedPropertyNames(expand.getExpandItems());
|
||||
ExpandSelectHelper.getExpandedPropertyNames(expand.getExpandItems());
|
||||
for (final String propertyName : type.getNavigationPropertyNames()) {
|
||||
if (expandAll || expanded.contains(propertyName)) {
|
||||
final EdmNavigationProperty property = type.getNavigationProperty(propertyName);
|
||||
final Link navigationLink = linked.getNavigationLink(property.getName());
|
||||
final ExpandItem innerOptions = expandAll ? null :
|
||||
ExpandSelectHelper.getExpandItem(expand.getExpandItems(), propertyName);
|
||||
ExpandSelectHelper.getExpandItem(expand.getExpandItems(), propertyName);
|
||||
if (innerOptions != null && innerOptions.getLevelsOption() != null) {
|
||||
throw new SerializerException("Expand option $levels is not supported.",
|
||||
SerializerException.MessageKeys.NOT_IMPLEMENTED);
|
||||
}
|
||||
writeExpandedNavigationProperty(metadata, property, navigationLink,
|
||||
innerOptions == null ? null : innerOptions.getExpandOption(),
|
||||
innerOptions == null ? null : innerOptions.getSelectOption(),
|
||||
innerOptions == null ? null : innerOptions.getCountOption(),
|
||||
innerOptions == null ? null : innerOptions.getSelectOption(),
|
||||
innerOptions == null ? null : innerOptions.getCountOption(),
|
||||
innerOptions == null ? false : innerOptions.hasCountPath(),
|
||||
innerOptions == null ? false : innerOptions.isRef(),
|
||||
innerOptions == null ? false : innerOptions.isRef(),
|
||||
json);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void writeExpandedNavigationProperty(
|
||||
final ServiceMetadata metadata, final EdmNavigationProperty property,
|
||||
final Link navigationLink, final ExpandOption innerExpand,
|
||||
final SelectOption innerSelect, final CountOption innerCount,
|
||||
final boolean writeOnlyCount, final boolean writeOnlyRef,
|
||||
final JsonGenerator json) throws IOException, SerializerException {
|
||||
|
||||
|
||||
if (property.isCollection()) {
|
||||
if (writeOnlyCount) {
|
||||
if (navigationLink == null || navigationLink.getInlineEntitySet() == null) {
|
||||
|
@ -443,11 +443,11 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
} else {
|
||||
writeInlineCount(property.getName(), navigationLink.getInlineEntitySet().getCount(), json);
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
if (navigationLink == null || navigationLink.getInlineEntitySet() == null) {
|
||||
if (innerCount != null && innerCount.getValue()) {
|
||||
writeInlineCount(property.getName(), 0, json);
|
||||
}
|
||||
}
|
||||
json.writeFieldName(property.getName());
|
||||
json.writeStartArray();
|
||||
json.writeEndArray();
|
||||
|
@ -473,7 +473,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
|
||||
protected void writeProperty(final ServiceMetadata metadata, final EdmProperty edmProperty, final Property property,
|
||||
final Set<List<String>> selectedPaths, final JsonGenerator json)
|
||||
throws IOException, SerializerException {
|
||||
throws IOException, SerializerException {
|
||||
json.writeFieldName(edmProperty.getName());
|
||||
if (property == null || property.isNull()) {
|
||||
if (edmProperty.isNullable() == Boolean.FALSE) {
|
||||
|
@ -494,7 +494,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
|
||||
private void writePropertyValue(final ServiceMetadata metadata, final EdmProperty edmProperty,
|
||||
final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json)
|
||||
throws IOException, SerializerException {
|
||||
throws IOException, SerializerException {
|
||||
final EdmType type = edmProperty.getType();
|
||||
try {
|
||||
if (edmProperty.isPrimitive()
|
||||
|
@ -529,7 +529,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
private void writePrimitiveCollection(final EdmPrimitiveType type, final Property property,
|
||||
final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
|
||||
final Boolean isUnicode, final JsonGenerator json)
|
||||
throws IOException, SerializerException {
|
||||
throws IOException, SerializerException {
|
||||
json.writeStartArray();
|
||||
for (Object value : property.asCollection()) {
|
||||
switch (property.getValueType()) {
|
||||
|
@ -557,7 +557,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
private void writeComplexCollection(final ServiceMetadata metadata, final EdmComplexType type,
|
||||
final Property property,
|
||||
final Set<List<String>> selectedPaths, final JsonGenerator json)
|
||||
throws IOException, SerializerException {
|
||||
throws IOException, SerializerException {
|
||||
json.writeStartArray();
|
||||
for (Object value : property.asCollection()) {
|
||||
switch (property.getValueType()) {
|
||||
|
@ -575,7 +575,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
private void writePrimitive(final EdmPrimitiveType type, final Property property,
|
||||
final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
|
||||
final Boolean isUnicode, final JsonGenerator json)
|
||||
throws EdmPrimitiveTypeException, IOException, SerializerException {
|
||||
throws EdmPrimitiveTypeException, IOException, SerializerException {
|
||||
if (property.isPrimitive()) {
|
||||
writePrimitiveValue(type, property.asPrimitive(),
|
||||
isNullable, maxLength, precision, scale, isUnicode, json);
|
||||
|
@ -618,7 +618,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
protected void writeComplexValue(final ServiceMetadata metadata, final Property complexProperty,
|
||||
final EdmComplexType type, final List<Property> properties,
|
||||
final Set<List<String>> selectedPaths, final JsonGenerator json)
|
||||
throws IOException, SerializerException {
|
||||
throws IOException, SerializerException {
|
||||
json.writeStartObject();
|
||||
|
||||
final EdmComplexType resolvedType = resolveComplexType(metadata,
|
||||
|
@ -633,7 +633,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
if (selectedPaths == null || ExpandSelectHelper.isSelected(selectedPaths, propertyName)) {
|
||||
writeProperty(metadata, (EdmProperty) resolvedType.getProperty(propertyName), property,
|
||||
selectedPaths == null ? null : ExpandSelectHelper.getReducedSelectedPaths(selectedPaths, propertyName),
|
||||
json);
|
||||
json);
|
||||
}
|
||||
}
|
||||
json.writeEndObject();
|
||||
|
@ -667,10 +667,10 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
json.writeFieldName(Constants.VALUE);
|
||||
writePrimitive(type, property,
|
||||
options == null ? null : options.isNullable(),
|
||||
options == null ? null : options.getMaxLength(),
|
||||
options == null ? null : options.getPrecision(),
|
||||
options == null ? null : options.getScale(),
|
||||
options == null ? null : options.isUnicode(), json);
|
||||
options == null ? null : options.getMaxLength(),
|
||||
options == null ? null : options.getPrecision(),
|
||||
options == null ? null : options.getScale(),
|
||||
options == null ? null : options.isUnicode(), json);
|
||||
}
|
||||
json.writeEndObject();
|
||||
|
||||
|
@ -710,16 +710,16 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
}
|
||||
final List<Property> values =
|
||||
property.isNull() ? Collections.<Property> emptyList() : property.asComplex().getValue();
|
||||
writeProperties(metadata, type, values, options == null ? null : options.getSelect(), json);
|
||||
if (!property.isNull() && property.isComplex()) {
|
||||
writeNavigationProperties(metadata, type, property.asComplex(),
|
||||
options == null ? null : options.getExpand(), json);
|
||||
}
|
||||
json.writeEndObject();
|
||||
writeProperties(metadata, type, values, options == null ? null : options.getSelect(), json);
|
||||
if (!property.isNull() && property.isComplex()) {
|
||||
writeNavigationProperties(metadata, type, property.asComplex(),
|
||||
options == null ? null : options.getExpand(), json);
|
||||
}
|
||||
json.writeEndObject();
|
||||
|
||||
json.close();
|
||||
outputStream.close();
|
||||
return SerializerResultImpl.with().content(buffer.getInputStream()).build();
|
||||
json.close();
|
||||
outputStream.close();
|
||||
return SerializerResultImpl.with().content(buffer.getInputStream()).build();
|
||||
} catch (final IOException e) {
|
||||
cachedException =
|
||||
new SerializerException(IO_EXCEPTION_TEXT, e, SerializerException.MessageKeys.IO_EXCEPTION);
|
||||
|
@ -745,10 +745,10 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
json.writeFieldName(Constants.VALUE);
|
||||
writePrimitiveCollection(type, property,
|
||||
options == null ? null : options.isNullable(),
|
||||
options == null ? null : options.getMaxLength(),
|
||||
options == null ? null : options.getPrecision(),
|
||||
options == null ? null : options.getScale(),
|
||||
options == null ? null : options.isUnicode(), json);
|
||||
options == null ? null : options.getMaxLength(),
|
||||
options == null ? null : options.getPrecision(),
|
||||
options == null ? null : options.getScale(),
|
||||
options == null ? null : options.isUnicode(), json);
|
||||
json.writeEndObject();
|
||||
|
||||
json.close();
|
||||
|
@ -825,7 +825,7 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
@Override
|
||||
public SerializerResult referenceCollection(final ServiceMetadata metadata, final EdmEntitySet edmEntitySet,
|
||||
final AbstractEntityCollection entityCollection, final ReferenceCollectionSerializerOptions options)
|
||||
throws SerializerException {
|
||||
throws SerializerException {
|
||||
OutputStream outputStream = null;
|
||||
SerializerException cachedException = null;
|
||||
|
||||
|
@ -898,13 +898,13 @@ public class ODataJsonSerializer extends AbstractODataSerializer {
|
|||
throws IOException {
|
||||
if (count != null) {
|
||||
if (isIEEE754Compatible) {
|
||||
json.writeStringField(propertyName+Constants.JSON_COUNT, String.valueOf(count));
|
||||
json.writeStringField(propertyName + Constants.JSON_COUNT, String.valueOf(count));
|
||||
} else {
|
||||
json.writeNumberField(propertyName+Constants.JSON_COUNT, count);
|
||||
json.writeNumberField(propertyName + Constants.JSON_COUNT, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void writeNextLink(final AbstractEntityCollection entitySet, final JsonGenerator json) throws IOException {
|
||||
if (entitySet.getNext() != null) {
|
||||
json.writeStringField(Constants.JSON_NEXT_LINK, entitySet.getNext().toASCIIString());
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
@ -58,8 +58,8 @@ public class ServiceDocumentJsonSerializer {
|
|||
if (!isODataMetadataNone) {
|
||||
final String metadataUri =
|
||||
(serviceRoot == null ? "" :
|
||||
serviceRoot.endsWith("/") ? serviceRoot : (serviceRoot + "/"))
|
||||
+ Constants.METADATA;
|
||||
serviceRoot.endsWith("/") ? serviceRoot : (serviceRoot + "/"))
|
||||
+ Constants.METADATA;
|
||||
gen.writeObjectField(Constants.JSON_CONTEXT, metadataUri);
|
||||
|
||||
if (metadata != null
|
||||
|
@ -73,9 +73,11 @@ public class ServiceDocumentJsonSerializer {
|
|||
gen.writeArrayFieldStart(Constants.VALUE);
|
||||
|
||||
final EdmEntityContainer container = metadata.getEdm().getEntityContainer();
|
||||
writeEntitySets(gen, container);
|
||||
writeFunctionImports(gen, container);
|
||||
writeSingletons(gen, container);
|
||||
if (container != null) {
|
||||
writeEntitySets(gen, container);
|
||||
writeFunctionImports(gen, container);
|
||||
writeSingletons(gen, container);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeEntitySets(final JsonGenerator gen, final EdmEntityContainer container) throws IOException {
|
||||
|
@ -102,7 +104,7 @@ public class ServiceDocumentJsonSerializer {
|
|||
|
||||
private void writeElement(final JsonGenerator gen, final String kind, final String reference, final String name,
|
||||
final String title)
|
||||
throws IOException {
|
||||
throws IOException {
|
||||
gen.writeStartObject();
|
||||
gen.writeObjectField(Constants.JSON_NAME, name);
|
||||
if (title != null) {
|
||||
|
|
|
@ -148,7 +148,7 @@ public class MetadataDocumentXmlSerializer {
|
|||
private static final String XML_CONTAINS_TARGET = "ContainsTarget";
|
||||
private static final String XML_TERM_ATT = "Term";
|
||||
private static final String XML_QUALIFIER_ATT = "Qualifier";
|
||||
private static final String XML_PROPERTY_Value = "PropertyValue";
|
||||
private static final String XML_PROPERTY_VALUE = "PropertyValue";
|
||||
private static final String XML_BASE_TERM = "BaseTerm";
|
||||
private static final String XML_APPLIES_TO = "AppliesTo";
|
||||
|
||||
|
@ -455,7 +455,7 @@ public class MetadataDocumentXmlSerializer {
|
|||
writer.writeAttribute(XML_TYPE, getAliasedFullQualifiedName(type, false));
|
||||
}
|
||||
for (EdmPropertyValue propValue : asRecord.getPropertyValues()) {
|
||||
writer.writeStartElement(XML_PROPERTY_Value);
|
||||
writer.writeStartElement(XML_PROPERTY_VALUE);
|
||||
writer.writeAttribute(XML_PROPERTY, propValue.getProperty());
|
||||
appendExpression(writer, propValue.getValue());
|
||||
appendAnnotations(writer, propValue);
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
@ -55,7 +55,7 @@ public class ServiceDocumentXmlSerializer {
|
|||
public void writeServiceDocument(final XMLStreamWriter writer) throws XMLStreamException {
|
||||
final String metadataUri =
|
||||
(serviceRoot == null ? "" : serviceRoot.endsWith("/") ? serviceRoot : (serviceRoot + "/"))
|
||||
+ Constants.METADATA;
|
||||
+ Constants.METADATA;
|
||||
|
||||
writer.writeStartDocument(ODataSerializer.DEFAULT_CHARSET, "1.0");
|
||||
writer.writeStartElement(APP, "service", NS_APP);
|
||||
|
@ -74,14 +74,16 @@ public class ServiceDocumentXmlSerializer {
|
|||
writer.writeStartElement(APP, "workspace", NS_APP);
|
||||
|
||||
final EdmEntityContainer container = metadata.getEdm().getEntityContainer();
|
||||
writer.writeStartElement(ATOM, Constants.ATOM_ELEM_TITLE, NS_ATOM);
|
||||
writer.writeCharacters(container.getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
writer.writeEndElement();
|
||||
if (container != null) {
|
||||
writer.writeStartElement(ATOM, Constants.ATOM_ELEM_TITLE, NS_ATOM);
|
||||
writer.writeCharacters(container.getFullQualifiedName().getFullQualifiedNameAsString());
|
||||
writer.writeEndElement();
|
||||
|
||||
writeEntitySets(writer, container);
|
||||
writeFunctionImports(writer, container);
|
||||
writeSingletons(writer, container);
|
||||
writeServiceDocuments(writer);
|
||||
writeEntitySets(writer, container);
|
||||
writeFunctionImports(writer, container);
|
||||
writeSingletons(writer, container);
|
||||
writeServiceDocuments(writer);
|
||||
}
|
||||
writer.writeEndElement(); // end workspace
|
||||
writer.writeEndElement(); // end service
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
@ -58,8 +58,10 @@ public class UriInfoImpl implements UriInfo {
|
|||
|
||||
private UriInfoKind kind;
|
||||
|
||||
private List<String> entitySetNames = new ArrayList<String>(); // for $entity
|
||||
private EdmEntityType entityTypeCast; // for $entity
|
||||
// for $entity
|
||||
private List<String> entitySetNames = new ArrayList<String>();
|
||||
// for $entity
|
||||
private EdmEntityType entityTypeCast;
|
||||
|
||||
private UriResource lastResourcePart;
|
||||
private List<UriResource> pathParts = new ArrayList<UriResource>();
|
||||
|
@ -175,12 +177,12 @@ public class UriInfoImpl implements UriInfo {
|
|||
* or an option of this kind has been added before
|
||||
*/
|
||||
public UriInfoImpl setSystemQueryOption(final SystemQueryOption systemOption) {
|
||||
final SystemQueryOptionKind kind = systemOption.getKind();
|
||||
if (systemQueryOptions.containsKey(kind)) {
|
||||
final SystemQueryOptionKind systemQueryOptionKind = systemOption.getKind();
|
||||
if (systemQueryOptions.containsKey(systemQueryOptionKind)) {
|
||||
throw new ODataRuntimeException("Double System Query Option: " + systemOption.getName());
|
||||
}
|
||||
|
||||
switch (kind) {
|
||||
switch (systemQueryOptionKind) {
|
||||
case EXPAND:
|
||||
case FILTER:
|
||||
case FORMAT:
|
||||
|
@ -193,7 +195,7 @@ public class UriInfoImpl implements UriInfo {
|
|||
case SKIPTOKEN:
|
||||
case TOP:
|
||||
case LEVELS:
|
||||
systemQueryOptions.put(kind, systemOption);
|
||||
systemQueryOptions.put(systemQueryOptionKind, systemOption);
|
||||
break;
|
||||
default:
|
||||
throw new ODataRuntimeException("Unsupported System Query Option: " + systemOption.getName());
|
||||
|
|
|
@ -45,7 +45,7 @@ public class UriResourceComplexPropertyImpl extends UriResourceTypedImpl impleme
|
|||
|
||||
@Override
|
||||
public EdmComplexType getComplexTypeFilter() {
|
||||
return (EdmComplexType) typeFilter;
|
||||
return (EdmComplexType) getTypeFilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
@ -25,7 +25,7 @@ import org.apache.olingo.server.api.uri.UriResourceKind;
|
|||
* Abstract class for resource-path elements in URI.
|
||||
*/
|
||||
public abstract class UriResourceImpl implements UriResource {
|
||||
protected UriResourceKind kind;
|
||||
private final UriResourceKind kind;
|
||||
|
||||
public UriResourceImpl(final UriResourceKind kind) {
|
||||
this.kind = kind;
|
||||
|
|
|
@ -40,7 +40,7 @@ public class UriResourceSingletonImpl extends UriResourceTypedImpl implements Ur
|
|||
|
||||
@Override
|
||||
public EdmEntityType getEntityTypeFilter() {
|
||||
return (EdmEntityType) typeFilter;
|
||||
return (EdmEntityType) getTypeFilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.apache.olingo.server.core.uri;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.EdmType;
|
||||
import org.apache.olingo.server.api.uri.UriResourceKind;
|
||||
|
||||
public class UriResourceStartingTypeFilterImpl extends UriResourceWithKeysImpl {
|
||||
|
||||
|
@ -32,11 +31,6 @@ public class UriResourceStartingTypeFilterImpl extends UriResourceWithKeysImpl {
|
|||
this.isCollection = isCollection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UriResourceKind getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmType getType() {
|
||||
return type;
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.olingo.server.api.uri.UriResourcePartTyped;
|
|||
|
||||
public abstract class UriResourceTypedImpl extends UriResourceImpl implements UriResourcePartTyped {
|
||||
|
||||
protected EdmType typeFilter = null;
|
||||
private EdmType typeFilter = null;
|
||||
|
||||
public UriResourceTypedImpl(final UriResourceKind kind) {
|
||||
super(kind);
|
||||
|
|
|
@ -28,9 +28,9 @@ import org.apache.olingo.server.api.uri.UriResourcePartTyped;
|
|||
|
||||
public abstract class UriResourceWithKeysImpl extends UriResourceImpl implements UriResourcePartTyped {
|
||||
|
||||
protected EdmType collectionTypeFilter = null;
|
||||
private EdmType collectionTypeFilter = null;
|
||||
protected List<UriParameter> keyPredicates = null;
|
||||
protected EdmType entryTypeFilter = null;
|
||||
private EdmType entryTypeFilter = null;
|
||||
|
||||
public UriResourceWithKeysImpl(final UriResourceKind kind) {
|
||||
super(kind);
|
||||
|
|
|
@ -316,7 +316,7 @@ public class ResourcePathParser {
|
|||
}
|
||||
|
||||
private void requireTyped(final UriResource previous, final String forWhat) throws UriParserException {
|
||||
if (previous == null || !(previous instanceof UriResourcePartTyped)) {
|
||||
if (!(previous instanceof UriResourcePartTyped)) {
|
||||
throw new UriParserSemanticException("Path segment before '" + forWhat + "' is not typed.",
|
||||
UriParserSemanticException.MessageKeys.PREVIOUS_PART_NOT_TYPED, forWhat);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,8 @@ public class SearchParser {
|
|||
private SearchExpression processExprAnd(UriTokenizer tokenizer) throws SearchParserException {
|
||||
SearchExpression left = processTerm(tokenizer);
|
||||
|
||||
while (tokenizer.next(TokenKind.AndOperatorSearch)) { // Could be whitespace or whitespace-surrounded 'AND'.
|
||||
while (tokenizer.next(TokenKind.AndOperatorSearch)) {
|
||||
// Could be whitespace or whitespace-surrounded 'AND'.
|
||||
final SearchExpression right = processTerm(tokenizer);
|
||||
left = new SearchBinaryImpl(left, SearchBinaryOperatorKind.AND, right);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
|
|||
|
||||
public class ExpandOptionImpl extends SystemQueryOptionImpl implements ExpandOption {
|
||||
|
||||
List<ExpandItem> expandItems = new ArrayList<ExpandItem>();
|
||||
private final List<ExpandItem> expandItems = new ArrayList<ExpandItem>();
|
||||
|
||||
public ExpandOptionImpl() {
|
||||
setKind(SystemQueryOptionKind.EXPAND);
|
||||
|
@ -42,5 +42,4 @@ public class ExpandOptionImpl extends SystemQueryOptionImpl implements ExpandOpt
|
|||
public List<ExpandItem> getExpandItems() {
|
||||
return Collections.unmodifiableList(expandItems);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
@ -24,7 +24,8 @@ import org.apache.olingo.server.api.uri.queryoption.expression.Expression;
|
|||
public class OrderByItemImpl implements OrderByItem {
|
||||
|
||||
private Expression expression;
|
||||
private boolean descending = false; // default sort order is ascending
|
||||
// default sort order is ascending
|
||||
private boolean descending = false;
|
||||
|
||||
@Override
|
||||
public boolean isDescending() {
|
||||
|
|
|
@ -55,11 +55,7 @@ public class SelectItemImpl implements SelectItem {
|
|||
|
||||
@Override
|
||||
public boolean isAllOperationsInSchema() {
|
||||
if (addOperationsInSchemaNameSpace == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return addOperationsInSchemaNameSpace != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,9 +62,9 @@ public class BinaryImpl implements Binary {
|
|||
|
||||
@Override
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
|
||||
T left = this.left.accept(visitor);
|
||||
T right = this.right.accept(visitor);
|
||||
return visitor.visitBinaryOperator(operator, left, right);
|
||||
T localLeft = this.left.accept(visitor);
|
||||
T localRight = this.right.accept(visitor);
|
||||
return visitor.visitBinaryOperator(operator, localLeft, localRight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
@ -96,7 +96,8 @@ public class MethodImpl implements Method {
|
|||
case ROUND:
|
||||
case FLOOR:
|
||||
case CEILING:
|
||||
kind = EdmPrimitiveTypeKind.Double; // Needs to be refined if Decimal must be distinguished from Double.
|
||||
// Needs to be refined if Decimal must be distinguished from Double.
|
||||
kind = EdmPrimitiveTypeKind.Double;
|
||||
break;
|
||||
case GEODISTANCE:
|
||||
case GEOLENGTH:
|
||||
|
|
|
@ -103,7 +103,7 @@ public class UriValidator {
|
|||
}
|
||||
}
|
||||
|
||||
private static Map<SystemQueryOptionKind, Integer> OPTION_INDEX;
|
||||
private static final Map<SystemQueryOptionKind, Integer> OPTION_INDEX;
|
||||
static {
|
||||
Map<SystemQueryOptionKind, Integer> temp =
|
||||
new EnumMap<SystemQueryOptionKind, Integer>(SystemQueryOptionKind.class);
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
|||
import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
|
||||
import org.apache.olingo.commons.api.ex.ODataException;
|
||||
import org.apache.olingo.commons.api.format.AcceptType;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||
|
|
|
@ -37,7 +37,6 @@ import java.util.List;
|
|||
import org.apache.olingo.commons.api.Constants;
|
||||
import org.apache.olingo.commons.api.data.ComplexValue;
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
import org.apache.olingo.commons.api.data.EntityCollection;
|
||||
import org.apache.olingo.commons.api.data.Link;
|
||||
import org.apache.olingo.commons.api.data.Property;
|
||||
import org.apache.olingo.commons.api.data.ValueType;
|
||||
|
|
|
@ -23,13 +23,19 @@ import java.util.List;
|
|||
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
||||
import org.apache.olingo.commons.api.edm.EdmType;
|
||||
import org.apache.olingo.server.api.ODataApplicationException;
|
||||
import org.apache.olingo.server.api.uri.UriInfoResource;
|
||||
import org.apache.olingo.server.api.uri.UriResource;
|
||||
import org.apache.olingo.server.api.uri.UriResourceLambdaAll;
|
||||
import org.apache.olingo.server.api.uri.UriResourceLambdaAny;
|
||||
import org.apache.olingo.server.api.uri.UriResourcePartTyped;
|
||||
import org.apache.olingo.server.api.uri.queryoption.FilterOption;
|
||||
import org.apache.olingo.server.api.uri.queryoption.expression.*;
|
||||
import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
|
||||
import org.apache.olingo.server.api.uri.queryoption.expression.Expression;
|
||||
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor;
|
||||
import org.apache.olingo.server.api.uri.queryoption.expression.Literal;
|
||||
import org.apache.olingo.server.api.uri.queryoption.expression.Member;
|
||||
import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
|
||||
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind;
|
||||
|
||||
public class FilterTreeToText implements ExpressionVisitor<String> {
|
||||
|
||||
|
|
Loading…
Reference in New Issue