GeoFireStore getLocation returns null - java

I tried to use GeoFireStore to set,get and query location.
I tried first to setLocation by using:
geoFirestoreRef = FirebaseFirestore.getInstance().collection("Locations");
geoFirestore = new GeoFirestore(geoFirestoreRef);
geoFirestore.setLocation( auth.getUid(), new GeoPoint(Lat_Coordinate,Lon_Coordinate) );
It all worked good and created the following in my database:
Now, I tried to getLocation to see if it is working by using:
geoFirestore.getLocation( auth.getUid(), new GeoFirestore.LocationCallback() {
#Override
public void onComplete(GeoPoint geoPoint, Exception e) {
Log.d("ERROR", "Error getting documents: " + e);
}
} );
and for some reason, it can't get anything eventho that I can see this location in my database.
I get the exception: java.lang.NullPointerException: Location doesn't exist.
Any ideas please?
Thank you

I had this issue with the library too. When looking into the source, I saw a little mistake here.
So I made a pull request with the fix. You can either use the fork link or clone the repository and fix line 192 with :
if (geoPoint != null)

Related

Incorrect Elasticsearch statistic via Java client

I am trying to get the index status for a very large index using the Java API. In the background, I am updating the same index with large amounts of data
I have tried
IndicesStatsResponse indicesStatsResponse = client.admin().indices()
.prepareStats(index_name).all().execute().actionGet();
but this does not return the correct size because it is a very large index. However using the REST call, I got the correct answer.
GET /index_name/_stats
Perhaps I need to use some kind of listener mechanism, so I tried
IndicesStatsRequest req = new IndicesStatsRequest();
req.all();
client.admin().indices().stats(req, new ActionListener<IndicesStatsResponse>()
{
#Override
public void onResponse(IndicesStatsResponse response)
{
long s = response.getIndex(indexName).getTotal().getStore().getSizeInBytes();
System.out.println(indexName + " " + s);
}
..
});
but this threw org.elasticsearch.common.util.concurrent.EsRejectedExecutionException
I also tried
IndicesStatsRequest req = new IndicesStatsRequest();
req.all();
ActionFuture<IndicesStatsResponse> statsResponseFeature = client.admin().indices().stats(req.clear().flush(true).refresh(true));
IndicesStatsResponse statsResponse = statsResponseFeature.get(1, TimeUnit.MINUTES);
But this did not retrieve any useful information.
Strangely enough, when I run it in debug mode in Eclipse, it works perfectly. So maybe there is some flush mechanism I am missing.
What is the way out?

Get related data from pointer

I have simple data structure:
"Issue" has poiter to other class "Status" in field "status"
From doc we know include - take key name and pointed data should be avalible in result without any action. But then I try to access pointed data I get null.
ParseQuery<Issue> query = ParseQuery.getQuery("Issues");
query.include("status");
query.whereEqualTo("owner", user);
query.findInBackground(new FindCallback<Issue>() {
public void done(List<Issue> issueList, ParseException e) {
if (e == null) {
Log.d(TAG, "Retrieved " + issueList.size() + " issues");
ParseObject status = issueList.get(0).getParseObject("status"); //NULL!
} else {
Log.d(TAG, "Error: " + e.getMessage());
}
}
});
Manualy form console I can see valid data and jump from Issue to Status by pointer (I have only one record in both)
Parse lib version - 1.11
What I'm doing wrong?
I think it should work.. Check your security and ACL settings in Parse Status class (if you don't have the rights to get the status you won't get it), make sure issueList.get(0) is not null and make sure that the Status object you are pointing to really exist in Parse Status table.

Cannot report new bugs to Bugzilla via J2Bugzilla

