use of com.servoy.j2db.IServiceProvider in project servoy-client by Servoy.
the class Debug method insertClientInfo.
@SuppressWarnings("nls")
private static boolean insertClientInfo(boolean insert) {
IServiceProvider serviceProvider = J2DBGlobals.getServiceProvider();
if (insert && serviceProvider != null) {
Solution solution = serviceProvider.getSolution();
String clientID = serviceProvider.getClientID();
if (solution != null && clientID != null) {
if (MDC.get("clientid") == null) {
MDC.put("clientid", clientID);
MDC.put("solution", solution.getName());
String username = serviceProvider.getUserName();
if (username != null)
MDC.put("username", username);
String useruuid = serviceProvider.getUserUID();
if (useruuid != null)
MDC.put("useruuid", username);
ClientInfo clientInfo = serviceProvider.getClientInfo();
if (clientInfo != null) {
MDC.put("clienttype", IApplication.getApplicationTypeAsString(clientInfo.getApplicationType()));
MDC.put("hostname", clientInfo.getHostName());
MDC.put("hostaddress", clientInfo.getHostAddress());
}
return true;
}
} else {
MDC.remove("clientid");
MDC.remove("solution");
MDC.remove("username");
MDC.remove("useruuid");
MDC.remove("clienttype");
MDC.remove("hostname");
MDC.remove("hostaddress");
}
} else {
MDC.remove("clientid");
MDC.remove("solution");
MDC.remove("username");
MDC.remove("useruuid");
MDC.remove("clienttype");
MDC.remove("hostname");
MDC.remove("hostaddress");
}
return false;
}
use of com.servoy.j2db.IServiceProvider in project servoy-client by Servoy.
the class TemplateGenerator method getFormHTMLAndCSS.
public static Pair<String, String> getFormHTMLAndCSS(int solution_id, int form_id) throws RepositoryException, RemoteException {
final IRepository repository = ApplicationServerRegistry.get().getLocalRepository();
Solution solution = (Solution) repository.getActiveRootObject(solution_id);
Form form = solution.getForm(form_id);
IServiceProvider sp = null;
if (WebClientSession.get() != null) {
sp = WebClientSession.get().getWebClient();
}
return getFormHTMLAndCSS(solution, form, sp, form.getName());
}
use of com.servoy.j2db.IServiceProvider in project servoy-client by Servoy.
the class SessionClient method getDataProviderValue.
public synchronized Object getDataProviderValue(String contextName, String dataProviderID) {
if (dataProviderID == null)
return null;
IServiceProvider prev = testThreadLocals();
try {
Object value = null;
if (ScopesUtils.isVariableScope(dataProviderID)) {
value = getScriptEngine().getSolutionScope().getScopesScope().get(null, dataProviderID);
} else {
Pair<IRecordInternal, FormScope> p = getContext(contextName);
if (p != null) {
FormScope fs = p.getRight();
IRecordInternal record = p.getLeft();
if (// how can fs be null.
fs != null && fs.has(dataProviderID, fs)) {
value = fs.get(dataProviderID);
} else if (record != null) {
value = record.getValue(dataProviderID);
}
// $NON-NLS-1$
if (value == Scriptable.NOT_FOUND)
value = "";
}
}
return value;
} finally {
unsetThreadLocals(prev);
}
}
use of com.servoy.j2db.IServiceProvider in project servoy-client by Servoy.
the class SessionClient method setDataProviderValues.
public synchronized int setDataProviderValues(String contextName, HttpServletRequest request_data) {
int retval = 0;
if (request_data.getCharacterEncoding() == null) {
try {
request_data.setCharacterEncoding(wicket_app.getRequestCycleSettings().getResponseRequestEncoding());
} catch (UnsupportedEncodingException e) {
Debug.log(e);
}
}
IServiceProvider prev = testThreadLocals();
try {
Pair<IRecordInternal, FormScope> p = getContext(contextName);
Enumeration<?> e = request_data.getParameterNames();
while (e.hasMoreElements()) {
String param = (String) e.nextElement();
Object val = request_data.getParameter(param);
Object oldVal = setDataProviderValue(p, param, val);
if (!(Utils.equalObjects(oldVal, val)))
retval++;
}
return retval;
} finally {
unsetThreadLocals(prev);
}
}
use of com.servoy.j2db.IServiceProvider in project servoy-client by Servoy.
the class SessionClient method testThreadLocals.
/**
* This method sets the service provider to this if needed. Will return the previous provider that should be set back later.
*
* @return previously set service provider.
*/
protected IServiceProvider testThreadLocals() {
if (wicket_app != null) {
if (!Application.exists()) {
Application.set(wicket_app);
}
if (ApplicationServerRegistry.get() != null) {
if (!Session.exists()) {
synchronized (wicket_app) {
if (wicket_session == null) {
wicket_app.fakeInit();
wicket_session = wicket_app.newSession(new EmptyRequest(), null);
}
}
Session.set(wicket_session);
}
}
}
IServiceProvider provider = J2DBGlobals.getServiceProvider();
if (provider != this) {
// if this happens it is a webclient in developer..
// and the provider is not set for this web client. so it must be set.
J2DBGlobals.setServiceProvider(this);
}
return provider;
}
Aggregations