How do I create a SimplePointLayer in Neo4J spatial? - java

I have seen a few posts here on stack that show how to create a simplePointLayer. However, the process is failing for me.
I am using Neo4J version 3.0.2 and the spatial plugin version 3.0.2.
I have been here, here, and here.
Each of these pages contains the same set of instructions for creating a SimplePointLayer, as shown below.
This step works just fine for me:
POST /db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer HTTP/1.1
Host: localhost:7474
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache
{
"layer" : "geom",
"lat" : "lat",
"lon" : "lon"
}
I'm not sure where to see a listing of layers, but the response is 200, so I'm assuming everything works as expected here.
The following step is where I am stuck:
POST /db/data/index/node/ HTTP/1.1
Host: localhost:7474
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache
{
"name" : "geom",
"config" : {
"provider" : "spatial",
"geometry_type" : "point",
"lat" : "lat",
"lon" : "lon"
}
}
I have the json above in a file tmp.json and I run
cat tmp.json | http :7474/db/data/index/node
This generates the following message:
HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Content-Length: 6887
Content-Type: application/json; charset=UTF-8
Date: Wed, 06 Jul 2016 18:14:18 GMT
Server: Jetty(9.2.9.v20150224)
{
"errors": [
{
"code": "Neo.DatabaseError.General.UnknownError",
"message": "No index provider 'spatial' found. Maybe the intended provider (or one more of its dependencies) aren't on the classpath or it failed to load.",
"stackTrace": "java.lang.IllegalArgumentException: No index provider 'spatial' found. Maybe the intended provider (or one more of its dependencies) aren't on the classpath or it failed to load.\n\tat org.neo4j.kernel.NeoStoreDataSource$1.apply(NeoStoreDataSource.java:386)\n\tat org.neo4j.kernel.NeoStoreDataSource$1.apply(NeoStoreDataSource.java:378)\n\tat org.neo4j.kernel.impl.index.LegacyIndexStore.findIndexConfig(LegacyIndexStore.java:105)\n\tat org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateIndexConfig(LegacyIndexStore.java:171)\n\tat org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateNodeIndexConfig(LegacyIndexStore.java:64)\n\tat org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeLegacyIndexCreateLazily(StateHandlingStatementOperations.java:1475)\n\tat org.neo4j.kernel.impl.api.OperationsFacade.nodeLegacyIndexCreateLazily(OperationsFacade.java:1195)\n\tat org.neo4j.kernel.impl.coreapi.IndexProviderImpl.getOrCreateNodeIndex(IndexProviderImpl.java:52)\n\tat org.neo4j.kernel.impl.coreapi.IndexManagerImpl.forNodes(IndexManagerImpl.java:81)\n\tat org.neo4j.server.rest.web.DatabaseActions.createNodeIndex(DatabaseActions.java:381)\n\tat org.neo4j.server.rest.web.RestfulGraphDatabase.jsonCreateNodeIndex(RestfulGraphDatabase.java:845)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)\n\tat com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)\n\tat com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)\n\tat org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)\n\tat com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)\n\tat com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)\n\tat com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)\n\tat com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)\n\tat com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)\n\tat com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)\n\tat com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)\n\tat com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)\n\tat org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:497)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)\n\tat org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)\n\tat java.lang.Thread.run(Thread.java:745)\n"
}
],
"exception": "IllegalArgumentException",
"fullname": "java.lang.IllegalArgumentException",
"message": "No index provider 'spatial' found. Maybe the intended provider (or one more of its dependencies) aren't on the classpath or it failed to load.",
"stackTrace": [
"org.neo4j.kernel.NeoStoreDataSource$1.apply(NeoStoreDataSource.java:386)",
"org.neo4j.kernel.NeoStoreDataSource$1.apply(NeoStoreDataSource.java:378)",
"org.neo4j.kernel.impl.index.LegacyIndexStore.findIndexConfig(LegacyIndexStore.java:105)",
"org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateIndexConfig(LegacyIndexStore.java:171)",
"org.neo4j.kernel.impl.index.LegacyIndexStore.getOrCreateNodeIndexConfig(LegacyIndexStore.java:64)",
"org.neo4j.kernel.impl.api.StateHandlingStatementOperations.nodeLegacyIndexCreateLazily(StateHandlingStatementOperations.java:1475)",
"org.neo4j.kernel.impl.api.OperationsFacade.nodeLegacyIndexCreateLazily(OperationsFacade.java:1195)",
"org.neo4j.kernel.impl.coreapi.IndexProviderImpl.getOrCreateNodeIndex(IndexProviderImpl.java:52)",
"org.neo4j.kernel.impl.coreapi.IndexManagerImpl.forNodes(IndexManagerImpl.java:81)",
"org.neo4j.server.rest.web.DatabaseActions.createNodeIndex(DatabaseActions.java:381)",
"org.neo4j.server.rest.web.RestfulGraphDatabase.jsonCreateNodeIndex(RestfulGraphDatabase.java:845)",
"java.lang.reflect.Method.invoke(Method.java:498)",
"org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
"org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
"java.lang.Thread.run(Thread.java:745)"
]
}
I'm not sure where to go from here. I am assuming the 'provider' is the plugin. I am not a JAVA person, so I'm not sure how to deal with classpaths. Has anyone encountered this error before \ know how to deal with this problem?

