Skip to content

Commit 8dc8be1

Browse files
committed
[JAVA-9814] Cleanup apache-olingo module
1 parent 6cee64d commit 8dc8be1

File tree

15 files changed

+46
-57
lines changed

15 files changed

+46
-57
lines changed

apache-olingo/olingo2/.gitignore renamed to apache-olingo/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ HELP.md
2727

2828
### VS Code ###
2929
.vscode/
30+

apache-olingo/Samples.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ This following table contains test URLs that can be used with the Olingo V2 demo
44

55
| URL | Description |
66
|------------------------------------------|-------------------------------------------------|
7-
| `http://localhost:8180/odata/$metadata` | fetch OData metadata document |
8-
| `http://localhost:8180/odata/CarMakers?$top=10&$skip=10` | Get 10 entities starting at offset 10 |
9-
| `http://localhost:8180/odata/CarMakers?$count` | Return total count of entities in this set |
10-
| `http://localhost:8180/odata/CarMakers?$filter=startswith(Name,'B')` | Return entities where the *Name* property starts with 'B' |
11-
| `http://localhost:8180/odata/CarModels?$filter=Year eq 2008 and CarMakerDetails/Name eq 'BWM'` | Return *CarModel* entities where the *Name* property of its maker starts with 'B' |
12-
| `http://localhost:8180/odata/CarModels(1L)?$expand=CarMakerDetails` | Return the *CarModel* with primary key '1', along with its maker|
13-
| `http://localhost:8180/odata/CarModels(1L)?$select=Name,Sku` | Return the *CarModel* with primary key '1', returing only its *Name* and *Sku* properties |
14-
| `http://localhost:8180/odata/CarModels?$orderBy=Name asc,Sku desc` | Return *CarModel* entities, ordered by the their *Name* and *Sku* properties |
15-
| `http://localhost:8180/odata/CarModels?$format=json` | Return *CarModel* entities, using a JSON representation|
7+
| `http://localhost:8080/odata/$metadata` | fetch OData metadata document |
8+
| `http://localhost:8080/odata/CarMakers?$top=10&$skip=10` | Get 10 entities starting at offset 10 |
9+
| `http://localhost:8080/odata/CarMakers?$count` | Return total count of entities in this set |
10+
| `http://localhost:8080/odata/CarMakers?$filter=startswith(Name,'B')` | Return entities where the *Name* property starts with 'B' |
11+
| `http://localhost:8080/odata/CarModels?$filter=Year eq 2008 and CarMakerDetails/Name eq 'BWM'` | Return *CarModel* entities where the *Name* property of its maker starts with 'B' |
12+
| `http://localhost:8080/odata/CarModels(1L)?$expand=CarMakerDetails` | Return the *CarModel* with primary key '1', along with its maker|
13+
| `http://localhost:8080/odata/CarModels(1L)?$select=Name,Sku` | Return the *CarModel* with primary key '1', returing only its *Name* and *Sku* properties |
14+
| `http://localhost:8080/odata/CarModels?$orderBy=Name asc,Sku desc` | Return *CarModel* entities, ordered by the their *Name* and *Sku* properties |
15+
| `http://localhost:8080/odata/CarModels?$format=json` | Return *CarModel* entities, using a JSON representation|
1616

1717

1818

apache-olingo/olingo2/pom.xml renamed to apache-olingo/pom.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6-
<groupId>com.baeldung.examples.olingo2</groupId>
7-
<artifactId>olingo2</artifactId>
8-
<name>olingo2</name>
9-
<description>Sample Olingo 2 Project</description>
6+
<groupId>com.baeldung.examples.olingo</groupId>
7+
<artifactId>apache-olingo</artifactId>
8+
<name>apache-olingo</name>
9+
<description>Sample Apache Olingo Project</description>
1010

1111
<parent>
1212
<groupId>com.baeldung</groupId>
1313
<artifactId>parent-boot-2</artifactId>
1414
<version>0.0.1-SNAPSHOT</version>
15-
<relativePath>../../parent-boot-2</relativePath>
15+
<relativePath>../parent-boot-2</relativePath>
1616
</parent>
1717

1818
<dependencies>
@@ -43,7 +43,7 @@
4343
<dependency>
4444
<groupId>org.apache.olingo</groupId>
4545
<artifactId>olingo-odata2-core</artifactId>
46-
<version>${olingo2.version}</version>
46+
<version>${olingo.version}</version>
4747
<!-- Avoid jax-rs version conflict by excluding Olingo's version -->
4848
<exclusions>
4949
<exclusion>
@@ -55,12 +55,12 @@
5555
<dependency>
5656
<groupId>org.apache.olingo</groupId>
5757
<artifactId>olingo-odata2-jpa-processor-core</artifactId>
58-
<version>${olingo2.version}</version>
58+
<version>${olingo.version}</version>
5959
</dependency>
6060
<dependency>
6161
<groupId>org.apache.olingo</groupId>
6262
<artifactId>olingo-odata2-jpa-processor-ref</artifactId>
63-
<version>${olingo2.version}</version>
63+
<version>${olingo.version}</version>
6464
<exclusions>
6565
<exclusion>
6666
<groupId>org.eclipse.persistence</groupId>
@@ -80,7 +80,7 @@
8080
</build>
8181

