/** * Abort current transaction and rollback operations. * * @param fireEvent */ public void abort(boolean fireEvent) { if (!aborted && active) { if (transaction != null) { transaction.executeSQL( "invalid sql statement", null, null, new SQLTransaction.SQLStatementErrorCallback() { @Override public boolean onError(SQLTransaction tx, SQLError error) { return true; // tell web sql to rollback transaction } }); transaction = null; } aborted = true; active = false; requestProcessor.stop(); if (fireEvent) { if (LogConfiguration.loggingIsEnabled()) { logger.log(Level.INFO, db.messages.databaseTransactionAborted(db.getName())); } if (transactionCallback != null) { try { transactionCallback.onAbort(); } catch (Exception e) { String message = db.messages.databaseTransactionError(db.getName(), e.getMessage()); reportError(transactionCallback, message, e); } } } } }
/** * simple wrapper for {@link LogConfiguration#loggingIsEnabled()} as this is not NPE safe in JUnit * mode * * @return */ public static boolean canLog() { try { if (LogConfiguration.loggingIsEnabled()) { return true; } } catch (Exception ignored) { } return false; }
public void onError(String errorMessage) { String message = db.messages.databaseTransactionError(db.getName(), errorMessage); active = false; requestProcessor.stop(); if (LogConfiguration.loggingIsEnabled()) { logger.log(Level.SEVERE, message); } if (transactionCallback != null) { transactionCallback.onError(message); } }
/** * redirect unauthorized calls to login * * <p>TODO method.getResponse() is not equal to response. unfortunately */ @Override public RequestCallback filter( final Method method, final Response response, RequestCallback callback) { if (LogConfiguration.loggingIsEnabled()) { Logger.getLogger(FilterawareRetryingCallback.class.getName()) .severe("Unauthorized: " + method.builder.getUrl()); } Window.Location.assign(target + Window.Location.getQueryString()); // useless return, anyway return callback; }
public void onSuccess() { if (LogConfiguration.loggingIsEnabled()) { logger.log(Level.INFO, db.messages.databaseTransactionCompleted(db.getName())); } active = false; requestProcessor.stop(); if (transactionCallback != null) { try { transactionCallback.onComplete(); } catch (Exception e) { String message = db.messages.databaseTransactionError(db.getName(), e.getMessage()); reportError(transactionCallback, message, e); } } }
private void log(final Level level, final String message) { if (LogConfiguration.loggingIsEnabled()) { LOGGER.log(level, message); } }
@Override public void onModuleLoad() { Profiler.initialize(); Profiler.enter("ApplicationConfiguration.onModuleLoad"); BrowserInfo browserInfo = BrowserInfo.get(); // Enable iOS6 cast fix (see #10460) if (browserInfo.isIOS6() && browserInfo.isWebkit()) { enableIOS6castFix(); } // Prepare the debugging window if (isDebugMode()) { /* * XXX Lots of implementation details here right now. This should be * cleared up when an API for extending the debug window is * implemented. */ VDebugWindow window = GWT.create(VDebugWindow.class); if (LogConfiguration.loggingIsEnabled()) { window.addSection((Section) GWT.create(LogSection.class)); } window.addSection((Section) GWT.create(InfoSection.class)); window.addSection((Section) GWT.create(HierarchySection.class)); window.addSection((Section) GWT.create(NetworkSection.class)); if (Profiler.isEnabled()) { window.addSection((Section) GWT.create(ProfilerSection.class)); } if (isQuietDebugMode()) { window.close(); } else { window.init(); } // Connect to the legacy API VConsole.setImplementation(window); Handler errorNotificationHandler = GWT.create(ErrorNotificationHandler.class); Logger.getLogger("").addHandler(errorNotificationHandler); } if (LogConfiguration.loggingIsEnabled()) { GWT.setUncaughtExceptionHandler( new UncaughtExceptionHandler() { @Override public void onUncaughtException(Throwable e) { /* * If the debug window is not enabled (?debug), this will * not show anything to normal users. "a1 is not an object" * style errors helps nobody, especially end user. It does * not work tells just as much. */ getLogger().log(Level.SEVERE, e.getMessage(), e); } }); if (isProductionMode()) { // Disable all logging if in production mode Logger.getLogger("").setLevel(Level.OFF); } } Profiler.leave("ApplicationConfiguration.onModuleLoad"); if (SuperDevMode.enableBasedOnParameter()) { // Do not start any application as super dev mode will refresh the // page once done compiling return; } registerCallback(GWT.getModuleName()); }
private void init() { GWT.setUncaughtExceptionHandler( new GWT.UncaughtExceptionHandler() { public void onUncaughtException(Throwable e) { log.log(Level.SEVERE, e.getMessage(), e); } }); if (LogConfiguration.loggingIsEnabled()) { /* Add remote logging handler */ RequestFactoryLogHandler.LoggingRequestProvider provider = new RequestFactoryLogHandler.LoggingRequestProvider() { public LoggingRequest getLoggingRequest() { return requestFactory.loggingRequest(); } }; Logger.getLogger("") .addHandler( new RequestFactoryLogHandler(provider, Level.WARNING, new ArrayList<String>())); } // AppEngine user authentication new GaeLoginWidgetDriver(requestFactory).setWidget(shell.loginWidget); new ReloadOnAuthenticationFailure().register(eventBus); /* Left side lets us pick from all the types of entities */ final Renderer<ProxyListPlace> placePickerRenderer = new ApplicationListPlaceRenderer(); Cell<ProxyListPlace> placePickerCell = new AbstractCell<ProxyListPlace>() { @Override public void render(Context context, ProxyListPlace value, SafeHtmlBuilder sb) { sb.appendEscaped(placePickerRenderer.render(value)); } }; CellList<ProxyListPlace> placePickerList = new CellList<ProxyListPlace>(placePickerCell, getMobileListResources()); placePickerList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); final ValuePicker<ProxyListPlace> placePickerView = new ValuePicker<ProxyListPlace>(placePickerList); Activity defaultActivity = new DefaultActivity(placePickerView); ProxyPlaceToListPlace proxyPlaceToListPlace = new ProxyPlaceToListPlace(); ProxyListPlacePicker proxyListPlacePicker = new ProxyListPlacePicker(placeController, proxyPlaceToListPlace); placePickerView.setAcceptableValues(getTopPlaces()); proxyListPlacePicker.register(eventBus, placePickerView); /* * Wrap the scaffoldMobileActivities so we can intercept activity requests * and remember the last activity (for back button support). */ scaffoldMobileActivities.setRootActivity(defaultActivity); ActivityMapper activityMapper = new ActivityMapper() { public Activity getActivity(Place place) { // Defer to scaffoldMobileActivities. Activity nextActivity = scaffoldMobileActivities.getActivity(place); // Clear the value of the placePicker so we can select a new top level // value. placePickerView.setValue(null, false); // Update the title, back and edit buttons. Button backButton = shell.getBackButton(); if (nextActivity instanceof IsScaffoldMobileActivity) { lastActivity = (IsScaffoldMobileActivity) nextActivity; // Update the title. shell.setTitleText(lastActivity.getTitleText()); // Update the back button. String backButtonText = lastActivity.getBackButtonText(); if (backButtonText == null || backButtonText.length() == 0) { shell.setBackButtonVisible(false); } else { shell.setBackButtonVisible(true); backButton.setText(backButtonText); } // Update the edit button. shell.setEditButtonVisible(lastActivity.hasEditButton()); } else { lastActivity = null; shell.setTitleText(""); shell.setBackButtonVisible(false); shell.setEditButtonVisible(false); } // Return the activity. return nextActivity; } }; /* * The body is run by an ActivityManager that listens for PlaceChange events * and finds the corresponding Activity to run */ final ActivityManager activityManager = new ActivityManager(activityMapper, eventBus); activityManager.setDisplay(shell.getBody()); /* Browser history integration */ ScaffoldPlaceHistoryMapper mapper = GWT.create(ScaffoldPlaceHistoryMapper.class); mapper.setFactory(placeHistoryFactory); PlaceHistoryHandler placeHistoryHandler = new PlaceHistoryHandler(mapper); placeHistoryHandler.register(placeController, eventBus, ROOT_PLACE); placeHistoryHandler.handleCurrentHistory(); shell .getBackButton() .addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { if (lastActivity != null) { Place backPlace = lastActivity.getBackButtonPlace(); if (backPlace != null) { placeController.goTo(backPlace); } } } }); shell .getEditButton() .addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { if (lastActivity != null) { Place editPlace = lastActivity.getEditButtonPlace(); if (editPlace != null) { placeController.goTo(editPlace); } } } }); }
protected void initHandlers() { GWT.setUncaughtExceptionHandler( new GWT.UncaughtExceptionHandler() { @Override public void onUncaughtException(final Throwable e) { Window.alert("Error: " + e.getMessage()); LOGGER.log(Level.SEVERE, e.getMessage(), e); } }); if (LogConfiguration.loggingIsEnabled()) { // Add remote logging handler final RequestFactoryLogHandler.LoggingRequestProvider provider = new RequestFactoryLogHandler.LoggingRequestProvider() { @Override public LoggingRequest getLoggingRequest() { return requestFactory.loggingRequest(); } }; Logger.getLogger("") .addHandler( new RequestFactoryLogHandler(provider, Level.WARNING, new ArrayList<String>())); } RequestEvent.register( eventBus, new RequestEvent.Handler() { // Only show loading status if a request isn't serviced in 250ms. private static final int LOADING_TIMEOUT = 250; @Override public void onRequestEvent(final RequestEvent requestEvent) { if (requestEvent.getState() == RequestEvent.State.SENT) { DOM.setStyleAttribute(shell.getElement(), "cursor", "wait"); shell.getMole().showDelayed(LOADING_TIMEOUT); } else { DOM.setStyleAttribute(shell.getElement(), "cursor", "default"); shell.getMole().hide(); } } }); if (shell instanceof PlaceChangeEvent.Handler) { eventBus.addHandler(PlaceChangeEvent.TYPE, (PlaceChangeEvent.Handler) shell); } LoginEvent.register(eventBus, this); LogoutEvent.register(eventBus, this); AuthRequiredEvent.register( eventBus, new AuthRequiredEvent.Handler() { @Override public void onAuthRequiredEvent(final AuthRequiredEvent authRequiredEvent) { placeController.goTo(new LoginPlace(History.getToken())); } }); RequestForbidenEvent.register( eventBus, new RequestForbidenEvent.Handler() { @Override public void onRequestForbidenEvent(final RequestForbidenEvent requestForbidenEvent) { shell.addMessage(i18n._03_title(), AlertType.ERROR); } }); }
@Override public void onModuleLoad() { // Don't run twice if the module has been inherited several times. if (moduleLoaded) { return; } moduleLoaded = true; Profiler.initialize(); Profiler.enter("ApplicationConfiguration.onModuleLoad"); BrowserInfo browserInfo = BrowserInfo.get(); // Enable iOS6 cast fix (see #10460) if (browserInfo.isIOS6() && browserInfo.isWebkit()) { enableIOS6castFix(); } // Enable IE prompt fix (#13367) if (browserInfo.isIE() && browserInfo.getBrowserMajorVersion() >= 10) { enableIEPromptFix(); } // Register pointer events (must be done before any events are used) PointerEventSupport.init(); // Prepare the debugging window if (isDebugMode()) { /* * XXX Lots of implementation details here right now. This should be * cleared up when an API for extending the debug window is * implemented. */ VDebugWindow window = GWT.create(VDebugWindow.class); if (LogConfiguration.loggingIsEnabled()) { window.addSection((Section) GWT.create(LogSection.class)); } window.addSection((Section) GWT.create(InfoSection.class)); window.addSection((Section) GWT.create(HierarchySection.class)); window.addSection((Section) GWT.create(NetworkSection.class)); window.addSection((Section) GWT.create(TestBenchSection.class)); if (Profiler.isEnabled()) { window.addSection((Section) GWT.create(ProfilerSection.class)); } if (isQuietDebugMode()) { window.close(); } else { // Load debug window styles asynchronously GWT.runAsync( new RunAsyncCallback() { @Override public void onSuccess() { DebugWindowStyles dws = GWT.create(DebugWindowStyles.class); dws.css().ensureInjected(); } @Override public void onFailure(Throwable reason) { Window.alert("Failed to load Vaadin debug window styles"); } }); window.init(); } // Connect to the legacy API VConsole.setImplementation(window); Handler errorNotificationHandler = GWT.create(ErrorNotificationHandler.class); Logger.getLogger("").addHandler(errorNotificationHandler); } if (LogConfiguration.loggingIsEnabled()) { GWT.setUncaughtExceptionHandler( new UncaughtExceptionHandler() { @Override public void onUncaughtException(Throwable e) { /* * If the debug window is not enabled (?debug), this will * not show anything to normal users. "a1 is not an object" * style errors helps nobody, especially end user. It does * not work tells just as much. */ getLogger().log(Level.SEVERE, e.getMessage(), e); } }); if (isProductionMode()) { // Disable all logging if in production mode Logger.getLogger("").setLevel(Level.OFF); } } Profiler.leave("ApplicationConfiguration.onModuleLoad"); if (SuperDevMode.enableBasedOnParameter()) { // Do not start any application as super dev mode will refresh the // page once done compiling return; } registerCallback(GWT.getModuleName()); }