List of usage examples for java.net MalformedURLException getMessage
public String getMessage()
From source file:com.comu.android.AsyncRequestListener.java
public void onMalformedURLException(MalformedURLException e, final Object state) { Log.e("stream", "Invalid URL:" + e.getMessage()); }
From source file:ResourceServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //get web.xml for display by a servlet String file = "/WEB-INF/web.xml"; URL url = null;// w w w. j a v a 2 s .co m URLConnection urlConn = null; PrintWriter out = null; BufferedInputStream buf = null; try { out = response.getWriter(); url = getServletContext().getResource(file); //set response header response.setContentType("text/xml"); urlConn = url.openConnection(); //establish connection with URL presenting web.xml urlConn.connect(); buf = new BufferedInputStream(urlConn.getInputStream()); int readBytes = 0; while ((readBytes = buf.read()) != -1) out.write(readBytes); } catch (MalformedURLException mue) { throw new ServletException(mue.getMessage()); } catch (IOException ioe) { throw new ServletException(ioe.getMessage()); } finally { if (out != null) out.close(); if (buf != null) buf.close(); } }
From source file:com.citypark.api.parser.XMLParser.java
protected XMLParser(final String feedUrl) { try {//w w w . j a va 2 s. c om final String encodedUrl; if (feedUrl != null) { encodedUrl = feedUrl.replaceAll(" ", "+"); } else { encodedUrl = feedUrl; } this.feedUrl = new URL(encodedUrl); } catch (MalformedURLException e) { Log.e(e.getMessage(), "XML parser - " + feedUrl); } }
From source file:de.nrw.hbz.regal.sync.ingest.OpusDownloader.java
protected void downloadObject(File dir, String pid) { try {/* www . ja va2 s . c om*/ // pid = pid.replace(':', '-'); downloadXMetaDissPlus(dir, pid); downloadPdfs(dir, pid); } catch (MalformedURLException e) { logger.error(e.getMessage()); } catch (IOException e) { logger.warn("", e); } }
From source file:com.comcast.cats.domain.service.AbstractService.java
public DeviceSearchService getDeviceSearchService() throws SettopNotFoundException { if (null == deviceSearchService) { try {// w w w . java2 s . com deviceSearchService = new DeviceSearchServiceEndpoint( new URL(getServerUrl() + ConfigServiceConstants.DEVICE_SEARCH_SERVICE_WSDL_LOCATION)) .getPort(); } catch (MalformedURLException e) { throw new SettopNotFoundException(e.getMessage()); } } return deviceSearchService; }
From source file:com.amalto.workbench.models.ObjectRetriever.java
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.bind(Messages.ObjectRetriever_TaskName, IConstants.TALEND), "admin".equals(username) ? 12 : 9);//$NON-NLS-1$ // Access to server and get port try {/* w w w. ja v a2s .c o m*/ switch (parentObject.getType()) { case TreeObject.WORKFLOW: objectName = "WorkflowAvailableModel";//$NON-NLS-1$ break; case TreeObject.JOB_REGISTRY: objectName = "JobAvailableModel";//$NON-NLS-1$ break; } TMDMService service = Util.getMDMService(new URL(endpointaddress), username, password); // commented this by jsxie to fix bug 21371 // parentObject.getServerRoot().removeChildFromUI(parentObject); List<IAvailableModel> availablemodels = AvailableModelUtil.getAvailableModels(); for (IAvailableModel model : availablemodels) { if (model.toString().indexOf(objectName) > 0) { model.addTreeObjects(service, monitor, parentObject.getServerRoot()); } } } catch (MalformedURLException e) { log.error(e.getMessage(), e); } catch (XtentisException e) { log.error(e.getMessage(), e); } }
From source file:com.aurel.track.util.PluginUtils.java
/** * Gets a file (or directory) with a specific name from the root of the web application * @param servletContext/*w ww. j a va 2s . c o m*/ * @param fileName * @return */ public static File getResourceFileFromWebAppRoot(ServletContext servletContext, String fileName) { URL urlDest; File file = null; //first try to get the template dir through class.getResource(path) urlDest = PluginUtils.class.getResource("/../../" + fileName); urlDest = createValidFileURL(urlDest); if (urlDest != null) { file = new File(urlDest.getPath()); } //second try to get the template dir through servletContext.getResource(path) if ((file == null || !file.exists()) && servletContext != null) { try { urlDest = servletContext.getResource("/" + fileName); urlDest = createValidFileURL(urlDest); if (urlDest != null) { file = new File(urlDest.getPath()); } } catch (MalformedURLException e) { LOGGER.error("Getting the URL through getServletContext().getResource(path) failed with " + e.getMessage()); } } //third try to get the template dir through servletContext.getRealPath(path) if ((file == null || !file.exists()) && servletContext != null) { String path; //does not work for unexpanded .war path = servletContext.getRealPath(File.separator) + fileName; file = new File(path); } return file; }
From source file:org.jahia.modules.sitemap.SitemapJob.java
/** * Execute the actual job. The job data map will already have been * applied as bean property values by execute. The contract is * exactly the same as for the standard Quartz execute method. * * @see #execute// w w w .j a v a2 s. co m */ @Override protected void executeInternal(JobExecutionContext context) throws JobExecutionException { JobDataMap mergedJobDataMap = context.getMergedJobDataMap(); List<String> searchEnginesList = (List<String>) mergedJobDataMap.get("searchEngines"); List<String> sites = (List<String>) mergedJobDataMap.get("sites"); for (String site : sites) { for (String s : searchEnginesList) { try { URL url = new URL(s + URLEncoder.encode(site + "/sitemap.xml", "UTF-8")); logger.debug("Calling " + url.toExternalForm()); URLConnection urlConnection = url.openConnection(); Source source = new Source(urlConnection); logger.debug(source.getTextExtractor().toString()); } catch (MalformedURLException e) { logger.error(e.getMessage(), e); } catch (UnsupportedEncodingException e) { logger.error(e.getMessage(), e); } catch (IOException e) { logger.error(e.getMessage(), e); } } } }
From source file:com.github.rnewson.couchdb.lucene.ConfigTest.java
@Test public void testGetClient() { try {//from w w w .jav a 2s . c om final Config config = new Config(); HttpClient client = config.getClient(); assertNotNull(client); } catch (ConfigurationException ce) { fail("ConfigurationException shouldn't have been thrown." + ce.getMessage()); } catch (MalformedURLException mue) { fail("MalformedURLException shouldn't have been thrown." + mue.getMessage()); } }
From source file:UrlServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //get the 'file' parameter String fileName = (String) request.getParameter("file"); if (fileName == null || fileName.equals("")) throw new ServletException("Invalid or non-existent file parameter in UrlServlet servlet."); if (fileName.indexOf(".pdf") == -1) fileName = fileName + ".pdf"; URL pdfDir = null;/*from w ww . java 2 s . c om*/ URLConnection urlConn = null; ServletOutputStream stream = null; BufferedInputStream buf = null; try { pdfDir = new URL(getServletContext().getInitParameter("remote-pdf-dir") + fileName); } catch (MalformedURLException mue) { throw new ServletException(mue.getMessage()); } try { stream = response.getOutputStream(); //set response headers response.setContentType("application/pdf"); response.addHeader("Content-Disposition", "attachment; filename=" + fileName); urlConn = pdfDir.openConnection(); response.setContentLength((int) urlConn.getContentLength()); buf = new BufferedInputStream(urlConn.getInputStream()); int readBytes = 0; //read from the file; write to the ServletOutputStream while ((readBytes = buf.read()) != -1) stream.write(readBytes); } catch (IOException ioe) { throw new ServletException(ioe.getMessage()); } finally { if (stream != null) stream.close(); if (buf != null) buf.close(); } }