Working on a basic map using UnfoldingMaps Library and Eclipse. It's for educational purposes(taking a course for OOP Java), and when trying to access the google map provider using map object:
AbstractMapProvider provider = new Google.GoogleProvider();
use then the draw() method to create the map.I run the applet(on eclipse) and it runs for the first time. But after I ran it the second time, it starts giving me the following error:
Unfolding Map v0.9.7 (UCSD edition)
Using OpenGLMapDisplay with processing.opengl.PGraphics2D
java.io.IOException: Server returned HTTP response code: 403 for URL: http://mt1.google.com/vt/lyrs=m#116&hl=de&x=180&y=414&z=10&s=Galileo
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.access$200(HttpURLConnection.java:91)
at sun.net.www.protocol.http.HttpURLConnection$9.run(HttpURLConnection.java:1466)
at sun.net.www.protocol.http.HttpURLConnection$9.run(HttpURLConnection.java:1464)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessController.doPrivilegedWithCombiner(AccessController.java:782)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1463)
at java.net.URL.openStream(URL.java:1045)
at processing.core.PApplet.createInputRaw(PApplet.java:7267)
at processing.core.PApplet.createInput(PApplet.java:7235)
at processing.core.PApplet.loadBytes(PApplet.java:7462)
at processing.core.PApplet.loadImage(PApplet.java:5879)
at de.fhpotsdam.unfolding.tiles.TileLoader.getTileFromUrl(Unknown Source)
at de.fhpotsdam.unfolding.tiles.TileLoader.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
The file "http://mt1.google.com/vt/lyrs=m#116&hl=de&x=180&y=414&z=10&s=Galileo" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
Possible causes I read online:
1.6 java compiler security concerns
trying to access tiles abuses terms of service with google API(really not super aware of the terms and since it's my first map, not sure the tiles how they are accessed)
multiple requests over the limit(not possible in my case as the second time I run the applet, it starts giving me the error)
I'm just trying to find a way if possible to use the google map provider for my project. I would not like to use other providers(such as Microsoft)as google's in my perspective is more complete.
Any help is much appreciated.
Maybe you are using more than one object to provide the map in your code, example:
AbstractMapProvider provider1 = new Google.GoogleTerrainProvider();
AbstractMapProvider provider2 = new Google.GoogleTerrainProvider();
Instead, use just one object provider in your whole code, and then reset your device ip address, or restart your router, because google won't allow the ip address to use the provider even after fixing your code due to the abuse of the service terms.
that will fix the problems.
You may have exceeded the number of allowed queries to Google for the day. You can use use an alternative map(http://unfoldingmaps.org/javadoc/de/fhpotsdam/unfolding/providers/package-summary.html) provider or work offline if this happens.You have reported that you will only be blocked for 24 hours from google so you can restore using the provider at that time.
Related
I used StartApplicationRequest to create a sample request to start the application as given below:
StartApplicationRequest request = StartApplicationRequest.builder()
.applicationId("test-app-name")
.build();
Then, I used the ReactorCloudFoundryClient to start the application as shown below:
cloudFoundryClient.applicationsV3().start(request);
But my test application test-app-name is not getting started. I'm using latest Java CF client version (v4.5.0 RELEASE), but not seeing a way around to start the application.
Quite surprisingly, the outdated version seems to be working with the below code:
cfstatus = cfClient.startApplication("test-app-name"); //start app
cfstatus = cfClient.stopApplication("test-app-name"); //stop app
cfstatus = cfClient.restartApplication("test-app-name"); //stop app
I want to do the same with latest CF client library, but I don't see any useful reference. I referred to test cases written at CloudFoundry official Github repo. I derived to the below code after checking out a lot of docs:
StartApplicationRequest request = StartApplicationRequest.builder()
.applicationId("test-app-name")
.build();
cloudFoundryClient.applicationsV3().start(request);
Note that cloudFoundryClient is ReactorCloudFoundryClient instance as the latest library doesn't support the client class used with outdated code. I would like to do all operations (start/stop/restart) with latest library. The above code isn't working.
A couple things here...
Using the reactor based client, your call to cloudFoundryClient.applicationsV3().start(request) returns a Mono<StartApplicationResponse>. That's not the actual response, it's the possibility of one. You need to do something to get the response. See here for more details.
If you would like similar behavior to the original cf-java-client, you can call .block() on the Mono<StartApplicationResponse> and it will wait and turn into a response.
Ex:
client.applicationsV3()
.start(StartApplicationRequest.builder()
.applicationId("test-app-name")
.build())
.block()
The second thing is that it's .applicationId not applicationName. You need to pass in an application guid, not the name. As it is, you're going to get a 404 saying the application doesn't exist. You can use the client to fetch the guid, or you can use CloudFoundryOperations instead (see #3).
The CloudFoundryOperations interface is a higher-level API. It's easier to use, in general, and supports things like starting an app based on the name instead of the guid.
Ex:
ops.applications()
.start(StartApplicationRequest.builder()
.name("test-app-name").build())
.block();
Is it possible using custom OSRM server (Docker) for routing in navigation SDK? If i have custom streets in postgrey db, how can i calculate route on this streets?
Something as
NavigationRoute.builder(this)
.baseUrl("my server url")
does make request to my server but with additional params in query which i dont want :
/route/v1/driving/directions/v5/mapbox/driving-traffic/
I need just
/route/v1/driving/
Is it possible or exist some lib which converts osrm format to mapbox format?
I've found that it's reasonably trivial to use OSRM as a backing server for the Graphhopper Navigation API (which was forked from Mapbox I believe). I haven't tried using it directly with the Mapbox SDKs, but it might be worth a shot. Basically all I had to do was start up a forwarding server that would grab the coordinates and route parameters and pass them to OSRM, then add a request UUID on the way back to stop the SDK from complaining. I implemented the server in Ruby using Sinatra, and the code is below:
require 'net/http'
require 'sinatra'
require 'sinatra/json'
get '/directions/v5/:user/driving/:coordinates' do
uri = URI("http://router.project-osrm.org/route/v1/driving/#{params['coordinates']}")
uri.query = URI.encode_www_form({
alternatives: params['alternatives'],
continue_straight: params['continue_straight'],
geometries: params['geometries'],
overview: params['overview'],
steps: params['steps']
})
res = JSON.parse(Net::HTTP.get_response(uri).body)
res["uuid"] = SecureRandom.uuid
json(res)
end
I'm using SparkJava 2.2 which is using Jetty 9.0.2.
I'm getting "Form too large" exception which is thrown by Jetty. I already know how to solve this problem if I was using Jetty directly:
Form too Large Exception
http://www.eclipse.org/jetty/documentation/current/setting-form-size.html
PROBLEM :
Now I need to find a way to change org.eclipse.jetty.server.Request.maxFormContentSize setting through SparkJava. Is there a way to do this?
I must note that other methods (JVM_OPTS, System.setProperty) do not work for me for some reason. I'm still getting the same exception.
Stacktrace:
[qtp1858644635-27] ERROR spark.webserver.MatcherFilter -
java.lang.IllegalStateException: Form too large 308913>200000
at org.eclipse.jetty.server.Request.extractParameters(Request.java:334)
at org.eclipse.jetty.server.Request.getParameterMap(Request.java:765)
at javax.servlet.ServletRequestWrapper.getParameterMap(ServletRequestWrapper.java:193)
at spark.QueryParamsMap.<init>(QueryParamsMap.java:59)
at spark.Request.initQueryMap(Request.java:364)
at spark.Request.queryMap(Request.java:349)
at spark.webserver.RequestWrapper.queryMap(RequestWrapper.java:213)
at com.xyz.analytics.webservice.RequestTools.getRequestQueryMap(RequestTools.java:27)
at com.xyz.analytics.webservice.RequestTools.getMandrillQueryParams(RequestTools.java:22)
at com.xyz.analytics.webservice.Endpoints.lambda$initiateEndpointsAndExceptionHandlers$2(Endpoints.java:61)
at com.xyz.analytics.webservice.Endpoints$$Lambda$3/1485697819.handle(Unknown Source)
at spark.SparkBase$1.handle(SparkBase.java:311)
at spark.webserver.MatcherFilter.doFilter(MatcherFilter.java:159)
at spark.webserver.JettyHandler.doHandle(JettyHandler.java:60)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:179)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:451)
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:252)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:266)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:240)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:596)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:527)
at java.lang.Thread.run(Thread.java:745)
Edit:
I must note that other methods (JVM_OPTS, System.setProperty) do not work for me.
Well, debugger doesn't even stop at any breakpoint set within org.eclipse.jetty.server.handlerContextHandler... Plus when it stops at org.eclipse.jetty.server.Request breakpoints, _context property is null. Seems that SparkJava is handling it differently. Dead end.
Request does one more thing before setting maxFormContentSize = 200000;. It checks _channel.getServer().getAttribute("org.eclipse.jetty.server.Request.maxFormContentSize").
Except Server's attribute collection is empty... And I don't see any way to add any attribute. Jetty Server is created by SparkBase.init() which calls SparkServer.ignite().
But it doesn't help us much. It's not easy to "break in" to make our own adjustments. It seems pretty hopeless.
Not possible with Spark 2.2
The creation of the ServerConnector is hardcoded in the SparkServer, you cannot change those values after the fact, they have to be passed into the ServerConnector before server start.
Would recommend filing a bug with Spark to make that configurable.
https://github.com/perwendel/spark/issues
Good news everyone :)
In Spark 2.6 (released April 2017) embedded Jetty is fully configurable!
Release notes: http://sparkjava.com/news#spark-26-released
See the original future request for more details here: https://github.com/perwendel/spark/issues/314
and related pull request here:
https://github.com/perwendel/spark/pull/813
NOTE that it is also possible to run Spark on another web server instead of the embedded Jetty server:
http://sparkjava.com/documentation#other-web-server
Well, having access to the server object, you can always do something like:
server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", 1024 * 1024);
Hope this helps!
I am new to CQ 5 Mobile Application Development what I want to achieve is,
When a mobile device send the request to the page it captures the attributes of mobile like mobile browser, mobile browser version, mobile OS and mobile OS version.
I want to LOG this information and in later stage use this to categorize them in different Device Group and render different components in different device groups.
Note I have already went through some of these links
CQ5 Mobile Development Docs
http://www.cognifide.com/blogs/cq/adobe-cq-5-5-mobile-improvements/
http://wurfl.sourceforge.net/help_doc.php
I have tried this code which throws Null Pointer Exception, since device has null value.
Correct me if I am doing wrong somewhere
SlingHttpServletRequest slingRequest = this.request.getSlingRequest();
Device device = slingRequest.adaptTo(Device.class);
Map<String, String> deviceAttributes = device.getAttributes();
LOG.info("Request is sent from Device with OS"+deviceAttributes.get("device_os"));
Here is the way I am testing this code, whenever a request is sent to the page which has this component which logs the attributes of the mobile device from one of the emulator, I check my LOG Files that
Please help me out if I am going wrong in the code or method to get the mobile device's attributes. Please let me know if you need more details on this.
Regards,
Yash
Hi Here is the Stack Trace for this :
Caused by: org.apache.sling.api.SlingException: An exception occurred processing JSP page /apps/companyname/components/content/mobilebreadcrum/mobilebreadcrum.jsp at line 5
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.handleJspExceptionInternal(JspServletWrapper.java:571)
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:496)
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:448)
at org.apache.sling.scripting.jsp.JspServletWrapperAdapter.service(JspServletWrapperAdapter.java:59)
at org.apache.sling.scripting.jsp.JspScriptEngineFactory.callJsp(JspScriptEngineFactory.java:173)
at org.apache.sling.scripting.jsp.JspScriptEngineFactory.access$100(JspScriptEngineFactory.java:84)
at org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:388)
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:358)
... 147 more Caused by: javax.el.ELException: Error reading 'modelName' on type com.companyname.www.components.content.mobilebreadcrumb.MobileBreadCrum
at javax.el.BeanELResolver.getValue(BeanELResolver.java:66)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at org.apache.el.parser.AstValue.getValue(AstValue.java:97)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.sling.scripting.jsp.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:923)
at org.apache.jsp.apps.companyname.components.content.mobilebreadcrum.mobilebreadcrum_jsp._jspService(mobilebreadcrum_jsp.java:160)
at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
... 152 more Caused by: java.lang.NullPointerException
at com.companyname.www.components.content.mobilebreadcrumb.MobileBreadCrum.getModelName(MobileBreadCrum.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
... 160 more
The JSP Code is :
<%#include file="/apps/companyname/components/global.jsp"%><ct:component
className="com.companyname.www.components.content.mobilebreadcrumb.MobileBreadCrum"
name="mobilebreadcrum" />${mobilebreadcrum.modelName}
The Java Code is:
public String getModelName() {
SlingHttpServletRequest slingRequest = this.request.getSlingRequest();
String resourceType = slingRequest.getResource().getResourceType();
String resourceSuperType = slingRequest.getResource().getResourceSuperType();
LOG.info("RESOURCE TYPE:"+resourceType);
LOG.info("RESOURCE SUPER TYPE:"+resourceSuperType);
Device device = request.getCurrentPage().adaptTo(Device.class);
device.getAttributes();
return modelName;
}
Please let me know if you want anything else
Regards,
Yash
Could you please go to /system/console/adapters and make sure that there is appropriate adapter SlingHttpServletRequest → Device?
I'd start diagnosis from there. In my case corresponding row looks like this:
Adaptable Class: org.apache.sling.api.SlingHttpServletRequest
Adapter Class: com.day.cq.wcm.mobile.api.device.DeviceGroup, com.day.cq.wcm.mobile.api.device.DeviceGroupList, com.day.cq.wcm.mobile.api.device.Device
Providing bundle: com.day.cq.wcm.cq-wcm-mobile-core (190)
Thanks,
Max.
To do this u should use real device, not an emulator. To detect a device CQ looks at user-agent data in the request, so when u open a page on desktop browser u send request with not-a-mobile device user-agent data. To test this feature u can use something like user agent switcher (eg for chrome), but in that case CQ will not use and draw an emulator wrapper cause it will assume that u use a mobile device.
Now I think how to combine right user-agent and drawing an emulator on desktop. Will post by results.
thinking a step above, if you are able to fix this issue how you gonna serve requests? will you always serve requests from publish Aem server or you want to utilize Dispatcher caching?
As your code is identifying device on server side, i doubt you would be able to leverage dispatcher caching. can you think of identifying device on apache level and add selectors in request.
eg. if request if coming from iphone5, then write a rewrite rule on apache to check User agent header and add a selector
http://somesite.com/my/page/url.html to http://somesite.com/my/page/url.iphone.html
if request coming from ipad then add other selector
http://somesite.com/my/page/url.ipad.html
Dispatcher will create different cache for different selectors and will start serving pages from cache.
In your component, you can implement different views for different selector.
Its just a thought, please rethink ...
Greetings,
I am creating a Java based server to create push notifications for Apple's iOS APNs service. I have found Javapns on google code which seems to provide a simple basic framework to communicate with APNs, and which seems to be fairly wide used.
http://code.google.com/p/javapns/
However, reading Apple's docs, there is an "enhanced format" for notifications which supports "expiry" i.e. setting a time (well, in seconds) for a notification to expire if it hasn't yet been delivered. I do not see any way to set this using Javapns, and I am unsure how the APNs service handles expiry of notifications if you do not explicitly set it. So,
Does anyone know how to support the enhanced notification format of APNs specifically how to set the expiry?
Does anyone know how Apple handles notification expiry if it isn't explicitly set?
Does anyone have any suggestions that don't require me to start from scratch, as the server is currently functional as is?
Thanks in advance.
Andrew
I have recently made substantial contributions to the JavaPNS project, which lead to the release of JavaPNS 2.0 a few days ago. That version provides full support for the enhanced notification format, including the ability to set your own expiry.
Sylvain
Nice that you found the java library... to bad you didn't read the docs there.
I'll post some of the highlights below:
The existing code uses the 'Simple notification format' which does not return an error EVER.
See docs at:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html
I've tried updating to the 'Enhanced notification format' which is supposed to return an error, but I'm unable to get any errors back from the APNS. (also in the link above)
With the Enhanced format, the connection isn't being dropped immediately after sending data, but I'm not getting anything back from my socket.getInputSocket.read() call.
This issue will have to be tabled until I have more time to troubleshoot.
(Someone else commented)
Thanks a lot for looking into it.
I got the same result as yours. Maybe it has something to do with Apple Gateway.
So... you could:
1) Build your own
2) Help improve the existing library
3) Try another library like: https://github.com/notnoop/java-apns
4) Do nothing
Enhanced ios push here.
To send a notification, you can do it in three steps:
Setup the connection
ApnsService service =
APNS.newService()
.withCert("/path/to/certificate.p12", "MyCertPassword")
.withSandboxDestination()
.build();
Create and send the message
String payload = APNS.newPayload().alertBody("Can't be simpler than this!").build();
String token = "fedfbcfb....";
service.push(token, payload);
To query the feedback service for inactive devices:
Map<String, Date> inactiveDevices = service.getInactiveDevices();
for (String deviceToken : inactiveDevices.keySet()) {
Date inactiveAsOf = inactiveDevices.get(deviceToken);
...
}