I tried searching this topic but nothing seems to cover my exact problem. I have a java and jsp program where I would like to be able to report bugs to my Bugzilla installation. I have been testing the method I created against the Bugzilla landfill first but I cant get it to work.
My problem is that I have tried all the sample code and I still end up with the same error which seems to stem from executeMethod().
Here is the sample of my jsp page which calls the method of my java class:
<jsp:useBean id="error" class="bug.TestClass" scope="session"/>
<% String result = error.reportBug("error");
out.print(result);%>
The Java method, which I have blocked out the username and password to Bugzillla landfill but I have checked and they are correct:
public static String reportBug(String bugError) {
try {
BugzillaConnector conn = new BugzillaConnector();
conn.connectTo("http://landfill.bugzilla.org/");
BugzillaMethod logIn = new LogIn ("*****#hotmail.com", "****");
conn.executeMethod(logIn);
BugFactory factory = new BugFactory();
Bug bug = factory.newBug()
.setOperatingSystem("WINDOWS")
.setPlatform("PC")
.setPriority("P1")
.setProduct("FoodReplicator")
.setComponent("Salt")
.setSummary(bugError)
.setVersion("1.0")
.setDescription("It doesn't work.")
.createBug();
ReportBug report = new ReportBug(bug);
conn.executeMethod(report);
int id = report.getID();
result += "Successful";
} catch (Exception e) {
result = e.toString();
}
return result;
}
And here is the error I am getting when I open the jsp page:
com.j2bugzilla.base.BugzillaException: An unknown error was encountered; fault code: 0
I have been working on this for days so any help would be really appreciated. Thanks
I met the same issue. Then I update j2bugzilla jar from 2.0 to 2.2.1. Then it works.

Why would this cause a StringIndexOutOfBoundsException? Android

I am working on a small file manager to help me learn the basics of android, but I keep running into an error. WHenever I have a lot of items in the folder, it crashes and I get a message similar to this one,
java.lang.StringIndexOutOfBoundsException: length=26; regionStart=23; regionLength=-2
What could be causing this? The line it points to is line 2:
1.)String mimeType = "";
2.)mimeType = URLConnection.guessContentTypeFromName(f.getName());
You are missing some key lines we need to see, such as where f (a File? a URI?) is defined. However when I have seen this problem before it was caused by a URI with no Protocol set.
Making sure you have an extension and using MimeTypeMap#getMimeTypeFromExtension() is probably a good bet too
This error happens to me when the URL has a fragment, which can be identified by a # followed by some value. (For more on URL fragments, see https://www.w3.org/Addressing/URL/4_2_Fragments.html)
The URL fragment is not helpful in guessing content type, and since it is problematic in this case, it should be removed before calling URLConnection.guessContentTypeFromName().
Here is a simple function that returns a URL without the fragment:
private fun getSafeUrlForGuessing(url: String): String {
return try {
val uri = Uri.parse(url)
if (uri.scheme?.startsWith("http") == true) {
uri.buildUpon()
.fragment(null) // URLs with fragments cause URLConnection.guessContentTypeFromName() to throw
.build()
.toString()
} else {
url
}
} catch (error: Throwable) {
url
}
}

Java Neo4j Deletion and Internal 500 Errors

When I delete my neo4j database after my tests like this
public static final DatabaseOperation clearDatabaseOperation = new DatabaseOperation() {
#Override public void performOperation(GraphDatabaseService db) {
//This is deprecated on the GraphDatabaseService interface,
// but the alternative is not supported by implementation (RestGraphDatabase)
for (Node node : db.getAllNodes()) {
for (Relationship relationship : node.getRelationships()) {
relationship.delete();
}
boolean notTheRootNode = node.getId() != 0;
if (notTheRootNode) {
node.delete();
}
}
When querying the database through an ajax search (i.e searching on an empty database it returns an internal 500 error)
localhost:9000/search-results?keywords=t 500 Internal Server Error
197ms
However if I delete the database manually like this
start r=relationship(*) delete r;
start n=node(*) delete n;
No exception is thrown
Its most likely an issue with my code at a lower level in the call and return.
Just wandering why the error only works on one of the scenarios above and not both
Use cypher,
you should probably state more obviously that you use the rest-graph-database.
Are you querying after the deletion or during it?
Please check your logs in data/graph.db/messages.log and data/log/console.log to find the error cause.
Perhaps you can also look at the response body of the http-500 request
As per your error I guess your data is getting corrupted after deletion.
I have used same code like yours and deleted the nodes, except I put the Iterator in transaction and shut down the database after opetation.
e.g.
Transaction _tx = _db.beginTx();
try {
for ( your conditions){
Your code
}
_tx.success();
} catch (Exception e) {
_logger.error(e.getMessage());
}finally{
_tx.finish();
_db.shutdown();
graphDbFactory.cleanUp();
}
Hope it will work for you.

Categories