[OLINGO-468] Minor code clean up
This commit is contained in:
parent
9e5b284a57
commit
d84f843f22
|
@ -106,7 +106,6 @@ public abstract class AbstractEdm implements Edm {
|
||||||
aliasToNamespaceInfo = new HashMap<String, String>();
|
aliasToNamespaceInfo = new HashMap<String, String>();
|
||||||
for (EdmSchema schema : schemas.values()) {
|
for (EdmSchema schema : schemas.values()) {
|
||||||
final String namespace = schema.getNamespace();
|
final String namespace = schema.getNamespace();
|
||||||
schemas.put(namespace, schema);
|
|
||||||
|
|
||||||
if (schema.getAlias() != null) {
|
if (schema.getAlias() != null) {
|
||||||
aliasToNamespaceInfo.put(schema.getAlias(), namespace);
|
aliasToNamespaceInfo.put(schema.getAlias(), namespace);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.olingo.server.core;
|
package org.apache.olingo.server.core;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
@ -59,7 +60,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
|
||||||
@Override
|
@Override
|
||||||
public void process(final HttpServletRequest request, final HttpServletResponse response) {
|
public void process(final HttpServletRequest request, final HttpServletResponse response) {
|
||||||
ODataRequest odRequest = null;
|
ODataRequest odRequest = null;
|
||||||
ODataResponse odResponse = null;
|
ODataResponse odResponse;
|
||||||
try {
|
try {
|
||||||
odRequest = createODataRequest(request, split);
|
odRequest = createODataRequest(request, split);
|
||||||
odResponse = handler.process(odRequest);
|
odResponse = handler.process(odRequest);
|
||||||
|
@ -99,11 +100,11 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
|
||||||
|
|
||||||
InputStream input = odResponse.getContent();
|
InputStream input = odResponse.getContent();
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
OutputStream output;
|
OutputStream output = null;
|
||||||
try {
|
try {
|
||||||
output = response.getOutputStream();
|
output = response.getOutputStream();
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
int n = 0;
|
int n;
|
||||||
while (-1 != (n = input.read(buffer))) {
|
while (-1 != (n = input.read(buffer))) {
|
||||||
output.write(buffer, 0, n);
|
output.write(buffer, 0, n);
|
||||||
}
|
}
|
||||||
|
@ -111,13 +112,18 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
|
||||||
LOG.error(e.getMessage(), e);
|
LOG.error(e.getMessage(), e);
|
||||||
throw new ODataRuntimeException(e);
|
throw new ODataRuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
if (input != null) {
|
closeStream(output);
|
||||||
|
closeStream(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void closeStream(Closeable closeable) {
|
||||||
|
if(closeable != null) {
|
||||||
try {
|
try {
|
||||||
input.close();
|
closeable.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ODataRuntimeException(e);
|
LOG.error(e.getMessage(), e);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,9 +156,9 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
|
||||||
|
|
||||||
if (xHttpMethod == null && xHttpMethodOverride == null) {
|
if (xHttpMethod == null && xHttpMethodOverride == null) {
|
||||||
odRequest.setMethod(httpRequestMethod);
|
odRequest.setMethod(httpRequestMethod);
|
||||||
} else if (xHttpMethod == null && xHttpMethodOverride != null) {
|
} else if (xHttpMethod == null) {
|
||||||
odRequest.setMethod(HttpMethod.valueOf(xHttpMethodOverride));
|
odRequest.setMethod(HttpMethod.valueOf(xHttpMethodOverride));
|
||||||
} else if (xHttpMethod != null && xHttpMethodOverride == null) {
|
} else if (xHttpMethodOverride == null) {
|
||||||
odRequest.setMethod(HttpMethod.valueOf(xHttpMethod));
|
odRequest.setMethod(HttpMethod.valueOf(xHttpMethod));
|
||||||
} else {
|
} else {
|
||||||
if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
|
if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
|
||||||
|
|
Loading…
Reference in New Issue