Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AfterSaveEventApplicationListener Neo4jRequest not working #332

Closed
igormontella opened this issue Feb 23, 2016 · 2 comments
Closed

AfterSaveEventApplicationListener Neo4jRequest not working #332

igormontella opened this issue Feb 23, 2016 · 2 comments

Comments

@igormontella
Copy link

The implementation cited in this link http://docs.spring.io/spring-data/neo4j/docs/4.1.0.M1/reference/html/#_full_text_indexes is not working anymore. After updating to OGM 2.0.0 the implamentation of DefaultRequest changed. Maybe I miss something, but I can't find any solution to pass through it.

@luanne
Copy link
Contributor

luanne commented Feb 24, 2016

Sorry about that, the docs were not updated. Here's the way to do this in 4.1 (using the Http Driver):

 @Bean
    ApplicationListener<AfterSaveEvent> afterSaveEventApplicationListener() {
        return new ApplicationListener<AfterSaveEvent>() {
            @Override
            public void onApplicationEvent(AfterSaveEvent event) {

                if(event.getEntity() instanceof Person) {
                    Person person = (Person) event.getEntity();
                    String json = "construct the JSON";

                    HttpPost httpPost = new HttpPost(Components.driver().getConfiguration().getURI() + "/db/data/index/node/" + indexName);

                    try {
                        httpPost.setEntity(new StringEntity(json.toString()));
                       HttpRequest.execute(httpClient, httpPost, Components.driver().getConfiguration().getCredentials());
                    } catch (Exception e) {
                       //handle this
                    } 

                }
            }
        };
    }

We'll update the docs for both the HTTP and Embedded drivers.

@igormontella
Copy link
Author

Thanks a lot, I spent long hours trying to figure it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants