Skip to content

Commit

Permalink
#161 log quota exceptions to server
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurensRietveld committed Oct 5, 2013
1 parent 53093e3 commit 3225f8d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* #L%
*/

import com.data2semantics.yasgui.client.helpers.JsMethods;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class ConnectivityHelper {
Expand Down
18 changes: 2 additions & 16 deletions src/main/java/com/data2semantics/yasgui/client/ViewElements.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@
import com.data2semantics.yasgui.client.tab.optionbar.LinkCreator;
import com.data2semantics.yasgui.client.tab.optionbar.endpoints.EndpointInput;
import com.data2semantics.yasgui.shared.exceptions.ElementIdException;
import com.data2semantics.yasgui.shared.exceptions.FetchException;
import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.VerticalAlignment;
Expand Down Expand Up @@ -285,23 +283,11 @@ public void onError(Throwable e) {
} else {
errorMsg = e.getMessage();
}
if (view.getConnHelper().isOnline()) {
//Log exception to server
new GwtCallbackWrapper<Void>(view) {
public void onCall(AsyncCallback<Void> callback) {
view.getRemoteService().logException(new FetchException("blaat"), callback);
}

protected void onFailure(Throwable throwable) {
}

protected void onSuccess(Void prefixes) {
}
}.call();
}
Helper.logExceptionToServer(e);

onError(errorMsg);
}

/**
* Modal popup window to show on error
*
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/data2semantics/yasgui/client/helpers/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import java.util.Set;
import java.util.logging.Logger;

import com.data2semantics.yasgui.client.services.YasguiServiceAsync;
import com.data2semantics.yasgui.shared.exceptions.ElementIdException;
import com.google.gwt.core.client.GWT;
import com.google.gwt.json.client.JSONArray;
Expand All @@ -62,6 +63,7 @@
import com.google.gwt.regexp.shared.MatchResult;
import com.google.gwt.regexp.shared.RegExp;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
Expand Down Expand Up @@ -350,4 +352,18 @@ public static boolean isSeleniumVisitor() {
}
return isSeleniumVisitor;
}

/**
* Try to log exception. Do nothing on either fail or success
* @param t
*/
public static void logExceptionToServer(Throwable t) {
YasguiServiceAsync yasguiService = YasguiServiceAsync.Util.getInstance();
yasguiService.logException(t, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
}
public void onSuccess(Void voidObj) {
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import java.util.Date;

import com.data2semantics.yasgui.client.View;
import com.data2semantics.yasgui.client.settings.Settings;
import com.data2semantics.yasgui.shared.CookieKeys;
import com.google.gwt.core.client.GWT;
Expand All @@ -48,8 +49,13 @@ public class LocalStorageHelper {
private static int COMPATABILITIES_SHOWN_EXPIRE_DAYS = 1000;
private static int PROPERTIES_EXPIRE_DAYS = 360;
private static int DEFAULT_EXPIRE_DAYS = 1000;
@SuppressWarnings("unused")
private static int UNKNOWN_EXPIRE_DAYS = 30;
private View view;

public LocalStorageHelper(View view) {
this.view = view;
}

/**
* Get value from local storage using expire date.
Expand Down Expand Up @@ -107,7 +113,7 @@ private static String getFromLocalStorage(String key) {
} else if (storageMap.containsKey(key)) {
//for backwards compatability (i.e. the time when we didnt use the basedomain as part of the key)
String value = storageMap.get(key);
setInLocalStorage(key, value); //settings it again stores it under correct key with domain name
storeInLocalStorage(key, value); //settings it again stores it under correct key with domain name
storageMap.remove(key);//remove old key
return value;
}
Expand All @@ -120,10 +126,14 @@ private static void removeLocalStorageKey(String key) {
html5Storage.removeItem(domain + "_" + key);
}

public static void setInLocalStorage(String key, String value) {
private static void storeInLocalStorage(String key, String value) {
if (Storage.isLocalStorageSupported()) {
Storage html5Storage = Storage.getLocalStorageIfSupported();
html5Storage.setItem(Helper.getCurrentHost() + "_" + key, value);
try {
html5Storage.setItem(Helper.getCurrentHost() + "_" + key, value);
} catch (Throwable t) {
Helper.logExceptionToServer(t);
}
}
}

Expand All @@ -139,7 +149,7 @@ public static void setInLocalStorage(String key, String value, boolean addTimeSt
if (addTimeStamp) {
value = Long.toString(currentDate.getTime()) + LOCAL_STORAGE_EXPIRE_SEPARATOR + value;
}
setInLocalStorage(key, value);
storeInLocalStorage(key, value);
}
}

Expand Down

0 comments on commit 3225f8d

Please sign in to comment.