[OLINGO-750] Fixed some critical issues
This commit is contained in:
parent
524dbebc4a
commit
637ca00db7
|
@ -21,6 +21,7 @@ package org.apache.olingo.client.core.communication.request;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.ODataStreamer;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -87,7 +88,7 @@ public abstract class AbstractODataStreamer implements ODataStreamer {
|
|||
|
||||
public Writer(final byte[] src, final OutputStream os) {
|
||||
this.os = os;
|
||||
this.src = src;
|
||||
this.src = Arrays.copyOf(src, src.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -61,8 +61,6 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
|
|||
import org.apache.olingo.commons.core.edm.primitivetype.EdmInt64;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmSingle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* URI utilities.
|
||||
|
@ -72,7 +70,7 @@ public final class URIUtils {
|
|||
/**
|
||||
* Logger.
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(URIUtils.class);
|
||||
// private static final Logger LOG = LoggerFactory.getLogger(URIUtils.class);
|
||||
|
||||
private static final Pattern ENUM_VALUE = Pattern.compile("(.+\\.)?.+'.+'");
|
||||
|
||||
|
@ -262,13 +260,8 @@ public final class URIUtils {
|
|||
: obj.toString();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.warn("While escaping '{}', using getName()", obj, e);
|
||||
if (obj == null) {
|
||||
value = "null";
|
||||
} else {
|
||||
value = obj.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
@ -298,7 +291,7 @@ public final class URIUtils {
|
|||
bytes = IOUtils.toByteArray(input);
|
||||
IOUtils.closeQuietly(input);
|
||||
} catch (IOException e) {
|
||||
LOG.error("While reading input for not chunked encoding", e);
|
||||
throw new RuntimeException("While reading input for not chunked encoding", e);
|
||||
}
|
||||
|
||||
entity = new ByteArrayEntity(bytes);
|
||||
|
@ -307,7 +300,6 @@ public final class URIUtils {
|
|||
}
|
||||
|
||||
if (!useChunked && entity.getContentLength() < 0) {
|
||||
LOG.error("Could not determine length - request will be sent as chunked.");
|
||||
useChunked = true;
|
||||
}
|
||||
// both entities can be sent in chunked way or not
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.olingo.server.core;
|
|||
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
@ -33,6 +33,7 @@ import javax.xml.stream.events.StartElement;
|
|||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.edm.geo.SRID;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlAction;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlActionImport;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlComplexType;
|
||||
|
@ -74,7 +75,7 @@ public class MetadataParser {
|
|||
void build(XMLEventReader reader, StartElement element, SchemaBasedEdmProvider provider,
|
||||
String name) throws XMLStreamException {
|
||||
String version = attr(element, "Version");
|
||||
if (version.equals("4.0")) {
|
||||
if ("4.0".equals(version)) {
|
||||
readDataServicesAndReference(reader, element, provider);
|
||||
}
|
||||
}
|
||||
|
@ -140,10 +141,9 @@ public class MetadataParser {
|
|||
throws XMLStreamException {
|
||||
if (name.equals("Action")) {
|
||||
readAction(reader, element, schema);
|
||||
} else if (name.equals("Annotations")) {
|
||||
// TODO:
|
||||
} else if (name.equals("Annotation")) {
|
||||
// TODO:
|
||||
// } else if (name.equals("Annotations")) {
|
||||
// } else if (name.equals("Annotation")) {
|
||||
// TODO: Add support for annotations
|
||||
} else if (name.equals("ComplexType")) {
|
||||
readComplexType(reader, element, schema);
|
||||
} else if (name.equals("EntityContainer")) {
|
||||
|
@ -182,7 +182,7 @@ public class MetadataParser {
|
|||
|
||||
private FullQualifiedName readType(StartElement element) {
|
||||
String type = attr(element, "Type");
|
||||
if (type.startsWith("Collection(") && type.endsWith(")")) {
|
||||
if (type != null && type.startsWith("Collection(") && type.endsWith(")")) {
|
||||
return new FullQualifiedName(type.substring(11, type.length() - 1));
|
||||
}
|
||||
return new FullQualifiedName(type);
|
||||
|
@ -190,7 +190,7 @@ public class MetadataParser {
|
|||
|
||||
private boolean isCollectionType(StartElement element) {
|
||||
String type = attr(element, "Type");
|
||||
if (type.startsWith("Collection(") && type.endsWith(")")) {
|
||||
if (type != null && type.startsWith("Collection(") && type.endsWith(")")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -217,6 +217,7 @@ public class MetadataParser {
|
|||
String srid = attr(element, "SRID");
|
||||
if (srid != null) {
|
||||
// TODO: no olingo support yet.
|
||||
returnType.setSrid(SRID.valueOf(srid));
|
||||
}
|
||||
operation.setReturnType(returnType);
|
||||
}
|
||||
|
@ -243,6 +244,7 @@ public class MetadataParser {
|
|||
String srid = attr(element, "SRID");
|
||||
if (srid != null) {
|
||||
// TODO: no olingo support yet.
|
||||
parameter.setSrid(SRID.valueOf(srid));
|
||||
}
|
||||
operation.getParameters().add(parameter);
|
||||
}
|
||||
|
@ -268,6 +270,7 @@ public class MetadataParser {
|
|||
String srid = attr(element, "SRID");
|
||||
if (srid != null) {
|
||||
// TODO: no olingo support yet.
|
||||
td.setSrid(SRID.valueOf(srid));
|
||||
}
|
||||
return td;
|
||||
}
|
||||
|
@ -283,7 +286,7 @@ public class MetadataParser {
|
|||
term.setDefaultValue(attr(element, "DefaultValue"));
|
||||
}
|
||||
if (attr(element, "AppliesTo") != null) {
|
||||
term.setAppliesTo(Arrays.asList(attr(element, "AppliesTo")));
|
||||
term.setAppliesTo(Collections.singletonList(attr(element, "AppliesTo")));
|
||||
}
|
||||
term.setNullable(Boolean.parseBoolean(attr(element, "Nullable")));
|
||||
String maxLength = attr(element, "MaxLength");
|
||||
|
@ -301,6 +304,7 @@ public class MetadataParser {
|
|||
String srid = attr(element, "SRID");
|
||||
if (srid != null) {
|
||||
// TODO: no olingo support yet.
|
||||
term.setSrid(SRID.valueOf(srid));
|
||||
}
|
||||
return term;
|
||||
}
|
||||
|
@ -473,6 +477,7 @@ public class MetadataParser {
|
|||
String srid = attr(element, "SRID");
|
||||
if (srid != null) {
|
||||
// TODO: no olingo support yet.
|
||||
property.setSrid(SRID.valueOf(srid));
|
||||
}
|
||||
String defaultValue = attr(element, "DefaultValue");
|
||||
if (defaultValue != null) {
|
||||
|
@ -570,7 +575,6 @@ public class MetadataParser {
|
|||
}
|
||||
|
||||
}.read(reader, element, bindings, "NavigationPropertyBinding");
|
||||
;
|
||||
}
|
||||
}.read(reader, element, schema, "EntitySet", "Singleton", "ActionImport", "FunctionImport");
|
||||
schema.setEntityContainer(container);
|
||||
|
@ -622,19 +626,19 @@ public class MetadataParser {
|
|||
|
||||
boolean hit = false;
|
||||
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
for (String name : names) {
|
||||
if (event.isStartElement()) {
|
||||
element = event.asStartElement();
|
||||
if (element.getName().getLocalPart().equals(names[i])) {
|
||||
if (element.getName().getLocalPart().equals(name)) {
|
||||
reader.nextEvent(); // advance cursor
|
||||
// System.out.println("reading = "+names[i]);
|
||||
build(reader, element, t, names[i]);
|
||||
build(reader, element, t, name);
|
||||
hit = true;
|
||||
}
|
||||
}
|
||||
if (event.isEndElement()) {
|
||||
EndElement e = event.asEndElement();
|
||||
if (e.getName().getLocalPart().equals(names[i])) {
|
||||
if (e.getName().getLocalPart().equals(name)) {
|
||||
reader.nextEvent(); // advance cursor
|
||||
// System.out.println("done reading = "+names[i]);
|
||||
hit = true;
|
||||
|
|
|
@ -752,16 +752,6 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
|
|||
isNullable, maxLength, precision, scale, isUnicode);
|
||||
if (value == null) {
|
||||
writer.writeAttribute(DATA, NS_DATA, "null", "true");
|
||||
} else if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Byte)
|
||||
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean)
|
||||
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Decimal)
|
||||
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Double)
|
||||
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int16)
|
||||
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32)
|
||||
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int64)
|
||||
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.SByte)
|
||||
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Single)) {
|
||||
writer.writeCharacters(value);
|
||||
} else {
|
||||
writer.writeCharacters(value);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import java.nio.channels.Channels;
|
|||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -73,7 +74,7 @@ public class AsyncProcessor<T extends Processor> {
|
|||
public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
|
||||
if (Processor.class.isAssignableFrom(method.getDeclaringClass())) {
|
||||
invokeMethod = method;
|
||||
invokeParameters = objects;
|
||||
invokeParameters = Arrays.copyOf(objects, objects.length);
|
||||
} else {
|
||||
throw new ODataRuntimeException("Invalid class '" + method.getDeclaringClass() +
|
||||
"' can not wrapped for asynchronous processing.");
|
||||
|
|
Loading…
Reference in New Issue