Hi,
I have tried to access a webmap in my enterprise portal (airgapped) from a runtime java application. When I try to access my enterprise portal using the following code
AuthenticationManager.setAuthenticationChallengeHandler(new DefaultAuthenticationChallengeHandler());
Portal portal = new Portal("http://xyz.com/arcgisportal",true")
portal.loadAsync()
A new window for entering user credentials is appearing on the screen and I have entered the credentials, but I am not able to access the webmap and when i Print
System.out.println(portal.getPortalInfo);
Null is coming.
Pls Suggest a solution
Thanks
J Jacob
I wonder if you are reading the portalInfo on the line of code which is after portal.loadAsync() ?
It is entirely possible you will get a null value back because you've read the value before the portal has had chance to load. Some asynchronous coding which uses the loadable pattern will help you here, even it only helps to diagnose the issue.
Some background notes on this are here.
So in your example you should add a DoneLoadingListener something like this:
// portal we want to use
Portal portal = new Portal("http://www.arcgis.com/");
//trigger a load
portal.loadAsync();
// listen to it loading before reading
portal.addDoneLoadingListener(() -> {
// check it is has loaded
if (portal.getLoadStatus() == LoadStatus.LOADED) {
// all is well and we can now read the portal info
System.out.println("waiting for it to load we get : " + portal.getPortalInfo().getPortalName());
}
});
You can also use the listener to diagnose loading issues.
Does this help?
Thank you for replying.
I tried with addDoneLoadListner only.
Can you pls elaborate on "You can also use the listener to diagnose loading issues"
Regards
"
Had adding the doneLoadingListener allowed you to fix the issue?
For detecting loading issues, you can look at the load status to see if it failed to load. I've updated my code to include a bad web address and reported the error in the console:
// portal we want to use. NOTE the bad web address!
Portal portal = new Portal("chttp://www.arcgis.com/");
//trigger a load
portal.loadAsync();
// listen to it loading before reading
portal.addDoneLoadingListener(() -> {
// check is has loaded
if (portal.getLoadStatus() == LoadStatus.LOADED) {
// all is well and we can now read the portal info
System.out.println("waiting for it to load we get : " + portal.getPortalInfo().getPortalName());
}
// check for error condition
if (portal.getLoadStatus() == LoadStatus.FAILED_TO_LOAD) {
System.out.println("load failure message : " + portal.getLoadError().getMessage());
System.out.println("load failure cause " + portal.getLoadError().getCause());
}
});