@Override protected String readURL(URL url) 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(); } return super.readURL(url); } @Override
@Override protected String readURL(URL url) 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(); } return super.readURL(url); } @Override
@Override public Map<String, List<MenuItemDescription>> listMenuItems() throws MenuServiceException { Map<String, List<MenuItemDescription>> retval = null; try { FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); URL url = asURL("/menuItems.json"); String json = readURL(url); retval = decoder.decodeMenuItemsMap(json); } catch (FormEncodingException e) { throw new MenuServiceException("Problem parsing menu items json file", 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 reading menu items json file", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } return retval; }
@Override public Map<String, List<MenuItemDescription>> listMenuItems() throws MenuServiceException { Map<String, List<MenuItemDescription>> retval = null; try { FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder(); URL url = asURL("/menuItems.json"); String json = readURL(url); retval = decoder.decodeMenuItemsMap(json); } catch (FormEncodingException e) { throw new MenuServiceException("Problem parsing menu items json file", 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 reading menu items json file", e); } catch (Exception e) { throw new MenuServiceException("Unexpected error", e); } return retval; }