Search in sources :

Example 1 with ModelContext

use of com.genexus.ModelContext in project JavaClasses by genexuslabs.

the class UserInformation method getLocalUtil.

public LocalUtil getLocalUtil() {
    String androidLanguage = com.artech.base.services.AndroidContext.ApplicationContext.getLanguageName();
    if (localUtil != null && androidLanguage != null) {
        String androidLanguageCode = Application.getClientPreferences().getProperty("language|" + androidLanguage, "code", (String) null);
        if (androidLanguageCode != null && !localUtil._language.equals(androidLanguageCode)) {
            // re create localUtil, language has changed.
            System.out.println("change LocalUtil language: " + androidLanguage + "");
            ModelContext tempContext = ModelContext.getModelContext();
            if (tempContext != null) {
                int res = ((HttpContext) tempContext.getHttpContext()).setLanguage(androidLanguage);
                this.setLocalUtil(tempContext.getHttpContext().getLanguageProperty("decimal_point").charAt(0), tempContext.getHttpContext().getLanguageProperty("date_fmt"), tempContext.getHttpContext().getLanguageProperty("time_fmt"), tempContext.getClientPreferences().getYEAR_LIMIT(), tempContext.getHttpContext().getLanguageProperty("code"));
            }
        }
    }
    return localUtil;
}
Also used : ModelContext(com.genexus.ModelContext) HttpContext(com.genexus.internet.HttpContext)

Example 2 with ModelContext

use of com.genexus.ModelContext in project JavaClasses by genexuslabs.

the class Reorganization method execute.

public void execute() {
    context = new ModelContext(getClass());
    new reorg(getHandle()).execute();
}
Also used : ModelContext(com.genexus.ModelContext)

Example 3 with ModelContext

use of com.genexus.ModelContext in project JavaClasses by genexuslabs.

the class GXOAuthUserInfo method doExecute.

protected void doExecute(HttpContext context) throws Exception {
    new WebApplicationStartup().init(Application.gxCfg, context);
    context.setStream();
    try {
        ModelContext modelContext = new ModelContext(Application.gxCfg);
        modelContext.setHttpContext(context);
        ModelContext.getModelContext().setHttpContext(context);
        String[] user = new String[] { "" };
        boolean[] flag = new boolean[] { false };
        GXSecurityProvider.getInstance().oauthgetuser(-2, modelContext, user, flag);
        if (!flag[0]) {
        } else {
            context.getResponse().setContentType("application/json");
            context.getResponse().setStatus(200);
            context.writeText(user[0]);
            context.getResponse().flushBuffer();
            return;
        }
    } catch (Throwable e) {
        context.sendResponseStatus(500, e.getMessage());
    }
}
Also used : ModelContext(com.genexus.ModelContext)

Example 4 with ModelContext

use of com.genexus.ModelContext in project JavaClasses by genexuslabs.

the class GXutil method now.

@SuppressWarnings("deprecation")
@Override
public Date now(boolean useClientTimeZone, boolean millisecond) {
    ModelContext context = ModelContext.getModelContext();
    Calendar cal = getCalendar();
    synchronized (cal) {
        cal.setTime(new Date());
        if (!millisecond)
            cal.set(Calendar.MILLISECOND, 0);
        if (Application.getClientPreferences().useTimezoneFix() && useClientTimeZone)
            return context.toContextTz(cal.getTime());
        return cal.getTime();
    }
}
Also used : ModelContext(com.genexus.ModelContext) Calendar(java.util.Calendar) Date(java.util.Date)

Example 5 with ModelContext

use of com.genexus.ModelContext in project JavaClasses by genexuslabs.

the class GXOAuthLogout method doExecute.

protected void doExecute(HttpContext context) throws Exception {
    new WebApplicationStartup().init(Application.gxCfg, context);
    context.setStream();
    try {
        ModelContext modelContext = new ModelContext(Application.gxCfg);
        modelContext.setHttpContext(context);
        ModelContext.getModelContext().setHttpContext(context);
        GXSecurityProvider.getInstance().oauthlogout(-2, modelContext);
        context.getResponse().setContentType("application/json");
        context.getResponse().setStatus(200);
        context.writeText("{}");
        context.getResponse().flushBuffer();
        return;
    } catch (Throwable e) {
        context.sendResponseStatus(500, e.getMessage());
    }
}
Also used : ModelContext(com.genexus.ModelContext)

Aggregations

ModelContext (com.genexus.ModelContext)11 HttpContext (com.genexus.internet.HttpContext)3 ServerPreferences (com.genexus.ServerPreferences)1 UserInformation (com.genexus.db.UserInformation)1 HttpContextNull (com.genexus.internet.HttpContextNull)1 HttpRequest (com.genexus.internet.HttpRequest)1 GXResult (com.genexus.security.GXResult)1 OutData (com.genexus.security.OutData)1 IHttpServletRequest (com.genexus.servlet.http.IHttpServletRequest)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Method (java.lang.reflect.Method)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 JSONArray (json.org.json.JSONArray)1 JSONObject (json.org.json.JSONObject)1