List of usage examples for java.net MalformedURLException getMessage
public String getMessage()
From source file:com.blackducksoftware.integration.hub.ScanExecutor.java
public Result setupAndRunScan(final String scanExec, final String oneJarPath, final String javaExec) throws HubIntegrationException { if (isConfiguredCorrectly(scanExec, oneJarPath, javaExec)) { try {//w w w .j a va2 s . c o m final URL url = new URL(getHubUrl()); final List<String> cmd = new ArrayList<>(); final String javaPath = javaExec; getLogger().debug("Using this java installation : " + javaPath); cmd.add(javaPath); cmd.add("-Done-jar.silent=true"); cmd.add("-Done-jar.jar.path=" + oneJarPath); if (StringUtils.isNotBlank(getProxyHost()) && getProxyPort() != null) { cmd.add("-Dhttp.proxyHost=" + getProxyHost()); cmd.add("-Dhttp.proxyPort=" + getProxyPort()); if (getNoProxyHosts() != null) { final StringBuilder noProxyHosts = new StringBuilder(); for (final Pattern pattern : getNoProxyHosts()) { if (noProxyHosts.length() > 0) { noProxyHosts.append("|"); } noProxyHosts.append(pattern.toString()); } cmd.add("-Dhttp.nonProxyHosts=" + noProxyHosts.toString()); } if (StringUtils.isNotBlank(getProxyUsername()) && StringUtils.isNotBlank(getProxyPassword())) { cmd.add("-Dhttp.proxyUser=" + getProxyUsername()); cmd.add("-Dhttp.proxyPassword=" + getProxyPassword()); } } cmd.add("-Xmx" + scanMemory + "m"); cmd.add("-jar"); cmd.add(scanExec); cmd.add("--scheme"); cmd.add(url.getProtocol()); cmd.add("--host"); cmd.add(url.getHost()); getLogger().debug("Using this Hub hostname : '" + url.getHost() + "'"); cmd.add("--username"); cmd.add(getHubUsername()); if (!supportHelper.hasCapability(HubCapabilitiesEnum.CLI_PASSWORD_ENVIRONMENT_VARIABLE)) { cmd.add("--password"); cmd.add(getHubPassword()); } if (url.getPort() != -1) { cmd.add("--port"); cmd.add(Integer.toString(url.getPort())); } else { if (url.getDefaultPort() != -1) { cmd.add("--port"); cmd.add(Integer.toString(url.getDefaultPort())); } else { getLogger().warn("Could not find a port to use for the Server."); } } if (isVerboseRun()) { cmd.add("-v"); } final String logDirectoryPath = getLogDirectoryPath(); cmd.add("--logDir"); cmd.add(logDirectoryPath); if (isDryRun()) { // The dryRunWriteDir is the same as the log directory path // The CLI will create a subdirectory for the json files cmd.add("--dryRunWriteDir"); cmd.add(getLogDirectoryPath()); } if (supportHelper.hasCapability(HubCapabilitiesEnum.CLI_STATUS_DIRECTORY_OPTION)) { // Only add the statusWriteDir option if the Hub supports // the statusWriteDir option // The scanStatusDirectoryPath is the same as the log // directory path // The CLI will create a subdirectory for the status files final String scanStatusDirectoryPath = getLogDirectoryPath(); cmd.add("--statusWriteDir"); cmd.add(scanStatusDirectoryPath); } if (StringUtils.isNotBlank(getProject()) && StringUtils.isNotBlank(getVersion())) { cmd.add("--project"); cmd.add(getProject()); cmd.add("--release"); cmd.add(getVersion()); } for (final String target : scanTargets) { cmd.add(target); } return executeScan(cmd, logDirectoryPath); } catch (final MalformedURLException e) { throw new HubIntegrationException("The server URL provided was not a valid", e); } catch (final IOException e) { throw new HubIntegrationException(e.getMessage(), e); } catch (final InterruptedException e) { throw new HubIntegrationException(e.getMessage(), e); } } else { return Result.FAILURE; } }
From source file:com.varaneckas.hawkscope.cfg.ConfigurationFactory.java
/** * Loads {@link Configuration}/*from w w w . ja v a2 s . c om*/ * * @see #configuration */ private void loadConfiguration() { final Map<String, String> cfg = getDefaults(); try { final ResourceBundle data = UTF8ResourceBundle.getBundle(CONFIG_FILE_NAME, new ClassLoader() { @Override protected URL findResource(final String name) { try { final String file = loadConfigFilePath() + "/." + name; log.debug("Resolving config file: " + file); return new File(file).toURI().toURL(); } catch (final MalformedURLException e) { log.error("Failed loading file", e); return null; } } }); final Enumeration<String> keys = data.getKeys(); while (keys.hasMoreElements()) { final String key = keys.nextElement(); cfg.put(key, data.getString(key)); } } catch (final MissingResourceException e) { log.debug("Configuration not found, using defaults. (" + e.getMessage() + ")"); write(new Configuration(cfg)); } configuration = new Configuration(cfg); }
From source file:gov.nih.nci.nbia.StandaloneDMDispatcher.java
private void getNewVersionInfo() { List<String> resp = null; if (!(os.contains("windows") || os.startsWith("mac"))) { String linuxOs = getLinuxPlatform(); if (linuxOs.equals("other")) { JOptionPane.showMessageDialog(null, "This app has not been tested on the OS platform of your system. Only Windows/MacOS/CentOS/Red Hat/Ubuntu are supported currently."); // return; //check the os properties of installed software to determined the installer type os = DownloaderProperties.getInstallerType(); } else/* w ww. j av a 2 s.com*/ os = linuxOs; } try { String versionServerUrl = serverUrl.substring(0, serverUrl.lastIndexOf('/')) .concat("/DownloadServletVersion"); resp = connectAndReadFromURL(new URL(versionServerUrl)); } catch (MalformedURLException e1) { JOptionPane.showMessageDialog(null, "Connection error 8: " + e1.getMessage()); e1.printStackTrace(); } if ((resp != null) && (resp.size() >= 3)) { key = resp.get(2); } if ((resp != null) && (resp.size() >= 6)) { System.setProperty("help.desk.url", resp.get(4)); System.setProperty("online.help.url", resp.get(5)); } if ((resp != null) && (Double.parseDouble(resp.get(0)) > Double.parseDouble(appVersion))) { if (resp.size() >= 4) { constructDownloadPanel(resp.get(1), resp.get(3)); } else constructDownloadPanel(resp.get(1)); } }
From source file:de.unikassel.puma.openaccess.sword.SwordService.java
/** * collects all informations to send Documents with metadata to repository * @throws SwordException // w w w . j a v a 2s.co m */ public void submitDocument(PumaData<?> pumaData, User user) throws SwordException { log.info("starting sword"); DepositResponse depositResponse = new DepositResponse(999); File swordZipFile = null; Post<?> post = pumaData.getPost(); // ------------------------------------------------------------------------------- /* * retrieve ZIP-FILE */ if (post.getResource() instanceof BibTex) { // fileprefix String fileID = HashUtils.getMD5Hash(user.getName().getBytes()) + "_" + post.getResource().getIntraHash(); // Destination directory File destinationDirectory = new File(repositoryConfig.getDirTemp() + "/" + fileID); // zip-filename swordZipFile = new File(destinationDirectory.getAbsoluteFile() + "/" + fileID + ".zip"); byte[] buffer = new byte[18024]; log.info("getIntraHash = " + post.getResource().getIntraHash()); /* * get documents */ // At the moment, there are no Documents delivered by method parameter post. // retrieve list of documents from database - workaround // get documents for post and insert documents into post ((BibTex) post.getResource()) .setDocuments(retrieveDocumentsFromDatabase(user, post.getResource().getIntraHash())); if (((BibTex) post.getResource()).getDocuments().isEmpty()) { // Wenn kein PDF da, dann Fehlermeldung ausgeben!! log.info("throw SwordException: noPDFattached"); throw new SwordException("error.sword.noPDFattached"); } try { // create directory boolean mkdir_success = (new File(destinationDirectory.getAbsolutePath())).mkdir(); if (mkdir_success) { log.info("Directory: " + destinationDirectory.getAbsolutePath() + " created"); } // open zip archive to add files to log.info("zipFilename: " + swordZipFile); ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(swordZipFile)); ArrayList<String> fileList = new ArrayList<String>(); for (final Document document : ((BibTex) post.getResource()).getDocuments()) { //getpostdetails // get file and store it in hard coded folder "/tmp/" //final Document document2 = logic.getDocument(user.getName(), post.getResource().getIntraHash(), document.getFileName()); // move file to user folder with username_resource-hash as folder name // File (or directory) to be copied //File fileToZip = new File(document.getFileHash()); fileList.add(document.getFileName()); // Move file to new directory //boolean rename_success = fileToCopy.renameTo(new File(destinationDirectory, fileToMove.getName())); /* if (!rename_success) { // File was not successfully moved } log.info("File was not successfully moved: "+fileToMove.getName()); } */ ZipEntry zipEntry = new ZipEntry(document.getFileName()); // Set the compression ratio zipOutputStream.setLevel(Deflater.DEFAULT_COMPRESSION); String inputFilePath = projectDocumentPath + document.getFileHash().substring(0, 2) + "/" + document.getFileHash(); FileInputStream in = new FileInputStream(inputFilePath); // Add ZIP entry to output stream. zipOutputStream.putNextEntry(zipEntry); // Transfer bytes from the current file to the ZIP file //out.write(buffer, 0, in.read(buffer)); int len; while ((len = in.read(buffer)) > 0) { zipOutputStream.write(buffer, 0, len); } zipOutputStream.closeEntry(); // Close the current file input stream in.close(); } // write meta data into zip archive ZipEntry zipEntry = new ZipEntry("mets.xml"); zipOutputStream.putNextEntry(zipEntry); // create XML-Document // PrintWriter from a Servlet MetsBibTexMLGenerator metsBibTexMLGenerator = new MetsBibTexMLGenerator(urlRenderer); metsBibTexMLGenerator.setUser(user); metsBibTexMLGenerator.setFilenameList(fileList); //metsGenerator.setMetadata(metadataMap); metsBibTexMLGenerator.setMetadata((PumaData<BibTex>) pumaData); // PumaPost additionalMetadata = new PumaPost(); // additionalMetadata.setExaminstitution(null); // additionalMetadata.setAdditionaltitle(null); // additionalMetadata.setExamreferee(null); // additionalMetadata.setPhdoralexam(null); // additionalMetadata.setSponsors(null); // additionalMetadata.setAdditionaltitle(null); // metsBibTexMLGenerator.setMetadata((Post<BibTex>) post); //StreamResult streamResult = new StreamResult(zipOutputStream); zipOutputStream.write(metsBibTexMLGenerator.generateMets().getBytes("UTF-8")); zipOutputStream.closeEntry(); // close zip archive zipOutputStream.close(); log.debug("saved to " + swordZipFile.getPath()); } catch (MalformedURLException e) { // e.printStackTrace(); log.info("MalformedURLException! " + e.getMessage()); } catch (IOException e) { //e.printStackTrace(); log.info("IOException! " + e.getMessage()); } catch (ResourceNotFoundException e) { // e.printStackTrace(); log.warn("ResourceNotFoundException! SwordService-retrievePost"); } } /* * end of retrieve ZIP-FILE */ //--------------------------------------------------- /* * do the SWORD stuff */ if (null != swordZipFile) { // get an instance of SWORD-Client Client swordClient = new Client(); PostMessage swordMessage = new PostMessage(); // create sword post message // message file // create directory in temp-folder // store post documents there // store meta data there in format http://purl.org/net/sword-types/METSDSpaceSIP // delete post document files and meta data file // add files to zip archive // -- send zip archive // -- delete zip archive swordClient.setServer(repositoryConfig.getHttpServer(), repositoryConfig.getHttpPort()); swordClient.setUserAgent(repositoryConfig.getHttpUserAgent()); swordClient.setCredentials(repositoryConfig.getAuthUsername(), repositoryConfig.getAuthPassword()); // message meta swordMessage.setNoOp(false); swordMessage.setUserAgent(repositoryConfig.getHttpUserAgent()); swordMessage.setFilepath(swordZipFile.getAbsolutePath()); swordMessage.setFiletype("application/zip"); swordMessage.setFormatNamespace("http://purl.org/net/sword-types/METSDSpaceSIP"); // sets packaging! swordMessage.setVerbose(false); try { // check depositurl against service document if (checkServicedokument(retrieveServicedocument(), repositoryConfig.getHttpServicedocumentUrl(), SWORDFILETYPE, SWORDFORMAT)) { // transmit sword message (zip file with document metadata and document files swordMessage.setDestination(repositoryConfig.getHttpDepositUrl()); depositResponse = swordClient.postFile(swordMessage); /* * 200 OK Used in response to successful GET operations and * to Media Resource Creation operations where X-No-Op is * set to true and the server supports this header. * * 201 Created * * 202 Accepted - One of these MUST be used to indicate that * a deposit was successful. 202 Accepted is used when * processing of the data is not yet complete. * * * 400 Bad Request - used to indicate that there is some * problem with the request where there is no more * appropriate 4xx code. * * 401 Unauthorized - In addition to the usage described in * HTTP, servers that support mediated deposit SHOULD use * this status code when the server does not understand the * value given in the X-Behalf-Of header. In this case a * human-readable explanation MUST be provided. * * 403 Forbidden - indicates that there was a problem making * the deposit, it may be that the depositor is not * authorised to deposit on behalf of the target owner, or * the target owner does not have permission to deposit into * the specified collection. * * 412 Precondition failed - MUST be returned by server * implementations if a calculated checksum does not match a * value provided by the client in the Content-MD5 header. * * 415 Unsupported Media Type - MUST be used to indicate * that the format supplied in either a Content-Type header * or in an X-Packaging header or the combination of the two * is not accepted by the server. */ log.info("throw SwordException: errcode" + depositResponse.getHttpResponse()); throw new SwordException("error.sword.errcode" + depositResponse.getHttpResponse()); } } catch (SWORDClientException e) { log.warn("SWORDClientException: " + e.getMessage() + "\n" + e.getCause() + " / " + swordMessage.getDestination()); throw new SwordException("error.sword.urlnotaccessable"); } } }
From source file:com.googlecode.fightinglayoutbugs.DetectInvalidImageUrls.java
private void checkFavicon() { try {/* w w w . java2 s .com*/ checkImageUrl(_faviconUrl, "Detected invalid favicon URL \"" + _faviconUrl + "\""); } catch (MalformedURLException e) { addLayoutBugIfNotPresent("Detected invalid favicon URL \"" + _faviconUrl + "\" -- " + e.getMessage()); } }
From source file:edu.harvard.i2b2.eclipse.LoginView.java
/** * opens logger browser in another display and separate thread * /* ww w .ja v a 2 s .co m*/ * @param shell- * the control that calls this method * * @return new thread to show browser with logger html file */ public Thread showLoggerBrowser(Shell shell) { final Shell myShell = shell; File file = new File(logFileName); URL url = null; // Convert the file object to a URL with an absolute path try { url = file.toURL(); } catch (MalformedURLException e) { log.debug(e.getMessage()); } final URL myurl = url; return new Thread() { @Override public void run() { new HelpBrowser().run(myurl.toString(), myShell); } }; }
From source file:org.apache.manifoldcf.authorities.authorities.sharepoint.SPSProxyHelper.java
/** * * @return true if connection OK/*from w w w . j a v a 2 s . c om*/ * @throws java.net.MalformedURLException * @throws javax.xml.rpc.ServiceException * @throws java.rmi.RemoteException */ public boolean checkConnection(String site) throws ManifoldCFException { try { if (site.equals("/")) site = ""; UserGroupWS userService = new UserGroupWS(baseUrl + site, userName, password, configuration, httpClient); com.microsoft.schemas.sharepoint.soap.directory.UserGroupSoap userCall = userService .getUserGroupSoapHandler(); // Get the info for the admin user com.microsoft.schemas.sharepoint.soap.directory.GetUserInfoResponseGetUserInfoResult userResp = userCall .getUserInfo(mapToClaimSpace(userName)); org.apache.axis.message.MessageElement[] userList = userResp.get_any(); return true; } catch (java.net.MalformedURLException e) { throw new ManifoldCFException("Bad SharePoint url: " + e.getMessage(), e); } catch (javax.xml.rpc.ServiceException e) { if (Logging.authorityConnectors.isDebugEnabled()) Logging.authorityConnectors.debug("SharePoint: Got a service exception checking connection", e); throw new ManifoldCFException("Service exception: " + e.getMessage(), e); } catch (org.apache.axis.AxisFault e) { if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HTTP"))) { org.w3c.dom.Element elem = e.lookupFaultDetail( new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HttpErrorCode")); if (elem != null) { elem.normalize(); String httpErrorCode = elem.getFirstChild().getNodeValue().trim(); if (httpErrorCode.equals("404")) { // Page did not exist throw new ManifoldCFException("The site at " + baseUrl + site + " did not exist"); } else if (httpErrorCode.equals("401")) throw new ManifoldCFException( "User did not authenticate properly, or has insufficient permissions to access " + baseUrl + site + ": " + e.getMessage(), e); else if (httpErrorCode.equals("403")) throw new ManifoldCFException( "Http error " + httpErrorCode + " while reading from " + baseUrl + site + " - check IIS and SharePoint security settings! " + e.getMessage(), e); else throw new ManifoldCFException("Unexpected http error code " + httpErrorCode + " accessing SharePoint at " + baseUrl + site + ": " + e.getMessage(), e); } throw new ManifoldCFException("Unknown http error occurred: " + e.getMessage(), e); } else if (e.getFaultCode() .equals(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"))) { org.w3c.dom.Element elem = e.lookupFaultDetail(new javax.xml.namespace.QName( "http://schemas.microsoft.com/sharepoint/soap/", "errorcode")); if (elem != null) { elem.normalize(); String sharepointErrorCode = elem.getFirstChild().getNodeValue().trim(); org.w3c.dom.Element elem2 = e.lookupFaultDetail(new javax.xml.namespace.QName( "http://schemas.microsoft.com/sharepoint/soap/", "errorstring")); String errorString = ""; if (elem != null) errorString = elem2.getFirstChild().getNodeValue().trim(); throw new ManifoldCFException( "Accessing site " + site + " failed with unexpected SharePoint error code " + sharepointErrorCode + ": " + errorString, e); } throw new ManifoldCFException("Unknown SharePoint server error accessing site " + site + " - axis fault = " + e.getFaultCode().getLocalPart() + ", detail = " + e.getFaultString(), e); } if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server.userException"))) { String exceptionName = e.getFaultString(); if (exceptionName.equals("java.lang.InterruptedException")) throw new ManifoldCFException("Interrupted", ManifoldCFException.INTERRUPTED); } throw new ManifoldCFException("Got an unknown remote exception accessing site " + site + " - axis fault = " + e.getFaultCode().getLocalPart() + ", detail = " + e.getFaultString(), e); } catch (java.rmi.RemoteException e) { // We expect the axis exception to be thrown, not this generic one! // So, fail hard if we see it. throw new ManifoldCFException( "Got an unexpected remote exception accessing site " + site + ": " + e.getMessage(), e); } }
From source file:ws.argo.Responder.Responder.java
private void sendResponse(String respondToURL, String payloadType, ResponsePayloadBean response) { // This method will likely need some thought and care in the error handling and error reporting // It's a had job at the moment. String responseStr = null;//from w w w. j a va 2s .c om String contentType = null; //MIME type switch (payloadType) { case "XML": { responseStr = response.toXML(); contentType = "application/xml"; break; } case "JSON": { responseStr = response.toJSON(); contentType = "application/json"; break; } default: responseStr = response.toJSON(); } try { HttpPost postRequest = new HttpPost(respondToURL); StringEntity input = new StringEntity(responseStr); input.setContentType(contentType); postRequest.setEntity(input); LOGGER.fine("Sending response"); LOGGER.fine("Response payload:"); LOGGER.fine(responseStr); CloseableHttpResponse httpResponse = httpClient.execute(postRequest); try { int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode > 300) { throw new RuntimeException( "Failed : HTTP error code : " + httpResponse.getStatusLine().getStatusCode()); } if (statusCode != 204) { BufferedReader br = new BufferedReader( new InputStreamReader((httpResponse.getEntity().getContent()))); LOGGER.fine("Successful response from response target - " + respondToURL); String output; LOGGER.fine("Output from Listener .... \n"); while ((output = br.readLine()) != null) { LOGGER.fine(output); } } } finally { httpResponse.close(); } LOGGER.fine("Response payload sent successfully to respondTo address."); } catch (MalformedURLException e) { LOGGER.fine("MalformedURLException occured\nThe respondTo URL was a no good. respondTo URL is: " + respondToURL); // e.printStackTrace(); } catch (IOException e) { LOGGER.fine("An IOException occured: the error message is - " + e.getMessage()); LOGGER.log(Level.SEVERE, e.getMessage()); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Some other error occured. the error message is - " + e.getMessage()); LOGGER.log(Level.SEVERE, e.getMessage()); } }
From source file:org.geppetto.frontend.controllers.GeppettoServletController.java
public void getSimulationConfiguration(String requestID, String url, GeppettoMessageInbound visitor) { String simulationConfiguration; try {//from ww w. j a v a2s. c om simulationConfiguration = visitor.getSimulationService().getSimulationConfig(new URL(url)); messageClient(requestID, visitor, OUTBOUND_MESSAGE_TYPES.SIMULATION_CONFIGURATION, simulationConfiguration); } catch (MalformedURLException e) { messageClient(requestID, visitor, OUTBOUND_MESSAGE_TYPES.ERROR_LOADING_SIMULATION_CONFIG, e.getMessage()); } catch (GeppettoInitializationException e) { messageClient(requestID, visitor, OUTBOUND_MESSAGE_TYPES.ERROR_LOADING_SIMULATION_CONFIG, e.getMessage()); } }