How to define the ObjectMapper instance in new Algolia API v3 - algolia

In the Java Client from previous algolia version (2.9) was pretty easy and documented how to customize the ObjectMapper to be used when indexing records. Now in v3 seems that there is no way or is not documented, so, anyone knows how do I set the ObjectMapper instance in algolia v3? Thank you!

With the Java client v3 you can still get the ObjectMapper like this: Defaults.getObjectMapper(); You can find the default settings for the ObjectMapper here but be careful when modifying those because they fit Algolia APIs requirements.

Related

Access Neustar API using scalasca

I am new to both scala and Neustar. I currently have this documentation as my reference: https://ipintelligence.neustar.biz/portal/#documentation but this does not mention any sample code on how to call this API using scala.
Does anyone have any pointers on this? Or maybe just in general on how to access a rest api using scala?
Thanks!
You can use STTP Client. This blogpost is a good start: https://softwaremill.com/introducing-sttp-the-scala-http-client/
DISCLAIMER: I work for SoftwareMill, which is creator of STTP.

How to use a RESTful API as ORM in CakePHP 3?

In CakePHP 1.x/2.x, it was fairly simple to have a model's data come from a REST API (as opposed to a relational database), by defining a custom datasource. (Neil Crookes' CakePHP-ReST-DataSource-Plugin was a great place to start.) Slap your custom datasource on your model, and you're making calls like $this->MyModel->find() just like you were querying a MySQL table called my_models.
I'm trying to figure out how to achieve this same effect under CakePHP 3.0. That is, make find()/save()/set()/get() calls against a Table/Entity driven by a REST API.
Since 3.0's ORM system is A) fairly new, and B) a rather large departure from the old way of doing things, I haven't found any information about how to do something like this. In fact, based on this SlideShare from
José Lorenzo Rodríguez, it sounds like it might not be possible.
This means:
not going to connect to stuff that is not a relational database.
Is there someone more familiar with CakePHP 3.0 that could clarify if what I'm looking for is possible under the new ORM system? If so, could you explain what classes you'd have to extend or implement to achieve such a function?
If you want to create a complete adapter for your Rest datasource using the interfaces and classes provided by CakePHP, take a look at this early experiment fro the CakePHP team on making a datasource for Elastic Search.
Elastic Search uses a Rest API and this plugin attempts to create classes that work similar to the CakePHP ORM:
https://github.com/cakephp/elastic-search
What it implements is basically the following:
A Type class that implements the RepositoryInterface
A Document class that implements the EntityInterface
A Query class that can be used as a collection object and has similar methods
In the near future it will provide a paginator adaptor and a form helper adaptor.
If you want to save yourself this trouble, because there for you there is little value in exposing your datasource as something ORM-like, you can just use guzzle or any similar library to interface with your API and use it as a service instead of a full-blown layer.
In the year since I asked this question, UseMuffin has built a Webservice plugin that purports to "bring [...] the power of the CakePHP ORM to your favourite webservices." This sounds like exactly what I wanted at the time.

ReactiveMongo & JSON4S

I'm using JSON4S to parse some JSON strings I'm getting from external APIs.
Is there anyway to get JSON entities like there is with the play reactivemongo JSONCollection or the spray-json to reactive mongo converter in sprest?
Its easy to use JSON4S with the standard Mongo Casbah lib e.g. builder.insert(JObjectParser.parse(obj))
But I really want to be able to do this with reactivemongo.
You can start by taking a look at how it's implemented in play-reactivemongo plugin (conversion between play's js reads/writes and reactivemongo's types) here.
I know this is an old question, but this is always the first thing that pops up when I google it.
I've begun working on a project that does this based on the Play Framework's plugin.
Check the issue tracker, because there are currently some problems that may make using it not an option.
https://github.com/Jacoby6000/Json4s-reactivemongo-compatibility

disable gwt obfuscation for certain model classes

Is it possible in GWT 2.4+ to disable obfuscation for certain java model classes?
The reason I am asking this question is we use GWT RPC to talk to the server and need to store these objects returned etc in local storage using the Indexed DB API, we are currently using websql api. If GWT obfuscates/renames your properties etc then this renders using the Indexed DB API useless in your code.
Maybe there is a way to ask GWT to replace a property string with the obfuscated version in your Indexed DB api queries?
I could create a whole new java model that uses javascript overlays so these are preserved when GWT compiled and replace GWT RPC with JSON RPC but this would be a lot of work.
Any other ideas would be appreciated!
I also looked at the AutoBean framework which produces nice JSON output of your model interfaces but I don't think has a nice simple javascript representation under the hood.
You can set GWT Compile style attribute to PRETTY or DETAILED. so that GWT will not replace the class, method or variable names. For more information refer this link.

Authentication with AOP, Guice and the new RequestFactories

I would like to use the new RequestFactories and the new approach to do AOP with Guice to do the Authentication.
I would like to have for example a RequestFactory Request method in a JPA Entity for example
findCustomer(int id) which i can anotate for example with #NeedsAuthorization(rights=Rigths.ADMIN)
This is just an example, but i am not so experienced in this field and it would be nice if there is an nice tutorial which shows such a possibility. Maybe HttpSession based.
Want to give myself an answer. After longer research i find a way to use Guice with RequestFactory in this software architecture example: https://github.com/mgenov/injecting-request-factory
In this project i saw an example of Authorizaton wit AOP: http://snippets.dzone.com/posts/show/11587
In the dynatableRF example of GWT i saw how to do the Authorization on Request Factory level (with AuthFilter)