use of com.google.gson.GsonBuilder in project ranger by apache.
the class RangerAdminClientImpl method init.
public void init(String serviceName, String appId, String configPropertyPrefix) {
Gson gson = null;
try {
gson = new GsonBuilder().setDateFormat("yyyyMMdd-HH:mm:ss.SSS-Z").setPrettyPrinting().create();
} catch (Throwable excp) {
LOG.error("RangerAdminClientImpl: failed to create GsonBuilder object", excp);
}
this.gson = gson;
}
use of com.google.gson.GsonBuilder in project ranger by apache.
the class RangerAdminClientImpl method init.
@Override
public void init(String serviceName, String appId, String configPropertyPrefix) {
Gson gson = null;
try {
gson = new GsonBuilder().setDateFormat("yyyyMMdd-HH:mm:ss.SSS-Z").setPrettyPrinting().create();
} catch (Throwable excp) {
LOG.error("RangerAdminClientImpl: failed to create GsonBuilder object", excp);
}
this.gson = gson;
}
use of com.google.gson.GsonBuilder in project SecurityCraft by Geforce132.
the class VersionUpdateChecker method getNBTTagCompound.
public static NBTTagCompound getNBTTagCompound() {
NBTTagCompound tag = new NBTTagCompound();
Gson gson = new GsonBuilder().create();
try {
URL updateURL = new URL("https://www.github.com/Geforce132/SecurityCraft/raw/master/Updates/" + Loader.MC_VERSION + ".json");
BufferedReader in = new BufferedReader(new InputStreamReader(updateURL.openStream()));
Update update = gson.fromJson(in, Update.class);
if (update == null)
return null;
if ((update.getVersion().matches("0.0.0") && update.getFileName().matches("test")) || update.getVersion().matches(SecurityCraft.getVersion())) {
SecurityCraft.log("Running the latest version, no new updates avaliable.");
return null;
}
tag.setString("newVersion", update.getVersion());
tag.setString("updateUrl", update.getDownloadURL());
tag.setString("changelog", update.getChangelog());
tag.setString("newFileName", update.getFileName());
tag.setBoolean("isDirectLink", true);
} catch (JsonSyntaxException e) {
e.printStackTrace();
return null;
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
return tag;
}
use of com.google.gson.GsonBuilder in project DVECTN by tanaponudom.
the class NetworkConnectionManager method callServer_dd_p3.
// //////////////////////////////////////////////////////////////////////////////////////////////
public void callServer_dd_p3(final OnNetworkCallback_DD_P3 listener, int member_id, int ex31, int ex32, int ex33, int ex34, int ex35, int ex36, int ex37) {
Gson gson = new GsonBuilder().setLenient().create();
final Retrofit retrofit = new Retrofit.Builder().baseUrl(Fragment_login.BASE_URL).addConverterFactory(GsonConverterFactory.create(gson)).build();
APISERVER callapi = retrofit.create(APISERVER.class);
Call call = callapi.getDataDDP3(member_id, ex31, ex32, ex33, ex34, ex35, ex36, ex37);
call.enqueue(new Callback<POJO_DD_P3>() {
@Override
public void onResponse(Call<POJO_DD_P3> call, Response<POJO_DD_P3> response) {
try {
POJO_DD_P3 affective3 = (POJO_DD_P3) response.body();
if (response.code() != 200) {
// Log.e("Network connected","Response code = "+response.code());
ResponseBody responseBody = response.errorBody();
if (responseBody != null) {
listener.onBodyError(responseBody);
} else if (responseBody == null) {
listener.onBodyErrorIsNull();
}
// Toast.makeText(, ""+loginRes.getAccesstoken(), Toast.LENGTH_SHORT).show();
// Log.e("Network connected","Response code = "+loginRes.getAccesstoken());
} else {
listener.onResponse(affective3);
}
} catch (Exception e) {
// Log.e("Network connect error",e.getMessage());
}
}
@Override
public void onFailure(Call<POJO_DD_P3> call, Throwable t) {
Log.e("NT", t.getMessage());
try {
listener.onFailure(t);
} catch (Exception e) {
listener.onFailure(t);
// Log.e("Network connectLogin",t.getMessage());
}
}
});
}
use of com.google.gson.GsonBuilder in project DVECTN by tanaponudom.
the class NetworkConnectionManager method callServer_dd_p2.
// /////////////////////////////////////////////////////////////////////////////////////////////////
public void callServer_dd_p2(final OnNetworkCallback_DD_P2 listener, int member_id, int ex22, int ex23, int ex24, int ex25, int ex26, int ex27, int ex28, int ex29) {
Gson gson = new GsonBuilder().setLenient().create();
final Retrofit retrofit = new Retrofit.Builder().baseUrl(Fragment_login.BASE_URL).addConverterFactory(GsonConverterFactory.create(gson)).build();
APISERVER callapi = retrofit.create(APISERVER.class);
Call call = callapi.getDataDDP2(member_id, ex22, ex23, ex24, ex25, ex26, ex27, ex28, ex29);
call.enqueue(new Callback<POJO_DD_P2>() {
@Override
public void onResponse(Call<POJO_DD_P2> call, Response<POJO_DD_P2> response) {
try {
POJO_DD_P2 affective2 = (POJO_DD_P2) response.body();
if (response.code() != 200) {
// Log.e("Network connected","Response code = "+response.code());
ResponseBody responseBody = response.errorBody();
if (responseBody != null) {
listener.onBodyError(responseBody);
} else if (responseBody == null) {
listener.onBodyErrorIsNull();
}
// Toast.makeText(, ""+loginRes.getAccesstoken(), Toast.LENGTH_SHORT).show();
// Log.e("Network connected","Response code = "+loginRes.getAccesstoken());
} else {
listener.onResponse(affective2);
}
} catch (Exception e) {
// Log.e("Network connect error",e.getMessage());
}
}
@Override
public void onFailure(Call<POJO_DD_P2> call, Throwable t) {
Log.e("NT", t.getMessage());
try {
listener.onFailure(t);
} catch (Exception e) {
listener.onFailure(t);
// Log.e("Network connectLogin",t.getMessage());
}
}
});
}
Aggregations