/** * Parses the MCEF configuration file. * * @param f The configuration file. * @return The parsed configuration file. */ private JsonObject readConfig(File f) { try { return (new JsonParser()).parse(new FileReader(f)).getAsJsonObject(); } catch(JsonIOException e) { Log.error("IOException while reading remote config."); e.printStackTrace(); return null; } catch(FileNotFoundException e) { Log.error("Couldn't find remote config."); e.printStackTrace(); return null; } catch(Exception e) { Log.error("Syntax error in remote config."); e.printStackTrace(); return null; } }
JQueryDataTableParamModel param = DataTablesParamUtility.getParam(request); if(companies.size()< param.iDisplayStart + param.iDisplayLength) { companies = companies.subList(param.iDisplayStart, companies.size()); } else { companies = companies.subList(param.iDisplayStart, param.iDisplayStart + param.iDisplayLength); } try { JsonObject jsonResponse = new JsonObject(); jsonResponse.addProperty("sEcho", sEcho); jsonResponse.addProperty("iTotalRecords", iTotalRecords); jsonResponse.addProperty("iTotalDisplayRecords", iTotalDisplayRecords); for(Company c : companies){ JsonArray row = new JsonArray(); row.add(new JsonPrimitive(c.getName())); row.add(new JsonPrimitive(c.getAddress())); row.add(new JsonPrimitive(c.getTown())); data.add(row); } jsonResponse.add("aaData", data); response.setContentType("application/Json"); response.getWriter().print(jsonResponse.toString()); } catch (JsonIOException e) { e.printStackTrace(); response.setContentType("text/html"); response.getWriter().print(e.getMessage()); }
/** * Main method that calls all methods above in a flow. * * @param args */ public static void main(String[] args) { try { SubscriptionSample subscriptionSample = new SubscriptionSample(); APIContext context = new APIContext(clientID, clientSecret, "sandbox"); subscriptionSample.create(context); System.out.println("create response:\n" + Plan.getLastResponse()); subscriptionSample.update(context); System.out.println("plan updated"); subscriptionSample.retrieve(context); System.out.println("retrieve response:\n" + Plan.getLastResponse()); } catch (JsonSyntaxException e) { e.printStackTrace(); } catch (JsonIOException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (PayPalRESTException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
e.printStackTrace(); } catch (JsonIOException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace();
e.printStackTrace(); } catch (JsonIOException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace();