use of com.servoy.j2db.IWebClientApplication in project servoy-client by Servoy.
the class WebClientSession method startSessionClient.
@SuppressWarnings("nls")
public IWebClientApplication startSessionClient(RootObjectMetaData sd, String method, StartupArguments argumentsScope) throws Exception {
String firstArgument = argumentsScope.getFirstArgument();
IWebClientApplication webClient = getWebClient();
if (webClient != null) {
boolean solutionLoaded = webClient.getSolution() != null;
if (solutionLoaded && !webClient.closeSolution(false, null)) {
// not allowed to close solution?
return webClient;
}
if (solutionLoaded && isSignedIn() && !Utils.getAsBoolean(Settings.getInstance().getProperty("servoy.allowSolutionBrowsing", "true")) && !sd.getName().equals(keepCredentialsSolutionName)) {
webClient.logout(null);
}
if (!isSignedIn()) {
SolutionMetaData smd = (SolutionMetaData) sd;
IRepository repository = ApplicationServerRegistry.get().getLocalRepository();
Solution sol = (Solution) repository.getActiveRootObject(smd.getName(), IRepository.SOLUTIONS);
if (sol.getLoginSolutionName() == null && sol.getLoginFormID() <= 0 && smd.getMustAuthenticate()) {
// signin first
throw new RestartResponseAtInterceptPageException(SignIn.class);
}
}
keepCredentialsSolutionName = null;
}
if (webClient == null || webClient.isShutDown()) {
HttpServletRequest req = ((WebRequest) RequestCycle.get().getRequest()).getHttpServletRequest();
httpSession = req.getSession();
webClient = createWebClient(req, credentials, method, firstArgument == null ? null : new Object[] { firstArgument, argumentsScope.toJSMap() }, sd.getName());
webClient.handleArguments(new String[] { sd.getName() }, argumentsScope);
if (RequestCycle.get() != null) {
// if this is inside a request cycle set the service provider.
// will be reset by the detach of the RequestCycle.
J2DBGlobals.setServiceProvider(webClient);
}
setAttribute("servoy_webclient", webClient);
} else {
webClient.handleArguments(firstArgument != null ? new String[] { sd.getName(), method, firstArgument } : new String[] { sd.getName(), method }, argumentsScope);
}
// fake first load
webClient.handleClientUserUidChanged(null, "");
if (webClient.getSolution() != null)
getSolutionLastModifiedTime(webClient.getSolution());
else {
if (webClient.getPreferedSolutionNameToLoadOnInit() != null) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("s", webClient.getPreferedSolutionNameToLoadOnInit());
map.put("m", webClient.getPreferedSolutionMethodNameToCall());
if (webClient.getPreferedSolutionMethodArguments() != null && webClient.getPreferedSolutionMethodArguments().length > 0) {
map.put("a", webClient.getPreferedSolutionMethodArguments()[0]);
}
throw new RestartResponseException(SolutionLoader.class, new PageParameters(map));
}
}
return webClient;
}
Aggregations