The spatial library is in a bit of flux at the moment with the introduction of user defined procedures in Neo4j 3.0. Specifically:
Procedures are becoming the recommended way to interact with spatial, and
The index provider has been removed from the spatial library (causing the error you encountered)
With procedures you now have access to spatial functionality from Cypher:
Create layer
CALL spatial.addPointLayer('cities');
Add all cities to the layer
MATCH (c:City)
WITH collect(c) AS cities
CALL spatial.addNodes('cities',cities) YIELD node
RETURN count(*)
Find cities within distance
MATCH (c:City {name:"Berlin"}) WITH c
CALL spatial.distance('cities', c , 200) YIELD node, distance
RETURN node.name AS name, round(distance) AS dist
See this for more info.

Related

Adding more than one InputMediaAsset to Job in Azure Media Encoder Standard results in 400

Trying to stitch videos using Azure Media Encoder Standard.
Using this piece of code in Java (com.microsoft.azure:azure-media:0.9.7) to create a job for Azure MES:
Job.Creator jobCreator = Job.create()
.setName(outputAssetName)
.addInputMediaAsset("nb:cid:UUID:ID1")
.addInputMediaAsset("nb:cid:UUID:ID2")
.setPriority(2)
.addTaskCreator(task);
When submitting the job, this results in the following error:
Nov 08, 2017 6:30:03 PM com.microsoft.windowsazure.services.media.implementation.MediaExceptionProcessor processCatch
WARNING: com.sun.jersey.api.client.UniformInterfaceException: Client response status: 400
com.sun.jersey.api.client.UniformInterfaceException: Client response status: 400
at com.microsoft.windowsazure.services.media.implementation.MediaBatchOperations.parseBatchResult(MediaBatchOperations.java:368)
at com.microsoft.windowsazure.services.media.models.Job$Creator.processResponse(Job.java:190)
at com.microsoft.windowsazure.services.media.entityoperations.EntityRestProxy.create(EntityRestProxy.java:138)
at com.microsoft.windowsazure.services.media.implementation.MediaExceptionProcessor.create(MediaExceptionProcessor.java:140)
...
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:748)
With a single InputMediaAsset this works fine.
Two questions:
Do you know the solution of how to submit more than one asset using Java?
If not, is there a way to get a more informative error message than just 400 out of Azure MES?
EDIT
Task config:
{
"Version": 1.0,
"Codecs": [
{
"Type": "CopyVideo"
},
{
"Type": "CopyAudio"
}
],
"Outputs": [
{
"FileName": "{Basename}_stitch.mp4",
"Format": {
"Type": "MP4Format"
}
}
],
"Sources": [
{
"AssetID": "nb:cid:UUID:ID1",
"StartTime": "00:00:00",
"Duration": "00:00:05"
},
{
"AssetID": "nb:cid:UUID:ID2",
"StartTime": "00:00:00",
"Duration": "00:00:05"
}
]
}
I dug deeper to see if I can at least get a better error message, and I got this:
HTTP/1.1 400 Bad Request
Content-ID: 2
X-Content-Type-Options: nosniff
Cache-Control: no-cache
DataServiceVersion: 1.0;
Content-Type: application/xml;charset=utf-8
<?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code /><m:message xml:lang="en-US">Input asset not used - nb:cid:UUID:ID2</m:message></m:error>
It is telling me that the second input asset is not used, even though I specify it in the task config - and the task config comes from Azure Media Services Explorer and works there.
In your Java code, you should be making a call to create a Task before invoking the Job.Creator. Something like the following:
Task.CreateBatchOperation task = Task.create(mediaProcessor.getId(), taskXml).setConfiguration(taskConfiguration).setName("Stitching Task");
In the above, the taskXml object should have references to both input Assets. The default Java sample code, such as the one here, will only have a reference to a single JobInputAsset element. Since you are using two (or more) input Assets, you will have to expand taskXml to include the additional JobInputAsset elements.

500 Error from Microsoft Graph on create child in approot

Got the following error while trying to create a folder in my app folder:
com.microsoft.graph.http.GraphFatalServiceException: [This is an unexpected error from Graph, please report this at https://github.com/microsoftgraph/msgraph-sdk-android/issues]
POST https://graph.microsoft.com/v1.0/me/drive/special/approot/children
SdkVersion : graph-android-v1.2.0
Authorization : bearer <REDACTED>
{"folder":{},"name":"gg"}
500 : Internal Server Error
Duration : 234.839
Cache-Control : private
X-Android-Sent-Millis : 1489454003081
Content-Type : application/json
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"West US","Slice":"SliceA","ScaleUnit":"000","Host":"AGSFE_IN_2","ADSiteName":"WST"}}
request-id : f25e8a83-5b40-493f-811c-7c9731790c9f
Date : Tue, 14 Mar 2017 01:13:37 GMT
Transfer-Encoding : chunked
X-Android-Response-Source : NETWORK 500
client-request-id : f25e8a83-5b40-493f-811c-7c9731790c9f
X-Android-Received-Millis : 1489454003395
{
"error": {
"code": "generalException",
"message": "An unspecified error has occurred.",
"innerError": {
"request-id": "f25e8a83-5b40-493f-811c-7c9731790c9f",
"date": "2017-03-14T01:13:37"
}
}
}
Per the app folder and the create folder documentation, the request should work given I have "Files.ReadWrite.AppFolder" permission scope.
I created the folder manually and tried to access its metadata and it failed similarly:
com.microsoft.graph.http.GraphFatalServiceException: [This is an unexpected error from Graph, please report this at https://github.com/microsoftgraph/msgraph-sdk-android/issues]
GET https://graph.microsoft.com/v1.0/me/drive/special/approot:/gg:
SdkVersion : graph-android-v1.2.0
Authorization : bearer <REDACTED>
500 : Internal Server Error
Duration : 199.4711
Cache-Control : private
X-Android-Sent-Millis : 1489455064558
Content-Type : application/json
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"West US","Slice":"SliceA","ScaleUnit":"003","Host":"AGSFE_IN_3","ADSiteName":"WST"}}
request-id : 660fad6b-491a-4876-98c5-9160c9f8715c
Date : Tue, 14 Mar 2017 01:31:19 GMT
Transfer-Encoding : chunked
X-Android-Response-Source : NETWORK 500
client-request-id : 660fad6b-491a-4876-98c5-9160c9f8715c
X-Android-Received-Millis : 1489455064872
{
"error": {
"code": "generalException",
"message": "An unspecified error has occurred.",
"innerError": {
"request-id": "660fad6b-491a-4876-98c5-9160c9f8715c",
"date": "2017-03-14T01:31:20"
}
}
}
There's a file in the app directory that I can access via its item id and get its contents without issues.
Any ideas what might be causing this issue?
The Files.ReadWrite.AppFolder scope is not currently supported, but cannot be removed for a list of reasons which are unfortunate. You will need to use a different scope, such as Files.ReadWrite, to gain access and create this folder.
Note that even after changing permissions requested by your app, you will need to reconsent to the app to get the new permissions. You can force that to happen to adding &prompt=consent to the end of the OAuth2 Authorization URL or you can remove consent to your app first from

Payeezy api integration - check events