8282
<properties>
83-
<olingo2.version>2.0.11</olingo2.version>
83+
<olingo.version>2.0.11</olingo.version>
8484
</properties>
8585

86-
</project>
86+
</project>
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
import org.slf4j.LoggerFactory;
2828
import org.springframework.stereotype.Component;
2929

30-
/**
31-
* ODataJPAServiceFactory implementation for our sample domain
32-
* @author Philippe
33-
*
34-
*/
3530
@Component
3631
public class CarsODataJPAServiceFactory extends ODataJPAServiceFactory {
3732

@@ -44,7 +39,7 @@ public CarsODataJPAServiceFactory() {
4439

4540
/**
4641
* This method will be called by Olingo on every request to
47-
* initialize the ODataJPAContext that will be used.
42+
* initialize the ODataJPAContext that will be used.
4843
*/
4944
@Override
5045
public ODataJPAContext initializeODataJPAContext() throws ODataJPARuntimeException {
@@ -54,14 +49,14 @@ public ODataJPAContext initializeODataJPAContext() throws ODataJPARuntimeExcepti
5449
ODataContext octx = ctx.getODataContext();
5550
HttpServletRequest request = (HttpServletRequest)octx.getParameter(ODataContext.HTTP_SERVLET_REQUEST_OBJECT);
5651
EntityManager em = (EntityManager)request.getAttribute(JerseyConfig.EntityManagerFilter.EM_REQUEST_ATTRIBUTE);
57-
52+
5853
// Here we're passing the EM that was created by the EntityManagerFilter (see JerseyConfig)
5954
ctx.setEntityManager(new EntityManagerWrapper(em));
6055
ctx.setPersistenceUnitName("default");
61-
56+
6257
// We're managing the EM's lifecycle, so we must inform Olingo that it should not
6358
// try to manage transactions and/or persistence sessions
64-
ctx.setContainerManaged(true);
59+
ctx.setContainerManaged(true);
6560
return ctx;
6661
}
6762

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
package com.baeldung.examples.olingo2;
1+
package com.baeldung.examples.olingo2;
22

3-
import java.io.IOException;
3+
import org.apache.olingo.odata2.api.ODataServiceFactory;
4+
import org.apache.olingo.odata2.core.rest.ODataRootLocator;
5+
import org.apache.olingo.odata2.core.rest.app.ODataApplication;
6+
import org.glassfish.jersey.server.ResourceConfig;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
import org.springframework.stereotype.Component;
410

511
import javax.persistence.EntityManager;
612
import javax.persistence.EntityManagerFactory;
@@ -15,28 +21,15 @@
1521
import javax.ws.rs.core.Context;
1622
import javax.ws.rs.ext.Provider;
1723

18-
import org.apache.olingo.odata2.api.ODataServiceFactory;
19-
import org.apache.olingo.odata2.core.rest.ODataRootLocator;
20-
import org.apache.olingo.odata2.core.rest.app.ODataApplication;
21-
import org.glassfish.jersey.server.ResourceConfig;
22-
import org.slf4j.Logger;
23-
import org.slf4j.LoggerFactory;
24-
import org.springframework.stereotype.Component;
25-
26-
/**
27-
* Jersey JAX-RS configuration
28-
* @author Philippe
29-
*
30-
*/
3124
@Component
3225
@ApplicationPath("/odata")
3326
public class JerseyConfig extends ResourceConfig {
34-
35-
36-
public JerseyConfig(CarsODataJPAServiceFactory serviceFactory, EntityManagerFactory emf) {
37-
27+
28+
29+
public JerseyConfig(CarsODataJPAServiceFactory serviceFactory, EntityManagerFactory emf) {
30+
3831
ODataApplication app = new ODataApplication();
39-
32+
4033
app
4134
.getClasses()
4235
.forEach( c -> {
@@ -46,11 +39,11 @@ public JerseyConfig(CarsODataJPAServiceFactory serviceFactory, EntityManagerFact
4639
register(c);
4740
}
4841
});
49-
50-
register(new CarsRootLocator(serviceFactory));
42+
43+
register(new CarsRootLocator(serviceFactory));
5144
register( new EntityManagerFilter(emf));
5245
}
53-
46+
5447
/**
5548
* This filter handles the EntityManager transaction lifecycle.
5649
* @author Philippe
@@ -72,7 +65,7 @@ public EntityManagerFilter(EntityManagerFactory emf) {
7265
}
7366

7467
@Override
75-
public void filter(ContainerRequestContext ctx) throws IOException {
68+
public void filter(ContainerRequestContext ctx) {
7669
log.info("[I60] >>> filter");
7770
EntityManager em = this.emf.createEntityManager();
7871
httpRequest.setAttribute(EM_REQUEST_ATTRIBUTE, em);
@@ -85,7 +78,7 @@ public void filter(ContainerRequestContext ctx) throws IOException {
8578
}
8679

8780
@Override
88-
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
81+
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) {
8982

9083
log.info("[I68] <<< filter");
9184
EntityManager em = (EntityManager) httpRequest.getAttribute(EM_REQUEST_ATTRIBUTE);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@SpringBootApplication
88
public class Olingo2SampleApplication extends SpringBootServletInitializer {
99

10-
public static void main(String[] args) {
10+
public static void main(String[] args) {
1111
SpringApplication.run(Olingo2SampleApplication.class);
1212
}
1313
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)