Neo4j Load Json using Apoc.load.Json in java - java

I want to load my Json file into neo4j server using Apoc procedure, for that I used following query...
call apoc.load.json("file:///training.json") yield value Return value
but it is showing me the error
"Failed to invoke procedure apoc.load.json: Caused by:
java.lang.RuntimeException: Can't read url file:///training.json as
json: \training.json (The system cannot find the file specified)".
Expected behaviour is Specified json file is to be loaded in to neo4j server.
problem is: It is not at all recognizing the file That is specified in URL.
please help me out to resolve this error

call apoc.load.json("file:///training.json") yield value Return value
for the above query the URL is specified as "file:///training.json". Instaed of this Specify full path name in URL.
for eg: I put my json file named "training.json" in following specified path
C:\Users\TEMP.DESKTOP9FCLQ6J.002\Documents\Neo4j\default.graphdb\import\training.json
so in query specify the above full path name. Instead of C:// specify the protocol name file:///
The correct answer is:
call apoc.load.json("file:///Users\\TEMP.DESKTOP-9FCLQ6J.002\\Documents\\Neo4j\\default.graphdb\\import\\test.json") yield value
Return value.
Thanks.

For the above call apoc.load.json, I'd use a backslash to get it working, on a Windows 10 PC:
WITH "file:///Users/mukundan/Documents/Neo4j/default.graphdb/import/sudish-graph_working1.json"
AS url
CALL apoc.load.json(url)
YIELD value

Related

Getting the JsonPath error: Expected to find an object with property ['id'] in path $ but found 'java.lang.String'

I want to get the path for a Json property and I am using the Json Path for parsing an Object in order to find the value of the property.
Unfortunately, I encounter the error: Expected to find an object with property ['id'] in path $ but found 'java.lang.String'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.
My code is below:
String path = "$.id";
return JsonPath.parse(document).read(path);
The json from which I want to extract the data (If I evaluate the JsonParse.parse(document)), is:
id:"12345678"
eventName:"MAINTAIN"
ind_Card:0
I am interested in getting the String value of the id. What am I doing wrong here?

How can I login multiple username and paasword using csv data set config in jmeter3.0?

In http request, I have set the variable names are
username=$(name)
password=$(psw)
In CSV data set config set the details are:
File name: /home/desktop/login.txt
Variable name: name,psw
Delimiter use: ,
In CSV file, I have three user accounts are:
radha,radha
sumithra,sumithra
moorthi,moorthi
In the above configuration, I have run the jmeter3.0 in Linux . But, It does not read the CSV/txt file data. the below invalid request passing my application.
POST data:
username=%24%28name%29&password=%24%28psw%29&userstate=others&submit=Enter
Kindly give me a useful solution.
Every step you have followed seems okay here. But as I can see you have missed declaring the variable properly in your scripts. In your Http request sampler, you have to send parameter as like below:
username=${name}
password=${psw}
In Http sampler:
Since URLs often contain characters outside the ASCII set, the URL has to be converted into a valid ASCII format.
URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits.
So in your case, POST data is shown as "username=%24%28name%29" because of the ( and ).
For Reference, See HTML URL Encoding Reference.

Get everything after the root domain name from an HTTP request

Is it possible to get everything after the root domain name from an HTTP request using Java?
So if the url being requested is http://example.com/my-path then I'd like to get the value of my-path
I'm using the PlayFramework so if there's a header called "Path" or something like that it should be easier to get it with:
String path = request.headers.get("path");
But this page suggests that such a thing doesn't exist:
https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
If there's a different solution to get the same result, that would also be appreciated. If it is possible it will provide a solution to this question as well:
http://stackoverflow.com/questions/28503129/redirect-example-com-to-www-example-com-in-playframework-1-2-x
To get everything after the domain, use uri:
String path = request.uri();
Or if you want to cut out query string parameters, use path:
String path = request.path();

Mule originalFilename is null

I am creating a process using Mule 3.4.1 which after processing a file it writes out the file with a specific filename.
The input filename is: MMDDYYYY_sys_newhires.csv
The processed filename is: MMDDYYYY_sys_newhires_NNN.csv
The code that i am using is below:
#[filename = message.inboundProperties.originalFilename;
filename= com.cfa.apps.icims.mule.CounterSingleton.getInstance().getCount()
+ filename.substring(0,filename.length() -1 -4) + ".csv";
filename]
The problem exists in the first line. message.inboundProperties.originalFilename.
I have tried a number of different combinations
message.inboundProperties.originalFilename
message.inboundProperties['originalFilename']
message.inboundProperties.originalFileName
message.inboundProperties['originalFileName']
message.inboundProperties.sourceFilename
message.inboundProperties['sourceFilename']
message.inboundProperties.sourceFileName
message.inboundProperties['sourceFileName']
Now I have also tried nesting the #[header:originalFilename], this works by itself, but you can't nest the expression within the code at least as far as I know.
Any help?
UPDATE: I am using the inbound file transport
Since you don't show the endpoint configuration, I'm going to assume that this is happening with a file inbound endpoint.
For a reason that goes beyond imagination, the file message receiver behind the inbound endpoint puts the originalFilename property in the outbound scope when evaluating the expression to generate the archived file name.
So use: message.outboundProperties.originalFilename
I have tested this mel EXPRESSION in ESB 3.7.1 and it is working fine!!
message.inboundProperties.originalFilename=='firstfile.txt'

edit LDAP Photo attribute, spring-ldap InvalidAttributeValueException

I develop an LDAP interface program which can modify person attributes, but when I try to modify the value of the photo attribute with an url string, I have this exception :
org.springframework.ldap.InvalidAttributeValueException: [LDAP: error code 21 - photo: no validator for syntax 1.3.6.1.4.1.1466.115.121.1.23];
I think I must send a JPG photo file to ldap but I don't know how to do it...
Anyone has an idea?
First, when you encounter such an error with a syntax OID, you can submit it to the OID repository. Here it will give you the following information "Values in this syntax are encoded as if they were octet strings".
This means that you have to encode your JPG or PNG file in Base64 and set the attribute with this value (in fact an array).
Second, in my understanding, there are 3 attributes to store photo-Data jpegPhoto, Photo and thumbnailPhoto. But for me it's better to store photos on a file system or a database and put in the Directory ans URL or something like that.
You'll find here a tutorial to handle them with java.

Categories

Resources