@Override protected void writeToURL(URL url, String json) throws FileNotFoundException, IOException { if (exceptionType != null) { if (exceptionType.equals(FileNotFoundException.class)) throw new FileNotFoundException(url.toExternalForm()); if (exceptionType.equals(IOException.class)) throw new IOException(url.toExternalForm()); throw new NullPointerException(); } super.writeToURL(url, json); } };
@Override protected void writeToURL(URL url, String json) throws FileNotFoundException, IOException { if (exceptionType != null) { if (exceptionType.equals(FileNotFoundException.class)) throw new FileNotFoundException(url.toExternalForm()); if (exceptionType.equals(IOException.class)) throw new IOException(url.toExternalForm()); throw new NullPointerException(); } super.writeToURL(url, json); } };
private void writeMenuItems(Map<String, List<MenuItemDescription>> items) throws MenuServiceException { try { FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder(); String json = encoder.encodeMenuItemsMap(items); URL url = asURL("/menuItems.json"); writeToURL(url, json); } catch (FormEncodingException e) { throw new MenuServiceException("Problem transforming menu items to json", e); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding menu items json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No menu items json file found", e); } catch (IOException e) { throw new MenuServiceException("Problem writing menu items json file", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } }
private void writeMenuItems(Map<String, List<MenuItemDescription>> items) throws MenuServiceException { try { FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder(); String json = encoder.encodeMenuItemsMap(items); URL url = asURL("/menuItems.json"); writeToURL(url, json); } catch (FormEncodingException e) { throw new MenuServiceException("Problem transforming menu items to json", e); } catch (URISyntaxException e) { throw new MenuServiceException("Problem finding menu items json file", e); } catch (FileNotFoundException e) { throw new MenuServiceException("No menu items json file found", e); } catch (IOException e) { throw new MenuServiceException("Problem writing menu items json file", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } }