[OLINGO-1391]OData V4: Move the olingo library to java 8

This commit is contained in:
ramya vasanth 2019-09-04 09:17:51 +05:30
parent 7632ec7268
commit 9f8cbc6fcc
6 changed files with 57 additions and 29 deletions

View File

@ -601,8 +601,13 @@ public class ODataDispatcher {
validateIsSingleton(method); validateIsSingleton(method);
validatePreconditions(request, false); validatePreconditions(request, false);
validatePreferHeader(request); validatePreferHeader(request);
handler.selectProcessor(isMedia ? MediaEntityProcessor.class : EntityProcessor.class) if (isMedia) {
.deleteEntity(request, response, uriInfo); ((MediaEntityProcessor) handler.selectProcessor(MediaEntityProcessor.class))
.deleteEntity(request, response, uriInfo);
} else {
((EntityProcessor) handler.selectProcessor(EntityProcessor.class))
.deleteEntity(request, response, uriInfo);
}
} else { } else {
throwMethodNotAllowed(method); throwMethodNotAllowed(method);
} }

View File

@ -100,12 +100,19 @@ public class FixedFormatDeserializerImpl implements FixedFormatDeserializer {
result.setType(type.getFullQualifiedName().getFullQualifiedNameAsString()); result.setType(type.getFullQualifiedName().getFullQualifiedNameAsString());
final EdmPrimitiveType primitiveType = (EdmPrimitiveType) type; final EdmPrimitiveType primitiveType = (EdmPrimitiveType) type;
try { try {
result.setValue(type.getKind() == EdmTypeKind.ENUM ? ValueType.ENUM : ValueType.PRIMITIVE, if (parameter.getMapping() == null) {
primitiveType.valueOfString(primitiveType.fromUriLiteral(content), result.setValue(type.getKind() == EdmTypeKind.ENUM ? ValueType.ENUM : ValueType.PRIMITIVE,
parameter.isNullable(), parameter.getMaxLength(), parameter.getPrecision(), parameter.getScale(), true, primitiveType.valueOfString(primitiveType.fromUriLiteral(content),
parameter.getMapping() == null ? parameter.isNullable(), parameter.getMaxLength(),
primitiveType.getDefaultType() : parameter.getPrecision(), parameter.getScale(), true,
parameter.getMapping().getMappedJavaClass())); primitiveType.getDefaultType()));
} else {
result.setValue(type.getKind() == EdmTypeKind.ENUM ? ValueType.ENUM : ValueType.PRIMITIVE,
primitiveType.valueOfString(primitiveType.fromUriLiteral(content),
parameter.isNullable(), parameter.getMaxLength(),
parameter.getPrecision(), parameter.getScale(), true,
parameter.getMapping().getMappedJavaClass()));
}
} catch (final EdmPrimitiveTypeException e) { } catch (final EdmPrimitiveTypeException e) {
throw new DeserializerException( throw new DeserializerException(
"Invalid value '" + content + "' for parameter " + parameter.getName(), e, "Invalid value '" + content + "' for parameter " + parameter.getName(), e,

View File

@ -619,12 +619,15 @@ public class ParserHelper {
parseAliasValue(parameter.getAlias(), parseAliasValue(parameter.getAlias(),
edmParameter.getType(), edmParameter.isNullable(), edmParameter.isCollection(), edmParameter.getType(), edmParameter.isNullable(), edmParameter.isCollection(),
edm, type, aliases).getText() : null; edm, type, aliases).getText() : null;
primitiveType.valueOfString(primitiveType.fromUriLiteral(text), if (edmParameter.getMapping() == null) {
edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(), primitiveType.valueOfString(primitiveType.fromUriLiteral(text),
edmParameter.getScale(), true, edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(),
edmParameter.getMapping() == null ? edmParameter.getScale(), true, primitiveType.getDefaultType());
primitiveType.getDefaultType() : } else {
edmParameter.getMapping().getMappedJavaClass()); primitiveType.valueOfString(primitiveType.fromUriLiteral(text),
edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(),
edmParameter.getScale(), true, edmParameter.getMapping().getMappedJavaClass());
}
} catch (final EdmPrimitiveTypeException e) { } catch (final EdmPrimitiveTypeException e) {
throw new UriValidationException( throw new UriValidationException(
"Invalid value '" + text + "' for parameter " + parameter.getName(), e, "Invalid value '" + text + "' for parameter " + parameter.getName(), e,

View File

@ -143,11 +143,17 @@ public class DataProvider {
throw new DataProviderException("Expression in key value is not supported yet!", throw new DataProviderException("Expression in key value is not supported yet!",
HttpStatusCode.NOT_IMPLEMENTED); HttpStatusCode.NOT_IMPLEMENTED);
} }
Object keyValue = null;
final String text = key.getAlias() == null ? key.getText() : ((Literal) key.getExpression()).getText(); final String text = key.getAlias() == null ? key.getText() : ((Literal) key.getExpression()).getText();
final Object keyValue = type.valueOfString(type.fromUriLiteral(text), if (Calendar.class.isAssignableFrom(value.getClass())) {
property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(), keyValue = type.valueOfString(type.fromUriLiteral(text),
property.isUnicode(), property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
Calendar.class.isAssignableFrom(value.getClass()) ? Calendar.class : value.getClass()); property.isUnicode(), Calendar.class);
} else {
keyValue = type.valueOfString(type.fromUriLiteral(text),
property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
property.isUnicode(), value.getClass());
}
if (!value.equals(keyValue)) { if (!value.equals(keyValue)) {
found = false; found = false;
break; break;
@ -958,10 +964,16 @@ public class DataProvider {
HttpStatusCode.NOT_IMPLEMENTED); HttpStatusCode.NOT_IMPLEMENTED);
} }
final String text = key.getAlias() == null ? key.getText() : ((Literal) key.getExpression()).getText(); final String text = key.getAlias() == null ? key.getText() : ((Literal) key.getExpression()).getText();
final Object keyValue = type.valueOfString(type.fromUriLiteral(text), Object keyValue = null;
property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(), if (Calendar.class.isAssignableFrom(value.getClass())) {
property.isUnicode(), keyValue = type.valueOfString(type.fromUriLiteral(text),
Calendar.class.isAssignableFrom(value.getClass()) ? Calendar.class : value.getClass()); property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
property.isUnicode(), Calendar.class);
} else {
keyValue = type.valueOfString(type.fromUriLiteral(text),
property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
property.isUnicode(), value.getClass());
}
if (!value.equals(keyValue)) { if (!value.equals(keyValue)) {
found = false; found = false;
break; break;

12
pom.xml
View File

@ -104,7 +104,7 @@
<!-- Project build settings --> <!-- Project build settings -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.source>1.6</project.build.source> <project.build.source>1.8</project.build.source>
<olingo.deploy.skip>true</olingo.deploy.skip> <olingo.deploy.skip>true</olingo.deploy.skip>
<!-- Setting needed for Java 8 release builds --> <!-- Setting needed for Java 8 release builds -->
@ -330,12 +330,12 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<version>2.12.1</version> <version>3.1.0</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version> <version>3.8.1</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -514,13 +514,15 @@
</goals> </goals>
</execution> </execution>
</executions> </executions>
<configuration> <configuration combine.self="override">
<outputFileFormat>xml</outputFileFormat> <outputFileFormat>xml</outputFileFormat>
<consoleOutput>true</consoleOutput> <consoleOutput>true</consoleOutput>
<enableRSS>false</enableRSS> <enableRSS>false</enableRSS>
<linkXRef>false</linkXRef> <linkXRef>false</linkXRef>
<configLocation>src/checkstyle/config.xml</configLocation> <configLocation>src/checkstyle/config.xml</configLocation>
<sourceDirectory>${basedir}/src</sourceDirectory> <sourceDirectories>
<sourceDirectory>${basedir}/src</sourceDirectory>
</sourceDirectories>
<encoding>${project.build.sourceEncoding}</encoding> <encoding>${project.build.sourceEncoding}</encoding>
<failOnViolation>true</failOnViolation> <failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity> <violationSeverity>warning</violationSeverity>

View File

@ -29,7 +29,6 @@
<module name="Checker"> <module name="Checker">
<property name="severity" value="warning"/> <property name="severity" value="warning"/>
<module name="TreeWalker"> <module name="TreeWalker">
<module name="FileContentsHolder"/>
<module name="IllegalImport"> <module name="IllegalImport">
<property name="severity" value="info"/> <property name="severity" value="info"/>
<property name="illegalPkgs" value="java.awt, javax.swing"/> <property name="illegalPkgs" value="java.awt, javax.swing"/>
@ -69,6 +68,6 @@
<module name="LineLength"> <module name="LineLength">
<property name="max" value="120"/> <property name="max" value="120"/>
</module> </module>
<module name="SuppressionCommentFilter"/>
</module> </module>
<module name="SuppressionCommentFilter"/>
</module> </module>