Skip to content
Open

jee9 #32

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ OData + Rest + Java ==> shake it ==> o-re-va (that's it, no other meaning behi
This is complete fork of OData4J for the use of Teiid, but I guess anybody who wants to implement OData V2 can use it.

There is no support JPA or JDBC in this version. I always thought they polluted the OData framework, they do not belong in
the core project. The frameworks needs to be about OData. JPA or JDBC can be additional modules.
the core project. The frameworks needs to be about OData. JPA or JDBC can be additional modules.

## Install with
$ mvn install -P release
24 changes: 24 additions & 0 deletions odata-core/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
Expand All @@ -29,5 +30,28 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
10 changes: 5 additions & 5 deletions odata-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
<version>${jsr311.version}</version>
</dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>${jakartawsrs.version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
Expand All @@ -48,7 +48,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import java.util.List;

import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.Response.StatusType;
import jakarta.ws.rs.core.Response.Status;
import jakarta.ws.rs.core.Response.StatusType;

import org.core4j.Enumerable;
import org.odata4j.core.OEntities;
Expand All @@ -25,7 +25,8 @@
import org.odata4j.stax2.XMLEventReader2;

/**
* Useful base class for {@link ODataClient} implementations with common functionality.
* Useful base class for {@link ODataClient} implementations with common
* functionality.
*/
public abstract class AbstractODataClient implements ODataClient {

Expand All @@ -48,7 +49,8 @@ public EdmDataServices getMetadata(ODataClientRequest request) throws ODataProdu

public Iterable<AtomCollectionInfo> getCollections(ODataClientRequest request) throws ODataProducerException {
ODataClientResponse response = doRequest(FormatType.ATOM, request, Status.OK);
Enumerable<AtomCollectionInfo> collections = Enumerable.create(AtomServiceDocumentFormatParser.parseWorkspaces(toXml(response)))
Enumerable<AtomCollectionInfo> collections = Enumerable
.create(AtomServiceDocumentFormatParser.parseWorkspaces(toXml(response)))
.selectMany(AtomWorkspaceInfo.GET_COLLECTIONS);
response.close();
return collections;
Expand Down Expand Up @@ -98,7 +100,8 @@ public void updateLink(ODataClientRequest request) throws ODataProducerException
doRequest(getFormatType(), request, Status.NO_CONTENT).close();
}

public Entry createRequestEntry(EdmEntitySet entitySet, OEntityKey entityKey, List<OProperty<?>> props, List<OLink> links) {
public Entry createRequestEntry(EdmEntitySet entitySet, OEntityKey entityKey, List<OProperty<?>> props,
List<OLink> links) {
final OEntity entity = entityKey == null
? OEntities.createRequest(entitySet, props, links)
: OEntities.create(entitySet, entityKey, props, links);
Expand All @@ -116,7 +119,8 @@ public OEntity getEntity() {
};
}

protected abstract ODataClientResponse doRequest(FormatType reqType, ODataClientRequest request, StatusType... expectedResponseStatus) throws ODataProducerException;
protected abstract ODataClientResponse doRequest(FormatType reqType, ODataClientRequest request,
StatusType... expectedResponseStatus) throws ODataProducerException;

protected abstract XMLEventReader2 toXml(ODataClientResponse response);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.core4j.Enumerable;
import org.core4j.Func;
import org.core4j.ReadOnlyIterator;
import org.core4j.ReadOnlyIterator.IterationResult;
import org.joda.time.LocalDateTime;
import org.odata4j.core.Guid;
import org.odata4j.core.OCollection;
Expand Down Expand Up @@ -186,10 +187,13 @@ public OFunctionRequest<T> pString(String name, String value) {
private OObject doRequest(ODataClientRequest request) throws ODataProducerException {
ODataClientResponse response = getClient().callFunction(request);

ODataVersion version = InternalUtil.getDataServiceVersion(response.getHeaders().getFirst(ODataConstants.Headers.DATA_SERVICE_VERSION));
ODataVersion version = InternalUtil
.getDataServiceVersion(response.getHeaders().getFirst(ODataConstants.Headers.DATA_SERVICE_VERSION));

Class<? extends OObject> returnTypeClass = function.getReturnType().isSimple() ? OSimpleObject.class
: EdmType.getInstanceType(function.getReturnType());
FormatParser<? extends OObject> parser = FormatParserFactory.getParser(
function.getReturnType().isSimple() ? OSimpleObject.class : EdmType.getInstanceType(function.getReturnType()),
returnTypeClass,
getClient().getFormatType(),
new Settings(
version,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.odata4j.consumer;

import javax.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.MultivaluedMap;

/**
* Generic OData http response used by the low-level {@link ODataClient} api.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MediaType;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
Expand Down
17 changes: 13 additions & 4 deletions odata-core/src/main/java/org/odata4j/core/ODataConstants.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
package org.odata4j.core;

import org.odata4j.core.ODataConstants.Charsets;

/**
* Useful constants.
*/
public class ODataConstants {

private ODataConstants() {}
private ODataConstants() {
}

public static final String TEXT_PLAIN = "text/plain";
public static final String TEXT_PLAIN_CHARSET_UTF8 = TEXT_PLAIN + ";charset=" + Charsets.Lower.UTF_8;

public static final String APPLICATION_ATOM_XML = "application/atom+xml";
public static final String APPLICATION_ATOM_XML_CHARSET_UTF8 = APPLICATION_ATOM_XML + ";charset=" + Charsets.Lower.UTF_8;
public static final String APPLICATION_ATOM_XML_CHARSET_UTF8 = APPLICATION_ATOM_XML + ";charset="
+ Charsets.Lower.UTF_8;

public static final String APPLICATION_ATOMSVC_XML = "application/atomsvc+xml";
public static final String APPLICATION_ATOMSVC_XML_CHARSET_UTF8 = APPLICATION_ATOMSVC_XML + ";charset=" + Charsets.Lower.UTF_8;
public static final String APPLICATION_ATOMSVC_XML_CHARSET_UTF8 = APPLICATION_ATOMSVC_XML + ";charset="
+ Charsets.Lower.UTF_8;

public static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
public static final String APPLICATION_XML = "application/xml";
public static final String APPLICATION_XML_CHARSET_UTF8 = "application/xml;charset=" + Charsets.Lower.UTF_8;
public static final String TEXT_JAVASCRIPT_CHARSET_UTF8 = "text/javascript;charset=" + Charsets.Lower.UTF_8;
public static final String APPLICATION_JAVASCRIPT = "application/json";
public static final String APPLICATION_JAVASCRIPT_CHARSET_UTF8 = APPLICATION_JAVASCRIPT + ";charset=" + Charsets.Lower.UTF_8;
public static final String APPLICATION_JAVASCRIPT_CHARSET_UTF8 = APPLICATION_JAVASCRIPT + ";charset="
+ Charsets.Lower.UTF_8;

public static final String JERSEY_CLIENT_CHUNKED_ENCODING_SIZE = "jersey.config.client.chunkedEncodingSize";

public static final ODataVersion DATA_SERVICE_VERSION = ODataVersion.V1;
public static final String DATA_SERVICE_VERSION_HEADER = DATA_SERVICE_VERSION.asString;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.odata4j.exceptions;

import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.Response.StatusType;
import jakarta.ws.rs.core.Response.Status;
import jakarta.ws.rs.core.Response.StatusType;

import org.odata4j.core.OError;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
import org.odata4j.core.OError;

/**
* A factory for instances of a specific sub-class of {@link ODataProducerException}.
* A factory for instances of a specific sub-class of
* {@link ODataProducerException}.
*
* <p>Implementations of this interface are registered to and used by {@link ODataProducerExceptions}.
* When an OData consumer receives an error message returned by an OData producer, the parsed
* {@link OError} is wrapped into an exception and thrown via the consumer API.</p>
* <p>
* Implementations of this interface are registered to and used by
* {@link ODataProducerExceptions}.
* When an OData consumer receives an error message returned by an OData
* producer, the parsed
* {@link OError} is wrapped into an exception and thrown via the consumer API.
* </p>
*
* @param <T> the concrete sub-class of {@link ODataProducerException} created
* @see ODataProducerExceptions#create(javax.ws.rs.core.Response.StatusType, OError)
* @param <T> the concrete sub-class of {@link ODataProducerException} created
* @see ODataProducerExceptions#create(jakarta.ws.rs.core.Response.StatusType,
* OError)
*/
public interface ExceptionFactory<T extends ODataProducerException> {

Expand All @@ -22,9 +28,11 @@ public interface ExceptionFactory<T extends ODataProducerException> {
int getStatusCode();

/**
* Creates an instance of a specific sub-class of {@link ODataProducerException}.
* Creates an instance of a specific sub-class of
* {@link ODataProducerException}.
*
* @param error the OData error message to be wrapped into the returned exception
* @param error the OData error message to be wrapped into the returned
* exception
* @return the exception instance
*/
T createException(OError error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.odata4j.exceptions;

import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.Response.StatusType;
import jakarta.ws.rs.core.Response.Status;
import jakarta.ws.rs.core.Response.StatusType;

import org.odata4j.core.OError;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.odata4j.exceptions;

import javax.ws.rs.core.Response.Status.Family;
import javax.ws.rs.core.Response.StatusType;
import jakarta.ws.rs.core.Response.Status.Family;
import jakarta.ws.rs.core.Response.StatusType;

import org.odata4j.core.OError;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.odata4j.exceptions;

import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.Response.StatusType;
import jakarta.ws.rs.core.Response.Status;
import jakarta.ws.rs.core.Response.StatusType;

import org.odata4j.core.OError;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.odata4j.exceptions;

import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.Response.StatusType;
import jakarta.ws.rs.core.Response.Status;
import jakarta.ws.rs.core.Response.StatusType;

import org.odata4j.core.OError;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.odata4j.exceptions;

import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.Response.StatusType;
import jakarta.ws.rs.core.Response.Status;
import jakarta.ws.rs.core.Response.StatusType;

import org.odata4j.core.OError;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.odata4j.exceptions;

import javax.ws.rs.core.Response.Status.Family;
import javax.ws.rs.core.Response.StatusType;
import jakarta.ws.rs.core.Response.Status.Family;
import jakarta.ws.rs.core.Response.StatusType;

import org.odata4j.core.OError;

Expand Down
Loading