[OLINGO-1191] Code Improvements
This commit is contained in:
parent
003f0f4ffa
commit
6bdaed4875
|
@ -80,7 +80,8 @@ public final class ODataErrorResponseChecker {
|
||||||
statusLine.getReasonPhrase());
|
statusLine.getReasonPhrase());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusLine.getStatusCode() >= 500 && (error.getDetails() == null || error.getDetails().isEmpty()) &&
|
if (statusLine.getStatusCode() >= 500 && error!= null &&
|
||||||
|
(error.getDetails() == null || error.getDetails().isEmpty()) &&
|
||||||
(error.getInnerError() == null || error.getInnerError().size() == 0)) {
|
(error.getInnerError() == null || error.getInnerError().size() == 0)) {
|
||||||
result = new ODataServerErrorException(statusLine);
|
result = new ODataServerErrorException(statusLine);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -137,7 +137,7 @@ public class ODataBatchUtilities {
|
||||||
|
|
||||||
notEndLine = isNotEndLine(controller, currentLine);
|
notEndLine = isNotEndLine(controller, currentLine);
|
||||||
|
|
||||||
if (notEndLine && os != null) {
|
if (notEndLine && os != null && currentLine!=null) {
|
||||||
os.write(currentLine.getBytes(Constants.UTF8));
|
os.write(currentLine.getBytes(Constants.UTF8));
|
||||||
os.write(ODataStreamer.CRLF);
|
os.write(ODataStreamer.CRLF);
|
||||||
}
|
}
|
||||||
|
@ -256,11 +256,14 @@ public class ODataBatchUtilities {
|
||||||
public static Map.Entry<Integer, String> readResponseLine(final ODataBatchLineIterator iterator) {
|
public static Map.Entry<Integer, String> readResponseLine(final ODataBatchLineIterator iterator) {
|
||||||
final String line = readBatchPart(new ODataBatchController(iterator, null), 1);
|
final String line = readBatchPart(new ODataBatchController(iterator, null), 1);
|
||||||
LOG.debug("Response line '{}'", line);
|
LOG.debug("Response line '{}'", line);
|
||||||
|
|
||||||
|
if(line !=null){
|
||||||
|
|
||||||
final Matcher matcher = RESPONSE_PATTERN.matcher(line.trim());
|
final Matcher matcher = RESPONSE_PATTERN.matcher(line.trim());
|
||||||
|
|
||||||
if (matcher.matches()) {
|
if (matcher.matches()) {
|
||||||
return new AbstractMap.SimpleEntry<Integer, String>(Integer.valueOf(matcher.group(1)), matcher.group(2));
|
return new AbstractMap.SimpleEntry<Integer, String>(Integer.valueOf(matcher.group(1)), matcher.group(2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalArgumentException("Invalid response line '" + line + "'");
|
throw new IllegalArgumentException("Invalid response line '" + line + "'");
|
||||||
|
|
|
@ -19,10 +19,8 @@
|
||||||
package org.apache.olingo.client.core.metadatavalidator;
|
package org.apache.olingo.client.core.metadatavalidator;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||||
|
|
|
@ -35,10 +35,12 @@ public class FilterFunction implements FilterArg {
|
||||||
@Override
|
@Override
|
||||||
public String build() {
|
public String build() {
|
||||||
final String[] strParams = params == null || params.length == 0 ? new String[0] : new String[params.length];
|
final String[] strParams = params == null || params.length == 0 ? new String[0] : new String[params.length];
|
||||||
for (int i = 0; i < strParams.length; i++) {
|
if(params !=null){
|
||||||
strParams[i] = params[i].build();
|
for (int i = 0; i < strParams.length; i++) {
|
||||||
|
strParams[i] = params[i].build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StringBuilder(function).
|
return new StringBuilder(function).
|
||||||
append('(').
|
append('(').
|
||||||
append(strParams.length == 0 ? StringUtils.EMPTY : StringUtils.join(strParams, ',')).
|
append(strParams.length == 0 ? StringUtils.EMPTY : StringUtils.join(strParams, ',')).
|
||||||
|
|
|
@ -63,8 +63,10 @@ public class DebugTabStacktrace implements DebugTab {
|
||||||
|
|
||||||
gen.writeFieldName("stacktrace");
|
gen.writeFieldName("stacktrace");
|
||||||
gen.writeStartArray();
|
gen.writeStartArray();
|
||||||
for (final StackTraceElement stackTraceElement : exception.getStackTrace()) {
|
if(exception != null){
|
||||||
appendJsonStackTraceElement(gen, stackTraceElement);
|
for (final StackTraceElement stackTraceElement : exception.getStackTrace()) {
|
||||||
|
appendJsonStackTraceElement(gen, stackTraceElement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gen.writeEndArray();
|
gen.writeEndArray();
|
||||||
|
|
||||||
|
|
|
@ -71,12 +71,13 @@ public class ServiceDocumentJsonSerializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
gen.writeArrayFieldStart(Constants.VALUE);
|
gen.writeArrayFieldStart(Constants.VALUE);
|
||||||
|
if(metadata != null){
|
||||||
final EdmEntityContainer container = metadata.getEdm().getEntityContainer();
|
final EdmEntityContainer container = metadata.getEdm().getEntityContainer();
|
||||||
if (container != null) {
|
if (container != null) {
|
||||||
writeEntitySets(gen, container);
|
writeEntitySets(gen, container);
|
||||||
writeFunctionImports(gen, container);
|
writeFunctionImports(gen, container);
|
||||||
writeSingletons(gen, container);
|
writeSingletons(gen, container);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue