Search in sources :

Example 6 with IServiceProvider

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;
}
Also used : IServiceProvider(com.servoy.j2db.IServiceProvider) ClientInfo(com.servoy.j2db.dataprocessing.ClientInfo) Solution(com.servoy.j2db.persistence.Solution)

Example 7 with IServiceProvider

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());
}
Also used : IServiceProvider(com.servoy.j2db.IServiceProvider) IForm(com.servoy.j2db.IForm) Form(com.servoy.j2db.persistence.Form) WebForm(com.servoy.j2db.server.headlessclient.WebForm) IRepository(com.servoy.j2db.persistence.IRepository) FlattenedSolution(com.servoy.j2db.FlattenedSolution) Solution(com.servoy.j2db.persistence.Solution)

Example 8 with IServiceProvider

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);
    }
}
Also used : IServiceProvider(com.servoy.j2db.IServiceProvider) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) FormScope(com.servoy.j2db.scripting.FormScope)

Example 9 with IServiceProvider

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);
    }
}
Also used : IServiceProvider(com.servoy.j2db.IServiceProvider) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) UnsupportedEncodingException(java.io.UnsupportedEncodingException) FormScope(com.servoy.j2db.scripting.FormScope)

Example 10 with IServiceProvider

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;
}
Also used : IServiceProvider(com.servoy.j2db.IServiceProvider)

Aggregations

IServiceProvider (com.servoy.j2db.IServiceProvider)14 Solution (com.servoy.j2db.persistence.Solution)3 FlattenedSolution (com.servoy.j2db.FlattenedSolution)2 FormController (com.servoy.j2db.FormController)2 IForm (com.servoy.j2db.IForm)2 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)2 Form (com.servoy.j2db.persistence.Form)2 FormScope (com.servoy.j2db.scripting.FormScope)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ApplicationException (com.servoy.j2db.ApplicationException)1 FormManager (com.servoy.j2db.FormManager)1 IFormController (com.servoy.j2db.IFormController)1 ClientInfo (com.servoy.j2db.dataprocessing.ClientInfo)1 IRepository (com.servoy.j2db.persistence.IRepository)1 RepositoryException (com.servoy.j2db.persistence.RepositoryException)1 RootObjectMetaData (com.servoy.j2db.persistence.RootObjectMetaData)1 WebForm (com.servoy.j2db.server.headlessclient.WebForm)1 NGClient (com.servoy.j2db.server.ngclient.NGClient)1 NGClientWebsocketSessionWindows (com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows)1 IApplicationServerSingleton (com.servoy.j2db.server.shared.IApplicationServerSingleton)1