I am trying to check my payeezy events online using follwoing url and api
https://developer.payeezy.com/payeezy-api/apis/get/events
I have set apikey and token and generated HMAC key for each time I generate request.
But getting following error response
Connection:
keep-alive
Content-Length:
206
Content-Type:
application/json
Date:
Fri, 27 May 2016 03:56:13 GMT
Server:
Apigee Router
{
"fault": {
"faultstring": "Execution of Hmac-authentication failed with error: Exception thrown from JavaScript : HMACERROR (hmac_helper#196)",
"detail": {
"errorcode": "steps.javascript.ScriptExecutionFailed"
}
}
}
Can anyone suggest why this happening with me :(

Why does response to my Java GET request have fewer headers than the same URL for Curl

I am playing with the OANDA API. The documentation states that responses to all successful GET requests will include an ETag header: http://developer.oanda.com/rest-live/development-guide/#etag
I have confirmed this is the case when I have a successful request with Curl:
$ curl -i "https://api-sandbox.oanda.com/v1/prices?instruments=EUR_USD"
HTTP/1.1 200 OK
Server: openresty/1.7.0.1
Date: Fri, 26 Dec 2014 17:27:01 GMT
Content-Type: application/json
Content-Length: 139
Connection: keep-alive
ETag: "6a6e222a3f90df8f333ff2a6edfb603e4a354905"
{
"prices" : [
{
"instrument" : "EUR_USD",
"time" : "2014-12-26T17:26:12.336249Z",
"bid" : 1.24105,
"ask" : 1.24119
}
]
}
When, however, I have a successful request with HttpClient org.apache.httpcomponents 4.3, the Content-Length and ETag headers are not included.
2014-12-26 17:27:54 INFO RestClient:91 - Executing request: GET https://api-sandbox.oanda.com/v1/prices?instruments=EUR_USD HTTP/1.1
2014-12-26 17:27:55 INFO RestClient:103 - Response OK, processing...
2014-12-26 17:27:55 INFO RestClient:108 - {
"prices" : [
{
"instrument" : "EUR_USD",
"time" : "2014-12-26T17:28:01.935790Z",
"bid" : 1.241,
"ask" : 1.24117
}
]
}
2014-12-26 17:27:55 INFO RestClient:110 - Headers: [Server: openresty/1.7.0.1, Date: Fri, 26 Dec 2014 17:28:14 GMT, Content-Type: application/json, Transfer-Encoding: chunked, Connection: keep-alive]
I am missing the ETag and Content-Length headers when I log all the headers received in response to my Java GET request.
I would like to use the ETag header in my Java code, so please can you help me understand why it is not returned.
HttpClient enabled compression by default and the OANDA API does not support ETags when compression is enabled:
Note: ETags can not be used in conjunction with compressed responses.

Swagger-UI doesn't recognize application/hal+json

I have RESTful API for a Spring Boot application. I ran into this when I was trying to figure out a separate issue that involved trying to add custom media-types.
After trying to do this I got a HttpMediaTypeNotAcceptable exception when I try to view my API documentation. This exception is visible only in the logs (if I turn the level up to DEBUG). On the browser I see 406 undefined. Here's a screenshot:
The exception I get from Spring Boot's logs is this:
2014-11-04 10:08:26.189 DEBUG 5496 --- [nio-8080-exec-9] .w.s.m.s.DefaultHandlerExceptionResolver : Resolving exception from handler [public org.springframework.http.ResponseEntity<com.wordnik.swagger.model.ResourceListing> com.mangofactory.swagger.controllers.DefaultSwaggerController.getResourceListing(java.lang.String)]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
The root of the problem is that the existing, producible-media-types are overwritten.
Without the code above, the list contains:
application/hal+json
application/json;charset=UTF-8
application/*+json;charset=UTF-8.
With my changes, the list only contains application/hal+json and my custom media-type. So what happens is that Spring cannot find a compatible media-type at all because Swagger UI has application/json in its Accept: header whereas http://localhost:8080/api-docs vends application/hal+json (I verified using curl):
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
X-Application-Context: application
Content-Type: application/hal+json
Transfer-Encoding: chunked
Date: Tue, 04 Nov 2014 16:56:57 GMT
I'm guessing that Swagger UI should probably set the accept header to application/json,application/hal+json or perhaps use a wildcard like application/*+json.
The current solution would be to update swagger-client.js - The part where the SwaggerClient is built, it is hard coded with application/json as the mime type.
The current line of code is https://github.com/swagger-api/swagger-ui/blob/master/dist/lib/swagger-client.js#L335 though that may obviously change in different versions (so may not be relevant in the future when reading this answer).
The swagger-client.js exists in two places - the /dist/lib dir for the pre-built application or directly under the /lib dir for the build process. You should change the value depending on what you're using.

Categories